← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15650: fixes to ProgramStage/ProgramStageDataElement import

 

------------------------------------------------------------
revno: 15650
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-06-12 15:35:43 +0200
message:
  fixes to ProgramStage/ProgramStageDataElement import
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ProgramStageSectionSchemaDescriptor.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.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/ProgramStageDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java	2014-06-12 09:53:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java	2014-06-12 13:35:43 +0000
@@ -155,6 +155,9 @@
         this.compulsory = compulsory;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Integer getSortOrder()
     {
         return sortOrder;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ProgramStageSectionSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ProgramStageSectionSchemaDescriptor.java	2014-05-31 13:18:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ProgramStageSectionSchemaDescriptor.java	2014-06-12 13:35:43 +0000
@@ -105,7 +105,7 @@
     public Schema getSchema()
     {
         Schema schema = new Schema( ProgramStageSection.class, SINGULAR, PLURAL );
-        schema.setOrder( 1470 );
+        schema.setOrder( 1511 );
 
         return schema;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-06-12 10:39:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-06-12 13:35:43 +0000
@@ -126,7 +126,7 @@
     @Autowired
     private SchemaService schemaService;
 
-    @Autowired(required = false)
+    @Autowired( required = false )
     private List<ObjectHandler<T>> objectHandlers;
 
     //-------------------------------------------------------------------------------------------------------
@@ -486,6 +486,9 @@
                 return;
             }
 
+            Collection<ProgramStageDataElement> programStageDataElementCollection =
+                ReflectionUtils.newCollectionInstance( programStageDataElements.getClass() );
+
             for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
             {
                 Map<Field, Object> identifiableObjects = detachFields( programStageDataElement );
@@ -496,10 +499,19 @@
                     programStageDataElement.setProgramStage( (ProgramStage) object );
                 }
 
-                programStageDataElementService.addProgramStageDataElement( programStageDataElement );
+                ProgramStageDataElement persisted = programStageDataElementService.get( programStageDataElement.getProgramStage(), programStageDataElement.getDataElement() );
+
+                if ( persisted == null )
+                {
+                    programStageDataElementService.addProgramStageDataElement( programStageDataElement );
+                }
+                else
+                {
+                    programStageDataElementCollection.add( persisted );
+                }
             }
 
-            ReflectionUtils.invokeSetterMethod( "programStageDataElements", object, programStageDataElements );
+            ReflectionUtils.invokeSetterMethod( "programStageDataElements", object, programStageDataElementCollection );
         }
 
         private void deleteProgramStageDataElements( T object )
@@ -598,7 +610,7 @@
 
         reattachFields( object, fields );
 
-        log.warn( "Trying to save new object => " + ImportUtils.getDisplayName( object ) + " (" + object.getClass().getSimpleName() + ")" );
+        log.debug( "Trying to save new object => " + ImportUtils.getDisplayName( object ) + " (" + object.getClass().getSimpleName() + ")" );
         objectBridge.saveObject( object );
 
         updatePeriodTypes( object );