← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9294: FRED-API: added sub-properties filtering

 

------------------------------------------------------------
revno: 9294
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-12-13 13:24:38 +0300
message:
  FRED-API: added sub-properties filtering
modified:
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.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-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2012-12-13 09:18:43 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2012-12-13 10:24:38 +0000
@@ -71,7 +71,9 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
@@ -198,7 +200,28 @@
             facility.setIdentifiers( null );
         }
 
-        if ( !strings.contains( "properties" ) )
+        if ( fields.indexOf( ':' ) >= 0 )
+        {
+            Map<String, Object> properties = facility.getProperties();
+            facility.setProperties( new HashMap<String, Object>() );
+
+            for ( String s : strings )
+            {
+                if ( s.contains( ":" ) )
+                {
+                    String[] split = s.split( ":" );
+
+                    if ( split.length > 1 )
+                    {
+                        if ( properties.containsKey( split[1] ) )
+                        {
+                            facility.getProperties().put( split[1], properties.get( split[1] ) );
+                        }
+                    }
+                }
+            }
+        }
+        else if ( !strings.contains( "properties" ) )
         {
             facility.setProperties( null );
         }