Domain Object
If a domain object resource (section 14) is accessed with the Apache Causeway profile, the resultant representation is a JSON object with simple key/value pairs for each property.
The contents of any collections are also eagerly returned, consisting of an array of elements of each referenced object.
Each such element contains key/value pairs of each property (in other words, a grid of data is returned).
Each element also has a special $$href
property (so that the client can easily navigate to a resource for that object) and a $$title
property (to use as a label, eg the hyperlink text).
In addition, the representation defined by the RO spec is also included, under a special $$ro
property.
For example, in a todo app, accessing this resource:
http://localhost:8080/restful/objects/TODO/45
with an Accept
request header of:
Accept: application/json;profile="urn:org.apache.causeway/v2"
returns the following representation:
{
"$$href" : "http://localhost:8080/restful/objects/TODO/45", (1)
"$$instanceId" : "45", (2)
"$$title" : "Buy bread due by 2015-12-04", (3)
"description" : "Buy bread", (4)
"category" : "Domestic",
"subcategory" : "Shopping",
"complete" : false,
"atPath" : "/users/sven",
...
"similarTo" : [ { (5)
"$$href" : "http://localhost:8080/restful/objects/TODO/46",
"$$instanceId" : "46",
"$$title" : "Buy milk due by 2015-12-04",
"description" : "Buy milk",
"category" : "Domestic",
...
}, {
"$$href" : "http://localhost:8080/restful/objects/TODO/47",
"$$instanceId" : "47",
"$$title" : "Buy stamps due by 2015-12-04",
"description" : "Buy stamps",
"category" : "Domestic",
...
},
...
} ],
"dependencies" : [ ],
"$$ro" : { (6)
"links" : [ ... ],
"extensions" : { /* ... */ },
"title" : "Buy bread due by 2015-12-04",
"domainType" : "TODO",
"instanceId" : "45",
"members" : { /* ... */ }
}
}
1 | hyperlink to the representation |
2 | instance id of the domain object (unique within its type) |
3 | title of the domain object |
4 | all the properties of the domain object (to which the caller has access), as key/value pairs |
5 | contents of each collection |
6 | special $$ro json-prop, being the normal RO Spec representation for this object |
with a Content-Type
header:
Content-Type: application/json;
profile="urn:org.apache.causeway/v2";repr-type="object"