APIs for Corticon.js Service Callouts
- Last Updated: April 22, 2024
- 1 minute read
- Corticon.js
- Documentation
| getLogger() | Returns a handle to the logger. It provides a mechanism to log trace or errors into the logfile based on the decision service configuration |
| getConfiguration() | Returns a reference to the service callout properties passed in the decision service overall configuration |
| getAllEntities() | Returns all the entities in the working memory. |
| getEntityTypes() | Returns all the entity types in the working memory. |
| getEntitiesByType() | Takes the Entity type as a parameter, and then returns all the entities of the type in the working memory. |
| createEntity(<entityType>) | Takes a String defining the entity vocabulary type. Creates an entity with the defined entity type at the root and a unique identifier. Returns the newly created Entity. |
| createEntity(<entityType>,{initializers}) | Takes a String defining the entity vocabulary type. The function also accepts an initializer JSON object to set the attributes of the entity. Creates a new entity with the defined entity type at the root. Returns the newly created Entity. |
| removeEntity(<entityObject>) | Removes the entity from the working memory. |
| getOperator() | Accesses a decimal, dateTime or date operator. See Use APIs to update attributes sections: |
| addAssociation(entityObject1, entityObject2, roleName) | Adds an association of the element Entity2 with Entity1, provided such an association is allowed by the Vocabulary. |
| setAssociation(entityObject1, entityObject2, roleName) | Replaces any existing elements of Entity1.roleName. |
| removeAssociation(entityObject1, entityObject2, roleName) | Removes the element Entity2 from Entity1.roleName, provided such element is currently associated. |
| addEntitiesAndAssociations(entityType, payload) | Adds entities and associations as top level entities. |
| addAssociationsToEntity(parentEntity, rolename, payload) | Adds nested associations to existing entities in the working memory. |
EXAMPLES
getLogger() example
|
getConfiguration() example
|
{ "prop1": "abc", "prop2":
12 }
getAllEntities() example
|
getEntityTypes() example
|
You can then use the entity types to get all the entities of a particular type and then update or modify the data as needed.
getEntitiesByType (<entityType>) example
|
createEntity(<entityType>) example
Another way to create an Entity is to just specify the entityType. This will create an entity with the defined entity type and a unique identifier.
|
You can then set the attributes of this new entity:
|
For more information, see Use APIs to update attributes
createEntity(<entityType>, {initializers}) example
Create an new entity at the root. Takes a String defining the entity vocabulary type. The function creates the entity in the JSON document with a unique identifier. The function also accepts an intitalizer JSON object to set the attributes of the entity. The function returns the newly created Entity.
For example, to initialize an Entity of type Aircraft, and also set the
attribute aircraftType to '737Boeing'
|
removeEntity(<entityObject>) example
|