Introduction
The views allow to get information on any resource available in Wedia repository. It is a selection of the properties of a unit object in Wedia as well as the properties of the related objects.
Configuration
To each view are an identifier and a JSON configuration associated.
JSON example
Code Block |
---|
{ "objectname": "asset", "query": "", "orderby":"pcreated desc", "secured":true, "max":0, "from":0, "fulltext":"", "props": [ "id", "name", "status.id", "status.name" ], "aggs": { "category": { "props":["id","name","status.id"] } } } |
Properties and sections
objectname: String - Object name (type)
description: String - Short description of view
query: String - Selection query (SQL syntax)
since 11.19*parameterizedQuery: String or Object - Selection query as SQL syntaxe or JSON Query (allowing among other things to make the query parameterisable)
orderby: String - Sorting algorithm (SQL syntax)
since 11.10sortbyrelevance: Boolean - (Relevant only if query is fulltext) Indicate if results are sorted first by relevance (true) or not (false). Default to true
since 11.10sortbyrelevanceiforderby: Boolean - (Relevant only if query is fulltext) this property allows to deactivate sorting by relevance if an order by clause is configured. If this property is false, sortbyrelevance must be explicity to true to get result sorted by relevance if there is an order by set. Default to true.
Secured: Boolean - Indicate if we apply (true) or not (false) the security. Default to true
max: Integer - The maximum number of instance to export at each call (page size)
from: Integer - The index of the first instance to get (0 based index)
fulltext: String - A text based search criteria
props: Array of Strings - defines attributes that should be retrieved
It is possible to export the properties of a linked object by adding a ‘.’ between the name of the property and the property name of the related object.
E.g. for the name of the object, the status name of the object, and the status color code: [“name”, “status.name”, “status.color.name”].aggs: Object<String, Object<String, Array of Strings>Aggregates section
Keys represent attributes on which aggregation informations should be computed. Array<String> represents list of properties that should be gathered for each aggregation result.
header: allows to add custom information regarding the service
since 11.18queryPolicies: object - allows you to manage rights on the requestable fields
since 11.18queryPoliciesByRoles: Object<string, object> - allows you to manage rights on the requestable fields, depending of role of the surfer
EndPoints
Two endpoints are available:
To get a view
To get the list of available views
EndPoint: Get a view
since 11.14
Code Block |
---|
GET http://host:port/app/api/json/view/{viewName}{/id} |
...
Supported methods: GET, HEAD
Parameters
viewName: String - View identifier
props: String - Comma separated names and properties (only properties available in the view can be requested, if blank all properties will be displayed)
query: String - A selection request following JSON type specific language (to combine with the configured request). For long requests (above URL maximum length), request can be defined in the header X-WEDIA-QUERY, or in the body of the request (supported content types: application/json, text/json)).
orderby - String (SQL syntax): Sorting algorithm
since 11.10sortbyrelevance: Boolean - Overrides sortbyrelevance from configuration
secured: boolean - To apply or not the security (if configuration is applied, then security must be applied)
fulltext: String - The text based search criteria
from: Integer - Number of the first requested object
max: Integer - Maximum number of the requested objects
rawValues Boolean - Indicates if we apply the localization (false by default)
headers: Boolean - Indicates if headers are required (Cf. hereafter, response format) (false by default)
aggHeaders: Boolean - Indicates if aggregates headers are separated from or mixed with properties headers (true by default)
since 11.10.2id (or form_id): String - single resource query (without aggregates)
Response format
Code Block |
---|
{ "viewname": "name of the view", "headers": { "Property name": { "name": "localized label of the property", "type": "type of property" }, "Name of object property": { "name": "localized label of the property", "type": "type of the property", "view": "Mapped view nam", "properties": { "Name of the property": { "name": "localized label of the property", "type": "type of the property" } } } }, "header": {},//the header section in the configuration "request": { "context": { // configuration information result "secured": false, "props": [] }, "parameters": { // Request parameters "viewname": "Name of the view", "headers": "true" } }, "response": { // The response "context": { // the configuration of the view "objectname": "the type of object", // hidden in production mode "query": "the JSON SQL query", //hidden in production mode "orderby": "Sorting algorithm", "props": { "Property name" }, "secured": true, "max": 20, "from": 0 }, "data": [ // the data { // one object per instance "Name of the property": <value of the property>, } ] }, "links": { // hypertext links "href": "http://…", // the link to get the same view in the same way "previous": "http:/…", // the link to get the previous data page "first": "http:/…", // the link to get the first data page "next": "http:/…", // the link to get the next data page }, "status": "", // the http status of the response "time": "" // The execution time } |
...
number (JSON type)
string (JSON type)
boolean (JSON type)
object (JSON type)
timestamp (Javascript timestamp )
resource (for a file)
separator (for a separator)
Example
Code Block |
---|
{ "objectname": "user", "orderby": "", "props": [ "id", "created", "name", "status.id", "status.name" ], "query": "", "secured": true, "aggs": { "fields": { "status": { "props": [ "Id", "name", "color.name" ] } }, "limit": 0 } } |
Request
Code Block |
---|
http://host:port/app/_plugins/WXM_RESTAPI/page/view.jspz?viewname=userview&headers=true |
Result
Code Block |
---|
{ "viewname": "userview", "headers": { "id": { "name": "id", "type": "number" }, "created": { "name": "created on", "type": "timestamp" }, "status": { "name": "Status", "type": "object", "view": "userstatusview", "properties": { "id": { "name": "id", "type": "number" }, "name": { "name": "User name", "type": "string" }, "color": { "name": "Color", "type": "string", "properties": { "name": { "name": "Name", "type": "string" } } }, "header": null, "request": { "context": { "secured": false, "props": [] }, "parameters": { "headers": "true", "viewname": "test" } }, "response": { "context": { "aggs": { "limit": 20, "fields": { "status": { "props": [ "id", "name" ] } } }, "objectname": "user", "orderby": "", "props": [ "id", "created", "name", "status.id", "status.name" ], "secured": true, "max": 20, "from": 0 }, "data": [ { "id": 4, "created": 1315522800000, "status": { "id": 2, "name": "Inactive" }, "name": "controller" }, { "id": 9, "created": 1354662000000, "status": { "id": 2, "name": "Inactive" }, "name": "designer" }, { "id": 1, "created": 1019084400000, "status": { "id": 6, "name": "Active" }, "name": "developer" }, { "id": 6, "created": 1354662000000, "status": { "id": 2, "name": "Inactive" }, "name": "documentalist" }, { "id": 3, "created": 1320274800000, "status": { "id": 6, "name": "Active" }, "name": "Example Groupe" }, { "id": 8, "created": 1354662000000, "status": { "id": 2, "name": "Inactive" }, "name": "marketingmanager" }, { "id": 7, "created": 1354662000000, "status": { "id": 2, "name": "Inactive" }, "name": "projectmanager" }, { "id": 5, "created": 1339974000000, "status": { "id": 2, "name": "Inactive" }, "name": "webmaster" }, { "id": 2, "created": 1315350000000, "status": { "id": 2, "name": "Inactive" }, "name": "writer" } ], "total": 9, "aggregates": { "status": [ { "count": 7, "data": { "id": 2, "name": "Inactive" } }, { "count": 2, "data": { "id": 6, "name": "Active" } } ] } }, "links": { "href": "http://localhost:8080/Engine/_plugins/WXM_RESTAPI/page/view.jspz?viewName=userview&headers=true", "previous": null, "next": "http://localhost:8080/Engine/_plugins/WXM_RESTAPI/page/view.jspz?viewName=userview&from=20&headers=true" }, "status": 200, "time": 104 } } } } |
Security
The view action from RESTAPI domain allows management of the endpoint call. There are two parameters:
surfer: surfer
viewName: the view identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/100 | Unknown view |
403 | 403/100 | Unreachable view (forbidden) |
404 | 404/900 | Object not found (single resource access) |
EndPoint: list of available views
since 11.12
Code Block |
---|
GET http//host:port/app/api/json/catalog/view |
...
Supported methods: GET, HEAD
Parameters
viewName: String - an optional Regular Expression filter (all accessible views are displayed by default)
headers: Boolean - Indicates if headers are required (Cf. hereafter, response format) (false by default).
Response format
Code Block |
---|
{ "catalog": "list of views", "request": { "parameters": { "headers": "true" } }, "response": { "data": { "name": "view name", "properties": [ "name of property 1", "name of property 2", "name of property 3" ], "headers": { "Name of property": { "name": "localized label of the property", "type": "type of the property" } } } }, "links": { "href": "http://host:port/app/_plugins/WXM_RESTAPI/page/catalog/view.jspz?headers=true" } } |
Security
The catalog action of the RESTAPI domain allows management of the endpoint call authorisation. There are two parameters:
surfer: surfer
endPoint: view value.
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/101 | Unreachable catalog (forbidden) |
Views mapping
Introduction
The view mapping allows association to object types with views. Hence it is possible to know the appropriate view to determinate the link type property value depending on its nature (related object type).
The view mapping are shared between views and tree structure views: beware not to have a similar name for two views (usual or tree structure).
Configuration
We can:
Associate an object nature with a view;
For a specific view, associate a nature with this view, this association has an higher priority than above;
For a specific view, and for an object property of this view, associate the nature with this view, this association has an higher priority than both above
JSON Example
Code Block |
---|
{ "nature1": "view1", "nature2": { "": "view2", "view3": "view4", "view5": { "": "view6", "prop1": "view7", "prop2": "view8" } } } |
...