Library Entity Commands¶
The commands that can be performed against a library entity (or library entities) are as follows:
Command | Purpose |
---|---|
edit | Edit an existing library entity |
disassociate | Disassociate library entities from entities |
associate | Associate library entities with entities |
promote | Promote business rules from an entity to a library entity |
import | Import one or more library entity business rules |
export | Export one or more library entities |
Glossary¶
Abbreviations used in this document:
Term | Meaning |
---|---|
EID | Entity ID (integer) |
LID | Library ID (integer) |
RAID | Real Attribute ID (integer) |
LAID | Library Attribute ID (integer) |
EBR | Entity Business Rule |
Edit¶
To edit a library entity, the request may contain the fields below:
{
"name": "library name",
"description": "description for the library"
}
The data element may contain one or both of two key-value pairs:
Key | Purpose |
---|---|
name | The new name of the entity |
description | The new description for the entity |
If the command is successful, the response will have no body.
Disassociate¶
The disassociate command may either disassociate a library entity from one or more real entities or one or more library entities from a real entity.
To disassociate a library entity from one or more real entities, the request would look like:
POST /api/repositories/jupiter/library/entities/1 HTTP/1.1
Content-Type: application/json
{
"command": "disassociate",
"data": {
"library": "3",
"entity": [
"1", "2"
],
"deleteRules": "1"
}
}
The library
and entity
fields are required.
The deleteRules
field is optional. If set to 1, all the rules will be deleted from the corresponding real entities after disassociation.
All the real entities specified in the entity
array will be disassociated from the library entity specified in the library
field.
To disassociate one or more library entities from a real entity, the request would look like:
POST /api/repositories/jupiter/library/entities HTTP/1.1
Content-Type: application/json
{
"command": "disassociate",
"data": {
"entity": "1",
"library": [
"2", "3"
],
"deleteRules": "1"
}
}
The entity
and library
fields are required.
deleteRules
field is optional. If set to 1, all the rules will be deleted from the corresponding real entity after disassociation.
All library entities specified in the library
array will be disassociated from the real entity specified in the entity
field.
A job is scheduled to run the disassociation in the background; the response to the request will contain the URL of the scheduled task.
{
"url": "/api/repositories/jupiter/scheduler/45"
}
Associate¶
The associate command may either associate a library entity with one or more real entities or one or more library entities with a real entity.
To associate a library entity with one or more real entities, the request would look like:
POST /api/repositories/jupiter/library/entities/1 HTTP/1.1
Content-Type: application/json
{
"command": "associate",
"data": {
"library": "1",
"entity": [
{
"id": "2",
"mapping": [
{
"realAttr": "1",
"libAttr": "1"
}
]
}
]
}
}
The library
and entity
fields are required.
library
should contain the library ID of the library entity to associated with the entities.
entity
is an array; each element contains an entity ID and the attributes to be mapped.
mapping
is an array of real and library attribute IDs to be mapped. All the real entities specified in the entity
array will be associated with the library entity specified in the library
field.
To associate one or more real entities to a library entity, the request would look like:
POST /api/repositories/jupiter/library/entities HTTP/1.1
Content-Type: application/json
{
"command": "associate",
"data": {
"entity": "1",
"library": [
{
"id": "2",
"mapping": [
{
"realAttr": "2",
"libAttr": "1"
}
]
}
]
}
}
The entity
and library
fields are required.
entity
will contain the entity ID of a real entity to associate with the library entities in library
.
library
is an array; each element contains a library ID and the attributes to be mapped.
mapping
is an array of real and library attribute IDs to be mapped. The real entity specified in entity
field will be associated with the library entities specified in the library
array.
A job is scheduled to run the association in the background; the response to the request will contain the URL of the scheduled task.
{
"url": "/api/repositories/jupiter/scheduler/43"
}
Promote¶
The Promote command is used to promote one or more business rules from a real entity to a library entity.
To promote one or more rules to a new library entity, the request would look like:
{
"command": "promote",
"data": {
"entity": "1",
"rules": ["1", "2"],
"library": {
"name": "my library",
"description": "my business rules library"
},
"operation": "COPY",
"mapping" : [
{
"realAttr": "1",
"libAttrName": "lib attribute"
}
]
}
}
To promote one or more rules to an existing library entity, the request would look like:
{
"command": "promote",
"data": {
"entity": "1",
"rules": ["1", "2"],
"library": {
"id": "2"
},
"operation": "ASSOC",
"mapping" : [
{
"realAttr": "1",
"libAttr": "1"
}
]
}
}
The library
, entity
, rules
and operation
fields are required. The mapping
field is optional.
entity
should contain the entity ID of the real entity where the rules are defined.
library
should contain the library ID of the library entity to which the rules will be promoted.
{
"library": {
"id": "2"
}
}
To promote the rules to a new library entity, LIBRARY
should contain the NAME
and DESCRIPTION
of the new library entity.
{
"library": {
"name": "lib1",
"description": "my library"
}
}
operation
can be one of the three following options:
Value | Purpose |
---|---|
COPY | Copy rules to a model entity. The mapping field is required in this case |
ASSOC | Promote rules to the library and associate entity to the library entity |
MOVE | Promote rules to the library entity and delete original rules from the entity |
For existing library attributes, mapping
is an array of real and library attribute IDs to be mapped.
{
"mapping" : [
{
"realAttr": "1",
"libAttr": "1"
}
]
}
For a new library entity, mapping
should be an array of real attribute ID and library attribute name. All the real entities specified in the entity
field will be associated with the library entity specified in the library
field.
{
"mapping" : [
{
"realAttr": "1",
"libAttrName": "library attribute"
}
]
}
Import¶
To import one or more library entity business rules, the request will look like:
{
"command": "import",
"data": {
"filenames": ["library1.ebr", "library2.ebr", "library3.ebr"],
"importType": "SERVER",
"fileType": "ebr"
}
}
The filenames
field is required; it should contain a list of the names of the EBR/XML/JSON file(s) to be imported. It should include the virtual path on the server where it resides. Please note that when importing a JSON file you must only specify a single JSON file to import:
{
"command": "import",
"data": {
"filenames": ["library.json"],
"importType": "SERVER",
"fileType": "json"
}
}
The importType
field is optional; it specifies whether the user wants to import the rules from the server file system or local filesystem. The values can be SERVER
or CLIENT
. Default value is SERVER
.
The fileType
field is required; the supported file types are: ebr, xml and json.
If the import is successful, a link to the import job scheduled will be returned to the client. For example:
{
"url": "/api/repositories/jupiter/scheduler/202"
}
If you are importing rules from the local filesystem, you must first call upload to upload the file to the server. The return value of this call should be passed in as the value of filenames
field. See the File Upload for more details.
The file upload uploads files to a temporary location and the files will be removed from that location once import is done, if importType
is CLIENT
.
Export¶
One or more entities can be exported from the library using the export
command. The export may be a scheduled task.
{
"command": "export",
"data": {
"filename": "myrules",
"fileType":"ebr",
"libEntity": ["2", "3", "4"]
}
}
The filename
value is required; it does not need to include the path.
The fileType
value is required; the supported file types are: ebr
, xml
and json
.
If the fileType
is json
, the export will happen as a foreground task; if the fileType
is xml
or ebr
, the export will happen as a scheduled task.
The libEntity
list is optional if the library entity ID is given in the URL. If libEntity
is present, it should contain one or more library entity IDs to be exported. If the fileType
is json
, only a single library entity ID is supported.
The table below shows all the fields that are available for edit:
Field | Description | Values |
---|---|---|
filename | Export Filename | |
fileType | Supported Export Format | ebr xml json |
libEntity | Library Entity ID(s) |
If the export is successful and the fileType
is json
, an array of link(s) to download the exported file is returned to the client. For example:
[
"/api/repositories/jupiter/download/myrules-LibInput-10.json"
]
If the fileType
is xml
or ebr
, a link to the scheduled task is returned to the client.
{
"url": "/api/repositories/jupiter/scheduler/462"
}
Once the scheduled task is complete, the exported file (or files) can be viewed using the file endpoint and subsequently downloaded using the download endpoint.
For an export in xml
or json
format, the library entity name and ID will be appended to the filename; any white space in the name will be replaced with “_”, as filenames with spaces are not supported when importing library business rules.
For example:
[
"/api/repositories/jupiter/download/myrules-Branches-2.xml",
"/api/repositories/jupiter/download/myrules-Services-3.xml",
"/api/repositories/jupiter/download/myrules-Sales_Person-4.xml"
]
Delete Unused Attributes¶
To delete unused attributes from library entity, the request may contain the fields below:
{
"command": "deleteUnusedAttributes",
"data": {
"libEntity": ["lid1", "lid2", "lidN"]
}
}
The libEntity
list is optional. If libEntity
is present, it should contain one or more library entity IDs to be exported. IF libEntity is not present, it will be fetched from the url.
If the command is successful, the response will have no body.