You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dr...@apache.org on 2016/04/08 11:25:29 UTC
incubator-unomi git commit: UNOMI-22 : Iterates on sub conditions and
check match on session or profile depending on condition type. Support both
"or" and "and" sub conditions
Repository: incubator-unomi
Updated Branches:
refs/heads/master 8dfd6ac2c -> 358c4df04
UNOMI-22 : Iterates on sub conditions and check match on session or profile depending on condition type. Support both "or" and "and" sub conditions
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/358c4df0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/358c4df0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/358c4df0
Branch: refs/heads/master
Commit: 358c4df04a01ef00dfb27632976e42ad4e572f79
Parents: 8dfd6ac
Author: Thomas Draier <dr...@apache.org>
Authored: Fri Apr 8 11:25:23 2016 +0200
Committer: Thomas Draier <dr...@apache.org>
Committed: Fri Apr 8 11:25:23 2016 +0200
----------------------------------------------------------------------
.../services/services/ProfileServiceImpl.java | 25 ++++++++++++++++----
1 file changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/358c4df0/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
index e097111..a25fc44 100644
--- a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
@@ -525,12 +525,27 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
@Override
public boolean matchCondition(Condition condition, Profile profile, Session session) {
ParserHelper.resolveConditionType(definitionsService, condition);
- Condition profileCondition = definitionsService.extractConditionByTag(condition, "profileCondition");
- Condition sessionCondition = definitionsService.extractConditionByTag(condition, "sessionCondition");
- if (profileCondition != null && !persistenceService.testMatch(profileCondition, profile)) {
- return false;
+
+ if (condition.getConditionTypeId().equals("booleanCondition")) {
+ List<Condition> subConditions = (List<Condition>) condition.getParameter("subConditions");
+ boolean isAnd = "and".equals(condition.getParameter("operator"));
+ for (Condition subCondition : subConditions) {
+ if (isAnd && !matchCondition(subCondition, profile, session)) {
+ return false;
+ }
+ if (!isAnd && matchCondition(subCondition, profile, session)) {
+ return true;
+ }
+ }
+ return subConditions.size() > 0 && isAnd;
+ } else {
+ Condition profileCondition = definitionsService.extractConditionByTag(condition, "profileCondition");
+ Condition sessionCondition = definitionsService.extractConditionByTag(condition, "sessionCondition");
+ if (profileCondition != null && !persistenceService.testMatch(profileCondition, profile)) {
+ return false;
+ }
+ return !(sessionCondition != null && !persistenceService.testMatch(sessionCondition, session));
}
- return !(sessionCondition != null && !persistenceService.testMatch(sessionCondition, session));
}
public void batchProfilesUpdate(BatchUpdate update) {