dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43676
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22138: enable commits in new dxf2 importer
------------------------------------------------------------
revno: 22138
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-03-04 15:58:53 +0700
message:
enable commits in new dxf2 importer
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataImportService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataImportParams.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.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/metadata2/DefaultMetadataImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataImportService.java 2016-03-03 03:59:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataImportService.java 2016-03-04 08:58:53 +0000
@@ -69,11 +69,13 @@
}
ObjectBundleParams bundleParams = params.toObjectBundleParams();
- ObjectBundle objectBundle = objectBundleService.create( bundleParams );
+ ObjectBundle bundle = objectBundleService.create( bundleParams );
- ObjectBundleValidation validation = objectBundleService.validate( objectBundle );
+ ObjectBundleValidation validation = objectBundleService.validate( bundle );
report.setErrorReports( validation.getErrorReports() );
+ objectBundleService.commit( bundle );
+
return report;
}
@@ -81,7 +83,7 @@
public MetadataImportParams getParamsFromMap( Map<String, List<String>> parameters )
{
MetadataImportParams params = new MetadataImportParams();
- params.setObjectBundleMode( getEnumWithDefault( ObjectBundleMode.class, parameters, "objectBundleMode", ObjectBundleMode.VALIDATE ) );
+ params.setObjectBundleMode( getEnumWithDefault( ObjectBundleMode.class, parameters, "objectBundleMode", ObjectBundleMode.COMMIT ) );
params.setPreheatMode( getEnumWithDefault( PreheatMode.class, parameters, "preheatMode", PreheatMode.REFERENCE ) );
params.setPreheatIdentifier( getEnumWithDefault( PreheatIdentifier.class, parameters, "preheatIdentifier", PreheatIdentifier.UID ) );
params.setImportMode( getEnumWithDefault( ImportStrategy.class, parameters, "importMode", ImportStrategy.CREATE_AND_UPDATE ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataImportParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataImportParams.java 2016-03-03 03:59:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataImportParams.java 2016-03-04 08:58:53 +0000
@@ -50,7 +50,7 @@
{
private User user;
- private ObjectBundleMode objectBundleMode = ObjectBundleMode.VALIDATE;
+ private ObjectBundleMode objectBundleMode = ObjectBundleMode.COMMIT;
private PreheatIdentifier preheatIdentifier = PreheatIdentifier.UID;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-03-04 04:07:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-03-04 08:58:53 +0000
@@ -298,6 +298,8 @@
private void handleCreates( List<IdentifiableObject> objects, ObjectBundle bundle )
{
+ log.info( "Creating " + objects.size() + " object of type " + objects.get( 0 ).getClass().getSimpleName() );
+
for ( IdentifiableObject object : objects )
{
if ( Preheat.isDefault( object ) ) continue;
@@ -321,18 +323,21 @@
private void handleUpdates( List<IdentifiableObject> objects, ObjectBundle bundle )
{
+ log.info( "Updating " + objects.size() + " object of type " + objects.get( 0 ).getClass().getSimpleName() );
+
for ( IdentifiableObject object : objects )
{
if ( Preheat.isDefault( object ) ) continue;
+ objectBundleHooks.forEach( hook -> hook.preUpdate( object, bundle ) );
+
+ preheatService.connectReferences( object, bundle.getPreheat(), bundle.getPreheatIdentifier() );
+
IdentifiableObject persistedObject = bundle.getPreheat().get( bundle.getPreheatIdentifier(), object );
persistedObject.mergeWith( object, bundle.getMergeMode() );
persistedObject.mergeSharingWith( object );
- objectBundleHooks.forEach( hook -> hook.preUpdate( persistedObject, bundle ) );
-
- preheatService.connectReferences( persistedObject, bundle.getPreheat(), bundle.getPreheatIdentifier() );
- manager.update( persistedObject, bundle.getUser() );
+ sessionFactory.getCurrentSession().update( persistedObject );
objectBundleHooks.forEach( hook -> hook.postUpdate( persistedObject, bundle ) );
@@ -346,6 +351,8 @@
private void handleDeletes( List<IdentifiableObject> objects, ObjectBundle bundle )
{
+ log.info( "Deleting " + objects.size() + " object of type " + objects.get( 0 ).getClass().getSimpleName() );
+
List<IdentifiableObject> persistedObjects = bundle.getPreheat().getAll( bundle.getPreheatIdentifier(), objects );
for ( IdentifiableObject object : persistedObjects )