dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29156
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14682: Event query, support for program status
------------------------------------------------------------
revno: 14682
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-04-05 00:14:22 +0200
message:
Event query, support for program status
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.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/ProgramInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java 2014-04-01 19:50:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java 2014-04-04 22:14:22 +0000
@@ -56,9 +56,7 @@
extends BaseIdentifiableObject
{
public static int STATUS_ACTIVE = 0;
-
public static int STATUS_COMPLETED = 1;
-
public static int STATUS_CANCELLED = 2;
/**
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java 2014-03-28 13:16:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java 2014-04-04 22:14:22 +0000
@@ -33,5 +33,17 @@
*/
public enum ProgramStatus
{
- ACTIVE, COMPLETED, CANCELLED
+ ACTIVE( 0 ), COMPLETED( 1 ), CANCELLED( 2 );
+
+ private int value;
+
+ private ProgramStatus( int value )
+ {
+ this.value = value;
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
}
=== 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 21:45:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-04-04 22:14:22 +0000
@@ -50,6 +50,7 @@
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
@@ -326,10 +327,10 @@
}
@Override
- public Events getEvents( List<Program> programs, List<ProgramStage> programStages,
+ public Events getEvents( List<Program> programs, List<ProgramStage> programStages, ProgramStatus programStatus,
List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
{
- List<Event> eventList = eventStore.getAll( programs, programStages, organisationUnits,
+ List<Event> eventList = eventStore.getAll( programs, programStages, programStatus, 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 21:45:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-04-04 22:14:22 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.scheduling.TaskId;
/**
@@ -55,7 +56,7 @@
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,
+ Events getEvents( List<Program> programs, List<ProgramStage> programStages, ProgramStatus programStatus, 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 21:45:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2014-04-04 22:14:22 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStatus;
import java.util.Date;
import java.util.List;
@@ -44,6 +45,6 @@
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,
+ List<Event> getAll( List<Program> programs, List<ProgramStage> programStages, ProgramStatus programStatus, List<OrganisationUnit> organisationUnits,
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:45:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-04-04 22:14:22 +0000
@@ -44,6 +44,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.system.util.SqlHelper;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -74,12 +75,12 @@
public List<Event> getAll( Program program, ProgramStage programStage, OrganisationUnit organisationUnit,
TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate )
{
- return getAll( Arrays.asList( program ), Arrays.asList( programStage ), Arrays.asList( organisationUnit ),
+ return getAll( Arrays.asList( program ), Arrays.asList( programStage ), null, Arrays.asList( organisationUnit ),
trackedEntityInstance, startDate, endDate, null );
}
@Override
- public List<Event> getAll( List<Program> programs, List<ProgramStage> programStages,
+ public List<Event> getAll( List<Program> programs, List<ProgramStage> programStages, ProgramStatus programStatus,
List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
{
List<Event> events = new ArrayList<Event>();
@@ -96,12 +97,12 @@
}
}
- String sql = buildSql( getIdList( programs ), getIdList( programStages ), getIdList( organisationUnits ),
+ String sql = buildSql( getIdList( programs ), getIdList( programStages ), programStatus, getIdList( organisationUnits ),
trackedEntityInstanceId, startDate, endDate, status );
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
- log.debug( "Event query SQL: " + sql );
+ log.info( "Event query SQL: " + sql );
Event event = new Event();
event.setEvent( "not_valid" );
@@ -176,7 +177,7 @@
return events;
}
- private String buildSql( List<Integer> programIds, List<Integer> programStageIds, List<Integer> orgUnitIds,
+ private String buildSql( List<Integer> programIds, List<Integer> programStageIds, ProgramStatus programStatus, List<Integer> orgUnitIds,
Integer trackedEntityInstanceId, Date startDate, Date endDate, EventStatus status )
{
SqlHelper hlp = new SqlHelper();
@@ -207,6 +208,11 @@
{
sql += hlp.whereAnd() + " ps.programstageid in (" + getCommaDelimitedString( programStageIds ) + ") ";
}
+
+ if ( programStatus != null )
+ {
+ sql += hlp.whereAnd() + " pi.status = " + programStatus.getValue() + " ";
+ }
if ( !orgUnitIds.isEmpty() )
{
=== 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-04 21:45:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-04-04 22:14:22 +0000
@@ -52,6 +52,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.scheduling.TaskCategory;
import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.system.scheduling.Scheduler;
@@ -126,6 +127,7 @@
public String getEvents(
@RequestParam( required = false ) String program,
@RequestParam( required = false ) String programStage,
+ @RequestParam( required = false ) ProgramStatus programStatus,
@RequestParam( required = false ) String trackedEntityInstance,
@RequestParam( required = false ) String orgUnit,
@RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
@@ -168,7 +170,7 @@
if ( rootOrganisationUnit == null && tei != null )
{
- Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), null, tei, startDate, endDate, status );
+ Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), programStatus, null, tei, startDate, endDate, status );
model.addAttribute( "model", events );
model.addAttribute( "viewClass", options.getViewClass( "detailed" ) );
@@ -195,7 +197,7 @@
organisationUnits.add( rootOrganisationUnit );
}
- Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), organisationUnits, tei, startDate, endDate, status );
+ Events events = eventService.getEvents( Arrays.asList( pr ), Arrays.asList( prs ), programStatus, organisationUnits, tei, startDate, endDate, status );
List<Event> eventList = new ArrayList<Event>( events.getEvents() );