Understanding Data Change Events

Using data change event listeners, application-level Java code (e.g. the Space Inventory application workflow rules) can register callbacks on startup with the datasource. The callback occurs if:

Single-record Changes

For individual records, the callback functions with these parameters:

Bulk Changes

For bulk changes, the callback functions with these parameters:

The callback can optionally decide to log this change or inspect the SQL statement textually to determine if it needs to perform any other action.

Other Conditions

Some other conditions are:

Transactions and Commits

If you are writing application-level logic, such as the logic that synchronizes the Workspace Transactions table with the Rooms table, whether to commit at any point is an application-level decision. Some application-level rules, such as those that create autonumbered records, must commit as a part of the logic.

If you are writing a callback for audit-logging purposes, do not commit. If the transaction is canceled, the originating change – as well as any records you wrote to the log – will be rolled back in conjunction if one of the database transactions fails.

Cascading Updates

Some user actions trigger cascading updates to the database. For instance, if you delete a room, the system clears all dependent references to that room in the other tables, e.g. the equipment, employee, work order, etc. tables. If you rename a room, the system updates all dependent tables.

The data change event notification fires only on the root record of the cascading change. For instance, in the case above, the data change event fires when the system updates the room record, and your data change service will get a notification that a particular primary key record in the room table was deleted or updated. However, your handler will not receive notification that the equipment, employee, work order, etc. tables have changed.

To take another example, suppose you delete a building record. This also deletes all floor and room records as well as clears all references to that building, those floors, and those rooms throughout the database. However, your handler will receive notice only that the root building with a particular primary key was deleted.

This is the correct notification choice for two reasons. First, the root record is the one with the most precise information. In the case of cascading updates, the system knows which particular table and key is being changed. The application knows of the relations between tables and can react to the change as needed. Second, this behavior is consistent across all databases.

Use Cases

Changing Room’s Owner-of-Record

User changes the Division and Department in the Rooms table to change the department that is the “owner of record”. The space domain provides a callback workflow rule that updates the transaction table (the Workspace Transactions table) to audit the change.

On being notified of a single-record update to a Room (rm) table record this WFR:

On being notified of a bulk update to the Rooms table, this WFR:

Only the CRE/FM department personnel make bulk changes – such as when they use Replace Column in the Smart Client or Edit Data Multiple in the Extension for AutoCAD. They also tend to make bulk changes on just the portion of the inventory that is new and is not yet managed using Space Transactions. As such, it is appropriate to ask these users to resynch after making extensive changes to the Room inventory.

The use case to change a room’s Category and Type and flow the appropriate change down to the Workspace Transactions table involves the same process.

The use case to change an Employee’s Primary-Room assignment in the employees (em) table also is the same process.

See RoomTransactionDataEventListener

Deleting a Room Record

This use case illustrates the need for the notification before the deletion occurs.

If a user deletes a room record, the data change event needs to archive the historical information for that room record that is currently in the Workspace Transactions table before the room is deleted. Otherwise, the room is deleted and the change already cascades to the Workspace Transactions table -- deleting the information that would need to be archived.

See RoomTransactionDataEventListener

Changing an Archibus User’s Information

The system activity supplies a logging callback workflow rule that the core calls whenever a user changes a User, Role, or Process Assignment record.

User uses the Smart Client, the Web Central Archibus Users form, or the My Profile form to change an afm_user record.

The callback workflow rule logs the single-record or bulk update to the table in the database event log, by recording the table, name of the user making the change, the date and time, and

In the case of an inquiry, the system administrator can review the log.

See LoggerDataEventListener

Reporting Exceptions

There are a number of cases in which the site can bypass the change events, for instance if users at the site update the database using direct SQL or by loading a database extract file.

In such a case, use the database transaction log or database triggers.

However, sites may wish to have an application-level exception report that detects when this kind of change has taken place.

For instance, consider the use case in which the Space Inventory application has a workflow rule that flows Room table changes to the Workspace Transactions table. Suppose a site then imports a set of room records using direct SQL statements that bypass the Archibus core. The activity can create an workflow rule that finds exceptions by comparing the values in the Rooms table to the most recent record in the Workspace Transactions table. If this exception report finds a difference it can set the resynchRoomPercentagesTable activity parameter to Yes. Key reports and actions that depend on Space Transactions check this activity parameter before running and alert the user if the table needs to be resynched.

Usage Notes

See Also

Data Change Events: Overview