dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43891
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22261: minor fixes to dxf2 importer
------------------------------------------------------------
revno: 22261
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2016-03-12 19:20:28 +0700
message:
minor fixes to 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/FlushMode.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
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundle.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleParams.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-11 03:24:27 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/DefaultMetadataImportService.java 2016-03-12 12:20:28 +0000
@@ -106,7 +106,7 @@
params.setPreheatIdentifier( getEnumWithDefault( PreheatIdentifier.class, parameters, "preheatIdentifier", PreheatIdentifier.UID ) );
params.setImportMode( getEnumWithDefault( ImportStrategy.class, parameters, "importMode", ImportStrategy.CREATE_AND_UPDATE ) );
params.setMergeMode( getEnumWithDefault( MergeMode.class, parameters, "mergeMode", MergeMode.MERGE ) );
- params.setFlushMode( getEnumWithDefault( FlushMode.class, parameters, "flushMode", FlushMode.OBJECTS ) );
+ params.setFlushMode( getEnumWithDefault( FlushMode.class, parameters, "flushMode", FlushMode.AUTO ) );
return params;
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/FlushMode.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/FlushMode.java 2016-03-10 11:35:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/FlushMode.java 2016-03-12 12:20:28 +0000
@@ -34,22 +34,12 @@
public enum FlushMode
{
/**
- * Flush for every db write (create, update)
+ * Flush for every db write.
*/
OBJECT,
/**
- * Flush when done with all db writes for a class type
- */
- OBJECTS,
-
- /**
- * Flush when import is done
- */
- DONE,
-
- /**
- * Don't flush (not recommended)
- */
- NONE
+ * Let the importer decide the flushing.
+ */
+ AUTO,
}
=== 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-10 11:35:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/MetadataImportParams.java 2016-03-12 12:20:28 +0000
@@ -60,7 +60,7 @@
private MergeMode mergeMode = MergeMode.MERGE;
- private FlushMode flushMode = FlushMode.OBJECTS;
+ private FlushMode flushMode = FlushMode.AUTO;
private Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> objects = new HashMap<>();
=== 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-12 08:52:42 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-03-12 12:20:28 +0000
@@ -98,7 +98,7 @@
public ObjectBundle create( ObjectBundleParams params )
{
ObjectBundle bundle = new ObjectBundle( params );
- bundle.putObjects( params.getObjects() );
+ bundle.addObjects( params.getObjects() );
if ( params.getUser() == null )
{
@@ -313,7 +313,7 @@
}
}
- session.flush();
+ if ( FlushMode.AUTO == bundle.getFlushMode() ) session.flush();
}
objectBundleHooks.forEach( hook -> hook.postImport( bundle ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundle.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundle.java 2016-03-10 11:35:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundle.java 2016-03-12 12:20:28 +0000
@@ -136,7 +136,7 @@
}
@SuppressWarnings( "unchecked" )
- public <T extends IdentifiableObject> void addObject( T object )
+ public void addObject( IdentifiableObject object )
{
if ( object == null )
{
@@ -149,25 +149,21 @@
}
objects.get( object.getClass() ).add( object );
- preheat.put( preheatIdentifier, object );
+
+ if ( preheat.get( preheatIdentifier, object ) == null )
+ {
+ preheat.put( preheatIdentifier, object );
+ }
}
- public <T extends IdentifiableObject> void addObjects( List<T> objects )
+ public void addObjects( List<IdentifiableObject> objects )
{
objects.forEach( this::addObject );
}
- public void putObjects( Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> objects )
+ public void addObjects( Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> objects )
{
- for ( Class<? extends IdentifiableObject> klass : objects.keySet() )
- {
- if ( !this.objects.containsKey( klass ) )
- {
- this.objects.put( klass, new ArrayList<>() );
- }
-
- this.objects.get( klass ).addAll( objects.get( klass ) );
- }
+ objects.keySet().forEach( klass -> addObjects( objects.get( klass ) ) );
}
public Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> getObjects()
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleParams.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleParams.java 2016-03-10 11:35:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleParams.java 2016-03-12 12:20:28 +0000
@@ -60,7 +60,7 @@
private MergeMode mergeMode = MergeMode.MERGE;
- private FlushMode flushMode = FlushMode.OBJECTS;
+ private FlushMode flushMode = FlushMode.AUTO;
private Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> objects = new HashMap<>();