Datome
Search
K

Model Example

Please see the sample below for a better understanding of the fabric lot and garment definitions.
The body of the POST request contains the Model:
curl --location --request POST
'https://[your_organization].datome.io/api/models/fabric/' \
--header 'Authorization: Bearer 74a6c88d-62fe-4c13-8b40-c21fabbae819' \
--header 'Content-Type: application/json' \
--data '{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://mangrovia.solutions/generic.json",
"type": "object",
"title": "fabric",
"properties": {
"unique_name": {
"type": "string"
},
"id_technician": {
"type": "number"
},
"id_employee": {
"type": "number"
},
"available": {
"type": "boolean"
},
"notes": {
"type": "string"
}
},
"required": [
"unique_name",
"id_technician"
],
"identifier": "#/properties/unique_name",
"additionalProperties": false,
"mutations": {
"send_to_processing": {
"changes": [
{
"type": "transition",
"target": "#/states/transitions/send_to_processing"
}
],
"authorized_groups": [
"/root/group/…/admin"
]
},
"send_to_confirmed": {
"changes": [
{
"type": "transition",
"target": "#/states/transitions/send_to_confirmed"
},
{
"type": "dynamic",
"required": true,
"target": "#/properties/id_technician"
},
{
"type": "dynamic",
"required": false,
"target": "#/properties/id_employee"
},
{
"type": "static",
"value": true,
"target": "#/properties/available"
}
],
"authorized_groups": [
"/root/group/…/admin",
"/root/group2/…/controller"
],
"external_mutations": [
{
"model": "garment",
"target": "#/mutations/send_to_available"
}
]
},
"send_to_recalled": {
"changes": [
{
"target": "#/states/transitions/send_to_recalled",
"type": "transition"
},
{
"target": "#/properties/notes",
"type": "dynamic",
"required": true
},
{
"type": "static",
"value": true,
"target": "#/properties/available"
}
]
}
},
"states": {
"default_state": "open",
"transitions": {
"send_to_processing": {
"required_state": "open",
"target_state": "processing"
},
"send_to_confirmed": {
"required_state": "processing",
"target_state": "confirmed"
},
"send_to_recalled": {
"required_state": "confirmed",
"target_state": "recalled"
}
}
},
"ui:order": [
"unique_name",
"available",
"id_employee",
"id_technician"
]
}
The same approach can be applied for the Model garment which has a one-to-one relation with the fabric Model that has been specified in the properties block using the relation keyword.
{
"$id": "https://mangrovia.solutions/garment.json",
"$schema": "https://json-schema.org/draft-07/schema",
"title": "garment",
"description": "Garment Model describes the manufacturing process of a garment.",
"type": "object",
"properties": {
"unique_name": {
"type": "string"
},
"serial_number": {
"type": "string"
},
"garment_type": {
"type": "string"
},
"size": {
"type": "string"
},
"available": {
"type": "boolean"
},
"fabric_relationship": {
"relation": {
"model": "fabric"
},
"type": "string",
"description": "Relation to a fabric model previously created"
}
},
"required": [
"unique_name",
"serial_number",
"garment_type",
"size",
"fabric_relationship"
],
"additionalProperties": false,
"identifier": "#/properties/serial_number",
"label": "#/properties/garment_type",
"states": {
"default_state": "created",
"transitions": {
"send_to_available": {
"required_state": "created",
"target_state": "available"
},
"send_to_recalled": {
"required_state": "available",
"target_state": "recalled"
}
}
},
"mutations": {
"send_to_available": {
"changes": [
{
"type": "transition",
"target": "#/states/transitions/send_to_available"
},
{
"type": "static",
"value": true,
"target": "#/properties/available"
}
],
"authorized_groups": [
"/root/group2/…/controller"
]
},
"send_to_recalled": {
"changes": [
{
"target": "#/states/transitions/send_to_recalled",
"type": "transition"
}
],
"external_mutations": [
{
"model": "fabric",
"target": "#/mutations/send_to_recalled"
}
]
}
}
}