← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21458: require importoption for add/update enrollments/tei

 

------------------------------------------------------------
revno: 21458
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-15 15:46:39 +0100
message:
  require importoption for add/update enrollments/tei
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
  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/trackedentity/AbstractTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java
  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/TrackedEntityInstanceController.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-12-14 15:03:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-12-15 14:46:39 +0000
@@ -30,12 +30,12 @@
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.common.exception.InvalidIdentifierReferenceException;
 import org.hisp.dhis.commons.collection.CachingMap;
 import org.hisp.dhis.dbms.DbmsManager;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.events.event.Note;
 import org.hisp.dhis.dxf2.events.trackedentity.Attribute;
 import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
@@ -200,14 +200,19 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummaries addEnrollments( List<Enrollment> enrollments )
+    public ImportSummaries addEnrollments( List<Enrollment> enrollments, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummaries importSummaries = new ImportSummaries();
         int counter = 0;
 
         for ( Enrollment enrollment : enrollments )
         {
-            importSummaries.addImportSummary( addEnrollment( enrollment ) );
+            importSummaries.addImportSummary( addEnrollment( enrollment, importOptions ) );
 
             if ( counter % FLUSH_FREQUENCY == 0 )
             {
@@ -221,8 +226,13 @@
     }
 
     @Override
-    public ImportSummary addEnrollment( Enrollment enrollment )
+    public ImportSummary addEnrollment( Enrollment enrollment, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummary importSummary = new ImportSummary();
 
         org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( enrollment.getTrackedEntityInstance() );
@@ -312,14 +322,19 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummaries updateEnrollments( List<Enrollment> enrollments )
+    public ImportSummaries updateEnrollments( List<Enrollment> enrollments, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummaries importSummaries = new ImportSummaries();
         int counter = 0;
 
         for ( Enrollment enrollment : enrollments )
         {
-            importSummaries.addImportSummary( updateEnrollment( enrollment ) );
+            importSummaries.addImportSummary( updateEnrollment( enrollment, importOptions ) );
 
             if ( counter % FLUSH_FREQUENCY == 0 )
             {
@@ -333,8 +348,13 @@
     }
 
     @Override
-    public ImportSummary updateEnrollment( Enrollment enrollment )
+    public ImportSummary updateEnrollment( Enrollment enrollment, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummary importSummary = new ImportSummary();
 
         if ( enrollment == null || enrollment.getEnrollment() == null )
@@ -397,7 +417,7 @@
 
         return importSummary;
     }
-    
+
     @Override
     public ImportSummary updateEnrollmentForNote( Enrollment enrollment )
     {
@@ -475,7 +495,7 @@
         ProgramInstance programInstance = programInstanceService.getProgramInstance( uid );
         programInstanceService.completeProgramInstanceStatus( programInstance );
     }
-    
+
     @Override
     public void incompleteEnrollment( String uid )
     {

=== 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-12-14 15:03:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java	2015-12-15 14:46:39 +0000
@@ -62,30 +62,30 @@
 
     ImportSummaries addEnrollmentsXml( InputStream inputStream, ImportOptions importOptions ) throws IOException;
 
-    ImportSummaries addEnrollments( List<Enrollment> enrollments );
+    ImportSummaries addEnrollments( List<Enrollment> enrollments, ImportOptions importOptions );
 
-    ImportSummary addEnrollment( Enrollment enrollment );
+    ImportSummary addEnrollment( Enrollment enrollment, ImportOptions importOptions );
 
     // -------------------------------------------------------------------------
     // UPDATE
     // -------------------------------------------------------------------------
 
-    ImportSummary updateEnrollmentJson( String id, InputStream inputStream ) throws IOException;
-    
+    ImportSummary updateEnrollmentJson( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException;
+
     ImportSummary updateEnrollmentForNoteJson( String id, InputStream inputStream ) throws IOException;
 
-    ImportSummary updateEnrollmentXml( String id, InputStream inputStream ) throws IOException;
-
-    ImportSummaries updateEnrollments( List<Enrollment> enrollments );
-
-    ImportSummary updateEnrollment( Enrollment enrollment );
-    
+    ImportSummary updateEnrollmentXml( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException;
+
+    ImportSummaries updateEnrollments( List<Enrollment> enrollments, ImportOptions importOptions );
+
+    ImportSummary updateEnrollment( Enrollment enrollment, ImportOptions importOptions );
+
     ImportSummary updateEnrollmentForNote( Enrollment enrollment );
-    
+
     void cancelEnrollment( String uid );
 
     void completeEnrollment( String uid );
-    
+
     void incompleteEnrollment( String uid );
 
     // -------------------------------------------------------------------------
@@ -95,5 +95,5 @@
     ImportSummary deleteEnrollment( String uid );
 
     ImportSummaries deleteEnrollments( List<String> uids );
-    
+
 }

=== 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-11-21 11:27:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java	2015-12-15 14:46:39 +0000
@@ -114,7 +114,7 @@
             enrollments.add( fromJson );
         }
 
-        return addEnrollments( enrollments, importOptions );
+        return addEnrollmentList( enrollments, importOptions );
     }
 
     @Override
@@ -134,10 +134,10 @@
             enrollments.add( fromXml );
         }
 
-        return addEnrollments( enrollments, importOptions );
+        return addEnrollmentList( enrollments, importOptions );
     }
 
-    private ImportSummaries addEnrollments( List<Enrollment> enrollments, ImportOptions importOptions )
+    private ImportSummaries addEnrollmentList( List<Enrollment> enrollments, ImportOptions importOptions )
     {
         ImportSummaries importSummaries = new ImportSummaries();
 
@@ -179,8 +179,8 @@
             delete.addAll( enrollments.stream().map( Enrollment::getEnrollment ).collect( Collectors.toList() ) );
         }
 
-        importSummaries.addImportSummaries( addEnrollments( create ) );
-        importSummaries.addImportSummaries( updateEnrollments( update ) );
+        importSummaries.addImportSummaries( addEnrollments( create, importOptions ) );
+        importSummaries.addImportSummaries( updateEnrollments( update, importOptions ) );
         importSummaries.addImportSummaries( deleteEnrollments( delete ) );
 
         return importSummaries;
@@ -191,14 +191,14 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummary updateEnrollmentJson( String id, InputStream inputStream ) throws IOException
+    public ImportSummary updateEnrollmentJson( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException
     {
         Enrollment enrollment = fromJson( inputStream, Enrollment.class );
         enrollment.setEnrollment( id );
 
-        return updateEnrollment( enrollment );
+        return updateEnrollment( enrollment, importOptions );
     }
-    
+
     @Override
     public ImportSummary updateEnrollmentForNoteJson( String id, InputStream inputStream ) throws IOException
     {
@@ -209,11 +209,11 @@
     }
 
     @Override
-    public ImportSummary updateEnrollmentXml( String id, InputStream inputStream ) throws IOException
+    public ImportSummary updateEnrollmentXml( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException
     {
         Enrollment enrollment = fromXml( inputStream, Enrollment.class );
         enrollment.setEnrollment( id );
 
-        return updateEnrollment( enrollment );
+        return updateEnrollment( enrollment, importOptions );
     }
 }

=== 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	2015-12-15 10:01:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2015-12-15 14:46:39 +0000
@@ -498,7 +498,6 @@
 
         EventRows eventRows = new EventRows();
 
-
         List<EventRow> eventRowList = eventStore.getEventRows( params, organisationUnits );
 
         eventRows.setEventRows( eventRowList );
@@ -649,6 +648,11 @@
 
     private ImportSummary updateEvent( Event event, User user, boolean singleValue, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummary importSummary = new ImportSummary();
         ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event.getEvent() );
 
@@ -658,11 +662,6 @@
             return importSummary.incrementIgnored();
         }
 
-        if ( importOptions == null )
-        {
-            importOptions = new ImportOptions();
-        }
-
         OrganisationUnit organisationUnit = getOrganisationUnit( importOptions.getIdSchemes().getOrgUnitIdScheme(), event.getOrgUnit() );
 
         if ( organisationUnit == null )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-11-19 04:01:09 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-12-15 14:46:39 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.commons.collection.CachingMap;
 import org.hisp.dhis.dbms.DbmsManager;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.importsummary.ImportConflict;
 import org.hisp.dhis.dxf2.importsummary.ImportStatus;
 import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
@@ -213,14 +214,19 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
+    public ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummaries importSummaries = new ImportSummaries();
         int counter = 0;
 
         for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
         {
-            importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
+            importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance, importOptions ) );
 
             if ( counter % FLUSH_FREQUENCY == 0 )
             {
@@ -234,8 +240,13 @@
     }
 
     @Override
-    public ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+    public ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummary importSummary = new ImportSummary();
 
         trackedEntityInstance.trimValuesToNull();
@@ -272,14 +283,19 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
+    public ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummaries importSummaries = new ImportSummaries();
         int counter = 0;
 
         for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
         {
-            importSummaries.addImportSummary( updateTrackedEntityInstance( trackedEntityInstance ) );
+            importSummaries.addImportSummary( updateTrackedEntityInstance( trackedEntityInstance, importOptions ) );
 
             if ( counter % FLUSH_FREQUENCY == 0 )
             {
@@ -293,8 +309,13 @@
     }
 
     @Override
-    public ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+    public ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, ImportOptions importOptions )
     {
+        if ( importOptions == null )
+        {
+            importOptions = new ImportOptions();
+        }
+
         ImportSummary importSummary = new ImportSummary();
 
         trackedEntityInstance.trimValuesToNull();
@@ -303,7 +324,8 @@
         importConflicts.addAll( checkRelationships( trackedEntityInstance ) );
         importConflicts.addAll( checkAttributes( trackedEntityInstance ) );
 
-        org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, trackedEntityInstance.getTrackedEntityInstance() );
+        org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class,
+            trackedEntityInstance.getTrackedEntityInstance() );
 
         if ( entityInstance == null )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java	2015-10-23 07:11:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java	2015-12-15 14:46:39 +0000
@@ -114,7 +114,7 @@
             trackedEntityInstances.add( fromXml );
         }
 
