Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the ChangeSummary of Java

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use the ChangeSummary of Java". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the ChangeSummary of Java".

ChangeSummary provides a mechanism to access the change history information of data objects in a data graph.

The change history covers all modifications to a data graph since the log was activated. If the log is no longer active, the log only includes changes before the log is frozen. Otherwise, it only includes changes since ChangeSummary was queried. Although the change information begins to be collected only when the log is activated, you can query the change information regardless of whether the log is activated or closed. The information returned by all queries is read-only.

The interface has the following methods:

Activate or freeze logs.

When the log starts, rebuild a DataObjects tree and clear the log.

Query log status.

Gets the DataGraph to which the ChangeSummary belongs.

Gets the root DataObject of the ChangeSummary.

Gets the modified DataObject.

Indicates whether a data object has been created, deleted, or modified.

At the beginning of the log, get the DataObject of the container type.

At the beginning of the log, get the properties contained in the DataObject.

At the beginning of the log, get the Sequence of the DataObject.

Gets a special old value.

Gets a list of old values.

Start or stop a change log

The beginLogging () method clears the list of changes to DataObject in ChangeSummary and starts a change log. The endLogging () method stops the change log. The undoChanges () method rebuilds the DataObject tree at the beginning of the log, and the undoChanges () method also clears the log, but has no effect on the isLogging () method.

Note: the beginLogging (), endLogging (), and undoChanges () methods are basically used by the service implementation because the service defines how to associate ChangeSummary processing with external resources. If ChangeSummary fails to capture the resulting changes, this may cause the service to perform updates to the data source based on the incomplete information of the ChangeSummary.

Scope of action (Scope)

The scope of ChangeSummary is defined as all data objects contained in the DataObject tree starting from the root of ChangeSummary. The ChangeSummary root object is the source DataObject where all changes are tracked. You can get the ChangeSummary root object through the getRootObject () method. This object is one of the following:

A data object that has ChangeSummary as a value of its property.

The root data object of the data graph

Old value (Old Values)

Use the getOldValues (DataObject dataObject) method to get a list of old values. The return order of the old values is determined by the implementation. For a deleted DataObject, the old values list contains all the attributes of the DataObject. For an DataObject that has been modified, the old values list contains only the modified attributes. For DataObject that has not been deleted or modified, the old values list is empty.

The old value is described as a ChangeSummary.Setting object (ChangeSummary.Setting is an internal interface to ChangeSummary). Each ChangeSummary.Setting has an attribute and a value, as well as a tag to indicate whether the attribute is a collection.

If a DataObject is deleted or modified, the getOldValue (DataObject dataObject, Property property) method returns a ChangeSummary.Setting that describes the specified property; otherwise, it returns null. If the setting.isSet () method of the old value returns false, the old value does not make any sense.

Sequential data objects (Sequenced DataObject)

At the beginning of the log, the getOldSequence (DataObject dataObject) method returns all the values in the order of a data object. The return value may be null. If the DataObject.getSequence () method returns null, then the getOldSequence (DataObject dataObject) method returns null.

Serialization and deserialization

When ChangeSummary is deserialized, if there is an element in the XML file, its log state will be on unless changeSummary marks the log as off. A serializer must generate an element in the XML file if:

Changes have been logged (getChangedDataObjects (). Size () > 0).

No changes are logged, but when serialized, the isLogging () method is true. In this case, an empty or element is created.

The state of the log is recorded in the logging attribute of the changeSummary element.

The serialization of ChangeSummary contains enough information to reconstruct the initial information of the DataObject when the log is started. When the log starts, the attribute tag DataObject in the newly created data graph will not be displayed, and the deleted attribute tag object contained in the ChangeSummary will no longer be included in the data graph. The tag can be IDs or, if available, a sdo path expression.

The content of the ChangeSummary element can be a deep copy of a deleted data object or a prototype of a data object that has only changes in data types and values of attributes that have been changed.

Associate change summary with data object

There are two possible ways to associate DataObject with ChangeSummary:

1. DataGraph uses the getChangeSummary () method to get a ChangeSummary.

This method is usually used when the ChangeSummary is external to the DataObject tree. ChangeSummary tracks changes in the tree of data objects starting with the root data object, which can be obtained through the getRootObject () method of DataGraph.

2. The type of DataObject can include an attribute that contains ChangeSummary.

This method is often used in situations where ChangeSummary is part of a DataObject tree, for example, when a root DataObject is a message header that contains both the body of DataObject and ChangeSummary. ChangeSummary starts tracking changes in the DataObject tree from the DataObject that contains the ChangeSummary.

Change Summary Interfac

The ChangeSummary interface provides the following methods:

Check the status of the log, or switch the log

When the log starts, redo all the changes in the log

Return root DataObject and DataGraph

Returns a DataObject that has been modified, created, or deleted

Identify the types of changes that have occurred (modify, create, delete)

Returns the old value of a data object that has been changed or deleted

Public interface ChangeSummary

{

Void beginLogging ()

Void endLogging ()

Boolean isLogging ()

Void undoChanges ()

DataGraph getDataGraph ()

DataObject getRootObject ()

List / * DataObject*/ getChangedDataObjects ()

Boolean isCreated (DataObject dataObject)

Boolean isDeleted (DataObject dataObject)

Boolean isModified (DataObject dataObject)

DataObject getOldContainer (DataObject dataObject)

Property getOldContainmentProperty (DataObject dataObject)

Sequence getOldSequence (DataObject dataObject)

Public interface Setting

{

Object getValue ()

Property getProperty ()

Boolean isSet ()

}

Setting getOldValue (DataObject DataObject, Property property)

List / * Setting*/ getOldValues (DataObject dataObject)

}

Thank you for your reading, the above is the content of "how to use Java ChangeSummary", after the study of this article, I believe you have a deeper understanding of how to use Java ChangeSummary, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report