← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15474: minor fixes to programStage importer

 

------------------------------------------------------------
revno: 15474
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-05-30 10:45:46 +0200
message:
  minor fixes to programStage importer
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.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-05-26 12:01:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java	2014-05-30 08:45:46 +0000
@@ -199,13 +199,7 @@
 
         ProgramStageDataElement that = (ProgramStageDataElement) o;
 
-        if ( compulsory != that.compulsory ) return false;
-        if ( allowDateInFuture != null ? !allowDateInFuture.equals( that.allowDateInFuture ) : that.allowDateInFuture != null )
-            return false;
-        if ( allowProvidedElsewhere != null ? !allowProvidedElsewhere.equals( that.allowProvidedElsewhere ) : that.allowProvidedElsewhere != null )
-            return false;
         if ( dataElement != null ? !dataElement.equals( that.dataElement ) : that.dataElement != null ) return false;
-        if ( displayInReports != null ? !displayInReports.equals( that.displayInReports ) : that.displayInReports != null ) return false;
         if ( programStage != null ? !programStage.equals( that.programStage ) : that.programStage != null ) return false;
 
         return true;
@@ -216,10 +210,20 @@
     {
         int result = programStage != null ? programStage.hashCode() : 0;
         result = 31 * result + (dataElement != null ? dataElement.hashCode() : 0);
-        result = 31 * result + (compulsory ? 1 : 0);
-        result = 31 * result + (allowProvidedElsewhere != null ? allowProvidedElsewhere.hashCode() : 0);
-        result = 31 * result + (displayInReports != null ? displayInReports.hashCode() : 0);
-        result = 31 * result + (allowDateInFuture != null ? allowDateInFuture.hashCode() : 0);
         return result;
     }
+
+    @Override
+    public String toString()
+    {
+        return "ProgramStageDataElement{" +
+            "programStage=" + programStage +
+            ", dataElement=" + dataElement +
+            ", compulsory=" + compulsory +
+            ", allowProvidedElsewhere=" + allowProvidedElsewhere +
+            ", sortOrder=" + sortOrder +
+            ", displayInReports=" + displayInReports +
+            ", allowDateInFuture=" + allowDateInFuture +
+            '}';
+    }
 }

=== 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-05-28 20:04:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-05-30 08:45:46 +0000
@@ -58,10 +58,9 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageDataElementService;
 import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
-import org.hisp.dhis.program.ProgramTrackedEntityAttributeService;
 import org.hisp.dhis.system.util.CollectionUtils;
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.system.util.functional.Function1;
@@ -465,7 +464,20 @@
 
         private void saveProgramStageDataElements( T object, Set<ProgramStageDataElement> programStageDataElements )
         {
-
+            for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
+            {
+                Map<Field, Object> identifiableObjects = detachFields( programStageDataElement );
+                reattachFields( programStageDataElement, identifiableObjects );
+
+                if ( ProgramStage.class.isAssignableFrom( object.getClass() ) )
+                {
+                    programStageDataElement.setProgramStage( (ProgramStage) object );
+                }
+
+                sessionFactory.getCurrentSession().persist( programStageDataElement );
+            }
+
+            ReflectionUtils.invokeSetterMethod( "programStageDataElements", object, programStageDataElements );
         }
 
         private void deleteProgramStageDataElements( T object )