syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject syncope git commit: [SYNCOPE-666] Introducing dynamic group memberships per any type
Date Thu, 03 Dec 2015 17:12:45 GMT
Repository: syncope
Updated Branches:
  refs/heads/master cfce9b9f3 -> 706cd3671


[SYNCOPE-666] Introducing dynamic group memberships per any type


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

Branch: refs/heads/master
Commit: 706cd3671d72b773358442e4a634f8a6c0e3cf6f
Parents: cfce9b9
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Thu Dec 3 18:12:23 2015 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Thu Dec 3 18:12:37 2015 +0100

----------------------------------------------------------------------
 .../syncope/common/lib/AnyOperations.java       | 17 ++--
 .../syncope/common/lib/patch/GroupPatch.java    | 29 ++++---
 .../apache/syncope/common/lib/to/GroupTO.java   | 23 ++---
 .../common/lib/types/EntityViolationType.java   |  1 +
 .../entity/anyobject/ADynGroupMembership.java   |  4 +
 .../persistence/api/entity/group/Group.java     | 12 ++-
 .../persistence/api/entity/task/AnyFilter.java  | 37 --------
 .../persistence/api/entity/task/PushTask.java   |  8 +-
 .../api/entity/task/PushTaskAnyFilter.java      | 37 ++++++++
 .../api/entity/user/UDynMembership.java         | 25 ------
 .../persistence/jpa/dao/JPAAnyObjectDAO.java    |  2 +-
 .../core/persistence/jpa/dao/JPAGroupDAO.java   | 35 ++++----
 .../jpa/entity/JPAEntityFactory.java            |  8 +-
 .../anyobject/JPAADynGroupMembership.java       | 17 ++++
 .../persistence/jpa/entity/group/JPAGroup.java  | 48 +++++++----
 .../jpa/entity/task/JPAAnyFilter.java           | 91 --------------------
 .../jpa/entity/task/JPAPushTask.java            | 24 +++---
 .../jpa/entity/task/JPAPushTaskAnyFilter.java   | 91 ++++++++++++++++++++
 .../jpa/entity/user/AbstractUDynMembership.java |  3 +-
 .../jpa/validation/entity/GroupValidator.java   | 35 +++++++-
 .../resources/META-INF/spring-orm-oracle.xml    |  6 +-
 .../resources/META-INF/spring-orm-sqlserver.xml |  6 +-
 .../src/main/resources/META-INF/spring-orm.xml  |  6 +-
 .../core/persistence/jpa/outer/GroupTest.java   | 22 ++---
 .../test/resources/domains/MasterContent.xml    | 52 +++++------
 .../java/data/GroupDataBinderImpl.java          | 59 +++++++------
 .../java/data/TaskDataBinderImpl.java           | 16 ++--
 .../provisioning/java/sync/PushJobDelegate.java |  2 +-
 .../syncope/fit/core/reference/GroupITCase.java |  2 +-
 29 files changed, 391 insertions(+), 327 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
index f9d4372..8ae413c 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
@@ -328,11 +328,9 @@ public final class AnyOperations {
         result.setGroupOwner(replacePatchItem(
                 original.getGroupOwner(), updated.getGroupOwner(), new LongReplacePatchItem()));
 
-        // 3. dynMembershipCond
-        result.setADynMembershipCond(replacePatchItem(
-                updated.getADynMembershipCond(), original.getADynMembershipCond(), new StringReplacePatchItem()));
-        result.setUDynMembershipCond(replacePatchItem(
-                updated.getUDynMembershipCond(), original.getUDynMembershipCond(), new StringReplacePatchItem()));
+        // 3. dynamic membership
+        result.setUDynMembershipCond(updated.getUDynMembershipCond());
+        result.getADynMembershipConds().putAll(updated.getADynMembershipConds());
 
         return result;
     }
@@ -442,12 +440,9 @@ public final class AnyOperations {
             result.setGroupOwner(groupPatch.getGroupOwner().getValue());
         }
 
-        if (groupPatch.getADynMembershipCond() != null) {
-            result.setADynMembershipCond(groupPatch.getADynMembershipCond().getValue());
-        }
-        if (groupPatch.getUDynMembershipCond() != null) {
-            result.setADynMembershipCond(groupPatch.getUDynMembershipCond().getValue());
-        }
+        result.setUDynMembershipCond(groupPatch.getUDynMembershipCond());
+        result.getADynMembershipConds().clear();
+        result.getADynMembershipConds().putAll(groupPatch.getADynMembershipConds());
 
         return result;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java
index 250194a..5e6a05f 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/GroupPatch.java
@@ -21,13 +21,17 @@ package org.apache.syncope.common.lib.patch;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.collections4.Predicate;
+import org.apache.syncope.common.lib.jaxb.XmlGenericMapAdapter;
 import org.apache.syncope.common.lib.to.TypeExtensionTO;
 
 @XmlRootElement(name = "groupPatch")
