Data Models

The platform6.datamodels service allows to create XML files validator.

Read the user guide of the Data models service to discover its operating mode.

List the data models identifiers

This resource returns the list of the data models identifiers.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) list.ids
platform6.request.user The email address of the user sending the message

Headers of the response

Header’s key Description
platform6.response.value The list of identifiers

Example

def cm = [ headers: [ 'platform6.request.action': 'list.ids' ] ]

print p6.service.request('platform6.datamodels', cm).headers['platform6.response.value']

The response will be:

[
    {
        "appKey":"",
        "name":"TransactionInfo"
    },
    {
        "appKey":"",
        "name":"_serviceConfiguration"
    }
]

Get a data model

Return the item by its identifier if it exists, otherwise, it throws an exception.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) get
id The identifier of the data model (required)
platform6.request.user The email address of the user sending the message

Headers of the response

Header’s key Description
platform6.response.value The data model

Example

def cm = [
    headers: [
        'platform6.request.action': 'get',
        'id': 'my_model'
    ]
]

print p6.service.request('platform6.datamodels', cm).headers['platform6.response.value']

The response will be:

{
    "name":"my_model",
    "appKey":"",
    "description":{
        "EN":"My model"
    },
    "enabled":false,
    "contentMode":"NONE",
    "lastModifiedBy":"admin@amalto.com",
    "lastModifiedDate":1528385069279,
    "revisionId":"ec964c6eb4c6d23eb42c3eba91e6d8e9",
    "schema":"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" attributeFormDefault=\"unqualified\" blockDefault=\"\" elementFormDefault=\"qualified\" finalDefault=\"\">\n\n\n    <xsd:element abstract=\"false\" name=\"Issue\" nillable=\"false\">\n        <xsd:annotation>\n            <xsd:documentation>A functional or technical error to be sent to the Error Management Console</xsd:documentation>\n        </xsd:annotation>\n        <xsd:complexType mixed=\"false\">\n            <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"id\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"date\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"trigger\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"triggeringDocument\" nillable=\"false\" type=\"xsd:anyType\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"routingOrder\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"step\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"itemPK\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"dataCluster\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"concept\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"unbounded\" minOccurs=\"1\" name=\"ids\" nillable=\"true\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"code\" nillable=\"true\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"state\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"comments\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"author\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"text\" nillable=\"false\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n                <xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"parameters\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"key\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"value\" nillable=\"false\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n            </xsd:sequence>\n        </xsd:complexType>\n        <xsd:unique name=\"Issue\">\n            <xsd:selector xpath=\".\"/>\n            <xsd:field xpath=\"id\"/>\n        </xsd:unique>\n    </xsd:element>\n\n\n\n</xsd:schema>\n"
}

If the data model is not found, it will return an error:

{
    "message" : "The data model 'my_model' is not found!",
    "stackTrace" : [
        "io.platform6.common.util.P6Exception: The data model 'my_model' is not found!",
        "    at com.amalto.service.datamodels.DataModelsService.notifyRequestMessage(DataModelsService.scala:84)",
        "    at com.amalto.b2box.core.impl.servicecomponent.AbstractServiceComponent.onCommonMessage(AbstractServiceComponent.java:688)",
        "    at com.amalto.b2box.core.impl.platform.messagebus.BusQueueController$ServiceQueueRunner.run(BusQueueController.java:183)",
        "    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)",
        "    at java.util.concurrent.FutureTask.run(FutureTask.java:266)",
        "    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)",
        "    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)",
        "    at java.lang.Thread.run(Thread.java:748)"
    ]
}

Check a data model’s existence

Return by its identifier the item if it exists, otherwise, it returns null.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) exists
id The identifier of the data model (required)
platform6.request.user The email address of the user sending the message

Headers of the response

Header’s key Description
platform6.response.value The data model

Example

def cm = [
    headers: [
        'platform6.request.action': 'exists',
        'id': 'my_model'
    ]
]

print p6.service.request('platform6.datamodels', cm).headers['platform6.response.value']

If it exists it returns the item (see below), otherwise, it returns null.

