Case as any object
ANY XML
Layers used in | Business |
Type | Business object |
Java interface | org.w3c.dom.Document |
DTO interface | org.w3c.dom.Element |
ANY XML represents any case - it is used in SOAP services. The Mercury DB (HgDB) system is responsible for, among other things, automatically identifying the type of case. The business service allows you to save any type of case presented using XML. An essential element of the case object representation is the existence of the mrcCaseHeader
field, the type of which was described in the article devoted to the CaseHeader.
There are limitations related to the naming of object fields, e.g. a field in the object represented by the case (simple or complex) cannot be called mrcCaseHeader
. There can be a maximum of 128 fields (tags) in the object (simple or complex) represented by the case.
Below is a simple example of an argument for saving any type of case using simple XML:
<caseXML>
<testObjectWithoutAttrs>
<mrcCaseHeader xmlns="http://business.dto.ws.hgdb.io/mrcObject"
xsi:schemaLocation="http://business.dto.ws.hgdb.io/mrcObject http://hgdb.io/xsd/dto/hgdb-mrc-object-3.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<typeCode><![CDATA[TestObjectWithoutAttrs]]></typeCode>
<status><![CDATA[A]]></status>
<storeId><![CDATA[2003]]></storeId>
<className><![CDATA[TestObjectWithoutAttrs]]></className>
<dirty><![CDATA[true]]></dirty>
<pkPropertyName><![CDATA[name]]></pkPropertyName>
</mrcCaseHeader>
<status><![CDATA[Aktywny]]></status>
<name><![CDATA[Mistrz]]></name>
</testObjectWithoutAttrs>
</caseXML>
In the example shown, we are sending a case with the following properties:
- The case type code is:
TestObjectWithoutAttrs
- The case type name is:
TestObjectWithoutAttrs
- The case will be assigned to the warehouse with the identifier 2003
- The case has a unique field defined called name
- The case represents a simple object of the type named as
TestObjectWithoutAttrs
has two fields named: status
(value of the Active field)name
(value of the Master field)
As a result of calling the writing service, we will receive an example XML representation of the case:
<variable type="TestObjectWithoutAttrs">
<mrcCaseHeader type="MrcCaseHeader" version="1" xmlns="http://business.dto.ws.hgdb.io/mrcObject"
xsi:schemaLocation="http://business.dto.ws.hgdb.io/mrcObject http://hgdb.io/xsd/dto/hgdb-mrc-object-3.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<caseId type="Integer">5012</caseId>
<groupId type="Integer">2507</groupId>
<typeId type="Integer">3008</typeId>
<typeCode type="String">TestObjectWithoutAttrs</typeCode>
<status type="String">A</status>
<previousVersionId type="Integer">4511</previousVersionId>
<priceValue type="Decimal">1000.0</priceValue>
<storeCount type="Integer">1</storeCount>
<storeId type="Integer">2003</storeId>
<createDate isEncoded="false" type="Date">2017/06/26 17:34:09.150 CEST</createDate>
<createdBy type="String">mateusz</createdBy>
<lastModifyDate isEncoded="false" type="Date">2017/06/26 17:34:09.150 CEST</lastModifyDate>
<lastModifiedBy type="String">mateusz</lastModifiedBy>
<modifyComment type="String">SOAP request</modifyComment>
<createdByRoleName type="String">CKBPM-Team</createdByRoleName>
<lastModifiedByRoleName type="String">CKBPM-Team</lastModifiedByRoleName>
<className type="String">TestObjectWithoutAttrs</className>
<version type="String">3</version>
<dirty type="Boolean">false</dirty>
<pkPropertyName type="String">name</pkPropertyName>
</mrcCaseHeader>
<status id="1" isEncoded="false" position="1" type="String" version="1">Aktywny</status>
<name id="2" isEncoded="false" position="2" type="String" version="1">Mistrz</name>
</variable>
XML tag attributes
To clarify the identification of the case type during the action of saving/updating it, it is recommended to add appropriate attributes to tags, based on which the system will be able to identify, for example, what type of a given field is, or the position in which the field appears in the case type definition. Below is a list of attributes that can be used in the case definition in XML format:
Attribute | Description | Type | Required | Allowed values |
---|---|---|---|---|
name | Field name (field definition name). If the attribute is empty, this value will be taken from the XML tag name. Representation of the definitionName field in the ParamDefinitionPK composite key of the ParamDefinition entity. | String | No | |
version | Parameter definition version stored in the Mercury DB database. Representation of the version field in the ParamDefinitionPK composite key of the ParamDefinition entity. | String | No | Integer field representation. Integer values greater than zero |
label | Recommended field label presented in the generated case edit (modification) form. If the attribute is empty, the label will assume the field name. Representation of the recomendedLabel field of the ParamDefinition entity. | String | No | |
id | XML identifier of the field. A field allowing the identification of fields with the same names (tags) in the transmitted XML - does not apply to list (collection) elements. If not provided, the field will assume the value of the field position in XML. Representation of the xmlId field in the TypeParam entity. | String | No | |
isRequired | Whether the field should be identified as a required field during later editing - a field for the purposes not only of generating case data edit forms of a given type. Representation of the isRequired field in the TypeParam entity. | String | No | Representation of the Boolean field: true or false |
updateable | Can the field be updated/changed? Representation of the updateable field in the TypeParam entity. | String | No | One of the values allowed: READWRITE , READONLY , ONCREATE , ONCREATEVISIBLE , OTHER |
isEncoded | Is the field encoded to the form stored in the Mercury database. If the field has a value set to false it means that the value is a presentational value. A simple example. The value of a Date field in the Mercury database is stored as a number of milliseconds. If isEncoded=”true” then a number will be sent, if isEncoded=”false” then a date formatted according to the given format in the context of the action. | String | Yes, if we want to send values that require decoding, e.g. for fields of type Date , Currency , Lob . | Representation of the Boolean field: true or false |
position | Attribute in XML defining the position of the field. Representation of the ‘position’ field in the primary key TypeParamPK of the TypeParam entity. | String | No | Representation of the Integer type field. Integer values [1..128] |
type | Name of the case field type. Equivalent of the subType field in the ParamDefinition entity. For field types that are a list of elements, it is recommended to append the suffix [] to the type name, e.g. Date[] , TestUser[] , etc., clearly indicating that the parameter is a list. | String | Recommended for types representing complex objects are their names, e.g. TestUser . To define simple types, the system clearly identifies simple types with the names: Boolean , BooleanInteger , Text , String , Password , Number , Decimal , Currency , Integer , Date , DateLong , Time , Image , Document , URL , Lob , NameValuePair . Otherwise, an attempt will be made to transform the field to the String type, and for lists (name with the [] suffix) to the Lob type field |
<role>
<mrcCaseHeader type="MrcCaseHeader" version="1" xmlns="http://business.dto.ws.hgdb.io/mrcObject"
xsi:schemaLocation="http://business.dto.ws.hgdb.io/mrcObject http://hgdb.io/xsd/dto/hgdb-mrc-object-3.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<groupId type="Integer"><![CDATA[2003]]></groupId>
<typeCode type="String"><![CDATA[TestRole]]></typeCode>
<status type="String"><![CDATA[A]]></status>
<priceValue type="Decimal"><![CDATA[1000.0]]></priceValue>
<storeCount type="Integer"><![CDATA[1]]></storeCount>
<storeId type="Integer"><![CDATA[2003]]></storeId>
<className type="String"><![CDATA[TestRole]]></className>
<version type="String"><![CDATA[1]]></version>
<dirty type="Boolean"><![CDATA[true]]></dirty>
<pkPropertyName type="String"><![CDATA[name]]></pkPropertyName>
</mrcCaseHeader>
<status id="1" label="Status roli" type="String"><![CDATA[Aktywny]]></status>
<name id="1" label="Nazwa roli" type="String"><![CDATA[Mistrz]]></name>
<priv id="2" label="Uprawnienia do panelu administracji" type="String"><![CDATA[RW]]></priv>
<priv id="3" label="Uprawnienia do portalu" type="String"><![CDATA[RO]]></priv>
<users id="4" label="Lista uprawnionych" type="String[]">
<item><![CDATA[slawas]]></item>
<item><![CDATA[ttesteusz]]></item>
</users>
</role>
Let's pay attention to the additional data sent to the Mercury DB (HgDB) system:
- Defined labels for individual fields (the
label
attribute) - Defined XML identifiers (the
id
attribute) for fields with the same names (in this case thepriv
field) - Defined attributes describing the types of individual fields.
ANY JSON
Layers used in | Business |
Type | Business object |
Java Interface | org.mercury.json.JSONObject |
DTO Abstraction | com.fasterxml.jackson.databind.JsonNode |
ANY JSON represents any case - it is used in REST services. An essential element of the case object representation is the existence of the mrcCaseHeader
field, the type of which was described in the article devoted to the CaseHeader case header.
Let us note that the JSON format is much poorer than the XML format. This has its advantage, because we send much less data. It also has the disadvantage that we cannot send too much information about the defined type.
{
"mrcCaseHeader": {
"caseId": 783695,
"groupId": 300042,
"typeId": 3509,
"typeCode": "SlawasTestObj",
"status": "A",
"rootVersionId": 783695,
"priceValue": 0,
"storeCount": 1,
"storeId": 1505,
"createDate": "12-01-2019 03:14:12 +01:00",
"createdBy": "slawas",
"lastModifyDate": "12-01-2019 03:14:12 +01:00",
"lastModifiedBy": "slawas",
"modifyComment": "SOAP request",
"createdByRoleName": "CKBPM-Team",
"lastModifiedByRoleName": "CKBPM-Team",
"className": "SlawasTestObj",
"version": "1",
"dirty": false,
"pkPropertyName": "name"
},
"status": "Aktywny",
"name": "aatest",
"priv": "RO",
"users": [
"slawa1233",
"slawas2",
"slawas3",
"slawas4",
"ttest2345"
]
}