General description
Data Access is intended as a powerful, highly configurable interface for accessing Entuity's internal data (like attribute values, stream data etc.)
The interface achieves this by processing the XML “templates” that describe sets of data to be exported. As these templates may be user-defined, this gives the customers an unprecedented level of control over the data itself, as well as their layout and format.
Currently, due to an extended set of possibilities in comparison to JSON, only XML template format is supported.
The interface consists of two parts (each described in detail later on): the “template management” which can be used to retrieve and modify templates residing on a server, and the “data access” part, which produces the output based on the early defined template.
Format of the export table
Example template:
The following example defines a template that would traverse the list of views (supplied by the user as a part of data output) and, based on the value of “selector” element, would traverse every device. For each device found, the element DEVICE_OBJECT will be created and populated with these element (in the order corresponding to their order in the template):
- The element name, with a value of the name attribute of a device.
- The attribute id, with a value of executing the simple;id statement on the current device.
- The stream data v_unifiedDeviceCPU appearing as a CPU element, with all the underlying attributes.
- The list of PORT_OBJECT elements, corresponding to the result of executing the simple;ref.ports statement on the current device. Each of these element would consist of:
- The attribute descr, with the value of simple;this.ifDescr statement for the current port.
- The element status, consisting of a list of samples, each containing two attributes: adminStatus (presented as an adm element) and operStatus, presented as an oper attribute.
An example XML Data Access Template
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<dataAccessTemplate name="Example template">
<description>This is a test description</description>
<object type="DeviceEx" tag="DEVICE_OBJECT">
<selector>simple;ref.devices</selector>
<filter></filter>
<attribute asElement="true" expression="name"/>
<attribute expression="simple;id" tag="id"/>
<stream allAttributes="true" name="v_unifiedDeviceCPU" tag="CPU"/>
<object type="PortEx" tag="PORT_OBJECT">
<selector>simple;ref.ports</selector>
<filter></filter>
<attribute asElement="true" expression="simple;this.ifDescr" tag="Descr"/>
<stream name="portStatus" tag="status">
<attribute asElement="true" expression="adminStatus" tag="adm"/>
<attribute expression="operStatus" tag="oper"/>
</stream>
</object>
</object>
</dataAccessTemplate>
Export template syntax:
The following table describes all the XML nodes that can be a part of a Data Access Template. Unless stated otherwise, the order of elements is not important.
In the description below, some nodes have one of three symbols: ? (question mark), + (plus sign) or * (an asterisk) appended (in parenthesis) to their names.
These symbols are not part of the name itself, but serve to define how many times a node of this type may appear under the same parent:
? – the node is optional and unique (i.e. may appear one or zero times)
* – the node is optional and not unique (i.e. may appear any number of times)
+ – the node is mandatory and not unique (i.e. must appear one or more times)
Nodes without any such symbol are implied to be mandatory and unique.
Name | Description |
---|---|
dataAccessTemplate |
XML element node that is the root node of every single Data Access Template. The list of attributes: name, type(?) The list of child elements: description(?), object |
name |
XML attribute node defining the name of the template. One server can only store templates with different names. Renaming of a template is not supported. |
description |
XML element node that serves as a placeholder for user-defined comment. It can only have one text node, with its body being the comment string. |
object |
XML element node that defines a group of objects. The list of attributes: type, tag(?), allAttributes(?), asElement(?), asAttribute(?), asText(?), allowMultibyte The list of child elements: selector, filter, object(*), stream(*) and attribute(*) |
attribute |
XML element node that defines a StormWorks attribute to be exported. The list of attributes: expression, tag(?), asElement(?), asAttribute(?), asText(?), allowMultibyte No child elements are permitted (attempt to do so, results in a processing failure). |
stream |
XML element node that defines a StormWorks stream to be exported. The list of attributes: name, tag(?), allAttributes(?), asElement(?), asAttribute(?), asText(?) The list of attributes: attribute(?) |
asElement |
XML attribute node that controls how data should be presented in a resulting XML file. Only one of these attributes can be set to “true” for any given node, and if none of them are set, they are inherited from parent. If still none of these attributes were set, the node is treated as if asTextwas set to “true”. Example: <SomeTag>SomeData</SomeTag>, if asElement is “true” SomeTag=”SomeData”, if asAttribute is “true” SomeData, if asText is “true” |
tag |
XML attribute defining the name of the type, under which all data related to this object will be anchored. This attribute may occur in object, stream and attribute nodes and is optional in all of them. If omitted in an object, it will be defaulted to the type attribute of this node. For stream node, it will be defaulted to the name attribute of a stream. For attribute node, it will be defaulted to its expression attribute, but only if the expression does not begin with “simple;” string (in which case the whole template is invalid and its processing will fail). Example: <object asElement=”true” type=”DeviceEx” tag=”DEVICE”> If the template fragment were changed to: |
type |
XML attribute node that defines the StormWorks type of object. The type of objects defines what attributes and streams may be access and exported. |
selector |
XML element node that is the StormWorks statement. This statement is evaluated to produce a list of children, each then undergoing subsequent processing according to their definition, etc. |
filter |
XML element node that is the StormWorks statement. This statement should evaluate to boolean value and can be used to restrict the list of children produced by a selector statement. |
Parameters can also be defined as templateParameters that can be used in expressions in the DataAccessTemplate. Any parameters passed in the URL that match an attribute name will be accessible in the statement language embedded in the template as 'templateParameter.<parameter value>'. Please see Data Access - Export Triggering: GET for further help and information on this.
Comments
0 comments
Please sign in to leave a comment.