← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12280: in personController, don't require orgUnit when searching for identifiers

 

------------------------------------------------------------
revno: 12280
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-27 13:42:42 +0200
message:
  in personController, don't require orgUnit when searching for identifiers
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.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/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java	2013-09-27 11:09:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java	2013-09-27 11:42:42 +0000
@@ -83,7 +83,7 @@
 
     @RequestMapping( value = "", method = RequestMethod.GET )
     public String getPersons(
-        @RequestParam( value = "orgUnit" ) String orgUnitUid,
+        @RequestParam( value = "orgUnit", required = false ) String orgUnitUid,
         @RequestParam( required = false ) Gender gender,
         @RequestParam( value = "program", required = false ) String programUid,
         @RequestParam( required = false ) String identifierType,
@@ -98,33 +98,31 @@
             Identifier id = new Identifier( identifierType, identifier );
             persons.getPersons().add( personService.getPerson( id ) );
         }
-        else if ( programUid != null && gender != null )
-        {
-            OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
-            Program program = getProgram( programUid );
-            persons = personService.getPersons( organisationUnit, program, gender );
-        }
-        else if ( orgUnitUid != null && gender != null )
-        {
-            OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
-            persons = personService.getPersons( organisationUnit, gender );
-        }
-        else if ( orgUnitUid != null && programUid != null )
-        {
-            OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
-            Program program = getProgram( programUid );
+        else if ( orgUnitUid != null )
+        {
+            if ( programUid != null && gender != null )
+            {
+                OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
+                Program program = getProgram( programUid );
+                persons = personService.getPersons( organisationUnit, program, gender );
+            }
+            else if ( gender != null )
+            {
+                OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
+                persons = personService.getPersons( organisationUnit, gender );
+            }
+            else if ( programUid != null )
+            {
+                OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
+                Program program = getProgram( programUid );
 
-            persons = personService.getPersons( organisationUnit, program );
-        }
-        else if ( programUid != null )
-        {
-            Program program = getProgram( programUid );
-            persons = personService.getPersons( program );
-        }
-        else
-        {
-            OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
-            persons = personService.getPersons( organisationUnit );
+                persons = personService.getPersons( organisationUnit, program );
+            }
+            else
+            {
+                OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
+                persons = personService.getPersons( organisationUnit );
+            }
         }
 
         model.addAttribute( "model", persons );