← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16426: null out setter/getter according to node isReadable, isWritable flag

 

------------------------------------------------------------
revno: 16426
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-08-16 22:11:14 +0700
message:
  null out setter/getter according to node isReadable, isWritable flag
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldSimpleNodePropertyIntrospectorServiceTest.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/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-08-16 14:30:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2014-08-16 15:11:14 +0000
@@ -215,6 +215,11 @@
         return getterMethod;
     }
 
+    public void setGetterMethod( Method getterMethod )
+    {
+        this.getterMethod = getterMethod;
+    }
+
     public Method getSetterMethod()
     {
         return setterMethod;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java	2014-08-16 14:30:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java	2014-08-16 15:11:14 +0000
@@ -119,6 +119,16 @@
                 property.setWritable( nodeSimple.isWritable() );
                 property.setReadable( nodeSimple.isReadable() );
 
+                if ( !nodeSimple.isWritable() )
+                {
+                    property.setSetterMethod( null );
+                }
+
+                if ( !nodeSimple.isReadable() )
+                {
+                    property.setGetterMethod( null );
+                }
+
                 if ( !StringUtils.isEmpty( nodeSimple.value() ) )
                 {
                     property.setName( nodeSimple.value() );
@@ -132,6 +142,16 @@
                 property.setWritable( nodeComplex.isWritable() );
                 property.setReadable( nodeComplex.isReadable() );
 
+                if ( !nodeComplex.isWritable() )
+                {
+                    property.setSetterMethod( null );
+                }
+
+                if ( !nodeComplex.isReadable() )
+                {
+                    property.setGetterMethod( null );
+                }
+
                 if ( !StringUtils.isEmpty( nodeComplex.value() ) )
                 {
                     property.setName( nodeComplex.value() );
@@ -144,6 +164,16 @@
                 property.setWritable( nodeCollection.isWritable() );
                 property.setReadable( nodeCollection.isReadable() );
 
+                if ( !nodeCollection.isWritable() )
+                {
+                    property.setSetterMethod( null );
+                }
+
+                if ( !nodeCollection.isReadable() )
+                {
+                    property.setGetterMethod( null );
+                }
+
                 if ( !StringUtils.isEmpty( nodeCollection.value() ) )
                 {
                     property.setCollectionName( nodeCollection.value() );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldSimpleNodePropertyIntrospectorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldSimpleNodePropertyIntrospectorServiceTest.java	2014-08-16 15:06:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldSimpleNodePropertyIntrospectorServiceTest.java	2014-08-16 15:11:14 +0000
@@ -56,14 +56,14 @@
     @NodeSimple( namespace = "http://ns.example.org"; )
     private String propertyWithNamespace;
 
-    public void setWriteOnly( boolean writeOnly )
+    public void setSimpleProperty( String simpleProperty )
     {
-
+        this.simpleProperty = simpleProperty;
     }
 
-    public boolean isWriteOnly()
+    public String getSimpleProperty()
     {
-        return writeOnly;
+        return simpleProperty;
     }
 }
 
@@ -112,6 +112,9 @@
 
         assertFalse( propertyMap.get( "writeOnly" ).isReadable() );
         assertTrue( propertyMap.get( "writeOnly" ).isWritable() );
+
+        assertNull( propertyMap.get( "readOnly" ).getSetterMethod() );
+        assertNull( propertyMap.get( "writeOnly" ).getGetterMethod() );
     }
 
     @Test
@@ -130,14 +133,14 @@
     @Test
     public void testGetter()
     {
-        assertNull( propertyMap.get( "simpleProperty" ).getGetterMethod() );
-        assertNotNull( propertyMap.get( "writeOnly" ).getGetterMethod() );
+        assertNotNull( propertyMap.get( "simpleProperty" ).getGetterMethod() );
+        assertNull( propertyMap.get( "renamedProperty" ).getGetterMethod() );
     }
 
     @Test
     public void testSetter()
     {
-        assertNull( propertyMap.get( "simpleProperty" ).getSetterMethod() );
-        assertNotNull( propertyMap.get( "writeOnly" ).getGetterMethod() );
+        assertNotNull( propertyMap.get( "simpleProperty" ).getSetterMethod() );
+        assertNull( propertyMap.get( "renamedProperty" ).getSetterMethod() );
     }
 }