← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19301: minor refactor, move methods for adding/updating multiple TEI from JacksonTEIService to AbstractT...

 

------------------------------------------------------------
revno: 19301
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-08 10:02:05 +0700
message:
  minor refactor, move methods for adding/updating multiple TEI from JacksonTEIService to AbstractTEIService
modified:
  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/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummaries.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/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-04-05 20:00:35 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-06-08 03:02:05 +0000
@@ -29,7 +29,6 @@
  */
 
 import com.google.common.collect.Lists;
-
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IdentifiableObjectManager;
@@ -38,6 +37,7 @@
 import org.hisp.dhis.common.QueryOperator;
 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.organisationunit.OrganisationUnit;
 import org.hisp.dhis.relationship.Relationship;
@@ -199,6 +199,19 @@
     // -------------------------------------------------------------------------
 
     @Override
+    public ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
+    {
+        ImportSummaries importSummaries = new ImportSummaries();
+
+        for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
+        {
+            importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
+        }
+
+        return importSummaries;
+    }
+
+    @Override
     public ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
     {
         ImportSummary importSummary = new ImportSummary();
@@ -237,6 +250,19 @@
     // -------------------------------------------------------------------------
 
     @Override
+    public ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
+    {
+        ImportSummaries importSummaries = new ImportSummaries();
+
+        for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
+        {
+            importSummaries.addImportSummary( updateTrackedEntityInstance( trackedEntityInstance ) );
+        }
+
+        return importSummaries;
+    }
+
+    @Override
     public ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
     {
         ImportSummary importSummary = new ImportSummary();

=== 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-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java	2015-06-08 03:02:05 +0000
@@ -169,15 +169,8 @@
             }
         }
 
-        for ( TrackedEntityInstance trackedEntityInstance : create.getTrackedEntityInstances() )
-        {
-            importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
-        }
-
-        for ( TrackedEntityInstance trackedEntityInstance : update.getTrackedEntityInstances() )
-        {
-            importSummaries.addImportSummary( updateTrackedEntityInstance( trackedEntityInstance ) );
-        }
+        importSummaries.addImportSummaries( addTrackedEntityInstances( create.getTrackedEntityInstances() ) );
+        importSummaries.addImportSummaries( updateTrackedEntityInstances( update.getTrackedEntityInstances() ) );
 
         return importSummaries;
     }

=== 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-02-24 03:57:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java	2015-06-08 03:02:05 +0000
@@ -34,6 +34,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -58,6 +59,8 @@
 
     ImportSummaries addTrackedEntityInstanceJson( InputStream inputStream, ImportStrategy strategy ) throws IOException;
 
+    ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances );
+
     ImportSummary addTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
 
     // -------------------------------------------------------------------------
@@ -68,6 +71,8 @@
 
     ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream ) throws IOException;
 
+    ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances );
+
     ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummaries.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummaries.java	2015-02-20 12:35:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummaries.java	2015-06-08 03:02:05 +0000
@@ -40,7 +40,7 @@
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-@JacksonXmlRootElement(localName = "importSummaries", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "importSummaries", namespace = DxfNamespaces.DXF_2_0 )
 public class ImportSummaries
 {
     private int imported;
@@ -55,6 +55,14 @@
     {
     }
 
+    public void addImportSummaries( ImportSummaries importSummaries )
+    {
+        for ( ImportSummary importSummary : importSummaries.getImportSummaries() )
+        {
+            addImportSummary( importSummary );
+        }
+    }
+
     public ImportSummaries addImportSummary( ImportSummary importSummary )
     {
         if ( importSummary.getImportCount() != null )
@@ -65,7 +73,7 @@
         }
 
         importSummaries.add( importSummary );
-        
+
         return this;
     }
 
@@ -83,21 +91,21 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public int getImported()
     {
         return imported;
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public int getUpdated()
     {
         return updated;
     }
 
     @JsonProperty
-    @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public int getIgnored()
     {
         return ignored;