← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18568: Event service, removed unecesssary overload

 

------------------------------------------------------------
revno: 18568
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-10 15:29:40 +0100
message:
  Event service, removed unecesssary overload
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2015-03-10 13:30:28 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2015-03-10 14:29:40 +0000
@@ -395,14 +395,7 @@
     @Override
     public Events getEvents( Program program, OrganisationUnit organisationUnit )
     {
-        return getEvents( program, null, null, null, Arrays.asList( organisationUnit ), null, null, null, null );
-    }
-
-    @Override
-    public Events getEvents( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp,
-        List<OrganisationUnit> organisationUnit, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
-    {
-        return getEvents( program, programStage, programStatus, followUp, organisationUnit, trackedEntityInstance, startDate, endDate, status, new IdSchemes() );
+        return getEvents( program, null, null, null, Arrays.asList( organisationUnit ), null, null, null, null, null );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java	2015-03-10 14:29:40 +0000
@@ -58,9 +58,6 @@
     Events getEvents( Program program, OrganisationUnit organisationUnit );
 
     Events getEvents( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp, List<OrganisationUnit> organisationUnit,
-        TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status );
-
-    Events getEvents( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp, List<OrganisationUnit> organisationUnit,
         TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status, IdSchemes idSchemes );
 
     Event getEvent( String uid );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java	2015-03-10 13:59:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java	2015-03-10 14:29:40 +0000
@@ -51,6 +51,7 @@
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.SqlHelper;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
+import org.hisp.dhis.util.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
@@ -112,6 +113,8 @@
         event.setEvent( "not_valid" );
 
         Set<String> notes = new HashSet<>();
+        
+        idSchemes = ObjectUtils.firstNonNull( idSchemes, new IdSchemes() );
 
         while ( rowSet.next() )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java	2015-03-10 14:29:40 +0000
@@ -73,7 +73,7 @@
         EventRows eventRows = new EventRows();
 
         Events events = eventService.getEvents( program, null, programStatus, null, organisationUnits, null, startDate,
-            endDate, eventStatus );
+            endDate, eventStatus, null );
 
         for ( Event event : events.getEvents() )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-03-10 14:29:40 +0000
@@ -234,7 +234,7 @@
         importSummary = eventService.addEvent( event );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
-        assertEquals( 1, eventService.getEvents( programA, programStageA, null, null, Arrays.asList( organisationUnitA ), null, null, null, null ).getEvents().size() );
+        assertEquals( 1, eventService.getEvents( programA, programStageA, null, null, Arrays.asList( organisationUnitA ), null, null, null, null, null ).getEvents().size() );
     }
 
     @Test

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2015-03-03 16:56:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2015-03-10 14:29:40 +0000
@@ -159,7 +159,7 @@
         ProgramStage prs = manager.get( ProgramStage.class, programStage );
         List<OrganisationUnit> organisationUnits = new ArrayList<>();
         TrackedEntityInstance tei = null;
-        OrganisationUnit rootOrganisationUnit = null;
+        OrganisationUnit ou = null;
 
         if ( trackedEntityInstance != null )
         {
@@ -174,29 +174,29 @@
 
         if ( orgUnit != null )
         {
-            rootOrganisationUnit = manager.get( OrganisationUnit.class, orgUnit );
+            ou = manager.get( OrganisationUnit.class, orgUnit );
 
-            if ( rootOrganisationUnit == null )
+            if ( ou == null )
             {
                 ContextUtils.conflictResponse( response, "Invalid orgUnit ID." );
                 return;
             }
         }
 
-        if ( rootOrganisationUnit != null )
+        if ( ou != null )
         {
             if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( ouMode ) )
             {
-                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( rootOrganisationUnit.getUid() ) );
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( ou.getUid() ) );
             }
             else if ( OrganisationUnitSelectionMode.CHILDREN.equals( ouMode ) )
             {
-                organisationUnits.add( rootOrganisationUnit );
-                organisationUnits.addAll( rootOrganisationUnit.getChildren() );
+                organisationUnits.add( ou );
+                organisationUnits.addAll( ou.getChildren() );
             }
             else // SELECTED
             {
-                organisationUnits.add( rootOrganisationUnit );
+                organisationUnits.add( ou );
             }
         }
 
@@ -252,7 +252,7 @@
         ProgramStage prs = manager.get( ProgramStage.class, programStage );
         List<OrganisationUnit> organisationUnits = new ArrayList<>();
         TrackedEntityInstance tei = null;
-        OrganisationUnit rootOrganisationUnit = null;
+        OrganisationUnit ou = null;
 
         if ( trackedEntityInstance != null )
         {
@@ -267,29 +267,29 @@
 
         if ( orgUnit != null )
         {
-            rootOrganisationUnit = manager.get( OrganisationUnit.class, orgUnit );
+            ou = manager.get( OrganisationUnit.class, orgUnit );
 
-            if ( rootOrganisationUnit == null )
+            if ( ou == null )
             {
                 ContextUtils.conflictResponse( response, "Invalid orgUnit ID." );
                 return null;
             }
         }
 
-        if ( rootOrganisationUnit != null )
+        if ( ou != null )
         {
             if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( ouMode ) )
             {
-                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( rootOrganisationUnit.getUid() ) );
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( ou.getUid() ) );
             }
             else if ( OrganisationUnitSelectionMode.CHILDREN.equals( ouMode ) )
             {
-                organisationUnits.add( rootOrganisationUnit );
-                organisationUnits.addAll( rootOrganisationUnit.getChildren() );
+                organisationUnits.add( ou );
+                organisationUnits.addAll( ou.getChildren() );
             }
             else // SELECTED
             {
-                organisationUnits.add( rootOrganisationUnit );
+                organisationUnits.add( ou );
             }
         }
 
@@ -342,27 +342,27 @@
 
         Program pr = manager.get( Program.class, program );
         List<OrganisationUnit> organisationUnits = new ArrayList<>();
-        OrganisationUnit rootOrganisationUnit = null;
+        OrganisationUnit ou = null;
 
         if ( orgUnit != null )
         {
-            rootOrganisationUnit = manager.get( OrganisationUnit.class, orgUnit );
+            ou = manager.get( OrganisationUnit.class, orgUnit );
         }
 
-        if ( rootOrganisationUnit != null )
+        if ( ou != null )
         {
             if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( ouMode ) )
             {
-                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( rootOrganisationUnit.getUid() ) );
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( ou.getUid() ) );
             }
             else if ( OrganisationUnitSelectionMode.CHILDREN.equals( ouMode ) )
             {
-                organisationUnits.add( rootOrganisationUnit );
-                organisationUnits.addAll( rootOrganisationUnit.getChildren() );
+                organisationUnits.add( ou );
+                organisationUnits.addAll( ou.getChildren() );
             }
             else // SELECTED
             {
-                organisationUnits.add( rootOrganisationUnit );
+                organisationUnits.add( ou );
             }
         }