← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13016: allow event-query without startDate/endDate in event-api, also make sure that date parameters are...

 

------------------------------------------------------------
revno: 13016
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-11-25 11:48:06 +0100
message:
  allow event-query without startDate/endDate in event-api, also make sure that date parameters are using medium date string
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java
  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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java	2013-11-25 07:31:02 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java	2013-11-25 10:48:06 +0000
@@ -30,7 +30,6 @@
 
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
-
 import org.hisp.dhis.dxf2.events.person.Person;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
@@ -50,6 +49,7 @@
 import java.util.List;
 
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdList;
+import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -211,7 +211,7 @@
 
                     if ( !StringUtils.isEmpty( psi_longitude ) && !StringUtils.isEmpty( psi_latitude ) )
                     {
-                        coordinate = new Coordinate(psi_longitude, psi_latitude);
+                        coordinate = new Coordinate( psi_longitude, psi_latitude );
                         try
                         {
                             List<Double> list = objectMapper.readValue( coordinate.getCoordinateString(),
@@ -317,10 +317,14 @@
             }
         }
 
-        if ( startDate != null && endDate != null )
-        {
-            sql += " and (psi.executiondate >= '" + startDate.toString() + "' and psi.executiondate <= '"
-                + endDate.toString() + "') ";
+        if ( startDate != null )
+        {
+            sql += " and psi.executiondate >= '" + getMediumDateString( startDate ) + "' ";
+        }
+
+        if ( endDate != null )
+        {
+            sql += " and psi.executiondate <= '" + getMediumDateString( endDate ) + "' ";
         }
 
         sql += " order by psi_uid;";

=== 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	2013-11-19 10:02:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java	2013-11-25 10:48:06 +0000
@@ -110,8 +110,8 @@
         @RequestParam( value = "programStage", required = false ) String programStageUid,
         @RequestParam( value = "person", required = false ) String personUid,
         @RequestParam( value = "orgUnit" ) String orgUnitUid,
-        @RequestParam @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date startDate,
-        @RequestParam @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date endDate,
+        @RequestParam( required =  false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date startDate,
+        @RequestParam( required =  false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date endDate,
         @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request ) throws NotFoundException
     {
         WebOptions options = new WebOptions( parameters );