Accessing Data : The Views
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
{
"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)
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)
11.10 sortbyrelevance: Boolean - (Relevant only if query is fulltext) Indicate if results are sorted first by relevance (true) or not (false). Default to true
11.10 sortbyrelevanceiforderby: 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
11.18 queryPolicies: object - allows you to manage rights on the requestable fields
11.18 queryPoliciesByRoles: 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
11.14
GET http://host:port/app/api/json/view/{viewName}{/id}
HEAD http://host:port/app/api/json/view/{viewName}{/id}
11.12
Legacy endpoint:
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
11.10 sortbyrelevance: 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)
11.10.2 id (or form_id): String - single resource query (without aggregates)
Response format
The property types are:
number (JSON type)
string (JSON type)
boolean (JSON type)
object (JSON type)
timestamp (Javascript timestamp )
resource (for a file)
separator (for a separator)
Example
Request
Result
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
11.12
Legacy endpoint:
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
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
For a x objet having prop1 property of child type and nature1 nature: the associated view will be view1, whatever the view where the object is.
For a x object x having prop1 property of child type and nature2 nature:
in the view view5, the associated view is view7
In the view view3, the associated view is view4
In all other views, the associated view is view2
For a x object having prop3 property of child type and nature2 nature:
in the view view5, the associated view is view6
In the view view3, the associated view is view4
In all other views, the associated view is view2