Class: Status
What
The abstract Status class provides methods to create a new Status object based on an existing Status Code.
Status codes are defined by creating an Resource Status Definition Asset within your Project.
Within this Asset you can create one or more Vendors which in turn may have a number of Status
entries.
Each of those Status entries has the following structure:
- ID: A unique number
- Logical name: A name which uniquely identifies a Status, e.g.
FIELD_UNKNOWN
- Language: One of the supported language codes, e.g.
en
- Message: The actual Status message. The message may contain placeholders, e.g.
The field with name %1 is unknown
. In this example, the placeholder%1
is filled with the respective value when creating the Status using method Status.create.
How to use
Based on the Vendor and the logical status name which you have defined, you can create a new Status.
The Status
can then be attached to a message or a passed as a result code when rolling back a stream (example).
Properties
code
code:
number
The code of the Status which was assigned when the Status was created.
Example
// Create a new Status
const status = Status.create(VENDOR, 42);
// Get the code
const c = status.code; // returns 42
message
message:
string
The message of the Status which was assigned when the Status was created. The message may contain placeholders which can be filled with parameters when creating the Status. Same as getMessage.
Example
// Create a new Status
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Putin');
// Get the message
const m = status.message; // returns "Field with name '%1' contains illegal value '%2'"
parameters
parameters:
string
[]
The parameters which were passed when the Status was created. These parameters are used to fill in placeholders in the message. Same as getParameters.
Example
// Create a new Status
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Putin');
// Get the parameters
const p = status.parameters; // returns ["LastName", "Putin"]
// In the above, the message placeholders %1 and %2 will be replaced by "LastName" and "Putin".
// So the final message may be "Field with name 'LastName' contains illegal value 'Putin'."
subStatus
subStatus:
Status
[]
Returns an array of States which are sub states to the current Status. Same as getSubStatus.
Example
// Get array of States.
const statusArray = status.subStatus;
Returns
- Array of States which are sub states to the current Status.
vendor
vendor:
Vendor
The vendor of the Status. See also Status.getVendor. Same as getVendor.
Example
// Create a new Status
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Putin');
// Get the vendor
const v = status.vendor; // returns VENDOR
vendorId
vendorId:
number
The ID of the Vendor which is associated with this Status. Same as getVendorId.
Example
// Create a new Status
const status = Status.create(VENDOR, 'ILLEGAL_VALUE', 'LastName', 'Putin');
// Get the vendor
const vId = status.vendorId; // returns 42
Methods
getCode()
getCode():
string
Returns the code of a Status.
Returns
string
- Status code
Example
// Get the status code
const code = status.getCode();
// Result: 4711