← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13211: minor deletion fix

 

------------------------------------------------------------
revno: 13211
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-12 15:44:41 +0100
message:
  minor deletion fix
modified:
  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-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	2013-12-12 13:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2013-12-12 14:44:41 +0000
@@ -54,6 +54,7 @@
 import org.hisp.dhis.expression.Expression;
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.importexport.ImportStrategy;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
@@ -163,7 +164,12 @@
                 deleteExpression( object, "leftSide" );
                 deleteExpression( object, "rightSide" );
                 deleteDataEntryForm( object, "dataEntryForm" );
-                // deleteDataElementOperands( object, "compulsoryDataElementOperands" );
+
+                if ( ImportStrategy.DELETES.equals( options.getImportStrategy() ) )
+                {
+                    deleteDataElementOperands( object, "compulsoryDataElementOperands" );
+                }
+
                 deleteDataElementOperands( object, "greyedFields" );
             }
         }
@@ -419,8 +425,19 @@
 
         log.debug( "Trying to delete object => " + ImportUtils.getDisplayName( persistedObject ) + " (" + persistedObject.getClass().getSimpleName() + ")" );
 
+        persistedObject.setUser( null );
+        NonIdentifiableObjects nonIdentifiableObjects = new NonIdentifiableObjects();
+        nonIdentifiableObjects.delete( persistedObject );
+
+        Map<Field, Object> fields = detachFields( persistedObject );
+        Map<Field, Collection<Object>> collectionFields = detachCollectionFields( persistedObject );
+
+        sessionFactory.getCurrentSession().flush();
+
         objectBridge.deleteObject( persistedObject );
 
+        sessionFactory.getCurrentSession().flush();
+
         log.debug( "Delete successful." );
 
         return true;
@@ -707,8 +724,6 @@
         }
         else if ( ImportStrategy.DELETES.equals( options.getImportStrategy() ) )
         {
-            sessionFactory.getCurrentSession().flush();
-
             if ( deleteObject( user, persistedObject ) )
             {
                 summaryType.incrementDeleted();