← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14868: EventController, removing support for org unit internal id, changed to single return point.

 

------------------------------------------------------------
revno: 14868
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-15 11:43:23 +0200
message:
  EventController, removing support for org unit internal id, changed to single return point.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.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/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java	2014-04-15 07:12:15 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java	2014-04-15 09:43:23 +0000
@@ -40,7 +40,6 @@
 
 import org.hisp.dhis.api.controller.WebMetaData;
 import org.hisp.dhis.api.controller.WebOptions;
-import org.hisp.dhis.api.controller.exception.NotFoundException;
 import org.hisp.dhis.api.utils.ContextUtils;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
@@ -133,7 +132,7 @@
         @RequestParam( required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date startDate,
         @RequestParam( required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date endDate,
         @RequestParam( required = false ) EventStatus status,
-        @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request ) throws NotFoundException
+        @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request )
     {
         WebOptions options = new WebOptions( parameters );        
         WebMetaData metaData = new WebMetaData();
@@ -141,59 +140,34 @@
         Program pr = manager.get( Program.class, program );
         ProgramStage prs = manager.get( ProgramStage.class, programStage );
         List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-        OrganisationUnit rootOrganisationUnit;
         TrackedEntityInstance tei = null;
+        OrganisationUnit rootOrganisationUnit = null;
 
         if ( trackedEntityInstance != null )
         {
             tei = trackedEntityInstanceService.getTrackedEntityInstance( trackedEntityInstance );
-
-            if ( tei == null )
-            {
-                throw new NotFoundException( "TrackedEntityInstance", trackedEntityInstance );
-            }
-        }
-
-        rootOrganisationUnit = manager.get( OrganisationUnit.class, orgUnit );
-
-        if ( rootOrganisationUnit == null )
-        {
-            try
-            {
-                rootOrganisationUnit = manager.get( OrganisationUnit.class, Integer.parseInt( orgUnit ) );
-            }
-            catch ( NumberFormatException ignored )
-            {
-            }
-        }
-
-        if ( rootOrganisationUnit == null && tei != null )
-        {
-            Events events = eventService.getEvents( pr, prs, programStatus, followUp, null, tei, startDate, endDate, status );
-
-            model.addAttribute( "model", events );
-            model.addAttribute( "viewClass", options.getViewClass( "detailed" ) );
-
-            return "events";            
-        }        
-
-        if ( rootOrganisationUnit == null )
-        {
-            throw new NotFoundException( "OrganisationUnit", program );
-        }
-
-        if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( ouMode ) )
-        {
-            organisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( rootOrganisationUnit.getUid() ) );
-        }
-        else if ( OrganisationUnitSelectionMode.CHILDREN.equals( ouMode ) )
-        {
-            organisationUnits.add( rootOrganisationUnit );
-            organisationUnits.addAll( rootOrganisationUnit.getChildren() );
-        }
-        else // SELECTED
-        {
-            organisationUnits.add( rootOrganisationUnit );
+        }
+
+        if ( orgUnit != null )
+        {
+            rootOrganisationUnit = manager.get( OrganisationUnit.class, orgUnit );
+        }
+
+        if ( rootOrganisationUnit != null )
+        {
+            if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( ouMode ) )
+            {
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( rootOrganisationUnit.getUid() ) );
+            }
+            else if ( OrganisationUnitSelectionMode.CHILDREN.equals( ouMode ) )
+            {
+                organisationUnits.add( rootOrganisationUnit );
+                organisationUnits.addAll( rootOrganisationUnit.getChildren() );
+            }
+            else // SELECTED
+            {
+                organisationUnits.add( rootOrganisationUnit );
+            }
         }
 
         Events events = eventService.getEvents( pr, prs, programStatus, followUp, organisationUnits, tei, startDate, endDate, status );