=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2014-04-02 11:36:07 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2014-05-28 12:38:13 +0000 @@ -28,7 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.google.common.collect.Lists; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.SessionFactory; @@ -38,6 +37,8 @@ import org.hisp.dhis.dxf2.timer.Timer; import org.hisp.dhis.importexport.ImportStrategy; import org.hisp.dhis.scheduling.TaskId; +import org.hisp.dhis.schema.Schema; +import org.hisp.dhis.schema.SchemaService; import org.hisp.dhis.system.notification.NotificationLevel; import org.hisp.dhis.system.notification.Notifier; import org.hisp.dhis.system.util.ReflectionUtils; @@ -69,7 +70,7 @@ // Dependencies //------------------------------------------------------------------------------------------------------- - @Autowired( required = false ) + @Autowired(required = false) private Set importerClasses = new HashSet(); @Autowired @@ -87,6 +88,9 @@ @Autowired private Notifier notifier; + @Autowired + private SchemaService schemaService; + //------------------------------------------------------------------------------------------------------- // ImportService Implementation //------------------------------------------------------------------------------------------------------- @@ -148,20 +152,9 @@ objectBridge.setPreheatCache( importOptions.isPreheatCache() ); objectBridge.init(); - List types; - - if ( importOptions.getImportStrategy().isDelete() ) - { - types = Lists.reverse( Lists.newArrayList( ExchangeClasses.getDeletableMap().values() ) ); - } - else - { - types = Lists.newArrayList( ExchangeClasses.getImportMap().values() ); - } - - for ( String type : types ) - { - Object value = ReflectionUtils.invokeGetterMethod( type, metaData ); + for ( Schema schema : schemaService.getMetadataSchemas() ) + { + Object value = ReflectionUtils.invokeGetterMethod( schema.getPlural(), metaData ); if ( value != null ) { @@ -171,7 +164,7 @@ if ( !objects.isEmpty() ) { - String message = "Importing " + objects.size() + " " + StringUtils.capitalize( type ); + String message = "Importing " + objects.size() + " " + StringUtils.capitalize( schema.getPlural() ); if ( taskId != null ) { @@ -193,12 +186,12 @@ } else { - log.warn( "Getter for '" + type + "' did not return a collection." ); + log.warn( "Getter for '" + schema.getPlural() + "' did not return a collection." ); } } else { - log.warn( "Can not find getter for '" + type + "'." ); + log.warn( "Can not find getter for '" + schema.getPlural() + "'." ); } }