← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9962: FRED-API: fixed minor issue with uuid at the service layer. allow uuid in urls (will be checked f...

 

------------------------------------------------------------
revno: 9962
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-03-04 15:07:19 +0300
message:
  FRED-API: fixed minor issue with uuid at the service layer. allow uuid in urls (will be checked for length). Expose ownership / type ou-group-sets if they are available. Changed to TreeSet for properties block so that its always sorted.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  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/domain/Facility.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.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-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2013-02-07 12:57:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2013-03-04 12:07:19 +0000
@@ -227,7 +227,7 @@
 
     public OrganisationUnit getOrganisationUnitByUuid( String uuid )
     {
-        return organisationUnitStore.getByUid( uuid );
+        return organisationUnitStore.getByUuid( uuid );
     }
 
     public List<OrganisationUnit> getOrganisationUnitByName( String name )

=== 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	2013-03-04 11:16:07 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2013-03-04 12:07:19 +0000
@@ -344,7 +344,16 @@
         @RequestParam( value = "fields", required = false ) String fields,
         HttpServletRequest request )
     {
-        OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id );
+        OrganisationUnit organisationUnit;
+
+        if ( id.length() == 11 )
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnit( id );
+        }
+        else
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnitByUuid( id );
+        }
 
         if ( organisationUnit == null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java	2013-02-07 02:14:21 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/domain/Facility.java	2013-03-04 12:07:19 +0000
@@ -29,16 +29,14 @@
 
 import org.hibernate.validator.constraints.Length;
 import org.hisp.dhis.web.webapi.v1.validation.constraint.annotation.ValidProperties;
-import org.hisp.dhis.web.webapi.v1.validation.group.Create;
 import org.hisp.dhis.web.webapi.v1.validation.group.Update;
 
 import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Null;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -77,7 +75,7 @@
 
     // Implementation specific custom properties
     @ValidProperties
-    private Map<String, Object> properties = new HashMap<String, Object>();
+    private Map<String, Object> properties = new TreeMap<String, Object>();
 
     public Facility()
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java	2013-02-19 11:50:18 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java	2013-03-04 12:07:19 +0000
@@ -30,6 +30,7 @@
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.web.webapi.v1.controller.FacilityController;
 import org.hisp.dhis.web.webapi.v1.domain.Facility;
@@ -120,6 +121,21 @@
 
         facility.getProperties().put( "level", organisationUnit.getOrganisationUnitLevel() );
 
+        for ( OrganisationUnitGroup group : organisationUnit.getGroups() )
+        {
+            if ( group.getGroupSet() == null )
+            {
+                continue;
+            }
+
+            String name = group.getGroupSet().getName();
+
+            if ( name.equalsIgnoreCase( "Ownership" ) || name.equalsIgnoreCase( "Type" ) )
+            {
+                facility.getProperties().put( name.toLowerCase(), group.getName() );
+            }
+        }
+
         return facility;
     }
 }