-        return addTrackedEntityInstance( trackedEntityInstances, importOptions );
+        return addTrackedEntityInstanceList( trackedEntityInstances, importOptions );
     }
 
     @Override
@@ -134,10 +134,10 @@
             trackedEntityInstances.add( fromJson );
         }
 
-        return addTrackedEntityInstance( trackedEntityInstances, importOptions );
+        return addTrackedEntityInstanceList( trackedEntityInstances, importOptions );
     }
 
-    private ImportSummaries addTrackedEntityInstance( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions )
+    private ImportSummaries addTrackedEntityInstanceList( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions )
     {
         ImportSummaries importSummaries = new ImportSummaries();
 
@@ -179,8 +179,8 @@
             delete.addAll( trackedEntityInstances.stream().map( TrackedEntityInstance::getTrackedEntityInstance ).collect( Collectors.toList() ) );
         }
 
-        importSummaries.addImportSummaries( addTrackedEntityInstances( create ) );
-        importSummaries.addImportSummaries( updateTrackedEntityInstances( update ) );
+        importSummaries.addImportSummaries( addTrackedEntityInstances( create, importOptions ) );
+        importSummaries.addImportSummaries( updateTrackedEntityInstances( update, importOptions ) );
         importSummaries.addImportSummaries( deleteTrackedEntityInstances( delete ) );
 
         return importSummaries;
