| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| // |
| |
| === Built-in condition types |
| |
| Apache Unomi comes with an extensive collection of built-in condition types. Instead of detailing them one by one you will |
| find here an overview of what a JSON condition descriptor looks like: |
| |
| [source,json] |
| ---- |
| { |
| "metadata": { |
| "id": "booleanCondition", |
| "name": "booleanCondition", |
| "description": "", |
| "systemTags": [ |
| "profileTags", |
| "logical", |
| "condition", |
| "profileCondition", |
| "eventCondition", |
| "sessionCondition", |
| "sourceEventCondition" |
| ], |
| "readOnly": true |
| }, |
| "conditionEvaluator": "booleanConditionEvaluator", |
| "queryBuilder": "booleanConditionESQueryBuilder", |
| "parameters": [ |
| { |
| "id": "operator", |
| "type": "String", |
| "multivalued": false, |
| "defaultValue": "and" |
| }, |
| { |
| "id": "subConditions", |
| "type": "Condition", |
| "multivalued": true |
| } |
| ] |
| } |
| ---- |
| |
| Note that condition types have two important identifiers: |
| |
| - conditionEvaluator |
| - queryBuilder |
| |
| This is because condition types can either be used to build queries or to evaluate a condition in real time. When implementing |
| a new condition type, both implementations much be provided. Here's an example an OSGi Blueprint registration for the |
| above condition type descriptor: |
| |
| From https://github.com/apache/unomi/blob/master/plugins/baseplugin/src/main/resources/OSGI-INF/blueprint/blueprint.xml |
| |
| [source,xml] |
| ---- |
| ... |
| <service |
| interface="org.apache.unomi.persistence.elasticsearch.conditions.ConditionESQueryBuilder"> |
| <service-properties> |
| <entry key="queryBuilderId" value="booleanConditionESQueryBuilder"/> |
| </service-properties> |
| <bean class="org.apache.unomi.plugins.baseplugin.conditions.BooleanConditionESQueryBuilder"/> |
| </service> |
| ... |
| <!-- Condition evaluators --> |
| <service interface="org.apache.unomi.persistence.elasticsearch.conditions.ConditionEvaluator"> |
| <service-properties> |
| <entry key="conditionEvaluatorId" value="booleanConditionEvaluator"/> |
| </service-properties> |
| <bean class="org.apache.unomi.plugins.baseplugin.conditions.BooleanConditionEvaluator"/> |
| </service> |
| ... |
| ---- |
| |
| As you can see two Java classes are used to build a single condition type. You don't need to understand all these details in |
| order to use condition types, but this might be interesting to know if you're interested in building your own condition |
| type implementations. For more details on building your own custom plugins/extensions, please refer to the corresponding |
| sections. |
| |
| ==== Existing condition type descriptors |
| |
| Here is a non-exhaustive list of condition types built into Apache Unomi. Feel free to browse the source code if you want to |
| discover more. But the list below should get you started with the most useful conditions: |
| |
| - https://github.com/apache/unomi/tree/master/plugins/baseplugin/src/main/resources/META-INF/cxs/conditions |
| |
| Of course it is also possible to build your own custom condition types by developing custom Unomi plugins/extensions. |
| |
| You will also note that some condition types can re-use a `parentCondition`. This is a way to inherit from another condition |
| type to make them more specific. |