Domain-Object Helpers

createDomainObject(type)

Creates a new domain object with a new UUID.

Parameters

NameTypeDescription
typeStringdomain 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

NameTypeDescription
attachmentIdStringattachment 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

NameTypeDescription
typeStringdomain 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

NameTypeDescription
typeNameStringGraphQL type name
objObservable | objectobject.

Return Value

Type: object

Object 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

NameTypeDescription
domainTypeStringdomain 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

NameTypeDescription
domainObjectobjectdomain 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

NameTypeDescription
domainObjectsArray<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

NameTypeDescription
optsObjectoptions
opts.domainTypeStringName of the associative entity ( e.g. "BazLink" )
opts.sourceIdsArray<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

NameTypeDescription
attachmentIdStringattachment id to store the attachment under. Might be an already existing id.
descriptionStringDescription of the attachment / former file name
typeStringMedia type for the attachment. If this is an empty string, the Java side will guess the type