You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2021/10/12 12:14:55 UTC
[unomi] branch unomi-1.6.x updated: UNOMI-515: allow event to be
evaluated by the sourceEventPropertyConditionEvaluator (#351)
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch unomi-1.6.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.6.x by this push:
new ec32a75 UNOMI-515: allow event to be evaluated by the sourceEventPropertyConditionEvaluator (#351)
ec32a75 is described below
commit ec32a75b30e080462cbf632b2b6d3e9f697473d3
Author: kevan Jahanshahi <ke...@jahia.com>
AuthorDate: Tue Oct 12 14:13:36 2021 +0200
UNOMI-515: allow event to be evaluated by the sourceEventPropertyConditionEvaluator (#351)
---
.../SourceEventPropertyConditionEvaluator.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/SourceEventPropertyConditionEvaluator.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/SourceEventPropertyConditionEvaluator.java
index 98669dd..19bbca7 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/SourceEventPropertyConditionEvaluator.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/SourceEventPropertyConditionEvaluator.java
@@ -17,6 +17,7 @@
package org.apache.unomi.plugins.baseplugin.conditions;
+import org.apache.unomi.api.Event;
import org.apache.unomi.api.Item;
import org.apache.unomi.api.conditions.Condition;
import org.apache.unomi.api.conditions.ConditionType;
@@ -54,6 +55,11 @@ public class SourceEventPropertyConditionEvaluator implements ConditionEvaluator
@Override
public boolean eval(Condition condition, Item item, Map<String, Object> context, ConditionEvaluatorDispatcher dispatcher) {
+ // in case the evaluated item is an event, we switch to his source internal object for further evaluations
+ if (item instanceof Event) {
+ item = ((Event) item).getSource();
+ }
+
Condition andCondition = new Condition(definitionsService.getConditionType("booleanCondition"));
andCondition.setParameter("operator", "and");
ArrayList<Condition> conditions = new ArrayList<Condition>();
@@ -63,9 +69,15 @@ public class SourceEventPropertyConditionEvaluator implements ConditionEvaluator
}
if(conditions.size() > 0){
- andCondition.setParameter("subConditions", conditions);
- return dispatcher.eval(andCondition, item);
+ if (item != null) {
+ andCondition.setParameter("subConditions", conditions);
+ return dispatcher.eval(andCondition, item);
+ } else {
+ // item is null but there is conditions: it's not a match
+ return false;
+ }
} else {
+ // no conditions: it's always a match
return true;
}
}