You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/05/25 16:50:59 UTC

[23/29] syncope git commit: [SYNCOPE-666] Initial commit, Travis CI builds disabled

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/MembershipDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/MembershipDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/MembershipDAO.java
deleted file mode 100644
index 964e0e8..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/MembershipDAO.java
+++ /dev/null
@@ -1,40 +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.dao;
-
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.membership.Membership;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-
-public interface MembershipDAO extends DAO<Membership, Long> {
-
-    Membership find(Long key);
-
-    Membership find(User user, Group group);
-
-    List<Membership> findAll();
-
-    Membership save(Membership membership);
-
-    void delete(Long key);
-
-    Membership authFetch(Long key);
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainAttrDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainAttrDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainAttrDAO.java
index 1aa5d5c..e15b634 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainAttrDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainAttrDAO.java
@@ -20,11 +20,11 @@ package org.apache.syncope.core.persistence.api.dao;
 
 import org.apache.syncope.core.persistence.api.entity.PlainAttr;
 
-public interface PlainAttrDAO extends DAO<PlainAttr, Long> {
+public interface PlainAttrDAO extends DAO<PlainAttr<?>, Long> {
 
-    <T extends PlainAttr> T find(Long key, Class<T> reference);
+    <T extends PlainAttr<?>> T find(Long key, Class<T> reference);
 
-    <T extends PlainAttr> void delete(Long key, Class<T> reference);
+    <T extends PlainAttr<?>> void delete(Long key, Class<T> reference);
 
-    <T extends PlainAttr> void delete(T attr);
+    <T extends PlainAttr<?>> void delete(T attr);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
index 122faee..2dda81e 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PlainSchemaDAO.java
@@ -19,19 +19,18 @@
 package org.apache.syncope.core.persistence.api.dao;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtils;
 import org.apache.syncope.core.persistence.api.entity.PlainAttr;
 import org.apache.syncope.core.persistence.api.entity.PlainSchema;
 
 public interface PlainSchemaDAO extends DAO<PlainSchema, String> {
 
-    <T extends PlainSchema> T find(String key, Class<T> reference);
+    PlainSchema find(String name);
 
-    <T extends PlainSchema> List<T> findAll(Class<T> reference);
+    List<PlainSchema> findAll();
 
-    <T extends PlainAttr> List<T> findAttrs(PlainSchema schema, Class<T> reference);
+    <T extends PlainAttr<?>> List<T> findAttrs(PlainSchema schema, Class<T> reference);
 
-    <T extends PlainSchema> T save(T schema);
+    PlainSchema save(PlainSchema derSchema);
 
-    void delete(String name, AttributableUtils attributableUtil);
+    void delete(String key);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
index dff687d..58281ff 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PolicyDAO.java
@@ -21,7 +21,7 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import org.apache.syncope.common.lib.types.PolicyType;
 import org.apache.syncope.core.persistence.api.entity.AccountPolicy;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.Policy;
 
 public interface PolicyDAO extends DAO<Policy, Long> {

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectDAO.java
deleted file mode 100644
index aca7bf4..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectDAO.java
+++ /dev/null
@@ -1,44 +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.dao;
-
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtils;
-import org.apache.syncope.core.persistence.api.entity.DerAttr;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.Subject;
-import org.apache.syncope.core.persistence.api.entity.VirAttr;
-
-public interface SubjectDAO<P extends PlainAttr, D extends DerAttr, V extends VirAttr>
-        extends DAO<Subject<P, D, V>, Long> {
-
-    List<? extends Subject<P, D, V>> findByAttrValue(
-            String schemaName, PlainAttrValue attrValue, AttributableUtils attrUtils);
-
-    Subject<P, D, V> findByAttrUniqueValue(
-            String schemaName, PlainAttrValue attrUniqueValue, AttributableUtils attrUtils);
-
-    List<? extends Subject<P, D, V>> findByDerAttrValue(
-            String schemaName, String value, AttributableUtils attrUtils);
-
-    List<? extends Subject<P, D, V>> findByResource(
-            ExternalResource resource, AttributableUtils attrUtils);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectSearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectSearchDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectSearchDAO.java
deleted file mode 100644
index a4cd7d4..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SubjectSearchDAO.java
+++ /dev/null
@@ -1,83 +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.dao;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.entity.Subject;
-
-public interface SubjectSearchDAO extends DAO<Subject<?, ?, ?>, Long> {
-
-    /**
-     * @param adminRealms realms for which the caller owns the proper entitlement(s)
-     * @param searchCondition the search condition
-     * @param type user or group
-     * @return size of search result
-     */
-    int count(Set<String> adminRealms, SearchCond searchCondition, SubjectType type);
-
-    /**
-     * @param adminRealms realms for which the caller owns the proper entitlement(s)
-     * @param searchCondition the search condition
-     * @param type user or group
-     * @param <T> user/group
-     * @return the list of users/groups matching the given search condition
-     */
-    <T extends Subject<?, ?, ?>> List<T> search(
-            Set<String> adminRealms, SearchCond searchCondition, SubjectType type);
-
-    /**
-     * @param adminRealms the set of admin groups owned by the caller
-     * @param searchCondition the search condition
-     * @param orderBy list of ordering clauses
-     * @param type user or group
-     * @param <T> user/group
-     * @return the list of users/groups matching the given search condition
-     */
-    <T extends Subject<?, ?, ?>> List<T> search(
-            Set<String> adminRealms, SearchCond searchCondition, List<OrderByClause> orderBy, SubjectType type);
-
-    /**
-     * @param adminRealms realms for which the caller owns the proper entitlement(s)
-     * @param searchCondition the search condition
-     * @param page position of the first result, start from 1
-     * @param itemsPerPage number of results per page
-     * @param orderBy list of ordering clauses
-     * @param type user or group
-     * @param <T> user/group
-     * @return the list of users/groups matching the given search condition (in the given page)
-     */
-    <T extends Subject<?, ?, ?>> List<T> search(
-            Set<String> adminRealms, SearchCond searchCondition, int page, int itemsPerPage,
-            List<OrderByClause> orderBy, SubjectType type);
-
-    /**
-     * Verify if user/group matches the given search condition.
-     *
-     * @param subject to be checked
-     * @param searchCondition to be verified
-     * @param type user or group
-     * @param <T> user/group
-     * @return true if user/group matches searchCondition
-     */
-    <T extends Subject<?, ?, ?>> boolean matches(T subject, SearchCond searchCondition, SubjectType type);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/TaskDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/TaskDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/TaskDAO.java
index 0b82276..02b1032 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/TaskDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/TaskDAO.java
@@ -21,7 +21,7 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.task.Task;
 
 public interface TaskDAO extends DAO<Task, Long> {

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
index 469a98f..a1e4d09 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/UserDAO.java
@@ -20,54 +20,22 @@ package org.apache.syncope.core.persistence.api.dao;
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Set;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.Role;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion;
-import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.UVirAttr;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 
-public interface UserDAO extends SubjectDAO<UPlainAttr, UDerAttr, UVirAttr> {
+public interface UserDAO extends AnyDAO<User> {
 
-    User find(Long key);
+    User authFind(String username);
 
     User find(String username);
 
-    User findByWorkflowId(String workflowId);
-
     User findByToken(String token);
 
     List<User> findBySecurityQuestion(SecurityQuestion securityQuestion);
 
-    List<User> findByDerAttrValue(String schemaName, String value);
-
-    List<User> findByAttrValue(String schemaName, UPlainAttrValue attrValue);
-
-    User findByAttrUniqueValue(String schemaName, UPlainAttrValue attrUniqueValue);
-
-    List<User> findByResource(ExternalResource resource);
-
-    List<User> findAll(Set<String> adminRealms, int page, int itemsPerPage);
-
-    List<User> findAll(Set<String> adminRealms, int page, int itemsPerPage, List<OrderByClause> orderBy);
-
-    int count(Set<String> adminRealms);
-
-    User save(User user);
-
-    void delete(Long key);
-
-    void delete(User user);
-
-    User authFetch(Long key);
-
-    User authFetch(String username);
-
     List<Role> findDynRoleMemberships(User user);
 
     List<Group> findDynGroupMemberships(User user);

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirAttrDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirAttrDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirAttrDAO.java
index 254372a..b62cb87 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirAttrDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirAttrDAO.java
@@ -21,15 +21,15 @@ package org.apache.syncope.core.persistence.api.dao;
 import java.util.List;
 import org.apache.syncope.core.persistence.api.entity.VirAttr;
 
-public interface VirAttrDAO extends DAO<VirAttr, Long> {
+public interface VirAttrDAO extends DAO<VirAttr<?>, Long> {
 
-    <T extends VirAttr> T find(Long key, Class<T> reference);
+    <T extends VirAttr<?>> T find(Long key, Class<T> reference);
 
-    <T extends VirAttr> List<T> findAll(Class<T> reference);
+    <T extends VirAttr<?>> List<T> findAll(Class<T> reference);
 
-    <T extends VirAttr> T save(T virtualAttribute);
+    <T extends VirAttr<?>> T save(T virtualAttribute);
 
-    <T extends VirAttr> void delete(Long key, Class<T> reference);
+    <T extends VirAttr<?>> void delete(Long key, Class<T> reference);
 
-    <T extends VirAttr> void delete(T virAttr);
+    <T extends VirAttr<?>> void delete(T virAttr);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
index 160f109..fc6c7fa 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/VirSchemaDAO.java
@@ -19,19 +19,18 @@
 package org.apache.syncope.core.persistence.api.dao;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.AttributableUtils;
 import org.apache.syncope.core.persistence.api.entity.VirAttr;
 import org.apache.syncope.core.persistence.api.entity.VirSchema;
 
 public interface VirSchemaDAO extends DAO<VirSchema, String> {
 
-    <T extends VirSchema> T find(String key, Class<T> reference);
+    VirSchema find(String name);
 
-    <T extends VirSchema> List<T> findAll(Class<T> reference);
+    List<VirSchema> findAll();
 
-    <T extends VirAttr> List<T> findAttrs(VirSchema virSchema, Class<T> reference);
+    <T extends VirAttr<?>> List<T> findAttrs(VirSchema virSchema, Class<T> reference);
 
-    <T extends VirSchema> T save(T virSchema);
+    VirSchema save(VirSchema derSchema);
 
-    void delete(String key, AttributableUtils attributableUtil);
+    void delete(String key);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/AnyCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/AnyCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/AnyCond.java
new file mode 100644
index 0000000..8bc9669
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/AnyCond.java
@@ -0,0 +1,35 @@
+/*
+ * 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.dao.search;
+
+/**
+ * Search condition to be applied when comparing bean field values.
+ */
+public class AnyCond extends AttributeCond {
+
+    private static final long serialVersionUID = -1880319220462653955L;
+
+    public AnyCond() {
+        super();
+    }
+
+    public AnyCond(final Type conditionType) {
+        super(conditionType);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/GroupCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/GroupCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/GroupCond.java
deleted file mode 100644
index 3dbb9b0..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/GroupCond.java
+++ /dev/null
@@ -1,39 +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.dao.search;
-
-public class GroupCond extends AbstractSearchCond {
-
-    private static final long serialVersionUID = -728155256293925989L;
-
-    private Long groupKey;
-
-    public Long getGroupKey() {
-        return groupKey;
-    }
-
-    public void setGroupKey(final Long groupKey) {
-        this.groupKey = groupKey;
-    }
-
-    @Override
-    public final boolean isValid() {
-        return groupKey != null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/MembershipCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/MembershipCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/MembershipCond.java
new file mode 100644
index 0000000..8872107
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/MembershipCond.java
@@ -0,0 +1,39 @@
+/*
+ * 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.dao.search;
+
+public class MembershipCond extends AbstractSearchCond {
+
+    private static final long serialVersionUID = -728155256293925989L;
+
+    private Long groupKey;
+
+    public Long getGroupKey() {
+        return groupKey;
+    }
+
+    public void setGroupKey(final Long groupKey) {
+        this.groupKey = groupKey;
+    }
+
+    @Override
+    public final boolean isValid() {
+        return groupKey != null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RelationshipCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RelationshipCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RelationshipCond.java
new file mode 100644
index 0000000..ec26eb8
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RelationshipCond.java
@@ -0,0 +1,39 @@
+/*
+ * 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.dao.search;
+
+public class RelationshipCond extends AbstractSearchCond {
+
+    private static final long serialVersionUID = 6865985945516722103L;
+
+    private Long anyObjectKey;
+
+    public Long getAnyObjectKey() {
+        return anyObjectKey;
+    }
+
+    public void setAnyObjectKey(final Long anyObjectKey) {
+        this.anyObjectKey = anyObjectKey;
+    }
+
+    @Override
+    public final boolean isValid() {
+        return anyObjectKey != null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SearchCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SearchCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SearchCond.java
index ab5b527..d942591 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SearchCond.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SearchCond.java
@@ -35,11 +35,13 @@ public class SearchCond extends AbstractSearchCond {
 
     private Type type;
 
-    private SubjectCond subjectCond;
+    private AnyCond anyCond;
 
     private AttributeCond attributeCond;
 
-    private GroupCond groupCond;
+    private RelationshipCond relationshipCond;
+
+    private MembershipCond membershipCond;
 
     private RoleCond roleCond;
 
@@ -53,8 +55,8 @@ public class SearchCond extends AbstractSearchCond {
         SearchCond nodeCond = new SearchCond();
 
         nodeCond.type = Type.LEAF;
-        if (attributeCond instanceof SubjectCond) {
-            nodeCond.subjectCond = (SubjectCond) attributeCond;
+        if (attributeCond instanceof AnyCond) {
+            nodeCond.anyCond = (AnyCond) attributeCond;
         } else {
             nodeCond.attributeCond = attributeCond;
         }
@@ -62,11 +64,20 @@ public class SearchCond extends AbstractSearchCond {
         return nodeCond;
     }
 
-    public static SearchCond getLeafCond(final GroupCond groupCond) {
+    public static SearchCond getLeafCond(final RelationshipCond relationshipCond) {
+        SearchCond nodeCond = new SearchCond();
+
+        nodeCond.type = Type.LEAF;
+        nodeCond.relationshipCond = relationshipCond;
+
+        return nodeCond;
+    }
+
+    public static SearchCond getLeafCond(final MembershipCond membershipCond) {
         SearchCond nodeCond = new SearchCond();
 
         nodeCond.type = Type.LEAF;
-        nodeCond.groupCond = groupCond;
+        nodeCond.membershipCond = membershipCond;
 
         return nodeCond;
     }
@@ -95,8 +106,14 @@ public class SearchCond extends AbstractSearchCond {
         return nodeCond;
     }
 
-    public static SearchCond getNotLeafCond(final GroupCond groupCond) {
-        SearchCond nodeCond = getLeafCond(groupCond);
+    public static SearchCond getNotLeafCond(final RelationshipCond relationshipCond) {
+        SearchCond nodeCond = getLeafCond(relationshipCond);
+        nodeCond.type = Type.NOT_LEAF;
+        return nodeCond;
+    }
+
+    public static SearchCond getNotLeafCond(final MembershipCond membershipCond) {
+        SearchCond nodeCond = getLeafCond(membershipCond);
         nodeCond.type = Type.NOT_LEAF;
         return nodeCond;
     }
@@ -156,12 +173,12 @@ public class SearchCond extends AbstractSearchCond {
         }
     }
 
-    public SubjectCond getSubjectCond() {
-        return subjectCond;
+    public AnyCond getAnyCond() {
+        return anyCond;
     }
 
-    public void setSubjectCond(final SubjectCond subjectCond) {
-        this.subjectCond = subjectCond;
+    public void setAnyCond(final AnyCond anyCond) {
+        this.anyCond = anyCond;
     }
 
     public AttributeCond getAttributeCond() {
@@ -172,12 +189,20 @@ public class SearchCond extends AbstractSearchCond {
         this.attributeCond = attributeCond;
     }
 
-    public GroupCond getGroupCond() {
-        return groupCond;
+    public RelationshipCond getRelationshipCond() {
+        return relationshipCond;
+    }
+
+    public void setRelationshipCond(final RelationshipCond relationshipCond) {
+        this.relationshipCond = relationshipCond;
+    }
+
+    public MembershipCond getMembershipCond() {
+        return membershipCond;
     }
 
-    public void setGroupCond(final GroupCond groupCond) {
-        this.groupCond = groupCond;
+    public void setMembershipCond(final MembershipCond membershipCond) {
+        this.membershipCond = membershipCond;
     }
 
     public RoleCond getRoleCond() {
@@ -231,11 +256,12 @@ public class SearchCond extends AbstractSearchCond {
         switch (type) {
             case LEAF:
             case NOT_LEAF:
-                isValid = (subjectCond != null || attributeCond != null
-                        || groupCond != null || roleCond != null || resourceCond != null)
-                        && (subjectCond == null || subjectCond.isValid())
+                isValid = (anyCond != null || attributeCond != null
+                        || relationshipCond != null || membershipCond != null
+                        || roleCond != null || resourceCond != null)
+                        && (anyCond == null || anyCond.isValid())
                         && (attributeCond == null || attributeCond.isValid())
-                        && (groupCond == null || groupCond.isValid())
+                        && (membershipCond == null || membershipCond.isValid())
                         && (roleCond == null || roleCond.isValid())
                         && (resourceCond == null || resourceCond.isValid());
                 break;

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SubjectCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SubjectCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SubjectCond.java
deleted file mode 100644
index 48e762f..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/SubjectCond.java
+++ /dev/null
@@ -1,35 +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.dao.search;
-
-/**
- * Search condition to be applied when comparing bean field values.
- */
-public class SubjectCond extends AttributeCond {
-
-    private static final long serialVersionUID = -1880319220462653955L;
-
-    public SubjectCond() {
-        super();
-    }
-
-    public SubjectCond(final Type conditionType) {
-        super(conditionType);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AccountPolicy.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AccountPolicy.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AccountPolicy.java
index e09aa2e..7a743c2 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AccountPolicy.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AccountPolicy.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.persistence.api.entity;
 
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import java.util.Set;
 
 public interface AccountPolicy extends Policy {

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
new file mode 100644
index 0000000..12bf9b6
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Any.java
@@ -0,0 +1,80 @@
+/*
+ * 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;
+
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import java.util.List;
+
+public interface Any<P extends PlainAttr<?>, D extends DerAttr<?>, V extends VirAttr<?>> extends AnnotatedEntity<Long> {
+
+    AnyType getType();
+
+    void setType(AnyType type);
+
+    Realm getRealm();
+
+    void setRealm(Realm realm);
+
+    String getStatus();
+
+    void setStatus(String status);
+
+    String getWorkflowId();
+
+    void setWorkflowId(String workflowId);
+
+    boolean add(P attr);
+
+    boolean remove(P attr);
+
+    P getPlainAttr(String plainSchemaName);
+
+    List<? extends P> getPlainAttrs();
+
+    boolean add(D derAttr);
+
+    boolean remove(D derAttr);
+
+    D getDerAttr(String derSchemaName);
+
+    List<? extends D> getDerAttrs();
+
+    boolean add(V virAttr);
+
+    boolean remove(V virAttr);
+
+    V getVirAttr(String virSchemaName);
+
+    List<? extends V> getVirAttrs();
+
+    boolean add(ExternalResource resource);
+
+    boolean remove(ExternalResource resource);
+
+    List<String> getResourceNames();
+
+    List<? extends ExternalResource> getResources();
+
+    boolean add(AnyTypeClass auxClass);
+
+    boolean remove(AnyTypeClass auxClass);
+
+    List<? extends AnyTypeClass> getAuxClasses();
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyAbout.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyAbout.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyAbout.java
new file mode 100644
index 0000000..2f1684b
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyAbout.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+public interface AnyAbout extends Entity<Long> {
+
+    Notification getNotification();
+
+    void setNotification(Notification notification);
+
+    AnyType getAnyType();
+
+    void setAnyType(AnyType anyType);
+
+    String get();
+
+    void set(String filter);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyType.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyType.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyType.java
new file mode 100644
index 0000000..c23897c
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyType.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;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+
+public interface AnyType extends Entity<String> {
+
+    void setKey(String key);
+
+    AnyTypeKind getKind();
+
+    void setKind(AnyTypeKind kind);
+
+    boolean add(AnyTypeClass anyTypeClass);
+
+    boolean remove(AnyTypeClass anyTypeClass);
+
+    List<? extends AnyTypeClass> getClasses();
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
new file mode 100644
index 0000000..fdd00bb
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.List;
+
+public interface AnyTypeClass extends Entity<String> {
+
+    void setKey(String key);
+
+    boolean add(PlainSchema schema);
+
+    boolean remove(PlainSchema schema);
+
+    List<? extends PlainSchema> getPlainSchemas();
+
+    boolean add(DerSchema schema);
+
+    boolean remove(DerSchema schema);
+
+    List<? extends DerSchema> getDerSchemas();
+
+    boolean add(VirSchema schema);
+
+    boolean remove(VirSchema schema);
+
+    List<? extends VirSchema> getVirSchemas();
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
new file mode 100644
index 0000000..836f0e3
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtils.java
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
+import java.util.List;
+import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.MappingPurpose;
+import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+
+public interface AnyUtils {
+
+    AnyTypeKind getAnyTypeKind();
+
+    <T extends Any<?, ?, ?>> Class<T> anyClass();
+
+    <T extends PlainAttr<?>> Class<T> plainAttrClass();
+
+    <T extends PlainAttr<?>> T newPlainAttr();
+
+    <T extends PlainAttrValue> Class<T> plainAttrValueClass();
+
+    <T extends PlainAttrValue> T newPlainAttrValue();
+
+    <T extends PlainAttrValue> Class<T> plainAttrUniqueValueClass();
+
+    <T extends PlainAttrValue> T newPlainAttrUniqueValue();
+
+    <T extends DerAttr<?>> Class<T> derAttrClass();
+
+    <T extends DerAttr<?>> T newDerAttr();
+
+    <T extends VirAttr<?>> Class<T> virAttrClass();
+
+    <T extends VirAttr<?>> T newVirAttr();
+
+    MappingItem getConnObjectKeyItem(Provision provision);
+
+    String getConnObjectLink(Provision provision);
+
+    List<MappingItem> getMappingItems(Provision provision, MappingPurpose purpose);
+
+    IntMappingType plainIntMappingType();
+
+    IntMappingType derIntMappingType();
+
+    IntMappingType virIntMappingType();
+
+    <T extends AnyTO> T newAnyTO();
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
new file mode 100644
index 0000000..2e2a49e
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyUtilsFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+
+public interface AnyUtilsFactory {
+
+    AnyUtils getInstance(AnyTypeKind anyTypeKind);
+
+    AnyUtils getInstance(String anyTypeKind);
+
+    AnyUtils getInstance(Any<?, ?, ?> any);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
index 144962e..2be01e9 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attr.java
@@ -18,11 +18,11 @@
  */
 package org.apache.syncope.core.persistence.api.entity;
 
-public interface Attr<S extends Schema> extends Entity<Long> {
+public interface Attr<S extends Schema, O extends Any<?, ?, ?>> extends Entity<Long> {
 
-    Attributable<?, ?, ?> getOwner();
+    O getOwner();
 
-    void setOwner(Attributable<?, ?, ?> owner);
+    void setOwner(O owner);
 
     S getSchema();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttrTemplate.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttrTemplate.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttrTemplate.java
deleted file mode 100644
index 6aaf916..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttrTemplate.java
+++ /dev/null
@@ -1,32 +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;
-
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-
-public interface AttrTemplate<S extends Schema> extends Entity<Long> {
-
-    Group getOwner();
-
-    void setOwner(Group group);
-
-    S getSchema();
-
-    void setSchema(S schema);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attributable.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attributable.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attributable.java
deleted file mode 100644
index e89181c..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Attributable.java
+++ /dev/null
@@ -1,48 +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;
-
-import java.util.List;
-
-public interface Attributable<P extends PlainAttr, D extends DerAttr, V extends VirAttr> extends AnnotatedEntity<Long> {
-
-    boolean addPlainAttr(P attr);
-
-    boolean addDerAttr(D derAttr);
-
-    boolean addVirAttr(V virAttr);
-
-    boolean removePlainAttr(P attr);
-
-    boolean removeDerAttr(D derAttr);
-
-    boolean removeVirAttr(V virAttr);
-
-    P getPlainAttr(String plainSchemaName);
-
-    List<? extends P> getPlainAttrs();
-
-    D getDerAttr(String derSchemaName);
-
-    List<? extends D> getDerAttrs();
-
-    V getVirAttr(String virSchemaName);
-
-    List<? extends V> getVirAttrs();
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtils.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtils.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtils.java
deleted file mode 100644
index 9539604..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtils.java
+++ /dev/null
@@ -1,89 +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;
-
-import java.util.List;
-import org.apache.syncope.common.lib.to.AbstractAttributableTO;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
-import org.apache.syncope.common.lib.types.AttributableType;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-
-public interface AttributableUtils {
-
-    AttributableType getType();
-
-    <T extends Attributable<?, ?, ?>> Class<T> attributableClass();
-
-    <T extends PlainSchema> Class<T> plainSchemaClass();
-
-    <T extends PlainSchema> T newPlainSchema();
-
-    <T extends PlainAttr> Class<T> plainAttrClass();
-
-    <T extends PlainAttr> T newPlainAttr();
-
-    <T extends PlainAttrValue> Class<T> plainAttrValueClass();
-
-    <T extends PlainAttrValue> T newPlainAttrValue();
-
-    <T extends AttrTemplate<PlainSchema>> Class<T> plainAttrTemplateClass();
-
-    <T extends PlainAttrValue> Class<T> plainAttrUniqueValueClass();
-
-    <T extends PlainAttrValue> T newPlainAttrUniqueValue();
-
-    <T extends DerSchema> Class<T> derSchemaClass();
-
-    <T extends DerSchema> T newDerSchema();
-
-    <T extends DerAttr> Class<T> derAttrClass();
-
-    <T extends DerAttr> T newDerAttr();
-
-    <T extends AttrTemplate<DerSchema>> Class<T> derAttrTemplateClass();
-
-    <T extends VirSchema> Class<T> virSchemaClass();
-
-    <T extends VirSchema> T newVirSchema();
-
-    <T extends VirAttr> Class<T> virAttrClass();
-
-    <T extends VirAttr> T newVirAttr();
-
-    <T extends AttrTemplate<VirSchema>> Class<T> virAttrTemplateClass();
-
-    <T extends MappingItem> T getAccountIdItem(ExternalResource resource);
-
-    String getAccountLink(ExternalResource resource);
-
-    <T extends MappingItem> List<T> getMappingItems(ExternalResource resource, MappingPurpose purpose);
-
-    IntMappingType plainIntMappingType();
-
-    IntMappingType derIntMappingType();
-
-    IntMappingType virIntMappingType();
-
-    <T extends MappingItem> Class<T> mappingItemClass();
-
-    <T extends AbstractAttributableTO> T newAttributableTO();
-
-    <T extends AbstractSubjectTO> T newSubjectTO();
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtilsFactory.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtilsFactory.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtilsFactory.java
deleted file mode 100644
index 4b5e363..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AttributableUtilsFactory.java
+++ /dev/null
@@ -1,33 +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;
-
-import org.apache.syncope.common.lib.types.AttributableType;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-
-public interface AttributableUtilsFactory {
-
-    AttributableUtils getInstance(AttributableType type);
-
-    AttributableUtils getInstance(String attributableType);
-
-    AttributableUtils getInstance(ObjectClass objectClass);
-
-    AttributableUtils getInstance(Attributable<?, ?, ?> attributable);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstance.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstance.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstance.java
index 88e8b00..eb665ea 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstance.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ConnInstance.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.persistence.api.entity;
 
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import java.util.List;
 import java.util.Set;
 import org.apache.syncope.common.lib.types.ConnConfProperty;

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
index 3857f9e..9eb3b7a 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DerAttr.java
@@ -20,7 +20,7 @@ package org.apache.syncope.core.persistence.api.entity;
 
 import java.util.Collection;
 
-public interface DerAttr extends Attr<DerSchema> {
+public interface DerAttr<O extends Any<?, ?, ?>> extends Attr<DerSchema, O> {
 
-    String getValue(Collection<? extends PlainAttr> attrs);
+    String getValue(Collection<? extends PlainAttr<?>> attrs);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
index 8770e35..b01fe70 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynGroupMembership.java
@@ -20,9 +20,9 @@ package org.apache.syncope.core.persistence.api.entity;
 
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 
-public interface DynGroupMembership extends DynMembership {
+public interface DynGroupMembership<A extends Any<?, ?, ?>> extends DynMembership<A> {
 
     Group getGroup();
 
-    void setGroup(Group role);
+    void setGroup(Group group);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
index 2fbecc3..ba0a62f 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynMembership.java
@@ -19,17 +19,16 @@
 package org.apache.syncope.core.persistence.api.entity;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.user.User;
 
-public interface DynMembership extends Entity<Long> {
+public interface DynMembership<A extends Any<?, ?, ?>> extends Entity<Long> {
 
     String getFIQLCond();
 
     void setFIQLCond(String fiql);
 
-    boolean addUser(User user);
+    boolean add(A any);
 
-    boolean removeUser(User user);
+    boolean remove(A any);
 
-    List<? extends User> getUsers();
+    List<? extends A> getMembers();
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynRoleMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynRoleMembership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynRoleMembership.java
deleted file mode 100644
index 5321434..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/DynRoleMembership.java
+++ /dev/null
@@ -1,26 +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;
-
-public interface DynRoleMembership extends DynMembership {
-
-    Role getRole();
-
-    void setRole(Role role);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ExternalResource.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ExternalResource.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ExternalResource.java
deleted file mode 100644
index c221f41..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/ExternalResource.java
+++ /dev/null
@@ -1,111 +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;
-
-import org.apache.syncope.core.persistence.api.entity.user.UMapping;
-import org.apache.syncope.core.persistence.api.entity.group.GMapping;
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.common.lib.types.PropagationMode;
-import org.apache.syncope.common.lib.types.TraceLevel;
-import org.identityconnectors.framework.common.objects.SyncToken;
-
-public interface ExternalResource extends AnnotatedEntity<String> {
-
-    AccountPolicy getAccountPolicy();
-
-    PasswordPolicy getPasswordPolicy();
-
-    SyncPolicy getSyncPolicy();
-
-    Set<ConnConfProperty> getConnInstanceConfiguration();
-
-    ConnInstance getConnector();
-
-    TraceLevel getCreateTraceLevel();
-
-    TraceLevel getUpdateTraceLevel();
-
-    TraceLevel getDeleteTraceLevel();
-
-    TraceLevel getSyncTraceLevel();
-
-    List<String> getPropagationActionsClassNames();
-
-    PropagationMode getPropagationMode();
-
-    Integer getPropagationPriority();
-
-    UMapping getUmapping();
-
-    GMapping getGmapping();
-
-    SyncToken getUsyncToken();
-
-    String getSerializedUSyncToken();
-
-    SyncToken getRsyncToken();
-
-    String getSerializedRSyncToken();
-
-    boolean isEnforceMandatoryCondition();
-
-    boolean isPropagationPrimary();
-
-    boolean isRandomPwdIfNotProvided();
-
-    void setKey(String name);
-
-    void setAccountPolicy(AccountPolicy accountPolicy);
-
-    void setPasswordPolicy(PasswordPolicy passwordPolicy);
-
-    void setSyncPolicy(SyncPolicy syncPolicy);
-
-    void setConnInstanceConfiguration(Set<ConnConfProperty> properties);
-
-    void setConnector(ConnInstance connector);
-
-    void setCreateTraceLevel(TraceLevel createTraceLevel);
-
-    void setUpdateTraceLevel(TraceLevel updateTraceLevel);
-
-    void setDeleteTraceLevel(TraceLevel deleteTraceLevel);
-
-    void setSyncTraceLevel(TraceLevel syncTraceLevel);
-
-    void setPropagationMode(PropagationMode propagationMode);
-
-    void setPropagationPriority(Integer priority);
-
-    void setUmapping(UMapping umapping);
-
-    void setGmapping(GMapping gmapping);
-
-    void setEnforceMandatoryCondition(boolean enforce);
-
-    void setPropagationPrimary(boolean condition);
-
-    void setRandomPwdIfNotProvided(boolean condition);
-
-    void setUsyncToken(SyncToken syncToken);
-
-    void setRsyncToken(SyncToken syncToken);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Mapping.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Mapping.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Mapping.java
deleted file mode 100644
index fb491fa..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Mapping.java
+++ /dev/null
@@ -1,42 +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;
-
-import java.util.List;
-
-public interface Mapping<T extends MappingItem> extends Entity<Long> {
-
-    T getAccountIdItem();
-
-    String getAccountLink();
-
-    List<? extends T> getItems();
-
-    ExternalResource getResource();
-
-    boolean addItem(T item);
-
-    boolean removeItem(T item);
-
-    void setAccountIdItem(T item);
-
-    void setAccountLink(String accountLink);
-
-    void setResource(ExternalResource resource);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/MappingItem.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/MappingItem.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/MappingItem.java
deleted file mode 100644
index ec6919e..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/MappingItem.java
+++ /dev/null
@@ -1,57 +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;
-
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-
-public interface MappingItem extends Entity<Long> {
-
-    String getExtAttrName();
-
-    String getIntAttrName();
-
-    IntMappingType getIntMappingType();
-
-    String getMandatoryCondition();
-
-    Mapping<?> getMapping();
-
-    MappingPurpose getPurpose();
-
-    boolean isAccountid();
-
-    boolean isPassword();
-
-    void setAccountid(boolean accountid);
-
-    void setExtAttrName(String extAttrName);
-
-    void setIntAttrName(String intAttrName);
-
-    void setIntMappingType(IntMappingType intMappingType);
-
-    void setMandatoryCondition(String condition);
-
-    void setMapping(Mapping<?> mapping);
-
-    void setPassword(boolean password);
-
-    void setPurpose(MappingPurpose purpose);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
new file mode 100644
index 0000000..8c040ab
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Membership.java
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+import org.apache.syncope.core.persistence.api.entity.group.Group;
+
+public interface Membership<L extends Any<?, ?, ?>> extends Relationship<L, Group> {
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Notification.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Notification.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Notification.java
index e505f24..dbf8552 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Notification.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Notification.java
@@ -26,49 +26,50 @@ public interface Notification extends Entity<Long> {
 
     List<String> getEvents();
 
-    String getRecipientAttrName();
-
-    IntMappingType getRecipientAttrType();
-
-    String getRecipients();
-
-    String getGroupAbout();
+    boolean isSelfAsRecipient();
 
-    String getSender();
+    void setSelfAsRecipient(boolean selfAsRecipient);
 
     List<String> getStaticRecipients();
 
-    String getSubject();
-
-    String getTemplate();
+    String getRecipientAttrName();
 
-    TraceLevel getTraceLevel();
+    void setRecipientAttrName(String recipientAttrName);
 
-    String getUserAbout();
+    IntMappingType getRecipientAttrType();
 
-    boolean isActive();
+    void setRecipientAttrType(IntMappingType recipientAttrType);
 
-    boolean isSelfAsRecipient();
+    String getRecipients();
 
-    void setActive(boolean active);
+    void setRecipients(String recipients);
 
-    void setRecipientAttrName(String recipientAttrName);
+    boolean add(AnyAbout about);
 
-    void setRecipientAttrType(IntMappingType recipientAttrType);
+    boolean remove(AnyAbout about);
 
-    void setRecipients(String recipients);
+    AnyAbout getAbout(AnyType anyType);
 
-    void setGroupAbout(String groupAbout);
+    List<? extends AnyAbout> getAbouts();
 
-    void setSelfAsRecipient(boolean selfAsRecipient);
+    String getSender();
 
     void setSender(String sender);
 
+    String getSubject();
+
     void setSubject(String subject);
 
+    String getTemplate();
+
     void setTemplate(String template);
 
+    TraceLevel getTraceLevel();
+
     void setTraceLevel(TraceLevel traceLevel);
 
-    void setUserAbout(String userAbout);
+    boolean isActive();
+
+    void setActive(boolean active);
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
index 8474778..b149851 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttr.java
@@ -20,17 +20,20 @@ package org.apache.syncope.core.persistence.api.entity;
 
 import java.util.List;
 
-public interface PlainAttr extends Attr<PlainSchema> {
+public interface PlainAttr<O extends Any<?, ?, ?>> extends Attr<PlainSchema, O> {
 
-    void addValue(String value, AttributableUtils attributableUtil);
+    void add(String value, AnyUtils anyUtils);
 
-    boolean removeValue(PlainAttrValue attrValue);
+    void add(String value, PlainAttrValue attrValue);
+
+    boolean remove(PlainAttrValue attrValue);
 
     PlainAttrUniqueValue getUniqueValue();
 
+    void setUniqueValue(PlainAttrUniqueValue uniqueValue);
+
     List<? extends PlainAttrValue> getValues();
 
     List<String> getValuesAsStrings();
 
-    void setUniqueValue(PlainAttrUniqueValue uniqueValue);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttrValue.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttrValue.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttrValue.java
index 7735d4c..e1f43b6 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttrValue.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/PlainAttrValue.java
@@ -23,7 +23,7 @@ import org.apache.syncope.common.lib.types.AttrSchemaType;
 
 public interface PlainAttrValue extends Entity<Long> {
 
-    PlainAttr getAttr();
+    PlainAttr<?> getAttr();
 
     byte[] getBinaryValue();
 
@@ -45,7 +45,7 @@ public interface PlainAttrValue extends Entity<Long> {
 
     void parseValue(PlainSchema schema, String value);
 
-    void setAttr(PlainAttr attr);
+    void setAttr(PlainAttr<?> attr);
 
     void setBinaryValue(byte[] binaryValue);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
new file mode 100644
index 0000000..df4d7ff
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Relationship.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public interface Relationship<L extends Any<?, ?, ?>, R extends Any<?, ?, ?>> extends Entity<Long> {
+
+    L getLeftEnd();
+
+    void setLeftEnd(L leftEnd);
+
+    R getRightEnd();
+
+    void setRightEnd(R rightEnd);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
index 5a9fe86..432efb1 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.persistence.api.entity;
 
+import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
 import java.util.List;
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Subject.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Subject.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Subject.java
deleted file mode 100644
index 11f0c81..0000000
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Subject.java
+++ /dev/null
@@ -1,36 +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;
-
-import java.util.Set;
-
-public interface Subject<N extends PlainAttr, D extends DerAttr, V extends VirAttr> extends Attributable<N, D, V> {
-
-    Realm getRealm();
-
-    void setRealm(Realm realm);
-
-    boolean addResource(ExternalResource resource);
-
-    boolean removeResource(ExternalResource resource);
-
-    Set<String> getResourceNames();
-
-    Set<? extends ExternalResource> getResources();
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/VirAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/VirAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/VirAttr.java
index 9df47cd..7761d93 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/VirAttr.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/VirAttr.java
@@ -20,11 +20,11 @@ package org.apache.syncope.core.persistence.api.entity;
 
 import java.util.List;
 
-public interface VirAttr extends Attr<VirSchema> {
+public interface VirAttr<O extends Any<?, ?, ?>> extends Attr<VirSchema, O> {
 
     List<String> getValues();
 
-    boolean addValue(String value);
+    boolean add(String value);
 
-    boolean removeValue(String value);
+    boolean remove(String value);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
new file mode 100644
index 0000000..ca5854a
--- /dev/null
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/anyobject/ADerAttr.java
@@ -0,0 +1,24 @@
+/*
+ * 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.anyobject;
+
+import org.apache.syncope.core.persistence.api.entity.DerAttr;
+
+public interface ADerAttr extends DerAttr<AnyObject> {
+}