Skip to main content

CreateAssociationUpdate@1

Node CreateAssociationUpdate@1 is used to create an update info object for creating or deleting associations between entities. Association update info objects are used to track changes in the relationships between entities in OctoMesh's Asset Repository.

Adapter Prerequisites

Node Configuration

For fields path, targetPath, targetValueWriteMode, and targetValueKind, see Overview.

transformations:
- type: CreateAssociationUpdate@1
targetPath: _updateItems # Path where the update info object should be stored in the payload
targetValueKind: Array # The target value kind; should be 'Array' to store multiple update info objects
targetValueWriteMode: Append # The target value write mode; should be 'Append' to add the update info object to the array
updateKind: CREATE # The update kind; 'CREATE' to create an association, 'DELETE' to delete an association
sourceRtId: 5fc8fda18b2fc75f925e21af # The runtime ID of the source entity in the association
sourceRtIdPath: $.sourceAssetId # The path to the source runtime ID in the payload; any valid JSON path is allowed. This property can be defined instead of the 'sourceRtId' property
sourceCkId: Industry.Energy/Photovoltaic.Module # The CK type ID of the source entity
sourceCkTypeIdPath: $.sourceCkTypeId # The path to the source CK type ID in the payload; any valid JSON path is allowed
targetRtId: 5fc8fda18b2fc75f925e21bf # The runtime ID of the target entity in the association
targetRtIdPath: $.targetAssetId # The path to the target runtime ID in the payload; any valid JSON path is allowed. This property can be defined instead of the 'targetRtId' property
targetCkId: Industry.Energy/Photovoltaic.Inverter # The CK type ID of the target entity
targetCkTypeIdPath: $.targetCkTypeId # The path to the target CK type ID in the payload; any valid JSON path is allowed
associationRoleId: Industry.Energy/Photovoltaic.ModuleToInverter # The CK association role ID defining the association
associationRoleIdPath: $.associationRoleId # The path to the association role ID in the payload; any valid JSON path is allowed

Configuration Properties

  • updateKind (AssociationUpdateKind?): The kind of update to perform. Use 'CREATE' to create an association or 'DELETE' to delete an association.

  • updateKindPath (string?): The JSON path to the update kind in the payload. This property can be defined instead of the updateKind property.

  • sourceRtId (OctoObjectId?): The runtime ID of the source entity in the association.

  • sourceRtIdPath (string?): The JSON path to the source runtime ID in the payload. This property can be defined instead of the sourceRtId property.

  • sourceCkId (CkId<CkTypeId>?): The CK type ID of the source entity.

  • sourceCkTypeIdPath (string?): The JSON path to the source CK type ID in the payload. This property can be defined instead of the sourceCkId property.

  • targetRtId (OctoObjectId?): The runtime ID of the target entity in the association.

  • targetRtIdPath (string?): The JSON path to the target runtime ID in the payload. This property can be defined instead of the targetRtId property.

  • targetCkId (CkId<CkTypeId>?): The CK type ID of the target entity.

  • targetCkTypeIdPath (string?): The JSON path to the target CK type ID in the payload. This property can be defined instead of the targetCkId property.

  • associationRoleId (CkId<CkAssociationRoleId>?): The CK association role ID defining the association between the source and target entities.

  • associationRoleIdPath (string?): The JSON path to the association role ID in the payload. This property can be defined instead of the associationRoleId property.

Usage Example

Here's an example of how you might use the CreateAssociationUpdate@1 node in a transformation pipeline:

transformations:
- type: CreateAssociationUpdate@1
targetPath: _associationUpdates # Store the association update info object in this path in the payload
targetValueKind: Array # Store multiple association update info objects in an array
targetValueWriteMode: Append # Append the new update info object to the array
updateKind: CREATE # Create a new association
sourceRtIdPath: $.rtId # Source entity runtime ID from the payload
sourceCkId: Industry.Basic-1.0.0/Alarm-1.0.0 # Source entity CK type ID from the payload
targetRtId: 0123456789012asdfb # Target entity runtime ID from the payload
targetCkTypeIdPath: $.location.ckTypeId # Target entity CK type ID from the payload
associationRoleId: Industry.Basic/Alarm # The CK association role ID defining the "LocatedAt" relationship

In this example:

  • We are creating an association between a device and a location.
  • The updateKind is set to 'CREATE', indicating we are creating a new association.
  • The source and target runtime IDs and CK type IDs are extracted from the payload using JSON paths.
  • The associationRoleId specifies the type of association between the two entities.

Notes

  • If both the direct value and the corresponding path are provided for a property (e.g., both sourceRtId and sourceRtIdPath), the direct value (sourceRtId) takes precedence.
  • Ensure that all necessary IDs (runtime IDs and CK type IDs) are provided either directly or via JSON paths; otherwise, the node will log an error and terminate processing for that item.
  • The targetValueKind should be set to 'Array' and targetValueWriteMode to 'Append' to accumulate multiple association updates in the payload.