syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [10/10] syncope git commit: [SYNCOPE-709] Adding linking mapping items in ResourceTO, for info
Date Thu, 22 Oct 2015 12:27:04 GMT
[SYNCOPE-709] Adding linking mapping items in ResourceTO, for info


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

Branch: refs/heads/master
Commit: 55fdc58c959fae949cf660d008b9c670f97e37ae
Parents: fa5e65a
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Thu Oct 22 14:26:29 2015 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Thu Oct 22 14:26:29 2015 +0200

----------------------------------------------------------------------
 .../org/apache/syncope/common/lib/to/MappingTO.java     |  9 +++++++++
 .../org/apache/syncope/common/lib/to/ProvisionTO.java   |  2 +-
 .../provisioning/java/data/ResourceDataBinderImpl.java  | 12 ++++++++----
 .../syncope/fit/core/reference/ResourceITCase.java      |  9 +++++++--
 4 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/55fdc58c/common/lib/src/main/java/org/apache/syncope/common/lib/to/MappingTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/MappingTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/MappingTO.java
index c573278..73c0523 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/MappingTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/MappingTO.java
@@ -40,6 +40,8 @@ public class MappingTO extends AbstractBaseBean {
 
     private final List<MappingItemTO> items = new ArrayList<>();
 
+    private final List<MappingItemTO> linkingItems = new ArrayList<>();
+
     public String getConnObjectLink() {
         return connObjectLink;
     }
@@ -96,4 +98,11 @@ public class MappingTO extends AbstractBaseBean {
     public boolean remove(final MappingItemTO item) {
         return this.items.remove(item);
     }
+
+    @XmlElementWrapper(name = "linkingItems")
+    @XmlElement(name = "item")
+    @JsonProperty("linkingItems")
+    public List<MappingItemTO> getLinkingItems() {
+        return linkingItems;
+    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/55fdc58c/common/lib/src/main/java/org/apache/syncope/common/lib/to/ProvisionTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ProvisionTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ProvisionTO.java
index b25053d..da23a59 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/ProvisionTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/ProvisionTO.java
@@ -43,7 +43,7 @@ public class ProvisionTO extends AbstractBaseBean {
 
     private MappingTO mapping;
 
-    private List<String> virSchemas = new ArrayList<>();
+    private final List<String> virSchemas = new ArrayList<>();
 
     public long getKey() {
         return key;

http://git-wip-us.apache.org/repos/asf/syncope/blob/55fdc58c/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
index d04dfd3..388f099 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
@@ -299,10 +299,6 @@ public class ResourceDataBinderImpl implements ResourceDataBinder {
 
     @Override
     public ResourceTO getResourceTO(final ExternalResource resource) {
-        if (resource == null) {
-            return null;
-        }
-
         ResourceTO resourceTO = new ResourceTO();
 
         // set sys info
@@ -336,6 +332,14 @@ public class ResourceDataBinderImpl implements ResourceDataBinder {
 
             for (VirSchema virSchema : virSchemaDAO.findByProvision(provision)) {
                 provisionTO.getVirSchemas().add(virSchema.getKey());
+
+                MappingItem linkingMappingItem = virSchema.asLinkingMappingItem();
+
+                MappingItemTO itemTO = new MappingItemTO();
+                itemTO.setKey(linkingMappingItem.getKey());
+                BeanUtils.copyProperties(linkingMappingItem, itemTO, MAPPINGITEM_IGNORE_PROPERTIES);
+
+                provisionTO.getMapping().getLinkingItems().add(itemTO);
             }
 
             resourceTO.getProvisions().add(provisionTO);

http://git-wip-us.apache.org/repos/asf/syncope/blob/55fdc58c/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
index 07433b7..e0539c8 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
@@ -453,8 +453,13 @@ public class ResourceITCase extends AbstractITCase {
 
     @Test
     public void read() {
-        ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
-        assertNotNull(actual);
+        ResourceTO resource = resourceService.read(RESOURCE_NAME_DBVIRATTR);
+        assertNotNull(resource);
+        
+        ProvisionTO provision = resource.getProvision(AnyTypeKind.USER.name());
+        assertNotNull(provision);
+        assertFalse(provision.getMapping().getItems().isEmpty());
+        assertFalse(provision.getMapping().getLinkingItems().isEmpty());
     }
 
     @Test


Mime
View raw message