← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15522: expose propertyMap on Schema

 

------------------------------------------------------------
revno: 15522
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-02 23:00:27 +0200
message:
  expose propertyMap on Schema
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.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	2014-05-28 11:24:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java	2014-06-02 21:00:27 +0000
@@ -45,7 +45,7 @@
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-@JacksonXmlRootElement( localName = "schema", namespace = DxfNamespaces.DXF_2_0 )
+@JacksonXmlRootElement(localName = "schema", namespace = DxfNamespaces.DXF_2_0)
 public class Schema implements Ordered
 {
     /**
@@ -103,6 +103,14 @@
     private List<Property> properties = Lists.newArrayList();
 
     /**
+     * Map of all exposed properties on this class, where key is property
+     * name, and value is instance of Property class.
+     *
+     * @see org.hisp.dhis.schema.Property
+     */
+    private Map<String, Property> propertyMap = Maps.newHashMap();
+
+    /**
      * Used for sorting of schema list when doing metadata import/export.
      */
     private int order = Ordered.LOWEST_PRECEDENCE;
@@ -130,14 +138,14 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isIdentifiableObject()
     {
         return identifiableObject;
     }
 
     @JsonProperty
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
     public boolean isNameableObject()
     {
         return nameableObject;
@@ -226,12 +234,17 @@
     @JacksonXmlProperty( localName = "property", namespace = DxfNamespaces.DXF_2_0 )
     public List<Property> getProperties()
     {
-        return properties;
-    }
-
-    public void setProperties( List<Property> properties )
-    {
-        this.properties = properties;
+        return Lists.newArrayList( propertyMap.values() );
+    }
+
+    public Map<String, Property> getPropertyMap()
+    {
+        return propertyMap;
+    }
+
+    public void setPropertyMap( Map<String, Property> propertyMap )
+    {
+        this.propertyMap = propertyMap;
     }
 
     private Map<AuthorityType, List<String>> authorityMap = Maps.newHashMap();
@@ -279,7 +292,7 @@
             ", plural='" + plural + '\'' +
             ", shareable=" + shareable +
             ", authorities=" + authorities +
-            ", properties=" + properties +
+            ", propertyMap=" + propertyMap +
             '}';
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2014-05-31 16:27:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java	2014-06-02 21:00:27 +0000
@@ -64,7 +64,7 @@
 
             if ( schema.getProperties().isEmpty() )
             {
-                schema.setProperties( propertyIntrospectorService.getProperties( schema.getKlass() ) );
+                schema.setPropertyMap( propertyIntrospectorService.getPropertiesMap( schema.getKlass() ) );
             }
 
             classSchemaMap.put( schema.getKlass(), schema );
@@ -109,7 +109,7 @@
         }
 
         schema = new Schema( klass, klass.getName(), klass.getName() );
-        schema.setProperties( propertyIntrospectorService.getProperties( schema.getKlass() ) );
+        schema.setPropertyMap( propertyIntrospectorService.getPropertiesMap( schema.getKlass() ) );
 
         return schema;
     }