@@ -191,20 +191,20 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream ) throws IOException
+    public ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException
     {
         TrackedEntityInstance trackedEntityInstance = fromXml( inputStream, TrackedEntityInstance.class );
         trackedEntityInstance.setTrackedEntityInstance( id );
 
-        return updateTrackedEntityInstance( trackedEntityInstance );
+        return updateTrackedEntityInstance( trackedEntityInstance, importOptions );
     }
 
     @Override
-    public ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream ) throws IOException
+    public ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException
     {
         TrackedEntityInstance trackedEntityInstance = fromJson( inputStream, TrackedEntityInstance.class );
         trackedEntityInstance.setTrackedEntityInstance( id );
 
-        return updateTrackedEntityInstance( trackedEntityInstance );
+        return updateTrackedEntityInstance( trackedEntityInstance, importOptions );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java	2015-10-23 05:08:59 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java	2015-12-15 14:46:39 +0000
@@ -64,21 +64,21 @@
 
     ImportSummaries addTrackedEntityInstanceJson( InputStream inputStream, ImportOptions importOptions ) throws IOException;
 
-    ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances );
+    ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions );
 
-    ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
+    ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, ImportOptions importOptions );
 
     // -------------------------------------------------------------------------
     // UPDATE
     // -------------------------------------------------------------------------
 
