You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/manuals/admin/database_model.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,6 +302,8 @@ Fields:
302
302
-**expression**: an expression used to evaluate if notifications has
303
303
to be sent or not when updates come. It may be composed of the following
304
304
fields: q, mq, georel, geometry and/or coords (optional)
305
+
-**jexlExpression**: an expression used to determine whether a notification must be sent.
306
+
Notifications are triggered only when the expression evaluates to `true` if this field is used (it is optional).
305
307
-**count**: the number of notifications sent associated to
306
308
the subscription.
307
309
-**format**: the format to use to send notification, possible values are **normalized**, **keyValues**, **simplifiedNormalized**, **simplifiedKeyValues** and **values**.
Copy file name to clipboardExpand all lines: doc/manuals/admin/statistics.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,8 +165,8 @@ The particular counters are as follows:
165
165
`last` includes the accumulation for all of them. In the case of mongoReadWait, only the time used
166
166
to get the results cursor is taken into account, but not the time to process cursors results (which
167
167
is time that belongs to mongoBackend counters).
168
-
*`exprJexlCtxBld`: time passed building context for custom notification expression evaluation (see [macro substitution](../orion-api.md#macro-substitution) and [JEXL support](../orion-api.md#jexl-support))
169
-
*`exprJexlEval`: time passed evaluating custom notification expressions (see [macro substitution](../orion-api.md#macro-substitution) and [JEXL support](../orion-api.md#jexl-support))
168
+
*`exprJexlCtxBld`: time passed building context for custom notification expression evaluation (see [macro substitution](../orion-api.md#macro-substitution) and [JEXL support in custom notifications](../orion-api.md#jexl-support-in-custom-notifications)). This also includes the time passed building context for `[`jexlExpressions`](../orion-api.md#subscriptionsubjectcondition).
169
+
*`exprJexlEval`: time passed evaluating custom notification expressions (see [macro substitution](../orion-api.md#macro-substitution) and [JEXL support in custom notifications](../orion-api.md#jexl-support-in-custom-notifications)). This also includes the time passed evaluating expressions for `[`jexlExpressions`](../orion-api.md#subscriptionsubjectcondition).
170
170
171
171
*NOTE*: if Orion binary is build without using cjexl and only basic replacement is available, then `exprBasicCtxtBld` and `exprBasicEval`
172
172
fields appear instead of `exprJexlCtxBld` and `exprJexlEval`.
-[JEXL support in custom notifications](#jexl-support-in-custom-notifications)
77
77
-[JEXL usage example](#jexl-usage-example)
78
78
-[Metadata support](#metadata-support)
79
79
-[Evaluation priority](#evaluation-priority)
@@ -452,7 +452,7 @@ There are some exception cases in which the above restrictions do not apply. In
452
452
* URL parameter `q` allows the special characters needed by the [Simple Query Language](#simple-query-language)
453
453
* URL parameter `mq` allows the special characters needed by the [Simple Query Language](#simple-query-language)
454
454
* URL parameter `georel` and `coords` allow `;`
455
-
* Within `ngsi` (i.e. `id`, `type` and attribute values) in [NGSI Payload patching](#ngsi-payload-patching) (to support characters used in the [JEXL expression syntax](#jexl-support))
455
+
* Within `ngsi` (i.e. `id`, `type` and attribute values) in [NGSI Payload patching](#ngsi-payload-patching) (to support characters used in the [JEXL support in custom notifications](#jexl-support-in-custom-notifications))
456
456
* Whichever attribute value which uses `TextUnrestricted` as attribute type (see [Special Attribute Types](#special-attribute-types) section)
457
457
458
458
## Identifiers syntax restrictions
@@ -478,7 +478,7 @@ In addition, the [General syntax restrictions](#general-syntax-restrictions) als
478
478
479
479
In case a client attempts to use a field that is invalid from a syntax point of view, the client gets a "Bad Request" error response, explaining the cause.
480
480
481
-
Note that although `:` and `-` are allowed in identifiers, they are strongly discouraged, as they collide with the [JEXL syntax](#jexl-support). In particular, `-` is used for subtraction operation (e.g. `${A-B}`) and `:` is used in the ternary operator (eg. `A?'A is true':'A is false`). Thus, an attribute name `lower-temperature` in an expression `${lower-temperature}` would be interpreted as the value of `lower` attribute minus `temperature` attribute (and not as the value of an attribute named `lower-temperature`).
481
+
Note that although `:` and `-` are allowed in identifiers, they are strongly discouraged, as they collide with the [JEXL syntax](#jexl-support-in-custom-notifications). In particular, `-` is used for subtraction operation (e.g. `${A-B}`) and `:` is used in the ternary operator (eg. `A?'A is true':'A is false`). Thus, an attribute name `lower-temperature` in an expression `${lower-temperature}` would be interpreted as the value of `lower` attribute minus `temperature` attribute (and not as the value of an attribute named `lower-temperature`).
482
482
483
483
## Error Responses
484
484
@@ -1930,18 +1930,25 @@ be automatically deleted in an unwanted way**.
1930
1930
Based on the [`condition` subscription field](#subscriptionsubjectcondition), upon
1931
1931
entity update, the notification triggering rules are as follow:
1932
1932
1933
-
* If `attrs` and `expression` are used, a notification is sent whenever one of the attributes in
1934
-
the `attrs` list changes (or is deleted) and at the same time `expression` matches.
1935
-
* If `attrs` is used and `expression` is not used, a notification is sent whenever any of the
1933
+
* If `attrs` and expressions are used, a notification is sent whenever one of the attributes in
1934
+
the `attrs` list changes (or is deleted) and at the same time expressions match.
1935
+
* If `attrs` is used and expressions are not used, a notification is sent whenever any of the
1936
1936
attributes in the `attrs` list changes (or is deleted).
1937
-
* If `attrs` is not used and `expression` is used, a notification is sent whenever any of the
1938
-
attributes of the entity changes (or is deleted) and at the same time `expression` matches.
1939
-
* If neither `attrs` nor `expression` are used, a notification is sent whenever any of the
1937
+
* If `attrs` is not used and expressions are used, a notification is sent whenever any of the
1938
+
attributes of the entity change (or is deleted) and at the same time expressions match.
1939
+
* If neither `attrs` nor expressions are used, a notification is sent whenever any of the
1940
1940
attributes of the entity changes (or is deleted).
1941
1941
1942
1942
Note that changing the metadata of a given attribute is considered a change even though the attribute
1943
1943
value itself hasn't changed.
1944
1944
1945
+
By *expressions* we mean at least one of the following
1946
+
1947
+
*`expression`
1948
+
*`jexlExpression`
1949
+
1950
+
If both are used (i.e. `expression` and a `jexlExpresion` at the same time) both must match to consider that expressions match in the above description of triggering rules.
1951
+
1945
1952
## Notification Messages
1946
1953
1947
1954
Notifications include two fields:
@@ -2069,7 +2076,7 @@ In case of `mqttCustom`:
2069
2076
*`topic`
2070
2077
2071
2078
Macro substitution for templates is based on the syntax `${<JEXL expression>}`. The support to JEXL
2072
-
is explained in [JEXL Support](#jexl-support) section. The following identifiers are included in
2079
+
is explained in [JEXL support in custom notifications](#jexl-support-in-custom-notifications) section. The following identifiers are included in
2073
2080
the context evaluated by the JEXL expression:
2074
2081
2075
2082
*`id`: for the `id` of the entity
@@ -2341,7 +2348,7 @@ Some considerations to take into account when using custom notifications:
2341
2348
(i.e. `ngsi` field) then `Ngsiv2-AttrsFormat: normalized` is used, as in a regular
2342
2349
notification (given that the notification format is actually the same).
2343
2350
2344
-
## JEXL Support
2351
+
## JEXL support in custom notifications
2345
2352
2346
2353
Orion Context Broker supports [JEXL expressions](https://github.com/TomFrost/Jexl) in custom notification [macro replacement](#macro-substitution). Thus, subscriptions like this can be defined:
2347
2354
@@ -5031,6 +5038,7 @@ A `condition` contains the following subfields:
|`attrs`| ✓ | array | Array of attribute names that will trigger the notification. Empty list is not allowed. |
5033
5040
|`expression`| ✓ | object| An expression composed of `q`, `mq`, `georel`, `geometry` and `coords` (see [List Entities](#list-entities-get-v2entities) operation above about this field). `expression` and sub elements (i.e. `q`) must have content, i.e. `{}` or `""` is not allowed. `georel`, `geometry` and `coords` have to be used together (i.e. "all or nothing"). Check the example using geoquery as expression [below](#create-subscription-post-v2subscriptions).|
5041
+
|`jexlExpression`| ✓ | string | JEXL expression evaluated to determine whether a notification must be sent. If this field is used (note it is optional), the notification is triggered only when the expression evaluates to `true`. It works in the same way as the [JEXL expressions in custom notifications](#jexl-support-in-custom-notifications).|
5034
5042
|`alterationTypes`| ✓ | array | Specify under which alterations (entity creation, entity modification, etc.) the subscription is triggered (see section [Subscriptions based in alteration type](#subscriptions-based-in-alteration-type)) |
5035
5043
|`notifyOnMetadataChange`| ✓ | boolean | If `true` then metadata is considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is triggered. If `false` then the metadata is not considered part of the value of the attribute in the context of notification, so if the value doesn't change but the metadata changes, then a notification is not triggered. Default value is `true`. |
0 commit comments