10Duke Enterprise release 3 documentation is no longer being updated

Generic graph API operations

The following are generic CRUD graph operations that can be used with all objects on the graph.

Create and update objects

To create or update objects, post/put an object graph to the graph API.

Note: Update calls to the Graph API perform business logic closer to a merge compared update. In many cases, create and update work together, because an object graph may consist of both new and existing objects.

Experiment with the client application to decide if it’s more feasible to implement a full query of all data subject to update, or to use only a partial query and let the server side apply the default logic. Client-sent data always takes priority over automated server-side logic.

This example shows how to create a company (type: Organization) with a related employees group (type: ProfileGroup):

POST /graph

{
  "__objType": "Organization",
  "type": "company",
  "name": "ACME",
  "id": "f2f7416a-eb3e-42c5-85dc-db31b3ed5613",
  "rel_Relations": [
    {
      "rel_Relation": {
        "__objType": "ObjectRelation",
        "multiplicity": "ONE_TO_MANY",
        "relatedObjectType": "com.tenduke.sdk2.objectmodel.identity.ProfileGroup"
      },
      "rel_RelatedObjectList": {
        "__objType": "RelatedObjectList",
        "rel_RelatedObjects": [
          {
            "__objType": "ProfileGroup",
            "name": "Employees",
            "referenceFields": {
              "__objType": "HashMap",
              "Entries": [
                {
                  "__objType": "KeyValue",
                  "value": {
                    "__objType": "UUID",
                    "value": "f2f7416a-eb3e-42c5-85dc-db31b3ed5613"
                  },
                  "key": {
                    "__objType": "String",
                    "value": "ref_Organization_id"
                  }
                }
              ]
            },
            "id": "cfd252be-2d14-41df-a671-c9ccac857c37",
            "type": "employees"
          }
        ]
      }
    }
  ]
}

Read and query objects

To read or query, issue an HTTP GET request with a selector as the request URI.

This example shows how to read the profile group that was created in the previous example:

GET /graph/Organization[@name='ACME']/~OneToMany/ProfileGroup[@type='employees']

Note the use of:

  • / (forward slash) to denote the start of a type selector

  • [] brackets to enclose a field selector

  • @ to denote a field and a corresponding condition on a value

  • ~ to denote a relation type

To extend the example slightly:

  1. GET /graph/Organization[@name~'Acme*']/~OneToMany/ProfileGroup{count}
    
  2. GET /graph/Organization[@name~'Acme*']/~OneToMany/ProfileGroup{i=0,r=5}
    

Delete objects

To delete, make an HTTP DELETE request with a selector as the request URI.

This example shows how to delete a profile group based on id:

DELETE /graph/ProfileGroup[@id='ID-HERE']