-    ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream ) throws IOException;
-
-    ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream ) throws IOException;
-
-    ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances );
-
-    ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
+    ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException;
+
+    ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream, ImportOptions importOptions ) throws IOException;
+
+    ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances, ImportOptions importOptions );
+
+    ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, ImportOptions importOptions );
 
     // -------------------------------------------------------------------------
     // DELETE

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-11-27 09:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-12-15 14:46:39 +0000
@@ -221,7 +221,7 @@
     public void testSaveSameEventMultipleTimesShouldOnlyGive1Event()
     {
         Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
+        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(),
@@ -252,7 +252,7 @@
     public void testSaveRepeatableStageWithoutEventIdShouldCreateNewEvent()
     {
         Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
+        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(),
@@ -287,7 +287,7 @@
     public void testSaveRepeatableStageWithEventIdShouldNotCreateAdditionalEvents()
     {
         Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
+        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(),

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-11-27 09:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-12-15 14:46:39 +0000
@@ -172,7 +172,7 @@
     public void testSaveWithEnrollmentShouldNotFail()
     {
         Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
+        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
@@ -185,7 +185,7 @@
     public void testSavingMultipleEventsShouldOnlyUpdate()
     {
         Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
+        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java	2015-10-22 06:03:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java	2015-12-15 14:46:39 +0000
@@ -136,7 +136,7 @@
         TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( maleA.getUid() );
         // person.setName( "UPDATED_NAME" );
 
-        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance );
+        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         // assertEquals( "UPDATED_NAME", personService.getTrackedEntityInstance( maleA.getUid() ).getName() );
@@ -150,7 +150,7 @@
         // person.setName( "NAME" );
         trackedEntityInstance.setOrgUnit( organisationUnitA.getUid() );
 
-        ImportSummary importSummary = trackedEntityInstanceService.addTrackedEntityInstance( trackedEntityInstance );
+        ImportSummary importSummary = trackedEntityInstanceService.addTrackedEntityInstance( trackedEntityInstance, null );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
         // assertEquals( "NAME", personService.getTrackedEntityInstance( importSummary.getReference() ).getName() );

=== 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	2015-12-14 15:03:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java	2015-12-15 14:46:39 +0000
@@ -29,7 +29,6 @@
  */
 
 import com.google.common.collect.Lists;
-
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.commons.util.TextUtils;
 import org.hisp.dhis.dxf2.common.ImportOptions;
@@ -68,7 +67,6 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
@@ -223,24 +221,24 @@
 
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
-    public void updateEnrollmentXml( @PathVariable String id, HttpServletRequest request, HttpServletResponse response ) throws IOException
+    public void updateEnrollmentXml( @PathVariable String id, ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws IOException
     {
-        ImportSummary importSummary = enrollmentService.updateEnrollmentXml( id, request.getInputStream() );
+        ImportSummary importSummary = enrollmentService.updateEnrollmentXml( id, request.getInputStream(), importOptions );
         webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
     }
 
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
-    public void updateEnrollmentJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response ) throws IOException
+    public void updateEnrollmentJson( @PathVariable String id, ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response ) throws IOException
     {
-        ImportSummary importSummary = enrollmentService.updateEnrollmentJson( id, request.getInputStream() );
+        ImportSummary importSummary = enrollmentService.updateEnrollmentJson( id, request.getInputStream(), importOptions );
         webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
     }
-    
+
     @RequestMapping( value = "/{id}/addNote", method = RequestMethod.PUT, consumes = "application/json" )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
     public void updateEnrollmentForNoteJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response ) throws IOException
-    {        
+    {
         ImportSummary importSummary = enrollmentService.updateEnrollmentForNoteJson( id, request.getInputStream() );
         webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
     }
@@ -270,7 +268,7 @@
 
         enrollmentService.completeEnrollment( id );
     }
-    
+
     @RequestMapping( value = "/{id}/incompleted", method = RequestMethod.PUT )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
     @ResponseStatus( HttpStatus.NO_CONTENT )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2015-11-17 18:29:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2015-12-15 14:46:39 +0000
@@ -140,7 +140,7 @@
         }
 
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
-        
+
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
             program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
@@ -397,19 +397,19 @@
 
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_INSTANCE_ADD')" )
-    public void updateTrackedEntityInstanceXml( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
+    public void updateTrackedEntityInstanceXml( @PathVariable String id, ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
-        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceXml( id, request.getInputStream() );
+        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceXml( id, request.getInputStream(), importOptions );
         webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
     }
 
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_INSTANCE_ADD')" )
-    public void updateTrackedEntityInstanceJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
+    public void updateTrackedEntityInstanceJson( @PathVariable String id, ImportOptions importOptions, HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
-        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceJson( id, request.getInputStream() );
+        ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceJson( id, request.getInputStream(), importOptions );
         webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
     }