Context repository
Definition
The context repository is a database that allows storing user data that could be useful in the event rules definition and not present in the data messages. The context may include, for instance, thresholds definition, geographical zones, a list of device identifiers, a user preference, a group of contexts. The context has a key-value format. The key is a string and the value can be a primitive (string, numeric…), a JSON object or an array. Optional tags are available to ease the search among the tenant contexts.
| for geographical zones, a dedicated geozone database is provided. Once the user has provisioned his geozones, they are automatically available in the user context. |
Context provisioning
The Live Objects API to manage context provisioning are described in the swagger documentation (Event processing - Context section) : https://liveobjects.orange-business.com/swagger-ui/index.html.
See a simple context example.
Context groups
A context value may reference other context keys. Instead of referencing each context individually, the rule can then reference the context group.
Example: See a context groups example.
|
extract context key
A context key is not necessarily hard coded in your rule. For instance, it can be extracted from your data message (using tags or device identifier). Here, the context key is generated with the concatenation of the value.streamId field and a string.
Here, the context key is extracted from the value.tags field.
|
Geozone repository
Definition
The Geozone repository is a database that allows the user to save his geographical sites/zones of interest. The geozones are stored as polygons (array of geopoints coordinates in decimal degrees). Meta information like a description and tags can be stored with the geozone.
|
Format:
Example of polygon :
|
Provisioning
The Live Objects API to manage geozone provisioning are described in the swagger documentation (Event processing - Geozone section) : https://liveobjects.orange-business.com/swagger-ui/index.html.
Example:
PUT liveobjects.orange-business.com/api/v0/eventprocessing/geozones/grand-orleans
{
"description": "my geozone grand Orleans",
"geometry": {
"coordinates": [[
[1.780892, 48.091452],
[2.301382, 48.000565],
[2.281961, 47.509630],
[1.252634, 47.729556],
[1.780892, 48.091452]
]],
"type": "Polygon"
},
"tags": ["zone-nord"]
}
-
Once a geozone is provisioned, it is available in the user context. Hence, it can be referenced in event processing rules or in groups of context.
-
When a geozone is updated, the modifications are immediately taken into account by the contexts or rules referencing the geozone.
Rules and JsonLogic syntax
A rule is a function applied on a data message in order to detect any significant change in the data (exceeding threshold, state modification, change of location). The rules in Simple Event Processsing and State Processing are defined within Live Objects plateform with the JsonLogic syntax.
| the JsonLogic log operator has been deactivated. |
Additional operators
In addition to the existing JsonLogic operators (logic and boolean operators, numeric operators, string operators, array operators), Live Objects provides geographic operators (distance, inside, insideindex, closeto, closetoindex), context operator (ctx) and miscellaneous operators (get, currentstate).
| Name |
|---|
distance |
Description |
Geographical operator. Returns the distance in meters between two points, given their latitude and longitude in decimal degrees. |
Parameters |
lon1, lat1, lon2, lat2 in decimal degrees |
Logic |
|
Data |
Eiffel Tower
|
Result |
|
| Name |
|---|
ctx |
Description |
Retrieve, from the context repository, one or several values using a key or an array of keys. Several ctx operators can be nested (group of contexts). |
Parameters |
key or array of keys |
Context |
In the following example, "freezingThreshold" and "liquidThreshold" must have been provisioned in the tenant context before being used.
|
Logic |
|
Pre-requisite |
Data |
|
Result |
|
| Name |
|---|
currentstate |
Description |
Retrieve the current state of a device when applying a stateProcessing function. For state processing rules only. In the following example, current state can be "cold", "normal" or "hot". The example following logic function is an hysteresis : if current state is not hot, transition to hot if value.temp > 100 if current state is hot, transition to normal if value.temp < 80 if value.temp < 0 transition to cold |
Logic |
|
Data |
|
Result |
|
| Name |
|---|
get |
Description |
Returns the element at the specified position in an array. |
Parameters |
array, index in the array |
Context |
In the following example, an array containing latitude and longitude values must have been provisioned in the tenant context :
|
Logic |
|
Data |
|
Result |
|
| Name |
|---|
inside |
Description |
Checks if a point defined by its latitude and longitude is inside a polygon (or at least one polygon if an array of polygons is provided as input parameter). |
Parameters |
longitude, latitude in decimal degrees for the point to be tested, polygon(s) defined by the coordinates of their vertices (lon, lat in decimal degrees). |
Logic |
|
Data |
|
Result |
|
| Name |
|---|
insideindex |
Description |
Checks if a point is inside an array of polygons. Returns the index of the first matching polygon. Returns -1 if no matching was found. This operator is usually in conjunction with the "get" operator which will return the matching polygon. |
Parameters |
longitude, latitude in decimal degrees for the point to be tested, array of polygons defined by the coordinates of their vertices (lon, lat in decimal degrees). |
Context |
In the example, an array containing latitude and longitude values must have been provisioned in the tenant context :
|
Logic |
} |
Data |
|
Result |
|
| Name |
|---|
closeto |
Description |
Checks if a circle is close to a polygon or at least one of the polygons (polygon array). |
Parameters |
longitude, latitude (in decimal degrees for the circle center), circle radius, polygon or array of polygons |
Logic |
|
Data1 : circle center outside polygons, the circle does not intersect any polygon. |
|
Result1 |
|
Data2 : circle center outside polygons, the circle intersects one polygon. |
|
Result2 |
|
Data3 : a point inside one of the polygons. |
Result3 |
|
| Name |
|---|
closetoindex |
Description |
Checks if a circle is close to an array of polygons. Returns the index of the first matching polygon (first index in the array is 0). Returns -1 if no matching was found. |
Parameters |
longitude, latitude (in decimal degrees for the circle center), circle radius, array of polygons |
Logic |
N.B.: first polygon in the array is the Orleans area; 2nd polygon is the Paris area. |
Data |
|
Result |
|
| Name |
|---|
now_utc |
Description |
Returns the processing time as ISO 8601 string. Similar to javaScript new Date().toISOString() |
Parameters |
none |
Logic |
|
Data |
|
Result |
true if processing hour is between 0 and 12 |
| Name |
|---|
get_utc_hours |
Description |
Returns the hour of the ISO 8601 provided parameter . Similar to javaScript new Date(param).getUTCHours() |
Parameters |
ISO 8601 String |
Logic |
|
Data |
|
Result |
13 |
| Name |
|---|
|
Description |
Returns the minutes of the ISO 8601 provided parameter . Similar to javaScript new Date(param).getUTCMinutes() |
Parameters |
ISO 8601 String |
Logic |
|
Data |
|
Result |
1 |
| Name |
|---|
|
Description |
Returns the day of the week of the ISO 8601 provided parameter . Similar to javaScript new Date(param).getUTCDay() |
Parameters |
ISO 8601 String |
Logic |
|
Data |
|
Result |
4 |
| Name |
|---|
|
Description |
Returns the day of the month of the ISO 8601 provided parameter . Similar to javaScript new Date(a).getUTCDate() |
Parameters |
ISO 8601 String |
Logic |
|
Data |
|
Result |
15 |
| Name |
|---|
|
Description |
Returns epoch (milliseconds) of the ISO 8601 provided parameter . Similar to javaScript new Date(a).getTime() |
Parameters |
ISO 8601 String |
Logic |
|
Data |
|
Result |
1516021237290.0 |





