Entity Factory

If Domain modelling is enabled, the SDK provides a Factory for entities. The factory offers methods to create new entity objects, grouped by the namespaces in which the entities are defined. After creation, the properties of the entity can be accessed. The created entity objects can then e.g. be used as input for services or commands.

Create new entity

The example below shows how to create entities using the factory:

// Create an Entity using entity factory
const entity1 = this.factory.entity.nsacrnm.Entityidentifier();
// Access entity1 properties
entity1.propIdentifier = 'some property value';


// Create a Root Entity using entity factory
const root1 = this.factory.entity.nsacrnm.RootEntityIdentifier();
// Access root1 properties
root1.propIdentifier = 'some property value';


// Create an Input Entity using entity factory
const input = this.factory.entity.nsacrnm.Service1_Input();
// Access input properties
input.propIdentifier = 'some property value';

Entity instance check

In the implementation file of a service, command, agent and operation entity instance check can be done through isInstanceOf functionality, the entity instance check will also check for the entity hierarchy.

// check an object
if (this.isInstanceOf.entity.ns1.BlueCar(car)) {
    // now one can access the special property that only blue car has
    const prop = car.specialPropOfBlueCar;
}

// check BlueCar is a Car (Since BlueCar is a child of Car, the entity instance check will also check for the entity hierarchy)
if (this.isInstanceOf.entity.ns1.Car(blueCar)) {
    // now one can access the special property that only car has
    const prop = blueCar.specialPropOfCar;
}