← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17828: various importer fixes

 

------------------------------------------------------------
revno: 17828
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-12-29 15:05:40 +0100
message:
  various importer fixes
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.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/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2014-12-29 13:13:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2014-12-29 14:05:40 +0000
@@ -282,7 +282,7 @@
 
     @Override
     @JsonProperty
-    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } )
+    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     @PropertyRange( min = 8, max = 8 )
     public String getPublicAccess()
@@ -297,7 +297,7 @@
 
     @Override
     @JsonProperty
-    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } )
+    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean getExternalAccess()
     {
@@ -311,7 +311,7 @@
 
     @Override
     @JsonProperty
-    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } )
+    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public User getUser()
@@ -326,7 +326,7 @@
 
     @Override
     @JsonProperty
-    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } )
+    @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
     @JacksonXmlElementWrapper( localName = "userGroupAccesses", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "userGroupAccess", namespace = DxfNamespaces.DXF_2_0 )
     public Set<UserGroupAccess> getUserGroupAccesses()

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2014-11-30 06:08:12 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2014-12-29 14:05:40 +0000
@@ -32,6 +32,8 @@
 import com.google.common.collect.Maps;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.common.AuditLogUtil;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.IdentifiableProperty;
@@ -42,6 +44,7 @@
 import org.hisp.dhis.system.deletion.DeletionManager;
 import org.hisp.dhis.system.timer.SystemTimer;
 import org.hisp.dhis.system.timer.Timer;
+import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserService;
@@ -83,6 +86,12 @@
     @Autowired
     private SchemaService schemaService;
 
+    @Autowired
+    private SessionFactory sessionFactory;
+
+    @Autowired
+    private CurrentUserService currentUserService;
+
     //-------------------------------------------------------------------------------------------------------
     // Internal and Semi-Public maps
     //-------------------------------------------------------------------------------------------------------
@@ -299,7 +308,8 @@
         {
             if ( writeEnabled )
             {
-                manager.update( (IdentifiableObject) object );
+                AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_UPDATE );
+                sessionFactory.getCurrentSession().update( object );
             }
 
             _updateInternalMaps( object, false );
@@ -318,7 +328,8 @@
             if ( writeEnabled )
             {
                 deletionManager.execute( object );
-                manager.delete( (IdentifiableObject) object );
+                AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_DELETE );
+                sessionFactory.getCurrentSession().delete( object );
             }
 
             _updateInternalMaps( object, true );

=== 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-12-19 15:42:38 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-12-29 14:05:40 +0000
@@ -896,7 +896,7 @@
             saveDataElementOperands( object, "compulsoryDataElementOperands", compulsoryDataElementOperands );
             saveDataElementOperands( object, "greyedFields", greyedFields );
             saveDataElementOperands( object, "dataElementOperands", dataElementOperands );
-            saveProgramStageDataElements( object, programStageDataElements );
+            // saveProgramStageDataElements( object, programStageDataElements );
             saveProgramTrackedEntityAttributes( object, programTrackedEntityAttributes );
             saveCategoryDimensions( object, categoryDimensions );
         }
@@ -1184,7 +1184,7 @@
             {
                 Map<Field, Object> identifiableObjects = detachFields( programTrackedEntityAttribute );
                 reattachFields( programTrackedEntityAttribute, identifiableObjects );
-                sessionFactory.getCurrentSession().persist( programTrackedEntityAttribute );
+                sessionFactory.getCurrentSession().save( programTrackedEntityAttribute );
             }
 
             ReflectionUtils.invokeSetterMethod( "programAttributes", object, programTrackedEntityAttributes );