Changeset 5039


Ignore:
Timestamp:
Aug 10, 2009, 11:23:49 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #108: Logging the change history of an item

  • Added core classes and test case.
  • Unreferenced history entries are deleted by cleanup.
Location:
trunk/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r5021 r5039  
    34993499    </description>
    35003500  </query>
     3501  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
     3502    <sql>
     3503      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
     3504    </sql>
     3505    <description>
     3506      An HQL query that selects all used item types in the change
     3507      history table.
     3508    </description>
     3509  </query>
     3510  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
     3511    <sql>
     3512      DELETE FROM ChangeHistoryDetailData
     3513      WHERE id IN (:ids)
     3514    </sql>
     3515    <description>
     3516      A HQL query that deletes all change history entries with the
     3517      id's given in the list.
     3518    </description>
     3519  </query>
     3520  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
     3521    <sql>
     3522      SELECT [ch].[id]
     3523      FROM [ChangeHistoryDetails] [ch]
     3524      LEFT JOIN [{1}] [t]
     3525        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
     3526      WHERE [t].[id] IS NULL
     3527      AND [ch].[item_type] = :type
     3528    </sql>
     3529    <description>
     3530      An SQL query that selects the ID of all change history entries
     3531      that references a missing item of a specified type.
     3532    </description>
     3533  </query>
     3534 
    35013535</predefined-queries>
  • trunk/src/core/net/sf/basedb/core/Application.java

    r5038 r5039  
    11391139      log.info("Found " + numDeleted + " stray any-to-any links");
    11401140     
     1141      // Change history entries referencing deleted items
     1142      numDeleted = ChangeHistory.deleteStrayEntries(null);
     1143      log.info("Found " + numDeleted + " stray change history entries");
     1144     
    11411145      // Item and project keys
    11421146      numDeleted = ItemKey.deleteUnusedItemKeys();
  • trunk/src/core/net/sf/basedb/core/Item.java

    r4889 r5039  
    216216  ANYTOANY(143, "Any-to-any link", "ata", AnyToAny.class, AnyToAnyData.class, null,
    217217    10),
     218   
     219  /**
     220    The item is a {@link ChangeHistory} entry.
     221  */
     222  CHANGEHISTORY(144, "Change history", "chh", ChangeHistory.class,
     223    ChangeHistoryDetailData.class, DefinedPermissions.read, 9999),
    218224
    219225  /**
  • trunk/src/test/TestAll.java

    r5022 r5039  
    126126    results.put("TestMessage", TestMessage.test_all());
    127127    results.put("TestAnyToAny", TestAnyToAny.test_all());
     128    results.put("TestChangeHistory", TestChangeHistory.test_all());
    128129    results.put("TestXMLUtil", TestXMLUtil.test_all());
    129130    results.put("TestParameterType", TestParameterType.test_all());
Note: See TracChangeset for help on using the changeset viewer.