← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19303: minor refactor in EnrollmentService, moved methods for bulk add/update from JacksonEnrollmentServ...

 

------------------------------------------------------------
revno: 19303
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-08 10:29:52 +0700
message:
  minor refactor in EnrollmentService, moved methods for bulk add/update from JacksonEnrollmentService => AbstractEnrollmentService
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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.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	2015-04-24 07:56:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-06-08 03:29:52 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
 import org.hisp.dhis.dxf2.importsummary.ImportConflict;
 import org.hisp.dhis.dxf2.importsummary.ImportStatus;
+import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -337,6 +338,19 @@
     // -------------------------------------------------------------------------
 
     @Override
+    public ImportSummaries addEnrollments( List<Enrollment> enrollments )
+    {
+        ImportSummaries importSummaries = new ImportSummaries();
+
+        for ( Enrollment enrollment : enrollments )
+        {
+            importSummaries.addImportSummary( addEnrollment( enrollment ) );
+        }
+
+        return importSummaries;
+    }
+
+    @Override
     public ImportSummary addEnrollment( Enrollment enrollment )
     {
         ImportSummary importSummary = new ImportSummary();
@@ -418,6 +432,19 @@
     // -------------------------------------------------------------------------
 
     @Override
+    public ImportSummaries updateEnrollments( List<Enrollment> enrollments )
+    {
+        ImportSummaries importSummaries = new ImportSummaries();
+
+        for ( Enrollment enrollment : enrollments )
+        {
+            importSummaries.addImportSummary( updateEnrollment( enrollment ) );
+        }
+
+        return importSummaries;
+    }
+
+    @Override
     public ImportSummary updateEnrollment( Enrollment enrollment )
     {
         ImportSummary importSummary = new ImportSummary();

=== 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	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java	2015-06-08 03:29:52 +0000
@@ -82,7 +82,7 @@
     Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit );
 
     Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
-    
+
     Enrollments getEnrollments( Program program, List<OrganisationUnit> organisationUnits, Date startDate, Date endDate );
 
     Enrollments getEnrollments( Collection<ProgramInstance> programInstances );
@@ -99,6 +99,8 @@
 
     ImportSummaries addEnrollmentsXml( InputStream inputStream, ImportStrategy strategy ) throws IOException;
 
+    ImportSummaries addEnrollments( List<Enrollment> enrollments );
+
     ImportSummary addEnrollment( Enrollment enrollment );
 
     // -------------------------------------------------------------------------
@@ -109,6 +111,8 @@
 
     ImportSummary updateEnrollmentXml( String id, InputStream inputStream ) throws IOException;
 
+    ImportSummaries updateEnrollments( List<Enrollment> enrollments );
+
     ImportSummary updateEnrollment( Enrollment enrollment );
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java	2015-06-08 03:29:52 +0000
@@ -169,15 +169,8 @@
             }
         }
 
-        for ( Enrollment enrollment : create.getEnrollments() )
-        {
-            importSummaries.addImportSummary( addEnrollment( enrollment ) );
-        }
-
-        for ( Enrollment enrollment : update.getEnrollments() )
-        {
-            importSummaries.addImportSummary( updateEnrollment( enrollment ) );
-        }
+        importSummaries.addImportSummaries( addEnrollments( create.getEnrollments() ) );
+        importSummaries.addImportSummaries( updateEnrollments( update.getEnrollments() ) );
 
         return importSummaries;
     }