=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java 2012-04-05 10:12:35 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java 2012-04-05 10:23:52 +0000 @@ -106,17 +106,6 @@ // Importer Implementation //------------------------------------------------------------------------------------------------------- - private void reset( Object type ) - { - imports = 0; - updates = 0; - ignores = 0; - - uidMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.UID ); - nameMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.NAME ); - codeMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.CODE ); - } - @Override public List importCollection( List objects, ImportOptions options ) { @@ -152,18 +141,6 @@ return importObjectLocal( object, options ); } - private ImportConflict importObjectLocal( T object, ImportOptions options ) - { - ImportConflict conflict = validateIdentifiableObject( object, options ); - - if ( conflict == null ) - { - conflict = startImport( object, options ); - } - - return conflict; - } - @Override public ImportCount getCurrentImportCount() { @@ -177,9 +154,32 @@ } //------------------------------------------------------------------------------------------------------- - // Helpers + // Internal methods //------------------------------------------------------------------------------------------------------- + private void reset( Object type ) + { + imports = 0; + updates = 0; + ignores = 0; + + uidMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.UID ); + nameMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.NAME ); + codeMap = manager.getIdMap( (Class) type.getClass(), IdentifiableObject.IdentifiableProperty.CODE ); + } + + private ImportConflict importObjectLocal( T object, ImportOptions options ) + { + ImportConflict conflict = validateIdentifiableObject( object, options ); + + if ( conflict == null ) + { + conflict = startImport( object, options ); + } + + return conflict; + } + private ImportConflict startImport( T object, ImportOptions options ) { T oldObject = getObject( object, options.getIdScheme() ); @@ -313,6 +313,10 @@ } } + //------------------------------------------------------------------------------------------------------- + // Protected methods + //------------------------------------------------------------------------------------------------------- + /** * Try to get a usable display based on current idScheme, mainly used for error-reporting * but can also be use elsewhere. Falls back to the name of the class, if no other alternative @@ -353,20 +357,4 @@ { return CodeGenerator.generateCode(); } - - protected void mergeIdentifiableObject( BaseIdentifiableObject target, BaseIdentifiableObject source ) - { - target.setId( source.getId() ); - target.setUid( source.getUid() ); - target.setName( source.getName() ); - target.setCode( source.getCode() ); - } - - protected void mergeNameableObject( BaseNameableObject target, BaseNameableObject source ) - { - mergeIdentifiableObject( target, source ); - - target.setShortName( source.getShortName() ); - target.setDescription( source.getDescription() ); - } }