You are viewing the documentation for Blueriq 15. Documentation for other versions is available in our documentation directory.
Creating and updating aggregates
When creating or updating an aggregate, a snapshot is made of the current profile that includes instances of all entities defined in the aggregate, and all those instances' relations that were included in the aggregate.
By default, all instances of singleton entities are included and no instances of multiton entities are included. The StoreInstances parameter is used to define which multiton instances are stored in the aggregate. The unique Id of the created aggregate will be saved in a selected attribute. This Id can then be used in other services to Read, Update or Delete the aggregate.
If the attribute selected for the AggregateId is not part of a singleton then the target instance parameter can be used to select the instance on which the aggregate Id must be stored. If the target instance has no value, then it is assumed that the selected attribute either belongs to a singleton entity, or that there is an active instance present. If not, an error is thrown. The target instance must be single valued.
Parameters
Name | Direction | Description | Type | Occurrences | Required |
---|---|---|---|---|---|
AggregateType | Input | Select the aggregate you want to create and store. This is a list of the aggregate definitions. | Aggregate | Single valued | true |
AggregateId | Output | The attribute on which you want to store the created aggregate Id. | Attribute | Single valued | true |
TargetInstance | Input | The instance you want to use for storing the aggregate Id. | Expression resulting in an instance | Single valued | false |
VersionIDOutput | Output | The attribute on which you want to store the version Id of the created aggregate. | Attribute | Single valued | false |
StoreInstances | Input | The starting point instance(s) for storing. | Expression(s) resulting in instance(s) | Multi valued | false |
User-set vs system-set
When storing an aggregate, only values that are user-set are stored, all system-set values are not stored. The data of the aggregate is stored in a XML blob.
Default metadata
Storing an aggregate also stores a set of metadata information in the database:
Field | Type | Description |
---|---|---|
AggregateID | Integer | Unique Id of the aggregate |
Type | String | Aggregate type |
CreatedByUserName | String | User name of the person/system that created the aggregate |
CreatedByID | String | Unique Id of the user. A user name can have duplicates, the user Id makes the user unique |
CreationDate | Datetime | Creation time stamp of the aggregate |
Events
This service uses default events for a commit and for an exception.
The Unauthorized
exit is triggered when the user does not have one of the roles that is set on the Aggregate definition.
Example
Below an example is given for a create service with versioning.
ER diagram | Aggregate definition |
Service definition |