dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33545
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17136: extend enrollment-controller to support getting enrollments by program, orgUnit, start, end, (+ opti...
------------------------------------------------------------
revno: 17136
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-16 16:11:20 +0700
message:
extend enrollment-controller to support getting enrollments by program,orgUnit,start,end, (+ optional status)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.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/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-10-16 08:57:58 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-10-16 09:11:20 +0000
@@ -233,6 +233,13 @@
}
@Override
+ public Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+ {
+ return getEnrollments(
+ programInstanceService.getProgramInstances( program, Arrays.asList( organisationUnit.getId() ), startDate, endDate, 0, Integer.MAX_VALUE ) );
+ }
+
+ @Override
public Enrollments getEnrollments( Program program, TrackedEntityInstance trackedEntityInstance )
{
org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( trackedEntityInstance
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2014-10-16 08:57:58 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2014-10-16 09:11:20 +0000
@@ -80,6 +80,8 @@
Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit );
+ Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
Enrollments getEnrollments( Collection<ProgramInstance> programInstances );
Enrollment getEnrollment( String id );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2014-06-11 20:27:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2014-10-16 09:11:20 +0000
@@ -28,9 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.webapi.webdomain.WebOptions;
-import org.hisp.dhis.webapi.controller.exception.NotFoundException;
-import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
@@ -44,7 +41,11 @@
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
+import org.hisp.dhis.webapi.controller.exception.NotFoundException;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.webdomain.WebOptions;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -59,6 +60,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.util.Date;
import java.util.Map;
/**
@@ -88,13 +90,24 @@
@RequestParam( value = "orgUnit", required = false ) String orgUnitUid,
@RequestParam( value = "program", required = false ) String programUid,
@RequestParam( value = "trackedEntityInstance", required = false ) String trackedEntityInstanceUid,
+ @RequestParam( required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date startDate,
+ @RequestParam( required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date endDate,
@RequestParam( value = "status", required = false ) EnrollmentStatus status,
@RequestParam Map<String, String> parameters, Model model ) throws NotFoundException
{
WebOptions options = new WebOptions( parameters );
Enrollments enrollments;
- if ( orgUnitUid == null && programUid == null && trackedEntityInstanceUid == null )
+ if ( startDate != null && endDate != null && programUid != null && orgUnitUid != null )
+ {
+ OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
+ Program program = getProgram( programUid );
+
+ enrollments = status != null ?
+ enrollmentService.getEnrollments( program, status, organisationUnit, startDate, endDate ) :
+ enrollmentService.getEnrollments( program, organisationUnit, startDate, endDate );
+ }
+ else if ( orgUnitUid == null && programUid == null && trackedEntityInstanceUid == null )
{
enrollments = status != null ? enrollmentService.getEnrollments( status ) : enrollmentService.getEnrollments();
}