Change log
Value resolver – Abstract
Purpose: Creates a change log that determines the differences between an object passed as an input value and a parameterized compare object and outputs them in structured form – as a 'change log'.
►IMPORTANT◄ This value resolver is not available in a Client workflow!
The Change log value resolver generates a change log that determines the differences between an object passed as input value and a compare object defined by the Compare value parameter and outputs them in a structured form – as a 'change log'.
The type of the return value depends on the type of the input value.
Input value type |
Examples |
Return value type |
Specific fields |
Simple value |
Text values, numeric values, enumeration values, etc. |
'Change Log > Simple value' (SimpleValueChangeLog) |
fromValue, toValue |
Collection |
List, Unique list, etc. |
'Change Log > Collection' (CollectionChangeLog) |
fromLength, toLength |
Entity |
Business object, Custom type definition, Line item, Configuration, |
'Change log> Entity' (EntityChangeLog) |
fromId, toId |
Other objects |
Client object, date value, date range, attribute (see also table below), etc. |
'Change log > Object' (ObjectChangeLog) |
fromClass, toClass |
►IMPORTANT◄ Technically, each change log type offers the fields fromIndex and toIndex, which refer to the sequence position within a collection. These fields contain the value -1 if the index is not applicable (due to lack of reference to a collection).
►NOTE◄ Changes to attributes of an entity can be determined in different ways. The return value type varies:
Input value for the change log |
Input value type |
Return value type |
Specific fields |
Attribute owner Parent entity of the attribute |
Entity |
'Change log > Entity' (EntityChangeLog) for the attribute owner, which contains one of the following change log types for each attribute that has been changed:
|
attributeType |
Attribute implementation e.g. 'Order > Text attribute' type |
Entity |
'ChangeLog > Entity' (EntityChangeLog) for an instance of the attribute implementation as a standalone entity containing the actual attribute as a value (see next line) in the value field. |
no attribute |
Attribute |
Object |
'Change Log > Object' (ObjectChangeLog) for the attribute containing change logs for other types (see above) to describe the actual changes. |
no attribute |
Compare logic:
If no differences are found between the input value and the compare object, the return value is 'No value' ($null)
If no Compare value is configured (default) and an entity is available as input value at runtime, its Original entity (i.e. the server-side state for the entity) is used as the compare object. This is the typical use case for the value resolver
The Ignore entity attributes option only works in this use case. It controls whether changes to the entity attributes ('Owner', Created by', 'Creation date', etc.) are ignored (default) or taken into account during a comparison.
If the entity in the input value contains other entities (e.g. line items or attributes), a change log is generated for them – recursively if necessary – which appears together with other 'changes' as part of the parent change log.
If the input value is not an entity, but e.g. a simple value, a list or a 'client object', then the Compare value should be configured explicitly, otherwise the input value is also a compare object and the value resolver returns 'No value' ($null).
If the input value is a list of entities, these will not be automatically compared with the respective Original entity if no Compare value is configured. However, if necessary, this can be achieved by explicit configuration for the Compare value (see Special use case in the 'Examples' section).
The Log details for deleted and created values option controls how much information the change log provides about objects that are classified as created or deleted in the context of the comparison:
For created or deleted values, only a minimal amount of information appears by default (option unchecked)
If the option is checked, the change log will output more data of the object in question:
An object classified as 'deleted' is reproduced in its entirety with all its details.
For an object classified as 'created', its data is reflected by a 'change log' with 'No value' ($null) as the compare object.
Example of a change log:
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
core
:EntityChangeLog [...]
fromIndex
=
"-1"
toIndex
=
"-1"
changeType
=
"MODIFIED"
fromClass
=
"shp:Shipment"
toClass
=
"shp:Shipment"
fromId
=
"51"
toId
=
"51"
>
<
changeLogs
>
<
core
:TypedAttributeChangeLog
name
=
"attributes"
fromIndex
=
"-1"
toIndex
=
"-1"
changeType
=
"MODIFIED"
fromClass
=
"shp:ShipmentText"
toClass
=
"shp:ShipmentText"
fromId
=
"1"
toId
=
"1"
attributeType
=
"base:TextAttribute"
type
=
"base:TextType#DESCRIPTION"
>
<
changeLogs
>
<
core
:ObjectChangeLog
name
=
"value"
fromIndex
=
"-1"
toIndex
=
"-1"
changeType
=
"MODIFIED"
fromClass
=
"base:TextAttribute"
toClass
=
"base:TextAttribute"
>
<
changeLogs
>
<
core
:SimpleValueChangeLog
name
=
"textValue"
fromIndex
=
"-1"
toIndex
=
"-1"
>
<
fromValue
xsi:type
=
"xsd:string"
>Description (original)</
fromValue
>
<
toValue
xsi:type
=
"xsd:string"
>Description (updated)</
toValue
>
</
core
:SimpleValueChangeLog>
</
changeLogs
>
</
core
:ObjectChangeLog>
</
changeLogs
>
</
core
:TypedAttributeChangeLog>
</
changeLogs
>
</
core
:EntityChangeLog>
The return value of the type 'Change log > Entity' (EntityChangeLog) defines via the toClass field that a shipment (see Shipments) was passed as input value and refers to its ID (toId) with the value 51.
Since the fromClass and from Id fields do not specify any data that differs from the input value, the comparison apparently involves two data statuses for the shipment with ID 51. Typically, the Original entity serves as the compare object here because no Compare value has been configured.
In the example, the changeLogs list field contains exactly one element of the 'Change log > Typed attribute' (TypedAttributeChangeLog) type, whose changeType field names the 'change type' as MODIFIED.
It can be seen from the fromClass and toClass fields that the TypedAttributeChangeLog concerns a typed text attribute – more precisely: its implementation – for a shipment (ShipmentText).
The attributeType field refers to the attribute type (TextAttribute) used as the value, and the type field identifies the 'Description' subtype (DESCRIPTION) defined as the value from the dynamic enumeration Text type (TextType).
The changeLogs list field within the TypedAttributeChangeLog element contains a 'Change log > Object' (ObjectChangeLog) that classifies the attribute (TextAttribute) as changed (MODIFIED).
The name field here refers to the name of the value field in the data model of the parent ShipmentText object.
The changeLogs list field within the ObjectChangeLogs contains a 'Change log > Simple value' (SimpleValueChangeLog) for the textValue field (see name) in the TextAttribute object.
The SimpleValueChangeLog documents the change of the text value from 'Description (original)' (fromValue) to 'Description (updated)' (toValue).
CAUTION
As the example shows, even a simple text value change within an existing typed attribute of a shipment generates a significant amount of information in the return value of the Change log value resolver.
When using the value resolver, it should be borne in mind that multiple changes within complex objects (such as a business object with a position hierarchy and attributes at all levels) require considerable 'computing effort' and can generate corresponding amounts of data. Often, a comprehensive Change log is subsequently evaluated specifically in order to obtain relevant information or to prepare it in a more easily 'readable' form.
Configuration
'Ignore entity attributes' option
The Ignore entity attributes option is checked by default. When comparing 'entity data', the so-called entity attributes are then not evaluated. Example: The input value is the volatile data of a random entity, which (without configuration for the Compare value) is matched with the server-side data state. In the default configuration for the Change log value resolver shown on the top right, the Ignore entity attributes option is checked. If the only change in the entity's volatile data is a 'change of owner' – i.e. a value for the entity attribute 'owner' (ownerId) field that has changed compared to the Original entity, the value resolver still returns 'No value' ($null), since the volatile data state is evaluated as unchanged despite the change. |
|
If the Ignore entity attributes option is unchecked, then the comparison between the input value and compare object for the change log will also include all entity attributes. For the above example, this means that a 'change of owner' is also considered a change, so that in the return value of the Change log value resolver you will find, among other things, a SimpleValueChangeLog object for the ownerId field. |
'Log details for deleted and created values' option
The Log details for deleted and created values option is unchecked by default. If the compare value is classified as 'created' or 'deleted', only the minimum functionality appears in the return value of the Change log value resolver. The respective 'change type' (changeType), i.e. DELETED or CREATED is specified in the header of the respective change log entry, without giving all details about the object. Example: The input value is volatile data for a company account in which the address (still) stored on the server side has been deleted. When the comparison is made with the Log details for deleted and created values option unchecked (see screenshot above right), an EntityChangeLog (with the embedded address as entity) is output for the address field, which shows the 'change type' (changeType) DELETED and identifies the deleted entity only via the fromClass and fromId fields. |
|
If the Log details for deleted and created values option is checked (see screenshot below right), then in the scenario described above the comparison will provide detailed information for the deleted address, which for this purpose is marked with 'No value' ($null). The EntityChangeLog for the address field contains, in addition to the data also listed in the default case (fromClass,fromId) in the changeLogs list field, a possibly very extensive listing of child change logs, as if each feature within the address had been deleted individually. By recursion, this also involves attributes of the address, address contacts, their attributes, etc. |
Compare value configuration
The optional Compare value parameter can be used to contrast the input value with a compare object. If a configuration for the compare value is completely omitted (default, see screenshot on the right), then the 'original object' for the input value is used as the compare object.
|
|
In the configuration on the right, the address of the Company of session (in the input value) is compared with the address specified for the User of session as a compare object.
►NOTE◄ If a guest user (see Guest users) is logged in, the User of session value resolver does not return a user account (see Users). Then the concatenated Input object (type safe) value resolver passes 'No value' ($null) to the Object property value resolver. However, since a guest user account does not have an address field, this would not work anyway. If a value resolver chain is configured for the Compare value that returns 'No value' ($null) at runtime, $null is used as the compare object. If an entity is present as input value, this results in an EntityChangeLog that evaluates the entity in the input value as 'created' (CREATED). Without configuration for the Compare value, on the other hand, $null would be returned, as described above. |
Examples
Change log > Simple value
The following examples use the JSON format to describe data structures.
Input value |
Compare value |
Change log |
"ABC" |
"XYZ" |
{ |
|
||
4711 |
3210 |
{ |
|
||
{ "class": "java.lang.Long", "value": "4711" } e.g. from a Long value resolver |
{ "class": "java.lang.Integer", "value": "4711" }
e.g. from an Integer value resolver |
{ |
|
||
Enumeration value 'East' (E) from the user-defined dynamic enumeration DIRECTIONS:
see also Any dynamic enumeration |
Enumeration value 'North' (N) from the user-defined dynamic enumeration DIRECTIONS:
see also Any dynamic enumeration |
{ |
|
Change log > Collection
The following examples use the JSON format to describe data structures.
Input value |
Compare value |
Change log |
["Tom","Dick","Harry","Sally"] |
["Tom","Dick","Harry"] |
{ |
|
||
["Tom","Dick","Harry"] |
["Tom","Dick","Harry","Sally"] |
{ |
|
||
{ "class": "set", "data": [ "Tom", "Harry" ] } |
{ "class": "set", "data": [ "Tom", "Harry", "Dick"] } |
{ |
►NOTE◄ The 'Unique list' does not manage index numbers for the entries. Therefore, the fromIndex and toIndex fields show the default value -1. |
||
[1,2,3] |
[3,2,1,0] |
{ |
►NOTE◄ The value 2 does not appear in the changeLogs field because it is considered completely unchanged. |
||
Special use case: Compare all entities in a list |
||
A collection created with the Create list contains volatile data from different entities that may have changed from the server-side state:
Both accounts have already been created and may have been changed in the current context. The Change log value resolver should detect any 'volatile' changes to the accounts listed as entities. |
As a Compare value, the list of entities in the input value is contrasted with a list of the associated 'original objects'. This can be achieved with the Collect values value resolver, which here uses the Original entity value resolver as the Value to collect in order to retrieve the server-side state for each element of the list of entities present as input value. |
{ |
|
Change log > Object
The following examples use the JSON format to describe data structures.
Input value |
Compare value |
Change log |
{ "class": "de.lobster.scm.utils.date.DateTime", A 'Date with time' object determined as Relative date with time:
|
{ "class": "de.lobster.scm.utils.date.DateTime",
|
{ |
|
||
{ "name": "Darth Vader", "nickname": "Dee-Vee" } |
{ "name": "Anakin" } |
{ |
|
||
{ "name": "Luke", } |
{ "name": "Luke" } |
{ |
|
Change log > Entity
The following examples optionally use the XML format and the JSON format to describe data structures.
Input value |
Compare value |
Return value |
An event handling is triggered by the 'Change' event (see Common action event) so that it reacts to the saving of already created entities. A Check type ensures that the event action becomes active only in the context of Association criteria. The input value is always the changed volatile data of the association criterion that is saved. Before saving changes, a Change log should be created so that – depending on the type of changes – an administrator can be notified if necessary. Example: <?xml version="1.0" encoding="UTF-8"?>
|
not configured, that is the Original entity to the entity in question |
{ |
Based on the changed state of the association criteria in the previous example, the notified administrator has reviewed the association criteria and now wants to save it again with changes. The event handling reacts again and determines the changes to the association criteria via the Change log value resolver. Example: <?xml version="1.0" encoding="UTF-8"?>
|
nicht konfiguriert, also das Original entity zur betreffenden Entität |
{ |