syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject syncope git commit: [SYNCOPE-1007] fix for fiql generation in case of incomplete condition
Date Fri, 03 Feb 2017 16:29:33 GMT
Repository: syncope
Updated Branches:
  refs/heads/master e9366d753 -> deac686f9


[SYNCOPE-1007] fix for fiql generation in case of incomplete condition


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/deac686f
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/deac686f
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/deac686f

Branch: refs/heads/master
Commit: deac686f90acd387486824d0402bebdf72defd00
Parents: e9366d7
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Fri Feb 3 17:28:57 2017 +0100
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Fri Feb 3 17:28:57 2017 +0100

----------------------------------------------------------------------
 .../console/panels/search/SearchUtils.java      | 250 ++++++++++---------
 .../console/wizards/any/GroupWrapper.java       |   7 +-
 2 files changed, 132 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/deac686f/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
index 61fca89..4e5181a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
@@ -205,160 +205,164 @@ public final class SearchUtils implements Serializable {
         for (SearchClause clause : clauses) {
             prevCondition = condition;
 
-            switch (clause.getType()) {
-                case GROUP_MEMBER:
-                    switch (clause.getComparator()) {
-                        case EQUALS:
-                            condition = ((GroupFiqlSearchConditionBuilder) builder).
-                                    withMembers(clause.getValue());
-                            break;
-
-                        case NOT_EQUALS:
-                            condition = ((GroupFiqlSearchConditionBuilder) builder).
-                                    withoutMembers(clause.getValue());
-                            break;
-
-                        default:
-                    }
-                    break;
-
-                case GROUP_MEMBERSHIP:
-                    if (StringUtils.isNotBlank(clause.getProperty())) {
-                        String groupKey = clause.getProperty().split(" ")[0];
-
-                        if (builder instanceof UserFiqlSearchConditionBuilder) {
-                            condition = clause.getComparator() == SearchClause.Comparator.EQUALS
-                                    ? ((UserFiqlSearchConditionBuilder) builder).inGroups(groupKey)
-                                    : ((UserFiqlSearchConditionBuilder) builder).notInGroups(groupKey);
-                        } else {
-                            condition = clause.getComparator() == SearchClause.Comparator.EQUALS
-                                    ? ((AnyObjectFiqlSearchConditionBuilder) builder).inGroups(groupKey)
-                                    : ((AnyObjectFiqlSearchConditionBuilder) builder).notInGroups(groupKey);
-                        }
-                    }
-                    break;
-
-                case RESOURCE:
-                    if (StringUtils.isNotBlank(clause.getProperty())) {
-                        condition = clause.getComparator() == SearchClause.Comparator.EQUALS
-                                ? builder.hasResources(clause.getProperty())
-                                : builder.hasNotResources(clause.getProperty());
-                    }
-                    break;
-
-                case ATTRIBUTE:
-                    if (StringUtils.isNotBlank(clause.getProperty())) {
-                        SyncopeProperty property = builder.is(clause.getProperty());
+            if (clause.getType() != null) {
+                switch (clause.getType()) {
+                    case GROUP_MEMBER:
                         switch (clause.getComparator()) {
-                            case IS_NULL:
-                                condition = builder.isNull(clause.getProperty());
-                                break;
-
-                            case IS_NOT_NULL:
-                                condition = builder.isNotNull(clause.getProperty());
-                                break;
-
-                            case LESS_THAN:
-                                condition = StringUtils.isNumeric(clause.getProperty())
-                                        ? property.lessThan(NumberUtils.toDouble(clause.getValue()))
-                                        : property.lexicalBefore(clause.getValue());
-                                break;
-
-                            case LESS_OR_EQUALS:
-                                condition = StringUtils.isNumeric(clause.getProperty())
-                                        ? property.lessOrEqualTo(NumberUtils.toDouble(clause.getValue()))
-                                        : property.lexicalNotAfter(clause.getValue());
-                                break;
-
-                            case GREATER_THAN:
-                                condition = StringUtils.isNumeric(clause.getProperty())
-                                        ? property.greaterThan(NumberUtils.toDouble(clause.getValue()))
-                                        : property.lexicalAfter(clause.getValue());
-                                break;
-
-                            case GREATER_OR_EQUALS:
-                                condition = StringUtils.isNumeric(clause.getProperty())
-                                        ? property.greaterOrEqualTo(NumberUtils.toDouble(clause.getValue()))
-                                        : property.lexicalNotBefore(clause.getValue());
+                            case EQUALS:
+                                condition = ((GroupFiqlSearchConditionBuilder) builder).
+                                        withMembers(clause.getValue());
                                 break;
 
                             case NOT_EQUALS:
-                                condition = property.notEqualTolIgnoreCase(clause.getValue());
+                                condition = ((GroupFiqlSearchConditionBuilder) builder).
+                                        withoutMembers(clause.getValue());
                                 break;
 
-                            case EQUALS:
                             default:
-                                condition = property.equalToIgnoreCase(clause.getValue());
-                                break;
                         }
-                    }
-                    break;
+                        break;
+
+                    case GROUP_MEMBERSHIP:
+                        if (StringUtils.isNotBlank(clause.getProperty())) {
+                            String groupKey = clause.getProperty().split(" ")[0];
+
+                            if (builder instanceof UserFiqlSearchConditionBuilder) {
+                                condition = clause.getComparator() == SearchClause.Comparator.EQUALS
+                                        ? ((UserFiqlSearchConditionBuilder) builder).inGroups(groupKey)
+                                        : ((UserFiqlSearchConditionBuilder) builder).notInGroups(groupKey);
+                            } else {
+                                condition = clause.getComparator() == SearchClause.Comparator.EQUALS
+                                        ? ((AnyObjectFiqlSearchConditionBuilder) builder).inGroups(groupKey)
+                                        : ((AnyObjectFiqlSearchConditionBuilder) builder).notInGroups(groupKey);
+                            }
+                        }
+                        break;
 
-                case ROLE_MEMBERSHIP:
-                    if (StringUtils.isNotBlank(clause.getProperty())) {
-                        switch (clause.getComparator()) {
-                            case EQUALS:
-                                condition = ((UserFiqlSearchConditionBuilder) builder).inRoles(clause.getProperty());
-                                break;
-                            case NOT_EQUALS:
-                                condition = ((UserFiqlSearchConditionBuilder) builder).notInRoles(clause.getProperty());
-                                break;
-                            default:
-                                break;
+                    case RESOURCE:
+                        if (StringUtils.isNotBlank(clause.getProperty())) {
+                            condition = clause.getComparator() == SearchClause.Comparator.EQUALS
+                                    ? builder.hasResources(clause.getProperty())
+                                    : builder.hasNotResources(clause.getProperty());
                         }
-                    }
-                    break;
+                        break;
 
-                case RELATIONSHIP:
-                    if (StringUtils.isNotBlank(clause.getProperty())) {
-                        if (builder instanceof UserFiqlSearchConditionBuilder) {
+                    case ATTRIBUTE:
+                        if (StringUtils.isNotBlank(clause.getProperty())) {
+                            SyncopeProperty property = builder.is(clause.getProperty());
                             switch (clause.getComparator()) {
+                                case IS_NULL:
+                                    condition = builder.isNull(clause.getProperty());
+                                    break;
+
                                 case IS_NOT_NULL:
-                                    condition = ((UserFiqlSearchConditionBuilder) builder).
-                                            inRelationshipTypes(clause.getProperty());
+                                    condition = builder.isNotNull(clause.getProperty());
                                     break;
-                                case IS_NULL:
-                                    condition = ((UserFiqlSearchConditionBuilder) builder).
-                                            notInRelationshipTypes(clause.getProperty());
+
+                                case LESS_THAN:
+                                    condition = StringUtils.isNumeric(clause.getProperty())
+                                            ? property.lessThan(NumberUtils.toDouble(clause.getValue()))
+                                            : property.lexicalBefore(clause.getValue());
                                     break;
-                                case EQUALS:
-                                    condition = ((UserFiqlSearchConditionBuilder) builder).
-                                            inRelationships(clause.getValue());
+
+                                case LESS_OR_EQUALS:
+                                    condition = StringUtils.isNumeric(clause.getProperty())
+                                            ? property.lessOrEqualTo(NumberUtils.toDouble(clause.getValue()))
+                                            : property.lexicalNotAfter(clause.getValue());
+                                    break;
+
+                                case GREATER_THAN:
+                                    condition = StringUtils.isNumeric(clause.getProperty())
+                                            ? property.greaterThan(NumberUtils.toDouble(clause.getValue()))
+                                            : property.lexicalAfter(clause.getValue());
                                     break;
+
+                                case GREATER_OR_EQUALS:
+                                    condition = StringUtils.isNumeric(clause.getProperty())
+                                            ? property.greaterOrEqualTo(NumberUtils.toDouble(clause.getValue()))
+                                            : property.lexicalNotBefore(clause.getValue());
+                                    break;
+
                                 case NOT_EQUALS:
-                                    condition = ((UserFiqlSearchConditionBuilder) builder).
-                                            notInRelationships(clause.getValue());
+                                    condition = property.notEqualTolIgnoreCase(clause.getValue());
                                     break;
+
+                                case EQUALS:
                                 default:
+                                    condition = property.equalToIgnoreCase(clause.getValue());
                                     break;
                             }
-                        } else {
+                        }
+                        break;
+
+                    case ROLE_MEMBERSHIP:
+                        if (StringUtils.isNotBlank(clause.getProperty())) {
                             switch (clause.getComparator()) {
-                                case IS_NOT_NULL:
-                                    condition = ((AnyObjectFiqlSearchConditionBuilder) builder).
-                                            inRelationshipTypes(clause.getProperty());
-                                    break;
-                                case IS_NULL:
-                                    condition = ((AnyObjectFiqlSearchConditionBuilder) builder).
-                                            notInRelationshipTypes(clause.getProperty());
-                                    break;
                                 case EQUALS:
-                                    condition = ((AnyObjectFiqlSearchConditionBuilder) builder).
-                                            inRelationships(clause.getValue());
+                                    condition = ((UserFiqlSearchConditionBuilder) builder).
+                                            inRoles(clause.getProperty());
                                     break;
                                 case NOT_EQUALS:
-                                    condition = ((AnyObjectFiqlSearchConditionBuilder) builder).
-                                            notInRelationships(clause.getValue());
+                                    condition = ((UserFiqlSearchConditionBuilder) builder).
+                                            notInRoles(clause.getProperty());
                                     break;
                                 default:
                                     break;
                             }
                         }
-                    }
-                    break;
+                        break;
+
+                    case RELATIONSHIP:
+                        if (StringUtils.isNotBlank(clause.getProperty())) {
+                            if (builder instanceof UserFiqlSearchConditionBuilder) {
+                                switch (clause.getComparator()) {
+                                    case IS_NOT_NULL:
+                                        condition = ((UserFiqlSearchConditionBuilder) builder).
+                                                inRelationshipTypes(clause.getProperty());
+                                        break;
+                                    case IS_NULL:
+                                        condition = ((UserFiqlSearchConditionBuilder) builder).
+                                                notInRelationshipTypes(clause.getProperty());
+                                        break;
+                                    case EQUALS:
+                                        condition = ((UserFiqlSearchConditionBuilder) builder).
+                                                inRelationships(clause.getValue());
+                                        break;
+                                    case NOT_EQUALS:
+                                        condition = ((UserFiqlSearchConditionBuilder) builder).
+                                                notInRelationships(clause.getValue());
+                                        break;
+                                    default:
+                                        break;
+                                }
+                            } else {
+                                switch (clause.getComparator()) {
+                                    case IS_NOT_NULL:
+                                        condition = ((AnyObjectFiqlSearchConditionBuilder)
builder).
+                                                inRelationshipTypes(clause.getProperty());
+                                        break;
+                                    case IS_NULL:
+                                        condition = ((AnyObjectFiqlSearchConditionBuilder)
builder).
+                                                notInRelationshipTypes(clause.getProperty());
+                                        break;
+                                    case EQUALS:
+                                        condition = ((AnyObjectFiqlSearchConditionBuilder)
builder).
+                                                inRelationships(clause.getValue());
+                                        break;
+                                    case NOT_EQUALS:
+                                        condition = ((AnyObjectFiqlSearchConditionBuilder)
builder).
+                                                notInRelationships(clause.getValue());
+                                        break;
+                                    default:
+                                        break;
+                                }
+                            }
+                        }
+                        break;
 
-                default:
-                    break;
+                    default:
+                        break;
+                }
             }
 
             if (notTheFirst) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/deac686f/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWrapper.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWrapper.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWrapper.java
index 97a3f6e..f64a345 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWrapper.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWrapper.java
@@ -76,8 +76,11 @@ public class GroupWrapper extends AnyWrapper<GroupTO> {
         if (this.aDynClauses != null && !this.aDynClauses.isEmpty()) {
             for (Map.Entry<String, List<SearchClause>> entry : this.aDynClauses.entrySet())
{
                 if (CollectionUtils.isNotEmpty(entry.getValue())) {
-                    res.put(entry.getKey(), SearchUtils.buildFIQL(entry.getValue(),
-                            SyncopeClient.getAnyObjectSearchConditionBuilder(entry.getKey())));
+                    final String fiql = SearchUtils.buildFIQL(entry.getValue(),
+                            SyncopeClient.getAnyObjectSearchConditionBuilder(entry.getKey()));
+                    if (fiql != null) {
+                        res.put(entry.getKey(), fiql);
+                    }
                 }
             }
         }


Mime
View raw message