@@ -42,9 +46,11 @@ public class GroupPatch extends AnyPatch {
 
     private LongReplacePatchItem groupOwner;
 
-    private StringReplacePatchItem adynMembershipCond;
+    private String udynMembershipCond;
 
-    private StringReplacePatchItem udynMembershipCond;
+    @XmlJavaTypeAdapter(XmlGenericMapAdapter.class)
+    @JsonIgnore
+    private final Map<String, String> adynMembershipConds = new HashMap<>();
 
     private final List<TypeExtensionTO> typeExtensions = new ArrayList<>();
 
@@ -72,23 +78,20 @@ public class GroupPatch extends AnyPatch {
         this.groupOwner = groupOwner;
     }
 
-    public StringReplacePatchItem getADynMembershipCond() {
-        return adynMembershipCond;
-    }
-
-    public void setADynMembershipCond(final StringReplacePatchItem adynMembershipCond) {
-        this.adynMembershipCond = adynMembershipCond;
-    }
-
-    public StringReplacePatchItem getUDynMembershipCond() {
+    public String getUDynMembershipCond() {
         return udynMembershipCond;
     }
 
-    public void setUDynMembershipCond(final StringReplacePatchItem udynMembershipCond) {
+    public void setUDynMembershipCond(final String udynMembershipCond) {
         this.udynMembershipCond = udynMembershipCond;
     }
 
     @JsonIgnore
+    public Map<String, String> getADynMembershipConds() {
+        return adynMembershipConds;
+    }
+
+    @JsonIgnore
     public TypeExtensionTO getTypeExtension(final String anyType) {
         return IterableUtils.find(typeExtensions, new Predicate<TypeExtensionTO>() {
 
@@ -110,7 +113,7 @@ public class GroupPatch extends AnyPatch {
     public boolean isEmpty() {
         return super.isEmpty()
                 && name == null && userOwner == null && groupOwner == null
-                && adynMembershipCond == null && udynMembershipCond == null && typeExtensions.isEmpty();
+                && udynMembershipCond == null && adynMembershipConds.isEmpty() && typeExtensions.isEmpty();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/common/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java
index bedd2f3..45b0220 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java
@@ -21,13 +21,17 @@ package org.apache.syncope.common.lib.to;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.collections4.Predicate;
+import org.apache.syncope.common.lib.jaxb.XmlGenericMapAdapter;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 
 @XmlRootElement(name = "group")
@@ -42,10 +46,12 @@ public class GroupTO extends AnyTO {
 
     private Long groupOwner;
 
-    private String adynMembershipCond;
-
     private String udynMembershipCond;
 
+    @XmlJavaTypeAdapter(XmlGenericMapAdapter.class)
+    @JsonIgnore
+    private final Map<String, String> adynMembershipConds = new HashMap<>();
+
     private final List<TypeExtensionTO> typeExtensions = new ArrayList<>();
 
     @Override
@@ -82,14 +88,6 @@ public class GroupTO extends AnyTO {
         this.groupOwner = groupOwner;
     }
 
-    public String getADynMembershipCond() {
-        return adynMembershipCond;
-    }
-
-    public void setADynMembershipCond(final String aDynMembershipCond) {
-        this.adynMembershipCond = aDynMembershipCond;
-    }
-
     public String getUDynMembershipCond() {
         return udynMembershipCond;
     }
@@ -99,6 +97,11 @@ public class GroupTO extends AnyTO {
     }
 
     @JsonIgnore
+    public Map<String, String> getADynMembershipConds() {
+        return adynMembershipConds;
+    }
+
+    @JsonIgnore
     public TypeExtensionTO getTypeExtension(final String anyType) {
         return IterableUtils.find(typeExtensions, new Predicate<TypeExtensionTO>() {
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/common/lib/src/main/java/org/apache/syncope/common/lib/types/EntityViolationType.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/EntityViolationType.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/EntityViolationType.java
index 8324525..1253eee 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/EntityViolationType.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/EntityViolationType.java
@@ -25,6 +25,7 @@ public enum EntityViolationType {
 
     Standard(""),
     InvalidAnyType("org.apache.syncope.core.persistence.validation.anytype"),
+    InvalidADynMemberships("org.apache.syncope.core.persistence.validation.group.adynMembershipCond"),
     InvalidConnInstanceLocation("org.apache.syncope.core.persistence.validation.conninstance.location"),
     InvalidConnPoolConf("org.apache.syncope.core.persistence.validation.conninstance.poolConf"),
     InvalidMapping("org.apache.syncope.core.persistence.validation.mapping"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADynGroupMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADynGroupMembership.java
index 1e09d24..19723cf 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADynGroupMembership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADynGroupMembership.java
@@ -18,8 +18,12 @@
  */
 package org.apache.syncope.core.persistence.api.entity.anyobject;
 
+import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.DynGroupMembership;
 
 public interface ADynGroupMembership extends DynGroupMembership<AnyObject> {
 
+    AnyType getAnyType();
+
+    void setAnyType(AnyType anyType);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
index 56fe5db..74a32f3 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/group/Group.java
@@ -51,14 +51,18 @@ public interface Group extends Any<GPlainAttr> {
     @Override
     List<? extends GPlainAttr> getPlainAttrs();
 
-    ADynGroupMembership getADynMembership();
-
-    void setADynMembership(ADynGroupMembership aDynMembership);
-
     UDynGroupMembership getUDynMembership();
 
     void setUDynMembership(UDynGroupMembership uDynMembership);
 
+    boolean add(ADynGroupMembership dynGroupMembership);
+
+    boolean remove(ADynGroupMembership dynGroupMembership);
+
+    ADynGroupMembership getADynMembership(AnyType anyType);
+
+    List<? extends ADynGroupMembership> getADynMemberships();
+
     boolean add(TypeExtension typeExtension);
 
     boolean remove(TypeExtension typeExtension);

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/AnyFilter.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/AnyFilter.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/AnyFilter.java
deleted file mode 100644
index 8ae4472..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/AnyFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.syncope.core.persistence.api.entity.task;
-
-import org.apache.syncope.core.persistence.api.entity.AnyType;
-import org.apache.syncope.core.persistence.api.entity.Entity;
-
-public interface AnyFilter extends Entity<Long> {
-
-    PushTask getPushTask();
-
-    void setPushTask(PushTask pushTask);
-
-    AnyType getAnyType();
-
-    void setAnyType(AnyType anyType);
-
-    String get();
-
-    void set(String filter);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTask.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTask.java
index 1de3209..0052cd5 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTask.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTask.java
@@ -23,11 +23,11 @@ import org.apache.syncope.core.persistence.api.entity.AnyType;
 
 public interface PushTask extends ProvisioningTask {
 
-    boolean add(AnyFilter filter);
+    boolean add(PushTaskAnyFilter filter);
 
-    boolean remove(AnyFilter filter);
+    boolean remove(PushTaskAnyFilter filter);
 
-    AnyFilter getFilter(AnyType anyType);
+    PushTaskAnyFilter getFilter(AnyType anyType);
 
-    List<? extends AnyFilter> getFilters();
+    List<? extends PushTaskAnyFilter> getFilters();
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTaskAnyFilter.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTaskAnyFilter.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTaskAnyFilter.java
new file mode 100644
index 0000000..76d54c2
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PushTaskAnyFilter.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.syncope.core.persistence.api.entity.task;
+
+import org.apache.syncope.core.persistence.api.entity.AnyType;
+import org.apache.syncope.core.persistence.api.entity.Entity;
+
+public interface PushTaskAnyFilter extends Entity<Long> {
+
+    PushTask getPushTask();
+
+    void setPushTask(PushTask pushTask);
+
+    AnyType getAnyType();
+
+    void setAnyType(AnyType anyType);
+
+    String getFIQLCond();
+
+    void setFIQLCond(String fiql);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDynMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDynMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDynMembership.java
deleted file mode 100644
index 7901a6e..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/user/UDynMembership.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.syncope.core.persistence.api.entity.user;
-
-import org.apache.syncope.core.persistence.api.entity.DynMembership;
-
-public interface UDynMembership extends DynMembership<User> {
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
index 193ed8f..83cc0a5 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
@@ -109,7 +109,7 @@ public class JPAAnyObjectDAO extends AbstractAnyDAO<AnyObject> implements AnyObj
     @Override
     public void delete(final AnyObject any) {
         for (Group group : findDynGroupMemberships(any)) {
-            group.getADynMembership().remove(any);
+            group.getADynMembership(any.getType()).remove(any);
         }
 
         entityManager().remove(any);

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index 671582c..66cee45 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -48,6 +48,7 @@ import org.apache.syncope.core.persistence.api.entity.Any;
 import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
 import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
 import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
@@ -173,16 +174,6 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     @Override
     public Group save(final Group group) {
         // refresh dynaminc memberships
-        if (group.getADynMembership() != null) {
-            List<AnyObject> matching = searchDAO.search(
-                    buildDynMembershipCond(group.getADynMembership().getFIQLCond(), group.getRealm()),
-                    AnyTypeKind.ANY_OBJECT);
-
-            group.getADynMembership().getMembers().clear();
-            for (AnyObject anyObject : matching) {
-                group.getADynMembership().add(anyObject);
-            }
-        }
         if (group.getUDynMembership() != null) {
             List<User> matching = searchDAO.search(
                     buildDynMembershipCond(group.getUDynMembership().getFIQLCond(), group.getRealm()),
@@ -193,6 +184,16 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
                 group.getUDynMembership().add(user);
             }
         }
+        for (ADynGroupMembership memb : group.getADynMemberships()) {
+            List<AnyObject> matching = searchDAO.search(
+                    buildDynMembershipCond(memb.getFIQLCond(), group.getRealm()),
+                    AnyTypeKind.ANY_OBJECT);
+
+            memb.getMembers().clear();
+            for (AnyObject anyObject : matching) {
+                memb.add(anyObject);
+            }
+        }
 
         return super.save(group);
     }
@@ -272,12 +273,14 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     @Override
     public void refreshDynMemberships(final AnyObject anyObject) {
         for (Group group : findAll()) {
-            if (group.getADynMembership() != null && !searchDAO.matches(
-                    anyObject,
-                    buildDynMembershipCond(group.getADynMembership().getFIQLCond(), group.getRealm()),
-                    AnyTypeKind.ANY_OBJECT)) {
-
-                group.getADynMembership().remove(anyObject);
+            for (ADynGroupMembership memb : group.getADynMemberships()) {
+                if (!searchDAO.matches(
+                        anyObject,
+                        buildDynMembershipCond(memb.getFIQLCond(), group.getRealm()),
+                        AnyTypeKind.ANY_OBJECT)) {
+
+                    memb.remove(anyObject);
+                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
index 90b5290..8fc70e3 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAEntityFactory.java
@@ -68,11 +68,11 @@ import org.apache.syncope.core.persistence.api.entity.group.TypeExtension;
 import org.apache.syncope.core.persistence.api.entity.resource.Mapping;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.task.AnyFilter;
 import org.apache.syncope.core.persistence.api.entity.task.AnyTemplateSyncTask;
 import org.apache.syncope.core.persistence.api.entity.task.NotificationTask;
 import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
+import org.apache.syncope.core.persistence.api.entity.task.PushTaskAnyFilter;
 import org.apache.syncope.core.persistence.api.entity.task.SchedTask;
 import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
 import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
@@ -103,7 +103,7 @@ import org.apache.syncope.core.persistence.jpa.entity.group.JPATypeExtension;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMappingItem;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAProvision;
-import org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyFilter;
+import org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyTemplateSyncTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPANotificationTask;
 import org.apache.syncope.core.persistence.jpa.entity.task.JPAPropagationTask;
@@ -228,8 +228,8 @@ public class JPAEntityFactory implements EntityFactory {
             result = (T) new JPASchedTask();
         } else if (reference.equals(TaskExec.class)) {
             result = (T) new JPATaskExec();
-        } else if (reference.equals(AnyFilter.class)) {
-            result = (T) new JPAAnyFilter();
+        } else if (reference.equals(PushTaskAnyFilter.class)) {
+            result = (T) new JPAPushTaskAnyFilter();
         } else if (reference.equals(AnyTemplateSyncTask.class)) {
             result = (T) new JPAAnyTemplateSyncTask();
         } else if (reference.equals(SecurityQuestion.class)) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
index c12b855..1d3d69e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
@@ -25,12 +25,15 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractDynMembership;
+import org.apache.syncope.core.persistence.jpa.entity.JPAAnyType;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
 
 @Entity
@@ -47,6 +50,9 @@ public class JPAADynGroupMembership extends AbstractDynMembership<AnyObject> imp
     @OneToOne
     private JPAGroup group;
 
+    @ManyToOne
+    private JPAAnyType anyType;
+
     @ManyToMany
     @JoinTable(joinColumns =
             @JoinColumn(name = "aDynGroupMembership_id"),
@@ -71,6 +77,17 @@ public class JPAADynGroupMembership extends AbstractDynMembership<AnyObject> imp
     }
 
     @Override
+    public AnyType getAnyType() {
+        return anyType;
+    }
+
+    @Override
+    public void setAnyType(final AnyType anyType) {
+        checkType(anyType, JPAAnyType.class);
+        this.anyType = (JPAAnyType) anyType;
+    }
+
+    @Override
     public boolean add(final AnyObject anyObject) {
         checkType(anyObject, JPAAnyObject.class);
         return anyObjects.add((JPAAnyObject) anyObject);

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
index e7a5579..bd3cbce 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
@@ -99,13 +99,12 @@ public class JPAGroup extends AbstractAny<GPlainAttr> implements Group {
 
     @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "group")
     @Valid
-    private JPAADynGroupMembership aDynMembership;
-
-    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "group")
-    @Valid
     private JPAUDynGroupMembership uDynMembership;
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "group")
+    private List<JPAADynGroupMembership> aDynMemberships = new ArrayList<>();
+
+    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "group")
     private List<JPATypeExtension> typeExtensions = new ArrayList<>();
 
     @Override
@@ -178,24 +177,13 @@ public class JPAGroup extends AbstractAny<GPlainAttr> implements Group {
     }
 
     @Override
-    public ADynGroupMembership getADynMembership() {
-        return aDynMembership;
-    }
-
-    @Override
-    public void setADynMembership(final ADynGroupMembership aDynMembership) {
-        checkType(aDynMembership, JPAADynGroupMembership.class);
-        this.aDynMembership = (JPAADynGroupMembership) aDynMembership;
-    }
-
-    @Override
     public UDynGroupMembership getUDynMembership() {
         return uDynMembership;
     }
 
     @Override
     public void setUDynMembership(final UDynGroupMembership uDynMembership) {
-        checkType(aDynMembership, JPAADynGroupMembership.class);
+        checkType(uDynMembership, JPAUDynGroupMembership.class);
         this.uDynMembership = (JPAUDynGroupMembership) uDynMembership;
     }
 
@@ -217,6 +205,34 @@ public class JPAGroup extends AbstractAny<GPlainAttr> implements Group {
     }
 
     @Override
+    public boolean add(final ADynGroupMembership dynGroupMembership) {
+        checkType(dynGroupMembership, JPAADynGroupMembership.class);
+        return this.aDynMemberships.add((JPAADynGroupMembership) dynGroupMembership);
+    }
+
+    @Override
+    public boolean remove(final ADynGroupMembership dynGroupMembership) {
+        checkType(dynGroupMembership, JPAADynGroupMembership.class);
+        return this.aDynMemberships.remove((JPAADynGroupMembership) dynGroupMembership);
+    }
+
+    @Override
+    public ADynGroupMembership getADynMembership(final AnyType anyType) {
+        return IterableUtils.find(aDynMemberships, new Predicate<ADynGroupMembership>() {
+
+            @Override
+            public boolean evaluate(final ADynGroupMembership dynGroupMembership) {
+                return anyType != null && anyType.equals(dynGroupMembership.getAnyType());
+            }
+        });
+    }
+
+    @Override
+    public List<? extends ADynGroupMembership> getADynMemberships() {
+        return aDynMemberships;
+    }
+
+    @Override
     public boolean add(final TypeExtension typeExtension) {
         checkType(typeExtension, JPATypeExtension.class);
         return this.typeExtensions.add((JPATypeExtension) typeExtension);

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyFilter.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyFilter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyFilter.java
deleted file mode 100644
index 93e10e3..0000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyFilter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.syncope.core.persistence.jpa.entity.task;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-import org.apache.syncope.core.persistence.api.entity.AnyType;
-import org.apache.syncope.core.persistence.api.entity.task.AnyFilter;
-import org.apache.syncope.core.persistence.api.entity.task.PushTask;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractEntity;
-import org.apache.syncope.core.persistence.jpa.entity.JPAAnyType;
-
-@Entity
-@Table(name = JPAAnyFilter.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "pushTask_id", "anyType_name" }))
-public class JPAAnyFilter extends AbstractEntity<Long> implements AnyFilter {
-
-    private static final long serialVersionUID = 3517381731849788407L;
-
-    public static final String TABLE = "AnyFilter";
-
-    @Id
-    private Long id;
-
-    @ManyToOne
-    private JPAPushTask pushTask;
-
-    @ManyToOne
-    private JPAAnyType anyType;
-
-    @Lob
-    private String filter;
-
-    @Override
-    public Long getKey() {
-        return id;
-    }
-
-    @Override
-    public PushTask getPushTask() {
-        return pushTask;
-    }
-
-    @Override
-    public void setPushTask(final PushTask syncTask) {
-        checkType(syncTask, JPAPushTask.class);
-        this.pushTask = (JPAPushTask) syncTask;
-    }
-
-    @Override
-    public AnyType getAnyType() {
-        return anyType;
-    }
-
-    @Override
-    public void setAnyType(final AnyType anyType) {
-        checkType(anyType, JPAAnyType.class);
-        this.anyType = (JPAAnyType) anyType;
-    }
-
-    @Override
-    public String get() {
-        return filter;
-    }
-
-    @Override
-    public void set(final String filter) {
-        this.filter = filter;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
index bbf3242..a6f6d75 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
@@ -35,8 +35,8 @@ import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.collections4.Predicate;
 import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
-import org.apache.syncope.core.persistence.api.entity.task.AnyFilter;
 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
+import org.apache.syncope.core.persistence.api.entity.task.PushTaskAnyFilter;
 
 @Entity
 @DiscriminatorValue("PushTask")
@@ -52,7 +52,7 @@ public class JPAPushTask extends AbstractProvisioningTask implements PushTask {
     private Set<String> actionsClassNames = new HashSet<>();
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "pushTask")
-    private List<JPAAnyFilter> filters = new ArrayList<>();
+    private List<JPAPushTaskAnyFilter> filters = new ArrayList<>();
 
     /**
      * Default constructor.
@@ -67,30 +67,30 @@ public class JPAPushTask extends AbstractProvisioningTask implements PushTask {
     }
 
     @Override
-    public boolean add(final AnyFilter filter) {
-        checkType(filter, JPAAnyFilter.class);
-        return this.filters.add((JPAAnyFilter) filter);
+    public boolean add(final PushTaskAnyFilter filter) {
+        checkType(filter, JPAPushTaskAnyFilter.class);
+        return this.filters.add((JPAPushTaskAnyFilter) filter);
     }
 
     @Override
-    public boolean remove(final AnyFilter filter) {
-        checkType(filter, JPAAnyFilter.class);
-        return this.filters.remove((JPAAnyFilter) filter);
+    public boolean remove(final PushTaskAnyFilter filter) {
+        checkType(filter, JPAPushTaskAnyFilter.class);
+        return this.filters.remove((JPAPushTaskAnyFilter) filter);
     }
 
     @Override
-    public AnyFilter getFilter(final AnyType anyType) {
-        return IterableUtils.find(filters, new Predicate<AnyFilter>() {
+    public PushTaskAnyFilter getFilter(final AnyType anyType) {
+        return IterableUtils.find(filters, new Predicate<PushTaskAnyFilter>() {
 
             @Override
-            public boolean evaluate(final AnyFilter filter) {
+            public boolean evaluate(final PushTaskAnyFilter filter) {
                 return anyType != null && anyType.equals(filter.getAnyType());
             }
         });
     }
 
     @Override
-    public List<? extends AnyFilter> getFilters() {
+    public List<? extends PushTaskAnyFilter> getFilters() {
         return filters;
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
new file mode 100644
index 0000000..5a310ba
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.syncope.core.persistence.jpa.entity.task;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.NotNull;
+import org.apache.syncope.core.persistence.api.entity.AnyType;
+import org.apache.syncope.core.persistence.api.entity.task.PushTask;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractEntity;
+import org.apache.syncope.core.persistence.jpa.entity.JPAAnyType;
+import org.apache.syncope.core.persistence.api.entity.task.PushTaskAnyFilter;
+
+@Entity
+@Table(name = JPAPushTaskAnyFilter.TABLE, uniqueConstraints =
+        @UniqueConstraint(columnNames = { "pushTask_id", "anyType_name" }))
+public class JPAPushTaskAnyFilter extends AbstractEntity<Long> implements PushTaskAnyFilter {
+
+    private static final long serialVersionUID = 3517381731849788407L;
+
+    public static final String TABLE = "PushTaskAnyFilter";
+
+    @Id
+    private Long id;
+
+    @ManyToOne
+    private JPAPushTask pushTask;
+
+    @ManyToOne
+    private JPAAnyType anyType;
+
+    @NotNull
+    private String fiql;
+
+    @Override
+    public Long getKey() {
+        return id;
+    }
+
+    @Override
+    public PushTask getPushTask() {
+        return pushTask;
+    }
+
+    @Override
+    public void setPushTask(final PushTask syncTask) {
+        checkType(syncTask, JPAPushTask.class);
+        this.pushTask = (JPAPushTask) syncTask;
+    }
+
+    @Override
+    public AnyType getAnyType() {
+        return anyType;
+    }
+
+    @Override
+    public void setAnyType(final AnyType anyType) {
+        checkType(anyType, JPAAnyType.class);
+        this.anyType = (JPAAnyType) anyType;
+    }
+
+    @Override
+    public String getFIQLCond() {
+        return fiql;
+    }
+
+    @Override
+    public void setFIQLCond(final String fiql) {
+        this.fiql = fiql;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/AbstractUDynMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/AbstractUDynMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/AbstractUDynMembership.java
index 00e85c4..5dd0902 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/AbstractUDynMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/AbstractUDynMembership.java
@@ -20,12 +20,11 @@ package org.apache.syncope.core.persistence.jpa.entity.user;
 
 import java.util.List;
 import javax.persistence.MappedSuperclass;
-import org.apache.syncope.core.persistence.api.entity.user.UDynMembership;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractDynMembership;
 
 @MappedSuperclass
-public abstract class AbstractUDynMembership extends AbstractDynMembership<User> implements UDynMembership {
+public abstract class AbstractUDynMembership extends AbstractDynMembership<User> {
 
     private static final long serialVersionUID = 6296230283800203205L;
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/GroupValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/GroupValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/GroupValidator.java
index 078217f..090c482 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/GroupValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/GroupValidator.java
@@ -18,19 +18,24 @@
  */
 package org.apache.syncope.core.persistence.jpa.validation.entity;
 
+import java.util.HashSet;
+import java.util.Set;
 import javax.validation.ConstraintValidatorContext;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.EntityViolationType;
+import org.apache.syncope.core.persistence.api.entity.AnyType;
+import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 
 public class GroupValidator extends AbstractValidator<GroupCheck, Group> {
 
     @Override
-    public boolean isValid(final Group object, final ConstraintValidatorContext context) {
+    public boolean isValid(final Group group, final ConstraintValidatorContext context) {
         context.disableDefaultConstraintViolation();
 
         boolean isValid = true;
 
-        if (object.getUserOwner() != null && object.getGroupOwner() != null) {
+        if (group.getUserOwner() != null && group.getGroupOwner() != null) {
             isValid = false;
 
             context.buildConstraintViolationWithTemplate(
@@ -39,6 +44,32 @@ public class GroupValidator extends AbstractValidator<GroupCheck, Group> {
                     addPropertyNode("owner").addConstraintViolation();
         }
 
+        if (isValid) {
+            Set<AnyType> anyTypes = new HashSet<>();
+            for (ADynGroupMembership memb : group.getADynMemberships()) {
+                anyTypes.add(memb.getAnyType());
+
+                if (memb.getAnyType().getKind() != AnyTypeKind.ANY_OBJECT) {
+                    isValid = false;
+
+                    context.buildConstraintViolationWithTemplate(
+                            getTemplate(EntityViolationType.InvalidADynMemberships,
+                                    "No user or group dynamic membership condition are allowed here")).
+                            addPropertyNode("aDynMemberships").addConstraintViolation();
+                }
+            }
+
+            if (isValid && anyTypes.size() < group.getADynMemberships().size()) {
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidADynMemberships,
+                                "Each dynamic membership condition requires a different "
+                                + AnyType.class.getSimpleName())).
+                        addPropertyNode("aDynMemberships").addConstraintViolation();
+                return false;
+            }
+
+        }
+
         return isValid;
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
index d1379c9..72fadcd 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
@@ -329,11 +329,11 @@ under the License.
     </attributes>
   </entity>
 
-  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyFilter">
+  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter">
     <attributes>
       <id name="id">
-        <generated-value generator="SEQ_AnyFilter" strategy="TABLE"/>
-        <table-generator name="SEQ_AnyFilter" pk-column-value="SEQ_AnyFilter" initial-value="1000"/>
+        <generated-value generator="SEQ_PushTaskAnyFilter" strategy="TABLE"/>
+        <table-generator name="SEQ_PushTaskAnyFilter" pk-column-value="SEQ_PushTaskAnyFilter" initial-value="1000"/>
       </id>
     </attributes>
   </entity>

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
index d1379c9..72fadcd 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
@@ -329,11 +329,11 @@ under the License.
     </attributes>
   </entity>
 
-  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyFilter">
+  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter">
     <attributes>
       <id name="id">
-        <generated-value generator="SEQ_AnyFilter" strategy="TABLE"/>
-        <table-generator name="SEQ_AnyFilter" pk-column-value="SEQ_AnyFilter" initial-value="1000"/>
+        <generated-value generator="SEQ_PushTaskAnyFilter" strategy="TABLE"/>
+        <table-generator name="SEQ_PushTaskAnyFilter" pk-column-value="SEQ_PushTaskAnyFilter" initial-value="1000"/>
       </id>
     </attributes>
   </entity>

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
index 584d8ec..5fc68ea 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
@@ -377,11 +377,11 @@ under the License.
     </attributes>
   </entity>
 
-  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAAnyFilter">
+  <entity class="org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTaskAnyFilter">
     <attributes>
       <id name="id">
-        <generated-value generator="SEQ_AnyFilter" strategy="TABLE"/>
-        <table-generator name="SEQ_AnyFilter" pk-column-value="SEQ_AnyFilter" initial-value="1000"/>
+        <generated-value generator="SEQ_PushTaskAnyFilter" strategy="TABLE"/>
+        <table-generator name="SEQ_PushTaskAnyFilter" pk-column-value="SEQ_PushTaskAnyFilter" initial-value="1000"/>
       </id>
     </attributes>
   </entity>

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/GroupTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/GroupTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/GroupTest.java
index e3db14f..7d40678 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/GroupTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/GroupTest.java
@@ -290,10 +290,11 @@ public class GroupTest extends AbstractTest {
         group.setName("new");
 
         ADynGroupMembership dynMembership = entityFactory.newEntity(ADynGroupMembership.class);
+        dynMembership.setAnyType(anyTypeDAO.find("PRINTER"));
         dynMembership.setFIQLCond("model==Canon MFC8030");
         dynMembership.setGroup(group);
 
-        group.setADynMembership(dynMembership);
+        group.add(dynMembership);
 
         Group actual = groupDAO.save(group);
         assertNotNull(actual);
@@ -303,14 +304,15 @@ public class GroupTest extends AbstractTest {
         // 2. verify that dynamic membership is there
         actual = groupDAO.find(actual.getKey());
         assertNotNull(actual);
-        assertNotNull(actual.getADynMembership());
-        assertNotNull(actual.getADynMembership().getKey());
-        assertEquals(actual, actual.getADynMembership().getGroup());
+        assertNotNull(actual.getADynMembership(anyTypeDAO.find("PRINTER")));
+        assertNotNull(actual.getADynMembership(anyTypeDAO.find("PRINTER")).getKey());
+        assertEquals(actual, actual.getADynMembership(anyTypeDAO.find("PRINTER")).getGroup());
 
         // 3. verify that expected any objects have the created group dynamically assigned
-        assertEquals(2, actual.getADynMembership().getMembers().size());
+        assertEquals(2, actual.getADynMembership(anyTypeDAO.find("PRINTER")).getMembers().size());
         assertEquals(new HashSet<>(Arrays.asList(1L, newAnyObjectKey)),
-                CollectionUtils.collect(actual.getADynMembership().getMembers(), new Transformer<AnyObject, Long>() {
+                CollectionUtils.collect(actual.getADynMembership(anyTypeDAO.find("PRINTER")).getMembers(),
+                        new Transformer<AnyObject, Long>() {
 
                     @Override
                     public Long transform(final AnyObject input) {
@@ -322,7 +324,7 @@ public class GroupTest extends AbstractTest {
         assertNotNull(anyObject);
         Collection<Group> dynGroupMemberships = findDynGroupMemberships(anyObject);
         assertEquals(1, dynGroupMemberships.size());
-        assertTrue(dynGroupMemberships.contains(actual.getADynMembership().getGroup()));
+        assertTrue(dynGroupMemberships.contains(actual.getADynMembership(anyTypeDAO.find("PRINTER")).getGroup()));
 
         // 4. delete the new any object and verify that dynamic membership was updated
         anyObjectDAO.delete(newAnyObjectKey);
@@ -330,11 +332,11 @@ public class GroupTest extends AbstractTest {
         anyObjectDAO.flush();
 
         actual = groupDAO.find(actual.getKey());
-        assertEquals(1, actual.getADynMembership().getMembers().size());
-        assertEquals(1L, actual.getADynMembership().getMembers().get(0).getKey(), 0);
+        assertEquals(1, actual.getADynMembership(anyTypeDAO.find("PRINTER")).getMembers().size());
+        assertEquals(1L, actual.getADynMembership(anyTypeDAO.find("PRINTER")).getMembers().get(0).getKey(), 0);
 
         // 5. delete group and verify that dynamic membership was also removed
-        Long dynMembershipKey = actual.getADynMembership().getKey();
+        Long dynMembershipKey = actual.getADynMembership(anyTypeDAO.find("PRINTER")).getKey();
 
         groupDAO.delete(actual);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 44335eb..5acb4f9 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -986,7 +986,7 @@ under the License.
   <AnyTemplateSyncTask id="41" syncTask_id="4" anyType_name="USER"
                        template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":["csv"],"derAttrs":[{"schema":"cn","readonly":false,"values":[""]}],"virAttrs":[],"resources":["resource-testdb"],"relationships":[],"memberships":[{"leftType":null,"leftKey":0,"rightType":"GROUP","rightKey":8,"groupName":null}],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"type","readonly":false,"values":["email == &apos;test8@syncope.apache.org&apos;? &apos;TYPE_8&apos;: &apos;TYPE_OTHER&apos;"]}]}'/>
   <AnyTemplateSyncTask id="42" syncTask_id="4" anyType_name="GROUP"
-                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"adynMembershipCond":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
+                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
   <Task DTYPE="SchedTask" type="SCHEDULED" id="5" name="SampleJob Task" 
         jobDelegateClassName="org.apache.syncope.fit.core.reference.TestSampleJobDelegate" cronExpression="0 0 0 1 * ?"/>
   <Task DTYPE="PropagationTask" type="PROPAGATION" id="6" operation="UPDATE"
@@ -999,7 +999,7 @@ under the License.
   <AnyTemplateSyncTask id="71" syncTask_id="7" anyType_name="USER"
                        template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"relationships":[],"memberships":[],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"type","readonly":false,"values":["&apos;type a&apos;"]},{"schema":"userId","readonly":false,"values":["&apos;reconciled@syncope.apache.org&apos;"]},{"schema":"fullname","readonly":false,"values":["&apos;reconciled fullname&apos;"]},{"schema":"surname","readonly":false,"values":["&apos;surname&apos;"]}]}'/>
   <AnyTemplateSyncTask id="72" syncTask_id="7" anyType_name="GROUP"
-                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"adynMembershipCond":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
+                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
   <Task DTYPE="NotificationTask" type="NOTIFICATION" id="8" sender="admin@prova.org" subject="Notification for SYNCOPE-81" 
         textBody="NOTIFICATION-81" htmlBody="NOTIFICATION-81" traceLevel="ALL"/>
   <Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="9" name="TestDB2 Task" resource_name="resource-testdb2"
@@ -1014,7 +1014,7 @@ under the License.
   <AnyTemplateSyncTask id="1" syncTask_id="11" anyType_name="USER"
                        template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":[],"derAttrs":[],"virAttrs":[{"schema":"virtualReadOnly","readonly":true,"values":[""]}],"resources":["resource-ldap"],"roles":[],"dynRoles":[],"relationships":[],"memberships":[],"dynGroups":[],"plainAttrs":[]}'/>
   <AnyTemplateSyncTask id="2" syncTask_id="11" anyType_name="GROUP"
-                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"adynMembershipCond":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[{"schema":"show","readonly":false,"values":["true"]}]}'/>
+                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[{"schema":"show","readonly":false,"values":["true"]}]}'/>
   <SyncTask_actionsClassNames SyncTask_id="11" actionClassName="org.apache.syncope.core.provisioning.java.sync.LDAPMembershipSyncActions"/>
   <Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="12" name="VirAttrCache test" resource_name="resource-csv"
         destinationRealm_id="1" performCreate="0" performUpdate="1" performDelete="0" syncStatus="0" syncMode="FULL_RECONCILIATION"
@@ -1022,66 +1022,66 @@ under the License.
   <Task DTYPE="PushTask" type="PUSH" id="13" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"         
         unmatchingRule="ASSIGN" matchingRule="IGNORE"/>  
-  <AnyFilter id="131" anyType_name="USER" pushTask_id="13" filter="surname==Vivaldi"/>
-  <AnyFilter id="132" anyType_name="GROUP" pushTask_id="13" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="131" anyType_name="USER" pushTask_id="13" fiql="surname==Vivaldi"/>
+  <PushTaskAnyFilter id="132" anyType_name="GROUP" pushTask_id="13" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="14" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"         
         unmatchingRule="PROVISION" matchingRule="IGNORE"/>
-  <AnyFilter id="141" anyType_name="USER" pushTask_id="14" filter="surname==Bellini"/>
-  <AnyFilter id="142" anyType_name="GROUP" pushTask_id="14" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="141" anyType_name="USER" pushTask_id="14" fiql="surname==Bellini"/>
+  <PushTaskAnyFilter id="142" anyType_name="GROUP" pushTask_id="14" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="15" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="UNLINK" matchingRule="IGNORE"/>
-  <AnyFilter id="151" anyType_name="USER" pushTask_id="15" filter="surname==Puccini"/>
-  <AnyFilter id="152" anyType_name="GROUP" pushTask_id="15" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="151" anyType_name="USER" pushTask_id="15" fiql="surname==Puccini"/>
+  <PushTaskAnyFilter id="152" anyType_name="GROUP" pushTask_id="15" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="16" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"         
         unmatchingRule="IGNORE" matchingRule="IGNORE"/>
-  <AnyFilter id="161" anyType_name="USER" pushTask_id="16" filter="surname==Verdi"/>
-  <AnyFilter id="162" anyType_name="GROUP" pushTask_id="16" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="161" anyType_name="USER" pushTask_id="16" fiql="surname==Verdi"/>
+  <PushTaskAnyFilter id="162" anyType_name="GROUP" pushTask_id="16" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="17" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="ASSIGN" matchingRule="UPDATE"/>
-  <AnyFilter id="171" anyType_name="USER" pushTask_id="17" filter="username==_NO_ONE_"/>
-  <AnyFilter id="172" anyType_name="GROUP" pushTask_id="17" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="171" anyType_name="USER" pushTask_id="17" fiql="username==_NO_ONE_"/>
+  <PushTaskAnyFilter id="172" anyType_name="GROUP" pushTask_id="17" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="18" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="IGNORE" matchingRule="DEPROVISION"/>
-  <AnyFilter id="181" anyType_name="USER" pushTask_id="18" filter="surname==Verdi"/>
-  <AnyFilter id="182" anyType_name="GROUP" pushTask_id="18" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="181" anyType_name="USER" pushTask_id="18" fiql="surname==Verdi"/>
+  <PushTaskAnyFilter id="182" anyType_name="GROUP" pushTask_id="18" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="19" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="IGNORE" matchingRule="UNASSIGN"/>
-  <AnyFilter id="191" anyType_name="USER" pushTask_id="19" filter="surname==Rossini"/>
-  <AnyFilter id="192" anyType_name="GROUP" pushTask_id="19" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="191" anyType_name="USER" pushTask_id="19" fiql="surname==Rossini"/>
+  <PushTaskAnyFilter id="192" anyType_name="GROUP" pushTask_id="19" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="20" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="IGNORE" matchingRule="LINK"/>
-  <AnyFilter id="201" anyType_name="USER" pushTask_id="20" filter="surname==Verdi"/>
-  <AnyFilter id="202" anyType_name="GROUP" pushTask_id="20" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="201" anyType_name="USER" pushTask_id="20" fiql="surname==Verdi"/>
+  <PushTaskAnyFilter id="202" anyType_name="GROUP" pushTask_id="20" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="21" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="IGNORE" matchingRule="UNLINK"/>
-  <AnyFilter id="211" anyType_name="USER" pushTask_id="21" filter="surname==Verdi"/>
-  <AnyFilter id="212" anyType_name="GROUP" pushTask_id="21" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="211" anyType_name="USER" pushTask_id="21" fiql="surname==Verdi"/>
+  <PushTaskAnyFilter id="212" anyType_name="GROUP" pushTask_id="21" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="22" name="Export on resource-testdb2" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
         
         unmatchingRule="IGNORE" matchingRule="UPDATE"/>
-  <AnyFilter id="221" anyType_name="USER" pushTask_id="22" filter="surname==Verdi"/>
-  <AnyFilter id="222" anyType_name="GROUP" pushTask_id="22" filter="name==_NO_ONE_"/>
+  <PushTaskAnyFilter id="221" anyType_name="USER" pushTask_id="22" fiql="surname==Verdi"/>
+  <PushTaskAnyFilter id="222" anyType_name="GROUP" pushTask_id="22" fiql="name==_NO_ONE_"/>
   <Task DTYPE="PushTask" type="PUSH" id="23" name="Export on resource-ldap" resource_name="resource-ldap"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"        
         unmatchingRule="ASSIGN" matchingRule="UNLINK"/>
-  <AnyFilter id="231" anyType_name="USER" pushTask_id="23" filter="username==_NO_ONE_"/>
-  <AnyFilter id="232" anyType_name="GROUP" pushTask_id="23" filter="name==citizen"/>
+  <PushTaskAnyFilter id="231" anyType_name="USER" pushTask_id="23" fiql="username==_NO_ONE_"/>
+  <PushTaskAnyFilter id="232" anyType_name="GROUP" pushTask_id="23" fiql="name==citizen"/>
   <Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="24" name="CSV Task (update matching; provision unmatching)" resource_name="resource-csv"
         destinationRealm_id="1" performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" syncMode="INCREMENTAL"
         unmatchingRule="PROVISION" matchingRule="UPDATE"/>
   <AnyTemplateSyncTask id="3" syncTask_id="24" anyType_name="USER"
                        template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":["resource-testdb"],"roles":[],"dynRoles":[],"relationships":[],"memberships":[],"dynGroups":[],"plainAttrs":[{"schema":"firstname","readonly":false,"values":[""]},{"schema":"userId","readonly":false,"values":["&apos;test&apos;"]},{"schema":"fullname","readonly":false,"values":["&apos;test&apos;"]},{"schema":"surname","readonly":false,"values":["&apos;test&apos;"]}]}'/>
   <AnyTemplateSyncTask id="4" syncTask_id="24" anyType_name="GROUP"
-                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"adynMembershipCond":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
+                       template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
   <Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="25" name="CSV (unlink matching; ignore unmatching)" resource_name="resource-csv"
         destinationRealm_id="1" performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" syncMode="INCREMENTAL"
         unmatchingRule="IGNORE" matchingRule="UNLINK"/>

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
index c71fce5..5ddb8bc 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/GroupDataBinderImpl.java
@@ -60,7 +60,7 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
     @Autowired
     private AnyTypeDAO anyTypeDAO;
 
-    private void setDynMembership(final Group group, final AnyTypeKind anyTypeKind, final String dynMembershipFIQL) {
+    private void setDynMembership(final Group group, final AnyType anyType, final String dynMembershipFIQL) {
         SearchCond dynMembershipCond = SearchCondConverter.convert(dynMembershipFIQL);
         if (!dynMembershipCond.isValid()) {
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression);
@@ -69,17 +69,17 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
         }
 
         DynGroupMembership<?> dynMembership;
-        if (anyTypeKind == AnyTypeKind.ANY_OBJECT && group.getADynMembership() == null) {
+        if (anyType.getKind() == AnyTypeKind.ANY_OBJECT && group.getADynMembership(anyType) == null) {
             dynMembership = entityFactory.newEntity(ADynGroupMembership.class);
             dynMembership.setGroup(group);
-            group.setADynMembership((ADynGroupMembership) dynMembership);
-        } else if (anyTypeKind == AnyTypeKind.USER && group.getUDynMembership() == null) {
+            group.add((ADynGroupMembership) dynMembership);
+        } else if (anyType.getKind() == AnyTypeKind.USER && group.getUDynMembership() == null) {
             dynMembership = entityFactory.newEntity(UDynGroupMembership.class);
             dynMembership.setGroup(group);
             group.setUDynMembership((UDynGroupMembership) dynMembership);
         } else {
-            dynMembership = anyTypeKind == AnyTypeKind.ANY_OBJECT
-                    ? group.getADynMembership()
+            dynMembership = anyType.getKind() == AnyTypeKind.ANY_OBJECT
+                    ? group.getADynMembership(anyType)
                     : group.getUDynMembership();
         }
         dynMembership.setFIQLCond(dynMembershipFIQL);
@@ -129,11 +129,17 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
             }
         }
 
-        if (groupTO.getADynMembershipCond() != null) {
-            setDynMembership(group, AnyTypeKind.ANY_OBJECT, groupTO.getADynMembershipCond());
-        }
+        // dynamic membership
         if (groupTO.getUDynMembershipCond() != null) {
-            setDynMembership(group, AnyTypeKind.USER, groupTO.getUDynMembershipCond());
+            setDynMembership(group, anyTypeDAO.findUser(), groupTO.getUDynMembershipCond());
+        }
+        for (Map.Entry<String, String> entry : groupTO.getADynMembershipConds().entrySet()) {
+            AnyType anyType = anyTypeDAO.find(entry.getKey());
+            if (anyType == null) {
+                LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), entry.getKey());
+            } else {
+                setDynMembership(group, anyType, entry.getValue());
+            }
         }
 
         // type extensions
@@ -218,20 +224,25 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
         }
 
         // dynamic membership
-        if (groupPatch.getADynMembershipCond() != null) {
-            if (groupPatch.getADynMembershipCond().getValue() == null) {
-                group.setADynMembership(null);
-            } else {
-                group.getADynMembership().getMembers().clear();
-                setDynMembership(group, AnyTypeKind.ANY_OBJECT, groupPatch.getADynMembershipCond().getValue());
+        if (groupPatch.getUDynMembershipCond() == null) {
+            if (group.getUDynMembership() != null) {
+                group.getUDynMembership().setGroup(null);
+                group.setUDynMembership(null);
             }
+        } else {
+            setDynMembership(group, anyTypeDAO.findUser(), groupPatch.getUDynMembershipCond());
         }
-        if (groupPatch.getUDynMembershipCond() != null) {
-            if (groupPatch.getUDynMembershipCond().getValue() == null) {
-                group.setUDynMembership(null);
+        for (Iterator<? extends ADynGroupMembership> itor = group.getADynMemberships().iterator(); itor.hasNext();) {
+            ADynGroupMembership memb = itor.next();
+            memb.setGroup(null);
+            itor.remove();
+        }
+        for (Map.Entry<String, String> entry : groupPatch.getADynMembershipConds().entrySet()) {
+            AnyType anyType = anyTypeDAO.find(entry.getKey());
+            if (anyType == null) {
+                LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), entry.getKey());
             } else {
-                group.getUDynMembership().getMembers().clear();
-                setDynMembership(group, AnyTypeKind.USER, groupPatch.getUDynMembershipCond().getValue());
+                setDynMembership(group, anyType, entry.getValue());
             }
         }
 
@@ -317,12 +328,12 @@ public class GroupDataBinderImpl extends AbstractAnyDataBinder implements GroupD
         fillTO(groupTO, group.getRealm().getFullPath(), group.getAuxClasses(),
                 group.getPlainAttrs(), derAttrValues, virAttrValues, group.getResources());
 
-        if (group.getADynMembership() != null) {
-            groupTO.setADynMembershipCond(group.getADynMembership().getFIQLCond());
-        }
         if (group.getUDynMembership() != null) {
             groupTO.setUDynMembershipCond(group.getUDynMembership().getFIQLCond());
         }
+        for (ADynGroupMembership memb : group.getADynMemberships()) {
+            groupTO.getADynMembershipConds().put(memb.getAnyType().getKey(), memb.getFIQLCond());
+        }
 
         for (TypeExtension typeExt : group.getTypeExtensions()) {
             TypeExtensionTO typeExtTO = new TypeExtensionTO();

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/TaskDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/TaskDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/TaskDataBinderImpl.java
index 5e69ad6..94dcd13 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/TaskDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/TaskDataBinderImpl.java
@@ -55,7 +55,6 @@ import org.apache.syncope.core.persistence.api.dao.RealmDAO;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.task.AnyFilter;
 import org.apache.syncope.core.persistence.api.entity.AnyTemplate;
 import org.apache.syncope.core.persistence.api.entity.task.AnyTemplateSyncTask;
 import org.apache.syncope.core.provisioning.java.sync.PushJobDelegate;
@@ -69,6 +68,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 import org.springframework.stereotype.Component;
+import org.apache.syncope.core.persistence.api.entity.task.PushTaskAnyFilter;
 
 @Component
 public class TaskDataBinderImpl implements TaskDataBinder {
@@ -118,21 +118,21 @@ public class TaskDataBinderImpl implements TaskDataBinder {
                 if (type == null) {
                     LOG.debug("Invalid AnyType {} specified, ignoring...", entry.getKey());
                 } else {
-                    AnyFilter filter = pushTask.getFilter(type);
+                    PushTaskAnyFilter filter = pushTask.getFilter(type);
                     if (filter == null) {
-                        filter = entityFactory.newEntity(AnyFilter.class);
+                        filter = entityFactory.newEntity(PushTaskAnyFilter.class);
                         filter.setAnyType(anyTypeDAO.find(entry.getKey()));
                         filter.setPushTask(pushTask);
                         pushTask.add(filter);
                     }
-                    filter.set(entry.getValue());
+                    filter.setFIQLCond(entry.getValue());
                 }
             }
             // remove all filters not contained in the TO
-            CollectionUtils.filter(pushTask.getFilters(), new Predicate<AnyFilter>() {
+            CollectionUtils.filter(pushTask.getFilters(), new Predicate<PushTaskAnyFilter>() {
 
                 @Override
-                public boolean evaluate(final AnyFilter anyFilter) {
+                public boolean evaluate(final PushTaskAnyFilter anyFilter) {
                     return pushTaskTO.getFilters().containsKey(anyFilter.getAnyType().getKey());
                 }
             });
@@ -349,8 +349,8 @@ public class TaskDataBinderImpl implements TaskDataBinder {
                 ((PushTaskTO) taskTO).setUnmatchingRule(((PushTask) task).getUnmatchingRule() == null
                         ? UnmatchingRule.ASSIGN : ((PushTask) task).getUnmatchingRule());
 
-                for (AnyFilter filter : ((PushTask) task).getFilters()) {
-                    ((PushTaskTO) taskTO).getFilters().put(filter.getAnyType().getKey(), filter.get());
+                for (PushTaskAnyFilter filter : ((PushTask) task).getFilters()) {
+                    ((PushTaskTO) taskTO).getFilters().put(filter.getAnyType().getKey(), filter.getFIQLCond());
                 }
                 break;
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
index b045a63..ba70634 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/PushJobDelegate.java
@@ -174,7 +174,7 @@ public class PushJobDelegate extends AbstractProvisioningJobDelegate<PushTask> {
 
                 String filter = pushTask.getFilter(provision.getAnyType()) == null
                         ? null
-                        : pushTask.getFilter(provision.getAnyType()).get();
+                        : pushTask.getFilter(provision.getAnyType()).getFIQLCond();
                 if (StringUtils.isBlank(filter)) {
                     handle(anyDAO.findAll(), handler, pushTask.getResource());
                 } else {

http://git-wip-us.apache.org/repos/asf/syncope/blob/706cd367/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
index c45fba4..5d3ba01 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
@@ -556,7 +556,7 @@ public class GroupITCase extends AbstractITCase {
 
         GroupPatch mod = new GroupPatch();
         mod.setKey(group.getKey());
-        mod.setUDynMembershipCond(new StringReplacePatchItem.Builder().value("cool==false").build());
+        mod.setUDynMembershipCond("cool==false");
         groupService.update(mod);
 
         assertTrue(userService.read(4L).getDynGroups().isEmpty());


Mime
View raw message