Skip to content

Document

Document Type / MetaDocument

Document Type is a composition of multiple DataObjects.

MetaDocument is a representation of record of Document Type.

API

All Document has an API REST and SOAP (not generated by default).

SavePatch

Method to partially change the MetaDocument, only update the passed fields and returns the updated MetaDocument.

Support changing any field including Object type. If the type is Object the value passed will be searched in the another metaObject using the foreign key configuration.

The rule used tries to follow as much as possible the rfc6902, but here we use the follow rules:

  • It's used the . to access nested properties
  • Operation rules:
    • add: Put a value in the field if just if current value is null
    • replace: Put a value in the field independent of the current value
    • remove: Remove the value from the field, the value passed is not required
  • For collections the rule used to check if the item is in the list is the configured Unique Key of DataObject:
    • add: Put an item in the list if it is not already in it
    • replace: Put an item in the list or change an existent one according to unique key
    • remove: Remove the item from the collection, if the value is null the entire list is cleaned

There are not support for SOAP yet.

REST (HTTP PATCH)

The url must be used with the object id, just like in the example above:

http://miisy.com/api/CoffeeDispenser/documents/coffeerequests/3

Given the follow Document:

  • List field coffeeMixtureList where the field name is the unique key
  • SubList field mixtureCommentList inside coffeeMixtureList where the field comment is the unique key
  • Field inside sublist coffeeMixtureList.information with DataObject type and field coffeeMixtureList.information.requester being the foreign key
  • Field coffeeData with DataObject type
  • Field coffeeData.status with field status without a foreign key configured
  • Field coffeeData.drinkTime of DateTime
  • Field coffeeData.requester of String
{
  "fields" : [
    { "op" : "add", "path" : "coffeeMixtureList", "value": [{ "name" : "baunilha" }] },
    { "op" : "remove", "path" : "coffeeMixtureList" },
    { "op" : "add", "path" : "coffeeMixtureList", "value": [{ "name" : "água doce", "additionTime" : "2019-02-27T16:00:00", "amount" : 5, "mixtureCommentList" : { "comment" : "doce" } }] },
    { "op" : "add", "path" : "coffeeMixtureList", "value": { "name" : "leite", "additionTime" : "2019-02-27T17:00:00", "information" : { "requester" : "Marcelo Beccari" } } },
    { "op" : "replace", "path" : "coffeeMixtureList", "value": { "name" : "leite", "additionTime" : "2019-02-20T10:00:00", "information" : { "requester" : "Renato Dias" } } },
    { "op" : "replace", "path" : "coffeeMixtureList", "value": [{ "name" : "leite", "amount" : 10, "mixtureCommentList" : [{ "comment" : "comentário" }] }] },
    { "op" : "add", "path" : "coffeeMixtureList", "value": [{ "name" : "avelã" }] },
    { "op" : "remove", "path" : "coffeeMixtureList", "value": { "name" : "avelã" } },
    { "op" : "remove", "path" : "coffeeData.type" },
    { "op" : "replace", "path" : "coffeeData.status", "value": { "status" : "patchTesting", "info" : "MetaDocumentSavePatchTest" } },
    { "op" : "replace", "path" : "coffeeData.drinkTime", "value": "2019-02-20T10:00:00" },
    { "op" : "add", "path" : "coffeeData.drinkTime", "value": "2019-02-01T16:00:00" },
    { "op" : "remove", "path" : "coffeeData.requester", "value": null },
    { "op" : "replace", "path" : "coffeeData.requester", "value": "Patch Adams" },
    { "op" : "add", "path" : "coffeeData.requester", "value": "Nem vai" }
  ]
}

The operations executed are, respectively, the follow:

  • Add an item baunilha to coffeeMixtureList
  • Clean the entire list coffeeMixtureList
  • Add an item água doce with an item in mixtureCommentList to coffeeMixtureList
  • Add an item leite with a MetaObject in information to coffeeMixtureList
  • Change the item leite (since the name is the unique key) putting a value to field amount and change the value information.requester
  • Change the item leite (since the name is the unique key) changing the value of amount and putting an item to mixtureCommentList
  • Add an item avelã to coffeeMixtureList
  • Remove just the item avelã from coffeeMixtureList (since the name is the unique key and passed the value)
  • Set value of coffeeData.type to null
  • Set a DataObject value to coffeeData.status but since the foreign key is not configured the value will be left null
  • Set a value to field coffeeData.drinkTime, since the type is DateTime a value using ISO8601 or an Integer are accepted
  • As the operation is add and the value of this field was set in the prior operation nothing is done
  • Set to null for coffeeData.requester, since the type is a primitive (String) the value is irrelevant
  • Set a value to coffeeData.requester, since the operation is replace the current value is irrelevant
  • As the operation is add and the value of this field was set in the prior operation nothing is done