dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29154
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14681: Event query, impl support for status
------------------------------------------------------------
revno: 14681
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-04-04 23:45:55 +0200
message:
Event query, impl support for status
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
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/EventStore.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.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-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2014-04-04 21:45:55 +0000
@@ -55,15 +55,10 @@
private static final long serialVersionUID = 6239130884678145713L;
public static final int ACTIVE_STATUS = 0;
-
public static final int COMPLETED_STATUS = 1;
-
public static final int VISITED_STATUS = 2;
-
public static final int FUTURE_VISIT_STATUS = 3;
-
public static final int LATE_VISIT_STATUS = 4;
-
public static final int SKIPPED_STATUS = 5;
private ProgramInstance programInstance;
=== 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 2014-04-04 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-04-04 21:45:55 +0000
@@ -327,10 +327,10 @@
@Override
public Events getEvents( List<Program> programs, List<ProgramStage> programStages,
- List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate )
+ List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
{
- List<Event> eventList = eventStore.getAll( programs, programStages, organisationUnits, trackedEntityInstance, startDate,
- endDate );
+ List<Event> eventList = eventStore.getAll( programs, programStages, organisationUnits,
+ trackedEntityInstance, startDate, endDate, status );
Events events = new Events();
events.setEvents( eventList );
=== 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 2014-04-04 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-04-04 21:45:55 +0000
@@ -52,9 +52,11 @@
// READ
// -------------------------------------------------------------------------
- Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
+ Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit,
+ TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
- Events getEvents( List<Program> programs, List<ProgramStage> programStages, List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
+ Events getEvents( List<Program> programs, List<ProgramStage> programStages, List<OrganisationUnit> organisationUnits,
+ TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status );
Event getEvent( String uid );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2014-04-04 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2014-04-04 21:45:55 +0000
@@ -41,8 +41,9 @@
*/
public interface EventStore
{
- List<Event> getAll( Program program, ProgramStage programStage, OrganisationUnit organisationUnit, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
+ List<Event> getAll( Program program, ProgramStage programStage, OrganisationUnit organisationUnit,
+ TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
List<Event> getAll( List<Program> programs, List<ProgramStage> programStages, List<OrganisationUnit> organisationUnits,
- TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate );
+ TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status );
}
=== 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 2014-04-04 21:24:04 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-04-04 21:45:55 +0000
@@ -38,6 +38,8 @@
import java.util.Date;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
@@ -58,6 +60,8 @@
public class JdbcEventStore
implements EventStore
{
+ private static final Log log = LogFactory.getLog( JdbcEventStore.class );
+
@Autowired
private JdbcTemplate jdbcTemplate;
@@ -71,12 +75,12 @@
TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate )
{
return getAll( Arrays.asList( program ), Arrays.asList( programStage ), Arrays.asList( organisationUnit ),
- trackedEntityInstance, startDate, endDate );
+ trackedEntityInstance, startDate, endDate, null );
}
@Override
public List<Event> getAll( List<Program> programs, List<ProgramStage> programStages,
- List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate )
+ List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
{
List<Event> events = new ArrayList<Event>();
@@ -93,9 +97,11 @@
}
String sql = buildSql( getIdList( programs ), getIdList( programStages ), getIdList( organisationUnits ),
- trackedEntityInstanceId, startDate, endDate );
+ trackedEntityInstanceId, startDate, endDate, status );
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+
+ log.debug( "Event query SQL: " + sql );
Event event = new Event();
event.setEvent( "not_valid" );
@@ -171,7 +177,7 @@
}
private String buildSql( List<Integer> programIds, List<Integer> programStageIds, List<Integer> orgUnitIds,
- Integer trackedEntityInstanceId, Date startDate, Date endDate )
+ Integer trackedEntityInstanceId, Date startDate, Date endDate, EventStatus status )
{
SqlHelper hlp = new SqlHelper();
@@ -209,12 +215,17 @@
if ( startDate != null )
{
- sql += " and psi.executiondate >= '" + getMediumDateString( startDate ) + "' ";
+ sql += hlp.whereAnd() + " psi.executiondate >= '" + getMediumDateString( startDate ) + "' ";
}
if ( endDate != null )
{
- sql += " and psi.executiondate <= '" + getMediumDateString( endDate ) + "' ";
+ sql += hlp.whereAnd() + " psi.executiondate <= '" + getMediumDateString( endDate ) + "' ";
+ }
+
+ if ( status != null )
+ {
+ sql += hlp.whereAnd() + " psi.status = " + status.getValue() + " ";
}
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 2014-04-01 04:22:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-04-04 21:45:55 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.events.event.EventService;
+import org.hisp.dhis.dxf2.events.event.EventStatus;
import org.hisp.dhis.dxf2.events.event.Events;
import org.hisp.dhis.dxf2.events.event.ImportEventTask;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
@@ -130,6 +131,7 @@
@RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
@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
{
WebOptions options = new WebOptions( parameters );
@@ -166,14 +168,13 @@
if ( rootOrganisationUnit == null && tei != null )
{
- Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), null, tei, startDate, endDate );
+ Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), null, tei, startDate, endDate, status );
model.addAttribute( "model", events );
model.addAttribute( "viewClass", options.getViewClass( "detailed" ) );
return "events";
}
-
if ( rootOrganisationUnit == null )
{
@@ -194,7 +195,7 @@
organisationUnits.add( rootOrganisationUnit );
}
- Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), organisationUnits, tei, startDate, endDate );
+ Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), organisationUnits, tei, startDate, endDate, status );
List<Event> eventList = new ArrayList<Event>( events.getEvents() );