{
    "name":"my_model",
    "appKey":"",
    "description":{
        "EN":" My model"
    },
    "enabled":false,
    "contentMode":"NONE",
    "lastModifiedBy":"admin@amalto.com",
    "lastModifiedDate":1528385069279,
    "revisionId":"ec964c6eb4c6d23eb42c3eba91e6d8e9",
    "schema":"<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" attributeFormDefault=\"unqualified\" blockDefault=\"\" elementFormDefault=\"qualified\" finalDefault=\"\">\n\n\n    <xsd:element abstract=\"false\" name=\"Issue\" nillable=\"false\">\n        <xsd:annotation>\n            <xsd:documentation>A functional or technical error to be sent to the Error Management Console</xsd:documentation>\n        </xsd:annotation>\n        <xsd:complexType mixed=\"false\">\n            <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"id\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"date\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"trigger\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"triggeringDocument\" nillable=\"false\" type=\"xsd:anyType\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"routingOrder\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"step\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"itemPK\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"dataCluster\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"concept\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"unbounded\" minOccurs=\"1\" name=\"ids\" nillable=\"true\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"code\" nillable=\"true\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"state\" nillable=\"false\" type=\"xsd:string\"/>\n                <xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"comments\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"author\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"text\" nillable=\"false\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n                <xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"parameters\" nillable=\"false\">\n                    <xsd:complexType mixed=\"false\">\n                        <xsd:sequence maxOccurs=\"1\" minOccurs=\"1\">\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"key\" nillable=\"false\" type=\"xsd:string\"/>\n                            <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"value\" nillable=\"false\" type=\"xsd:string\"/>\n                        </xsd:sequence>\n                    </xsd:complexType>\n                </xsd:element>\n            </xsd:sequence>\n        </xsd:complexType>\n        <xsd:unique name=\"Issue\">\n            <xsd:selector xpath=\".\"/>\n            <xsd:field xpath=\"id\"/>\n        </xsd:unique>\n    </xsd:element>\n\n\n\n</xsd:schema>\n"
}

Add/update a data model

If the data model exists, it will overwrite the existing properties with the new ones. If not, it will create a new data model.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) put
id The identifier of the data model (required)
description The English description of the data model (required)
schema The schema of the data model
platform6.request.user The email address of the user sending the message

The new data model will be verified before upsert.

The last author of the modification will be the user who sent the common message.

The content mode will automatically be set to NONE.

Warning

The identifier must validate the service’s item rules.

Headers of the response

Header’s key Description
platform6.response.status A boolean set to true

Example

def cm = [
    headers: [
        'platform6.request.action': 'put',
        'id': 'my_new_data_model',
        'description': 'A new data model',
        'schema': '<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"></xsd:schema>'
    ]
]

print p6.service.request('platform6.datamodels', cm).headers['platform6.response.status']

The response will be true if the data model is validated and created/updated.

If a field of the input is incorrect, it will throw an exception.

{
    "message" : "Unexpected exception upserting a new data model 'my_new_data_model': the parameter 'description' is missing.",
    "stackTrace" : [
        "io.platform6.common.util.P6Exception: Unexpected exception upserting a new data model 'my_new_data_model': the parameter 'description' is missing.",
        "    at com.amalto.service.datamodels.DataModelsService.notifyRequestMessage(DataModelsService.scala:106)",
        "    at com.amalto.b2box.core.impl.servicecomponent.AbstractServiceComponent.onCommonMessage(AbstractServiceComponent.java:688)",
        "    at com.amalto.b2box.core.impl.platform.messagebus.BusQueueController$ServiceQueueRunner.run(BusQueueController.java:183)",
        "    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)",
        "    at java.util.concurrent.FutureTask.run(FutureTask.java:266)",
        "    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)",
        "    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)",
        "    at java.lang.Thread.run(Thread.java:748)"
    ]
}

Remove a data model

Delete a data model by its identifier.

It returns the data model which has been deleted.

Parameters

Headers of the request

Header’s key Description Value
platform6.request.action The action to perform (required) remove
id The identifier of the data model (required)
platform6.request.user The email address of the user sending the message

Headers of the response

Header’s key Description
platform6.response.value The data model deleted

Example

def cm = [
    headers: [
        'platform6.request.action': 'remove',
        'id': 'my_new_data_model'
    ]
]

print p6.service.request('platform6.datamodels', cm).headers['platform6.response.value']

If the data model does not exist, the value will be null.

If it does, it will be deleted and the response will be:

{
    "name":"my_new_data_model",
    "appKey":"",
    "description":{
        "EN":"A new data model"
    },
    "enabled":false,
    "contentMode":"NONE",
    "lastModifiedBy":"admin@amalto.com",
    "lastModifiedDate":1529930114177,
    "revisionId":"3e6d52554aa5a4d8e3cdeb38237896dd",
    "schema":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" attributeFormDefault=\"unqualified\" blockDefault=\"\" elementFormDefault=\"unqualified\" finalDefault=\"\"/>"
}