← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20276: adds new property on Schema: references, a list of all types that this Schema references, can be ...

 

------------------------------------------------------------
revno: 20276
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-22 10:42:40 +0700
message:
  adds new property on Schema: references, a list of all types that this Schema references, can be used to know which classes to preload for preheating etc.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-09-21 04:59:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2015-09-22 03:42:40 +0000
@@ -48,6 +48,8 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -442,6 +444,16 @@
         this.propertyMap = propertyMap;
     }
 
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "references", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "reference", namespace = DxfNamespaces.DXF_2_0 )
+    public Set<Class> getReferences()
+    {
+        return getProperties().stream()
+            .filter( p -> p.isCollection() ? PropertyType.REFERENCE == p.getItemPropertyType() : PropertyType.REFERENCE == p.getPropertyType() )
+            .map( p -> p.isCollection() ? p.getItemKlass() : p.getKlass() ).collect( Collectors.toSet() );
+    }
+
     public Map<String, Property> getPersistedProperties()
     {
         if ( persistedProperties == null )