Domain-Object Helpers
createDomainObject(type)
Creates a new domain object with a new UUID.
Parameters
Name | Type | Description |
---|---|---|
type | String | domain type name |
deleteAttachment(attachmentId)
Calls the attachment controller to delete the attachment with the given id. The deletion might fail if there are still references to the attachment in the database.
Parameters
Name | Type | Description |
---|---|---|
attachmentId | String | attachment id |
Return Value
Type: Promise<void>resolves after the promise has been successfully deleted, rejects otherwise
deleteDomainObject(type, id)
Deletes the given domain object with the given id.
Parameters
Name | Type | Description |
---|---|---|
type | String | domain type name |
id | * | id field as string or number or generic scalar object. is converted into a generic scalar object if it is not one already |
extractTypeData(typeName, obj)
Extracts type data of a specified type from the given object. The method will return a plain object containing only the properties of the specified type.
Parameters
Name | Type | Description |
---|---|---|
typeName | String | GraphQL type name |
obj | Observable | object | object. |
Return Value
Type: objectObject containing just the type fields (and _type)
generateDomainObjectId(domainType)
Generates a new unique id for the given domain type using the application specific id generator (a server-side Spring bean implementing de.quinscape.automaton.runtime.domain.IdGenerator)
Parameters
Name | Type | Description |
---|---|---|
domainType | String | domain type name |
storeDomainObject(domainObject)
Stores a single domain object and resolves to the id of the stored object. You can use special id values (e.g. "" for UUIDGenerator an or 0 for SequenceIdGenerator) for them to be replaced with a new UUID or autoincrement id.
Parameters
Name | Type | Description |
---|---|---|
domainObject | object | domain object |
storeDomainObjects(domainObjects)
Stores a heterogeneous list of domain objects. You can use special id values (e.g. "" for UUIDGenerator an or 0 for SequenceIdGenerator) for them to be replaced with a new UUID or autoincrement id.
Parameters
Name | Type | Description |
---|---|---|
domainObjects | Array<object> | list of domain objects |
updateAssociations(opts, opts.domainType, opts.sourceIds)
Updates a many-to-many / associative entity from one of the associated objects. Ids may be placeholder id values.
Parameters
Name | Type | Description |
---|---|---|
opts | Object | options |
opts.domainType | String | Name of the associative entity ( e.g. "BazLink" ) |
opts.sourceIds | Array<object | *> | Array of id values for the source object. Each will be automatically wrapped as generic scalar unless it already is an object in which case it is used as-is. |
uploadAttachment(attachmentId, description, type)
Uploads the given file as attachment
Parameters
Name | Type | Description |
---|---|---|
attachmentId | String | attachment id to store the attachment under. Might be an already existing id. |
description | String | Description of the attachment / former file name |
type | String | Media type for the attachment. If this is an empty string, the Java side will guess the type |