← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6545: Renamed DXF2 => MetaData. Removed IdScheme for meta-data, now matched in the order uid, code, nam...

 

------------------------------------------------------------
revno: 6545
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-11 18:11:09 +0300
message:
  Renamed DXF2 => MetaData. Removed IdScheme for meta-data, now matched in the order uid, code, name, shortName, alternativeName. AbstractImporter takes into account the uniqueness of NameableObject properties.
removed:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DXF2.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/IdScheme.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractIdentifiableObjectImporter.java
added:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/ConstantImporter.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.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/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-04-07 09:02:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2012-04-11 15:11:09 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+import org.hisp.dhis.common.NameableObject.NameableProperty;
 
 import java.util.Collection;
 import java.util.Map;
@@ -42,13 +43,15 @@
     void update( IdentifiableObject object );
 
     <T extends IdentifiableObject> void get( Class<T> clazz, String uid );
-    
+
     <T extends IdentifiableObject> Collection<T> getAll( Class<T> clazz );
 
     void delete( IdentifiableObject object );
 
     <T extends IdentifiableObject> Map<String, T> getIdMap( Class<T> clazz, IdentifiableProperty property );
 
+    <T extends NameableObject> Map<String, T> getIdMap( Class<T> clazz, NameableProperty property );
+
     <T extends IdentifiableObject> T getObject( Class<T> clazz, IdentifiableProperty property, String id );
 
     IdentifiableObject getObject( String uid, String simpleClassName );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java	2012-04-06 21:31:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObject.java	2012-04-11 15:11:09 +0000
@@ -30,15 +30,20 @@
 public interface NameableObject
     extends IdentifiableObject
 {
-    final String[] I18N_PROPERTIES = { "name", "shortName", "description" };
-            
+    final String[] I18N_PROPERTIES = {"name", "shortName", "description"};
+
+    enum NameableProperty
+    {
+        SHORT_NAME, ALTERNATIVE_NAME
+    }
+
     String getAlternativeName();
 
     String getShortName();
 
     String getDescription();
-    
+
     String getDisplayShortName();
-    
+
     String getDisplayDescription();
 }
\ No newline at end of file

=== removed file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DXF2.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DXF2.java	2012-04-03 10:24:37 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DXF2.java	1970-01-01 00:00:00 +0000
@@ -1,661 +0,0 @@
-package org.hisp.dhis.dxf2.metadata;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.attribute.Attribute;
-import org.hisp.dhis.chart.Chart;
-import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.concept.Concept;
-import org.hisp.dhis.constant.Constant;
-import org.hisp.dhis.datadictionary.DataDictionary;
-import org.hisp.dhis.dataelement.*;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.document.Document;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.mapping.MapLayer;
-import org.hisp.dhis.mapping.MapLegend;
-import org.hisp.dhis.mapping.MapLegendSet;
-import org.hisp.dhis.mapping.MapView;
-import org.hisp.dhis.message.MessageConversation;
-import org.hisp.dhis.option.OptionSet;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.report.Report;
-import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.sqlview.SqlView;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.hisp.dhis.user.UserGroup;
-import org.hisp.dhis.validation.ValidationRule;
-import org.hisp.dhis.validation.ValidationRuleGroup;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "dxf2", namespace = Dxf2Namespace.NAMESPACE )
-public class DXF2
-{
-    private List<Attribute> attributeTypes = new ArrayList<Attribute>();
-
-    private List<User> users = new ArrayList<User>();
-
-    private List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>();
-
-    private List<UserGroup> userGroups = new ArrayList<UserGroup>();
-
-    private List<MessageConversation> messageConversations = new ArrayList<MessageConversation>();
-
-    private List<DataElement> dataElements = new ArrayList<DataElement>();
-
-    private List<OptionSet> optionSets = new ArrayList<OptionSet>();
-
-    private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
-
-    private List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>();
-
-    private List<Concept> concepts = new ArrayList<Concept>();
-
-    private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
-
-    private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
-
-    private List<DataElementCategoryCombo> categoryCombos = new ArrayList<DataElementCategoryCombo>();
-
-    private List<DataElementCategoryOptionCombo> categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
-
-    private List<Indicator> indicators = new ArrayList<Indicator>();
-
-    private List<IndicatorGroup> indicatorGroups = new ArrayList<IndicatorGroup>();
-
-    private List<IndicatorGroupSet> indicatorGroupSets = new ArrayList<IndicatorGroupSet>();
-
-    private List<IndicatorType> indicatorTypes = new ArrayList<IndicatorType>();
-
-    private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-
-    private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
-
-    private List<OrganisationUnitGroupSet> organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>();
-
-    private List<OrganisationUnitLevel> organisationUnitLevels = new ArrayList<OrganisationUnitLevel>();
-
-    private List<DataSet> dataSets = new ArrayList<DataSet>();
-
-    private List<ValidationRule> validationRules = new ArrayList<ValidationRule>();
-
-    private List<ValidationRuleGroup> validationRuleGroups = new ArrayList<ValidationRuleGroup>();
-
-    private List<SqlView> sqlViews = new ArrayList<SqlView>();
-
-    private List<Chart> charts = new ArrayList<Chart>();
-
-    private List<Report> reports = new ArrayList<Report>();
-
-    private List<ReportTable> reportTables = new ArrayList<ReportTable>();
-
-    private List<Document> documents = new ArrayList<Document>();
-
-    private List<Constant> constants = new ArrayList<Constant>();
-
-    private List<MapView> maps = new ArrayList<MapView>();
-
-    private List<MapLegend> mapLegends = new ArrayList<MapLegend>();
-
-    private List<MapLegendSet> mapLegendSets = new ArrayList<MapLegendSet>();
-
-    private List<MapLayer> mapLayers = new ArrayList<MapLayer>();
-
-    private List<DataDictionary> dataDictionaries = new ArrayList<DataDictionary>();
-
-    public DXF2()
-    {
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "attributeTypes", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "attributeType", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Attribute> getAttributeTypes()
-    {
-        return attributeTypes;
-    }
-
-    public void setAttributeTypes( List<Attribute> attributeTypes )
-    {
-        this.attributeTypes = attributeTypes;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "users", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "user", namespace = Dxf2Namespace.NAMESPACE )
-    public List<User> getUsers()
-    {
-        return users;
-    }
-
-    public void setUsers( List<User> users )
-    {
-        this.users = users;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "userAuthorityGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "userAuthorityGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<UserAuthorityGroup> getUserAuthorityGroups()
-    {
-        return userAuthorityGroups;
-    }
-
-    public void setUserAuthorityGroups( List<UserAuthorityGroup> userAuthorityGroups )
-    {
-        this.userAuthorityGroups = userAuthorityGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "userGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "userGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<UserGroup> getUserGroups()
-    {
-        return userGroups;
-    }
-
-    public void setUserGroups( List<UserGroup> userGroups )
-    {
-        this.userGroups = userGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "messageConversations", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "messageConversation", namespace = Dxf2Namespace.NAMESPACE )
-    public List<MessageConversation> getMessageConversations()
-    {
-        return messageConversations;
-    }
-
-    public void setMessageConversations( List<MessageConversation> messageConversations )
-    {
-        this.messageConversations = messageConversations;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "dataElements", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataElement", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-
-    public void setDataElements( List<DataElement> dataElements )
-    {
-        this.dataElements = dataElements;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "optionSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "optionSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<OptionSet> getOptionSets()
-    {
-        return optionSets;
-    }
-
-    public void setOptionSets( List<OptionSet> optionSets )
-    {
-        this.optionSets = optionSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataElementGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
-
-    public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
-    {
-        this.dataElementGroups = dataElementGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "dataElementGroupSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataElementGroupSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementGroupSet> getDataElementGroupSets()
-    {
-        return dataElementGroupSets;
-    }
-
-    public void setDataElementGroupSets( List<DataElementGroupSet> dataElementGroupSets )
-    {
-        this.dataElementGroupSets = dataElementGroupSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "concepts", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "concept", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Concept> getConcepts()
-    {
-        return concepts;
-    }
-
-    public void setConcepts( List<Concept> concepts )
-    {
-        this.concepts = concepts;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "categories", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "category", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementCategory> getCategories()
-    {
-        return categories;
-    }
-
-    public void setCategories( List<DataElementCategory> categories )
-    {
-        this.categories = categories;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "categoryOptions", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "categoryOption", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementCategoryOption> getCategoryOptions()
-    {
-        return categoryOptions;
-    }
-
-    public void setCategoryOptions( List<DataElementCategoryOption> categoryOptions )
-    {
-        this.categoryOptions = categoryOptions;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "categoryCombos", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "categoryCombo", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementCategoryCombo> getCategoryCombos()
-    {
-        return categoryCombos;
-    }
-
-    public void setCategoryCombos( List<DataElementCategoryCombo> categoryCombos )
-    {
-        this.categoryCombos = categoryCombos;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "categoryOptionCombos", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "categoryOptionCombo", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataElementCategoryOptionCombo> getCategoryOptionCombos()
-    {
-        return categoryOptionCombos;
-    }
-
-    public void setCategoryOptionCombos( List<DataElementCategoryOptionCombo> categoryOptionCombos )
-    {
-        this.categoryOptionCombos = categoryOptionCombos;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "indicators", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "indicator", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Indicator> getIndicators()
-    {
-        return indicators;
-    }
-
-    public void setIndicators( List<Indicator> indicators )
-    {
-        this.indicators = indicators;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "indicatorGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "indicatorGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<IndicatorGroup> getIndicatorGroups()
-    {
-        return indicatorGroups;
-    }
-
-    public void setIndicatorGroups( List<IndicatorGroup> indicatorGroups )
-    {
-        this.indicatorGroups = indicatorGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "indicatorGroupSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "indicatorGroupSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<IndicatorGroupSet> getIndicatorGroupSets()
-    {
-        return indicatorGroupSets;
-    }
-
-    public void setIndicatorGroupSets( List<IndicatorGroupSet> indicatorGroupSets )
-    {
-        this.indicatorGroupSets = indicatorGroupSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "indicatorTypes", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "indicatorType", namespace = Dxf2Namespace.NAMESPACE )
-    public List<IndicatorType> getIndicatorTypes()
-    {
-        return indicatorTypes;
-    }
-
-    public void setIndicatorTypes( List<IndicatorType> indicatorTypes )
-    {
-        this.indicatorTypes = indicatorTypes;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "organisationUnit", namespace = Dxf2Namespace.NAMESPACE )
-    public List<OrganisationUnit> getOrganisationUnits()
-    {
-        return organisationUnits;
-    }
-
-    public void setOrganisationUnits( List<OrganisationUnit> organisationUnits )
-    {
-        this.organisationUnits = organisationUnits;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<OrganisationUnitGroup> getOrganisationUnitGroups()
-    {
-        return organisationUnitGroups;
-    }
-
-    public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
-    {
-        this.organisationUnitGroups = organisationUnitGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "organisationUnitGroupSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "organisationUnitGroupSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
-    {
-        return organisationUnitGroupSets;
-    }
-
-    public void setOrganisationUnitGroupSets( List<OrganisationUnitGroupSet> organisationUnitGroupSets )
-    {
-        this.organisationUnitGroupSets = organisationUnitGroupSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "organisationUnitLevel", namespace = Dxf2Namespace.NAMESPACE )
-    public List<OrganisationUnitLevel> getOrganisationUnitLevels()
-    {
-        return organisationUnitLevels;
-    }
-
-    public void setOrganisationUnitLevels( List<OrganisationUnitLevel> organisationUnitLevels )
-    {
-        this.organisationUnitLevels = organisationUnitLevels;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "dataSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataSet> getDataSets()
-    {
-        return dataSets;
-    }
-
-    public void setDataSets( List<DataSet> dataSets )
-    {
-        this.dataSets = dataSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "validationRules", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "validationRule", namespace = Dxf2Namespace.NAMESPACE )
-    public List<ValidationRule> getValidationRules()
-    {
-        return validationRules;
-    }
-
-    public void setValidationRules( List<ValidationRule> validationRules )
-    {
-        this.validationRules = validationRules;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "validationRuleGroups", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "validationRuleGroup", namespace = Dxf2Namespace.NAMESPACE )
-    public List<ValidationRuleGroup> getValidationRuleGroups()
-    {
-        return validationRuleGroups;
-    }
-
-    public void setValidationRuleGroups( List<ValidationRuleGroup> validationRuleGroups )
-    {
-        this.validationRuleGroups = validationRuleGroups;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "sqlViews", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "sqlView", namespace = Dxf2Namespace.NAMESPACE )
-    public List<SqlView> getSqlViews()
-    {
-        return sqlViews;
-    }
-
-    public void setSqlViews( List<SqlView> sqlViews )
-    {
-        this.sqlViews = sqlViews;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "charts", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "chart", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Chart> getCharts()
-    {
-        return charts;
-    }
-
-    public void setCharts( List<Chart> charts )
-    {
-        this.charts = charts;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "reports", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "report", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Report> getReports()
-    {
-        return reports;
-    }
-
-    public void setReports( List<Report> reports )
-    {
-        this.reports = reports;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "reportTables", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "reportTable", namespace = Dxf2Namespace.NAMESPACE )
-    public List<ReportTable> getReportTables()
-    {
-        return reportTables;
-    }
-
-    public void setReportTables( List<ReportTable> reportTables )
-    {
-        this.reportTables = reportTables;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "documents", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "document", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Document> getDocuments()
-    {
-        return documents;
-    }
-
-    public void setDocuments( List<Document> documents )
-    {
-        this.documents = documents;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "constants", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "constant", namespace = Dxf2Namespace.NAMESPACE )
-    public List<Constant> getConstants()
-    {
-        return constants;
-    }
-
-    public void setConstants( List<Constant> constants )
-    {
-        this.constants = constants;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "maps", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "map", namespace = Dxf2Namespace.NAMESPACE )
-    public List<MapView> getMaps()
-    {
-        return maps;
-    }
-
-    public void setMaps( List<MapView> maps )
-    {
-        this.maps = maps;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "mapLegends", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "mapLegend", namespace = Dxf2Namespace.NAMESPACE )
-    public List<MapLegend> getMapLegends()
-    {
-        return mapLegends;
-    }
-
-    public void setMapLegends( List<MapLegend> mapLegends )
-    {
-        this.mapLegends = mapLegends;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "mapLegendSets", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "mapLegendSet", namespace = Dxf2Namespace.NAMESPACE )
-    public List<MapLegendSet> getMapLegendSets()
-    {
-        return mapLegendSets;
-    }
-
-    public void setMapLegendSets( List<MapLegendSet> mapLegendSets )
-    {
-        this.mapLegendSets = mapLegendSets;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "mapLayers", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "mapLayer", namespace = Dxf2Namespace.NAMESPACE )
-    public List<MapLayer> getMapLayers()
-    {
-        return mapLayers;
-    }
-
-    public void setMapLayers( List<MapLayer> mapLayers )
-    {
-        this.mapLayers = mapLayers;
-    }
-
-    @JsonProperty
-    @JacksonXmlElementWrapper( localName = "dataDictionaries", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataDictionary", namespace = Dxf2Namespace.NAMESPACE )
-    public List<DataDictionary> getDataDictionaries()
-    {
-        return dataDictionaries;
-    }
-
-    public void setDataDictionaries( List<DataDictionary> dataDictionaries )
-    {
-        this.dataDictionaries = dataDictionaries;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "DXF2{" +
-            "attributeTypes=" + attributeTypes.size() +
-            ", users=" + users.size() +
-            ", userAuthorityGroups=" + userAuthorityGroups.size() +
-            ", userGroups=" + userGroups.size() +
-            ", messageConversations=" + messageConversations.size() +
-            ", dataElements=" + dataElements.size() +
-            ", optionSets=" + optionSets.size() +
-            ", dataElementGroups=" + dataElementGroups.size() +
-            ", dataElementGroupSets=" + dataElementGroupSets.size() +
-            ", concepts=" + concepts.size() +
-            ", categories=" + categories.size() +
-            ", categoryOptions=" + categoryOptions.size() +
-            ", categoryCombos=" + categoryCombos.size() +
-            ", categoryOptionCombos=" + categoryOptionCombos.size() +
-            ", indicators=" + indicators.size() +
-            ", indicatorGroups=" + indicatorGroups.size() +
-            ", indicatorGroupSets=" + indicatorGroupSets.size() +
-            ", indicatorTypes=" + indicatorTypes.size() +
-            ", organisationUnits=" + organisationUnits.size() +
-            ", organisationUnitGroups=" + organisationUnitGroups.size() +
-            ", organisationUnitGroupSets=" + organisationUnitGroupSets.size() +
-            ", organisationUnitLevels=" + organisationUnitLevels.size() +
-            ", dataSets=" + dataSets.size() +
-            ", validationRules=" + validationRules.size() +
-            ", validationRuleGroups=" + validationRuleGroups.size() +
-            ", sqlViews=" + sqlViews.size() +
-            ", charts=" + charts.size() +
-            ", reports=" + reports.size() +
-            ", reportTables=" + reportTables.size() +
-            ", documents=" + documents.size() +
-            ", constants=" + constants.size() +
-            ", maps=" + maps.size() +
-            ", mapLegends=" + mapLegends.size() +
-            ", mapLegendSets=" + mapLegendSets.size() +
-            ", mapLayers=" + mapLayers.size() +
-            ", dataDictionaries=" + dataDictionaries.size() +
-            '}';
-    }
-}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-04-07 09:02:05 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-04-11 15:11:09 +0000
@@ -79,15 +79,15 @@
     protected IdentifiableObjectManager manager;
 
     @Override
-    public DXF2 getMetaData()
+    public MetaData getMetaData()
     {
         return getMetaData( ExportOptions.getDefaultExportOptions() );
     }
 
     @Override
-    public DXF2 getMetaData( ExportOptions exportOptions )
+    public MetaData getMetaData( ExportOptions exportOptions )
     {
-        DXF2 dxf2 = new DXF2();
+        MetaData dxf2 = new MetaData();
 
         if ( exportOptions.isAttributeTypes() )
         {

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-07 12:36:39 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-11 15:11:09 +0000
@@ -98,13 +98,13 @@
     //-------------------------------------------------------------------------------------------------------
 
     @Override
-    public ImportSummary importDxf2( DXF2 dxf2 )
+    public ImportSummary importDxf2( MetaData dxf2 )
     {
         return importDxf2( dxf2, ImportOptions.getDefaultImportOptions() );
     }
 
     @Override
-    public ImportSummary importDxf2( DXF2 dxf2, ImportOptions importOptions )
+    public ImportSummary importDxf2( MetaData dxf2, ImportOptions importOptions )
     {
         ImportSummary importSummary = new ImportSummary();
 

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java	2012-04-07 09:02:05 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ExportService.java	2012-04-11 15:11:09 +0000
@@ -32,7 +32,7 @@
  */
 public interface ExportService
 {
-    DXF2 getMetaData();
+    MetaData getMetaData();
 
-    DXF2 getMetaData( ExportOptions options );
+    MetaData getMetaData( ExportOptions options );
 }

=== removed file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/IdScheme.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/IdScheme.java	2012-04-07 08:07:14 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/IdScheme.java	1970-01-01 00:00:00 +0000
@@ -1,89 +0,0 @@
-package org.hisp.dhis.dxf2.metadata;
-
-/*
- * Copyright (c) 2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class IdScheme
-{
-    public static final String UID_SCHEME = "uid";
-    public static final String CODE_SCHEME = "code";
-    public static final String NAME_SCHEME = "name";
-
-    private String scheme;
-
-    private boolean uidScheme;
-
-    private boolean codeScheme;
-
-    private boolean nameScheme;
-
-    public static IdScheme getDefaultIdScheme()
-    {
-        return new IdScheme( IdScheme.UID_SCHEME );
-    }
-
-    public IdScheme( String scheme )
-    {
-        setScheme( scheme );
-    }
-
-    public String getScheme()
-    {
-        return scheme;
-    }
-
-    public void setScheme( String scheme )
-    {
-        this.scheme = scheme;
-
-        if ( scheme != null )
-        {
-            uidScheme = scheme.equals( IdScheme.UID_SCHEME );
-            nameScheme = scheme.equals( IdScheme.NAME_SCHEME );
-            codeScheme = scheme.equals( IdScheme.CODE_SCHEME );
-        }
-    }
-
-    public boolean isUidScheme()
-    {
-        return uidScheme;
-    }
-
-    public boolean isNameScheme()
-    {
-        return nameScheme;
-    }
-
-    public boolean isCodeScheme()
-    {
-        return codeScheme;
-    }
-}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java	2012-04-02 17:23:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java	2012-04-11 15:11:09 +0000
@@ -35,12 +35,9 @@
 {
     private boolean dryRun = false;
 
-    private IdScheme idScheme = IdScheme.getDefaultIdScheme();
-
     private ImportStrategy importStrategy;
 
-    private static ImportOptions defaultImportOptions = new ImportOptions( IdScheme.getDefaultIdScheme(),
-        ImportStrategy.getDefaultImportStrategy() );
+    private static ImportOptions defaultImportOptions = new ImportOptions( ImportStrategy.getDefaultImportStrategy() );
 
     public static ImportOptions getDefaultImportOptions()
     {
@@ -49,13 +46,11 @@
 
     public ImportOptions()
     {
-        this.idScheme = IdScheme.getDefaultIdScheme();
         this.importStrategy = ImportStrategy.getDefaultImportStrategy();
     }
 
-    public ImportOptions( IdScheme idScheme, ImportStrategy importStrategy )
+    public ImportOptions( ImportStrategy importStrategy )
     {
-        this.idScheme = idScheme;
         this.importStrategy = importStrategy;
     }
 
@@ -69,16 +64,6 @@
         this.dryRun = dryRun;
     }
 
-    public IdScheme getIdScheme()
-    {
-        return idScheme;
-    }
-
-    public void setIdScheme( IdScheme idScheme )
-    {
-        this.idScheme = idScheme;
-    }
-
     public ImportStrategy getImportStrategy()
     {
         return importStrategy;

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportService.java	2012-04-07 09:22:54 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportService.java	2012-04-11 15:11:09 +0000
@@ -36,7 +36,7 @@
 @Service
 public interface ImportService
 {
-    ImportSummary importDxf2( DXF2 dxf2 );
+    ImportSummary importDxf2( MetaData dxf2 );
 
-    ImportSummary importDxf2( DXF2 dxf2, ImportOptions importOptions );
+    ImportSummary importDxf2( MetaData dxf2, ImportOptions importOptions );
 }

=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java	2012-04-11 15:11:09 +0000
@@ -0,0 +1,661 @@
+package org.hisp.dhis.dxf2.metadata;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.datadictionary.DataDictionary;
+import org.hisp.dhis.dataelement.*;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.document.Document;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.mapping.MapLayer;
+import org.hisp.dhis.mapping.MapLegend;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.message.MessageConversation;
+import org.hisp.dhis.option.OptionSet;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.report.Report;
+import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.sqlview.SqlView;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserAuthorityGroup;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.validation.ValidationRule;
+import org.hisp.dhis.validation.ValidationRuleGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "metaData", namespace = Dxf2Namespace.NAMESPACE )
+public class MetaData
+{
+    private List<Attribute> attributeTypes = new ArrayList<Attribute>();
+
+    private List<User> users = new ArrayList<User>();
+
+    private List<UserAuthorityGroup> userAuthorityGroups = new ArrayList<UserAuthorityGroup>();
+
+    private List<UserGroup> userGroups = new ArrayList<UserGroup>();
+
+    private List<MessageConversation> messageConversations = new ArrayList<MessageConversation>();
+
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
+
+    private List<OptionSet> optionSets = new ArrayList<OptionSet>();
+
+    private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
+
+    private List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>();
+
+    private List<Concept> concepts = new ArrayList<Concept>();
+
+    private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
+
+    private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
+
+    private List<DataElementCategoryCombo> categoryCombos = new ArrayList<DataElementCategoryCombo>();
+
+    private List<DataElementCategoryOptionCombo> categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+
+    private List<Indicator> indicators = new ArrayList<Indicator>();
+
+    private List<IndicatorGroup> indicatorGroups = new ArrayList<IndicatorGroup>();
+
+    private List<IndicatorGroupSet> indicatorGroupSets = new ArrayList<IndicatorGroupSet>();
+
+    private List<IndicatorType> indicatorTypes = new ArrayList<IndicatorType>();
+
+    private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
+
+    private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+
+    private List<OrganisationUnitGroupSet> organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>();
+
+    private List<OrganisationUnitLevel> organisationUnitLevels = new ArrayList<OrganisationUnitLevel>();
+
+    private List<DataSet> dataSets = new ArrayList<DataSet>();
+
+    private List<ValidationRule> validationRules = new ArrayList<ValidationRule>();
+
+    private List<ValidationRuleGroup> validationRuleGroups = new ArrayList<ValidationRuleGroup>();
+
+    private List<SqlView> sqlViews = new ArrayList<SqlView>();
+
+    private List<Chart> charts = new ArrayList<Chart>();
+
+    private List<Report> reports = new ArrayList<Report>();
+
+    private List<ReportTable> reportTables = new ArrayList<ReportTable>();
+
+    private List<Document> documents = new ArrayList<Document>();
+
+    private List<Constant> constants = new ArrayList<Constant>();
+
+    private List<MapView> maps = new ArrayList<MapView>();
+
+    private List<MapLegend> mapLegends = new ArrayList<MapLegend>();
+
+    private List<MapLegendSet> mapLegendSets = new ArrayList<MapLegendSet>();
+
+    private List<MapLayer> mapLayers = new ArrayList<MapLayer>();
+
+    private List<DataDictionary> dataDictionaries = new ArrayList<DataDictionary>();
+
+    public MetaData()
+    {
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "attributeTypes", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "attributeType", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Attribute> getAttributeTypes()
+    {
+        return attributeTypes;
+    }
+
+    public void setAttributeTypes( List<Attribute> attributeTypes )
+    {
+        this.attributeTypes = attributeTypes;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "users", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "user", namespace = Dxf2Namespace.NAMESPACE )
+    public List<User> getUsers()
+    {
+        return users;
+    }
+
+    public void setUsers( List<User> users )
+    {
+        this.users = users;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "userAuthorityGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "userAuthorityGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<UserAuthorityGroup> getUserAuthorityGroups()
+    {
+        return userAuthorityGroups;
+    }
+
+    public void setUserAuthorityGroups( List<UserAuthorityGroup> userAuthorityGroups )
+    {
+        this.userAuthorityGroups = userAuthorityGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "userGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "userGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<UserGroup> getUserGroups()
+    {
+        return userGroups;
+    }
+
+    public void setUserGroups( List<UserGroup> userGroups )
+    {
+        this.userGroups = userGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "messageConversations", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "messageConversation", namespace = Dxf2Namespace.NAMESPACE )
+    public List<MessageConversation> getMessageConversations()
+    {
+        return messageConversations;
+    }
+
+    public void setMessageConversations( List<MessageConversation> messageConversations )
+    {
+        this.messageConversations = messageConversations;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "dataElements", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "dataElement", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElement> getDataElements()
+    {
+        return dataElements;
+    }
+
+    public void setDataElements( List<DataElement> dataElements )
+    {
+        this.dataElements = dataElements;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "optionSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "optionSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<OptionSet> getOptionSets()
+    {
+        return optionSets;
+    }
+
+    public void setOptionSets( List<OptionSet> optionSets )
+    {
+        this.optionSets = optionSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "dataElementGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementGroup> getDataElementGroups()
+    {
+        return dataElementGroups;
+    }
+
+    public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
+    {
+        this.dataElementGroups = dataElementGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "dataElementGroupSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "dataElementGroupSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementGroupSet> getDataElementGroupSets()
+    {
+        return dataElementGroupSets;
+    }
+
+    public void setDataElementGroupSets( List<DataElementGroupSet> dataElementGroupSets )
+    {
+        this.dataElementGroupSets = dataElementGroupSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "concepts", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "concept", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Concept> getConcepts()
+    {
+        return concepts;
+    }
+
+    public void setConcepts( List<Concept> concepts )
+    {
+        this.concepts = concepts;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "categories", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "category", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementCategory> getCategories()
+    {
+        return categories;
+    }
+
+    public void setCategories( List<DataElementCategory> categories )
+    {
+        this.categories = categories;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "categoryOptions", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "categoryOption", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementCategoryOption> getCategoryOptions()
+    {
+        return categoryOptions;
+    }
+
+    public void setCategoryOptions( List<DataElementCategoryOption> categoryOptions )
+    {
+        this.categoryOptions = categoryOptions;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "categoryCombos", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "categoryCombo", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementCategoryCombo> getCategoryCombos()
+    {
+        return categoryCombos;
+    }
+
+    public void setCategoryCombos( List<DataElementCategoryCombo> categoryCombos )
+    {
+        this.categoryCombos = categoryCombos;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "categoryOptionCombos", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "categoryOptionCombo", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataElementCategoryOptionCombo> getCategoryOptionCombos()
+    {
+        return categoryOptionCombos;
+    }
+
+    public void setCategoryOptionCombos( List<DataElementCategoryOptionCombo> categoryOptionCombos )
+    {
+        this.categoryOptionCombos = categoryOptionCombos;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "indicators", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "indicator", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Indicator> getIndicators()
+    {
+        return indicators;
+    }
+
+    public void setIndicators( List<Indicator> indicators )
+    {
+        this.indicators = indicators;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "indicatorGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "indicatorGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<IndicatorGroup> getIndicatorGroups()
+    {
+        return indicatorGroups;
+    }
+
+    public void setIndicatorGroups( List<IndicatorGroup> indicatorGroups )
+    {
+        this.indicatorGroups = indicatorGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "indicatorGroupSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "indicatorGroupSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<IndicatorGroupSet> getIndicatorGroupSets()
+    {
+        return indicatorGroupSets;
+    }
+
+    public void setIndicatorGroupSets( List<IndicatorGroupSet> indicatorGroupSets )
+    {
+        this.indicatorGroupSets = indicatorGroupSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "indicatorTypes", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "indicatorType", namespace = Dxf2Namespace.NAMESPACE )
+    public List<IndicatorType> getIndicatorTypes()
+    {
+        return indicatorTypes;
+    }
+
+    public void setIndicatorTypes( List<IndicatorType> indicatorTypes )
+    {
+        this.indicatorTypes = indicatorTypes;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "organisationUnit", namespace = Dxf2Namespace.NAMESPACE )
+    public List<OrganisationUnit> getOrganisationUnits()
+    {
+        return organisationUnits;
+    }
+
+    public void setOrganisationUnits( List<OrganisationUnit> organisationUnits )
+    {
+        this.organisationUnits = organisationUnits;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<OrganisationUnitGroup> getOrganisationUnitGroups()
+    {
+        return organisationUnitGroups;
+    }
+
+    public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
+    {
+        this.organisationUnitGroups = organisationUnitGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "organisationUnitGroupSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "organisationUnitGroupSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
+    {
+        return organisationUnitGroupSets;
+    }
+
+    public void setOrganisationUnitGroupSets( List<OrganisationUnitGroupSet> organisationUnitGroupSets )
+    {
+        this.organisationUnitGroupSets = organisationUnitGroupSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "organisationUnitLevel", namespace = Dxf2Namespace.NAMESPACE )
+    public List<OrganisationUnitLevel> getOrganisationUnitLevels()
+    {
+        return organisationUnitLevels;
+    }
+
+    public void setOrganisationUnitLevels( List<OrganisationUnitLevel> organisationUnitLevels )
+    {
+        this.organisationUnitLevels = organisationUnitLevels;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "dataSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "dataSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataSet> getDataSets()
+    {
+        return dataSets;
+    }
+
+    public void setDataSets( List<DataSet> dataSets )
+    {
+        this.dataSets = dataSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "validationRules", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "validationRule", namespace = Dxf2Namespace.NAMESPACE )
+    public List<ValidationRule> getValidationRules()
+    {
+        return validationRules;
+    }
+
+    public void setValidationRules( List<ValidationRule> validationRules )
+    {
+        this.validationRules = validationRules;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "validationRuleGroups", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "validationRuleGroup", namespace = Dxf2Namespace.NAMESPACE )
+    public List<ValidationRuleGroup> getValidationRuleGroups()
+    {
+        return validationRuleGroups;
+    }
+
+    public void setValidationRuleGroups( List<ValidationRuleGroup> validationRuleGroups )
+    {
+        this.validationRuleGroups = validationRuleGroups;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "sqlViews", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "sqlView", namespace = Dxf2Namespace.NAMESPACE )
+    public List<SqlView> getSqlViews()
+    {
+        return sqlViews;
+    }
+
+    public void setSqlViews( List<SqlView> sqlViews )
+    {
+        this.sqlViews = sqlViews;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "charts", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "chart", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Chart> getCharts()
+    {
+        return charts;
+    }
+
+    public void setCharts( List<Chart> charts )
+    {
+        this.charts = charts;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "reports", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "report", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Report> getReports()
+    {
+        return reports;
+    }
+
+    public void setReports( List<Report> reports )
+    {
+        this.reports = reports;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "reportTables", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "reportTable", namespace = Dxf2Namespace.NAMESPACE )
+    public List<ReportTable> getReportTables()
+    {
+        return reportTables;
+    }
+
+    public void setReportTables( List<ReportTable> reportTables )
+    {
+        this.reportTables = reportTables;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "documents", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "document", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Document> getDocuments()
+    {
+        return documents;
+    }
+
+    public void setDocuments( List<Document> documents )
+    {
+        this.documents = documents;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "constants", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "constant", namespace = Dxf2Namespace.NAMESPACE )
+    public List<Constant> getConstants()
+    {
+        return constants;
+    }
+
+    public void setConstants( List<Constant> constants )
+    {
+        this.constants = constants;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "maps", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "map", namespace = Dxf2Namespace.NAMESPACE )
+    public List<MapView> getMaps()
+    {
+        return maps;
+    }
+
+    public void setMaps( List<MapView> maps )
+    {
+        this.maps = maps;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "mapLegends", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "mapLegend", namespace = Dxf2Namespace.NAMESPACE )
+    public List<MapLegend> getMapLegends()
+    {
+        return mapLegends;
+    }
+
+    public void setMapLegends( List<MapLegend> mapLegends )
+    {
+        this.mapLegends = mapLegends;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "mapLegendSets", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "mapLegendSet", namespace = Dxf2Namespace.NAMESPACE )
+    public List<MapLegendSet> getMapLegendSets()
+    {
+        return mapLegendSets;
+    }
+
+    public void setMapLegendSets( List<MapLegendSet> mapLegendSets )
+    {
+        this.mapLegendSets = mapLegendSets;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "mapLayers", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "mapLayer", namespace = Dxf2Namespace.NAMESPACE )
+    public List<MapLayer> getMapLayers()
+    {
+        return mapLayers;
+    }
+
+    public void setMapLayers( List<MapLayer> mapLayers )
+    {
+        this.mapLayers = mapLayers;
+    }
+
+    @JsonProperty
+    @JacksonXmlElementWrapper( localName = "dataDictionaries", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "dataDictionary", namespace = Dxf2Namespace.NAMESPACE )
+    public List<DataDictionary> getDataDictionaries()
+    {
+        return dataDictionaries;
+    }
+
+    public void setDataDictionaries( List<DataDictionary> dataDictionaries )
+    {
+        this.dataDictionaries = dataDictionaries;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "DXF2{" +
+            "attributeTypes=" + attributeTypes.size() +
+            ", users=" + users.size() +
+            ", userAuthorityGroups=" + userAuthorityGroups.size() +
+            ", userGroups=" + userGroups.size() +
+            ", messageConversations=" + messageConversations.size() +
+            ", dataElements=" + dataElements.size() +
+            ", optionSets=" + optionSets.size() +
+            ", dataElementGroups=" + dataElementGroups.size() +
+            ", dataElementGroupSets=" + dataElementGroupSets.size() +
+            ", concepts=" + concepts.size() +
+            ", categories=" + categories.size() +
+            ", categoryOptions=" + categoryOptions.size() +
+            ", categoryCombos=" + categoryCombos.size() +
+            ", categoryOptionCombos=" + categoryOptionCombos.size() +
+            ", indicators=" + indicators.size() +
+            ", indicatorGroups=" + indicatorGroups.size() +
+            ", indicatorGroupSets=" + indicatorGroupSets.size() +
+            ", indicatorTypes=" + indicatorTypes.size() +
+            ", organisationUnits=" + organisationUnits.size() +
+            ", organisationUnitGroups=" + organisationUnitGroups.size() +
+            ", organisationUnitGroupSets=" + organisationUnitGroupSets.size() +
+            ", organisationUnitLevels=" + organisationUnitLevels.size() +
+            ", dataSets=" + dataSets.size() +
+            ", validationRules=" + validationRules.size() +
+            ", validationRuleGroups=" + validationRuleGroups.size() +
+            ", sqlViews=" + sqlViews.size() +
+            ", charts=" + charts.size() +
+            ", reports=" + reports.size() +
+            ", reportTables=" + reportTables.size() +
+            ", documents=" + documents.size() +
+            ", constants=" + constants.size() +
+            ", maps=" + maps.size() +
+            ", mapLegends=" + mapLegends.size() +
+            ", mapLegendSets=" + mapLegendSets.size() +
+            ", mapLayers=" + mapLayers.size() +
+            ", dataDictionaries=" + dataDictionaries.size() +
+            '}';
+    }
+}

=== removed file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractIdentifiableObjectImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractIdentifiableObjectImporter.java	2012-04-07 12:36:39 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractIdentifiableObjectImporter.java	1970-01-01 00:00:00 +0000
@@ -1,571 +0,0 @@
-package org.hisp.dhis.dxf2.metadata.importers;
-
-/*
- * Copyright (c) 2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.CodeGenerator;
-import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.importsummary.ImportConflict;
-import org.hisp.dhis.dxf2.importsummary.ImportCount;
-import org.hisp.dhis.dxf2.metadata.IdScheme;
-import org.hisp.dhis.dxf2.metadata.ImportOptions;
-import org.hisp.dhis.dxf2.metadata.Importer;
-import org.hisp.dhis.system.util.ReflectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public abstract class AbstractIdentifiableObjectImporter<T extends BaseIdentifiableObject>
-    implements Importer<T>
-{
-    private static final Log log = LogFactory.getLog( AbstractIdentifiableObjectImporter.class );
-
-    //-------------------------------------------------------------------------------------------------------
-    // Dependencies
-    //-------------------------------------------------------------------------------------------------------
-
-    @Autowired
-    protected IdentifiableObjectManager manager;
-
-    //-------------------------------------------------------------------------------------------------------
-    // Current import counts
-    //-------------------------------------------------------------------------------------------------------
-
-    protected int imports;
-
-    protected int updates;
-
-    protected int ignores;
-
-    //-------------------------------------------------------------------------------------------------------
-    // Mappings from identifier (uid, name, code) to a db object.
-    //
-    // WARNING: These maps might be out-of-date, depending on if new inserts has been made after the were
-    //          fetched.
-    //-------------------------------------------------------------------------------------------------------
-
-    protected Map<String, T> uidMap;
-
-    protected Map<String, T> nameMap;
-
-    protected Map<String, T> codeMap;
-
-    //-------------------------------------------------------------------------------------------------------
-    // Generic implementations of newObject and updatedObject
-    //-------------------------------------------------------------------------------------------------------
-
-    /**
-     * Called every time a new object is to be imported.
-     *
-     * @param object  Object to import
-     * @param options Current import options
-     * @return An ImportConflict instance if there was a conflict, otherwise null
-     */
-    protected ImportConflict newObject( T object, ImportOptions options )
-    {
-        if ( options.isDryRun() )
-        {
-            return null;
-        }
-        log.info( "Trying to save new object with UID: " + object.getUid() );
-
-        findAndUpdateCollections( object );
-        //manager.save( object );
-        //updateIdMaps( object );
-
-        log.info( "Save successful." );
-
-        return null;
-    }
-
-    /**
-     * Update object from old => new.
-     *
-     * @param object    Object to import
-     * @param oldObject The current version of the object
-     * @param options   Current import options
-     * @return An ImportConflict instance if there was a conflict, otherwise null
-     */
-    protected ImportConflict updatedObject( T object, T oldObject, ImportOptions options )
-    {
-        if ( options.isDryRun() )
-        {
-            return null;
-        }
-
-        log.info( "Trying to update object with UID: " + oldObject.getUid() );
-
-        findAndUpdateCollections( object );
-        // oldObject.mergeWith( object );
-        // manager.update( oldObject );
-
-        log.info( "Update successful." );
-
-        return null;
-    }
-
-    private void findAndUpdateCollections( T object )
-    {
-        Field[] fields = object.getClass().getDeclaredFields();
-
-        for ( Field field : fields )
-        {
-            if(ReflectionUtils.isType( field, IdentifiableObject.class ))
-            {
-                IdentifiableObject identifiableObject = ReflectionUtils.invokeGetterMethod( field.getName(), object );
-                // we now have the identifiableObject, and can make sure that the reference is OK
-                log.info( identifiableObject );
-            }
-            else
-            {
-                boolean b = ReflectionUtils.isCollection( field.getName(), object, IdentifiableObject.class );
-
-                if ( b )
-                {
-                    Collection<IdentifiableObject> identifiableObjects = ReflectionUtils.invokeGetterMethod( field.getName(), object );
-                    // we now have the collection, and can make sure that references are OK
-                    log.info( identifiableObjects );
-                }
-            }
-        }
-    }
-
-    /**
-     * Current object name, used to fill name part of a ImportConflict
-     *
-     * @return Name of object
-     */
-    protected abstract String getObjectName();
-
-    //-------------------------------------------------------------------------------------------------------
-    // Importer<T> Implementation
-    //-------------------------------------------------------------------------------------------------------
-
-    @Override
-    public List<ImportConflict> importObjects( List<T> objects, ImportOptions options )
-    {
-        List<ImportConflict> conflicts = new ArrayList<ImportConflict>();
-
-        if ( objects.isEmpty() )
-        {
-            return conflicts;
-        }
-
-        reset( objects.get( 0 ) );
-
-        for ( T object : objects )
-        {
-            ImportConflict importConflict = importObjectLocal( object, options );
-
-            if ( importConflict != null )
-            {
-                conflicts.add( importConflict );
-            }
-        }
-
-        return conflicts;
-    }
-
-    @Override
-    public ImportConflict importObject( T object, ImportOptions options )
-    {
-        if ( object != null )
-        {
-            reset( object );
-        }
-
-        return importObjectLocal( object, options );
-    }
-
-    @Override
-    public ImportCount getCurrentImportCount()
-    {
-        ImportCount importCount = new ImportCount( getObjectName() );
-
-        importCount.setImports( imports );
-        importCount.setUpdates( updates );
-        importCount.setIgnores( ignores );
-
-        return importCount;
-    }
-
-    //-------------------------------------------------------------------------------------------------------
-    // Internal methods
-    //-------------------------------------------------------------------------------------------------------
-
-    private void reset( T type )
-    {
-        imports = 0;
-        updates = 0;
-        ignores = 0;
-
-        uidMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.UID );
-        nameMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.NAME );
-        codeMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.CODE );
-    }
-
-    private ImportConflict importObjectLocal( T object, ImportOptions options )
-    {
-        ImportConflict conflict = validateIdentifiableObject( object, options );
-
-        if ( conflict == null )
-        {
-            conflict = startImport( object, options );
-        }
-
-        if ( conflict != null )
-        {
-            ignores++;
-        }
-
-        return conflict;
-    }
-
-    private ImportConflict startImport( T object, ImportOptions options )
-    {
-        T oldObject = getObject( object, options.getIdScheme() );
-        ImportConflict conflict;
-
-        if ( options.getImportStrategy().isNewStrategy() )
-        {
-            prepareIdentifiableObject( object );
-            conflict = newObject( object, options );
-
-            if ( conflict != null )
-            {
-                return conflict;
-            }
-
-            imports++;
-        }
-        else if ( options.getImportStrategy().isUpdatesStrategy() )
-        {
-            conflict = updatedObject( object, oldObject, options );
-
-            if ( conflict != null )
-            {
-                return conflict;
-            }
-
-            updates++;
-        }
-        else if ( options.getImportStrategy().isNewAndUpdatesStrategy() )
-        {
-            if ( oldObject != null )
-            {
-                conflict = updatedObject( object, oldObject, options );
-
-                if ( conflict != null )
-                {
-                    return conflict;
-                }
-
-                updates++;
-            }
-            else
-            {
-                prepareIdentifiableObject( object );
-                conflict = newObject( object, options );
-
-                if ( conflict != null )
-                {
-                    return conflict;
-                }
-
-                imports++;
-            }
-        }
-
-        return null;
-    }
-
-    private ImportConflict validateIdentifiableObject( T object, ImportOptions options )
-    {
-        T uidObject = uidMap.get( object.getUid() );
-        T nameObject = nameMap.get( object.getName() );
-        T codeObject = codeMap.get( object.getCode() );
-
-        ImportConflict conflict = null;
-
-        if ( options.getImportStrategy().isNewStrategy() )
-        {
-            conflict = validateForNewStrategy( object, options );
-        }
-        else if ( options.getImportStrategy().isUpdatesStrategy() )
-        {
-            conflict = validateForUpdatesStrategy( object, options );
-        }
-        else if ( options.getImportStrategy().isNewAndUpdatesStrategy() )
-        {
-            if ( options.getIdScheme().isUidScheme() )
-            {
-                if ( uidObject == null )
-                {
-                    conflict = validateForNewStrategy( object, options );
-                }
-                else
-                {
-                    conflict = validateForUpdatesStrategy( object, options );
-                }
-            }
-            else if ( options.getIdScheme().isNameScheme() )
-            {
-                if ( nameObject == null )
-                {
-                    conflict = validateForNewStrategy( object, options );
-                }
-                else
-                {
-                    conflict = validateForUpdatesStrategy( object, options );
-                }
-            }
-            else if ( options.getIdScheme().isCodeScheme() )
-            {
-                if ( codeObject == null )
-                {
-                    conflict = validateForNewStrategy( object, options );
-                }
-                else
-                {
-                    conflict = validateForUpdatesStrategy( object, options );
-                }
-            }
-        }
-
-        return conflict;
-    }
-
-    private ImportConflict validateForUpdatesStrategy( T object, ImportOptions options )
-    {
-        T uidObject = uidMap.get( object.getUid() );
-        T nameObject = nameMap.get( object.getName() );
-        T codeObject = codeMap.get( object.getCode() );
-
-        ImportConflict conflict = null;
-
-        if ( options.getIdScheme().isUidScheme() )
-        {
-            if ( uidObject == null )
-            {
-                conflict = reportUidLookupConflict( object, options );
-            }
-            else if ( nameObject != null && nameObject != uidObject )
-            {
-                conflict = reportNameConflict( object, options );
-            }
-            else if ( codeObject != null && codeObject != uidObject )
-            {
-                conflict = reportCodeConflict( object, options );
-            }
-        }
-        else if ( options.getIdScheme().isNameScheme() )
-        {
-            if ( nameObject == null )
-            {
-                conflict = reportNameLookupConflict( object, options );
-            }
-            else if ( uidObject != null && uidObject != nameObject )
-            {
-                conflict = reportUidConflict( object, options );
-            }
-            else if ( codeObject != null && codeObject != nameObject )
-            {
-                conflict = reportCodeConflict( object, options );
-            }
-        }
-        else if ( options.getIdScheme().isCodeScheme() )
-        {
-            if ( codeObject == null )
-            {
-                conflict = reportCodeLookupConflict( object, options );
-            }
-            else if ( uidObject != null && uidObject != codeObject )
-            {
-                conflict = reportUidConflict( object, options );
-            }
-            else if ( nameObject != null && nameObject != codeObject )
-            {
-                conflict = reportNameConflict( object, options );
-            }
-        }
-
-        return conflict;
-    }
-
-    private ImportConflict validateForNewStrategy( T object, ImportOptions options )
-    {
-        T uidObject = uidMap.get( object.getUid() );
-        T nameObject = nameMap.get( object.getName() );
-        T codeObject = codeMap.get( object.getCode() );
-
-        ImportConflict conflict = null;
-
-        if ( uidObject != null )
-        {
-            conflict = reportUidConflict( object, options );
-        }
-        else if ( nameObject != null )
-        {
-            conflict = reportNameConflict( object, options );
-        }
-        else if ( codeObject != null )
-        {
-            conflict = reportCodeConflict( object, options );
-        }
-
-        return conflict;
-    }
-
-    private ImportConflict reportUidLookupConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object does not exist, lookup done using UID." );
-    }
-
-    private ImportConflict reportNameLookupConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object does not exist, lookup done using NAME." );
-    }
-
-    private ImportConflict reportCodeLookupConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object does not exist, lookup done using CODE." );
-    }
-
-    private ImportConflict reportUidConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object already exists, lookup done using UID." );
-    }
-
-    private ImportConflict reportNameConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object already exists, lookup done using NAME." );
-    }
-
-    private ImportConflict reportCodeConflict( IdentifiableObject object, ImportOptions options )
-    {
-        return new ImportConflict( getDisplayName( object, options.getIdScheme() ), "Object already exists, lookup done using CODE." );
-    }
-
-    private T getObject( T object, IdScheme scheme )
-    {
-        if ( scheme.isUidScheme() )
-        {
-            return uidMap.get( object.getUid() );
-        }
-        else if ( scheme.isNameScheme() )
-        {
-            return nameMap.get( object.getName() );
-        }
-        else if ( scheme.isCodeScheme() )
-        {
-            return codeMap.get( object.getCode() );
-        }
-
-        return null;
-    }
-
-    //-------------------------------------------------------------------------------------------------------
-    // Protected methods
-    //-------------------------------------------------------------------------------------------------------
-
-    protected void updateIdMaps( T object )
-    {
-        if ( object.getUid() != null )
-        {
-            uidMap.put( object.getUid(), object );
-        }
-
-        if ( object.getName() != null )
-        {
-            nameMap.put( object.getName(), object );
-        }
-
-        if ( object.getCode() != null )
-        {
-            codeMap.put( object.getCode(), object );
-        }
-    }
-
-    protected void prepareIdentifiableObject( BaseIdentifiableObject object )
-    {
-        if ( object.getUid() == null && object.getLastUpdated() == null )
-        {
-            object.setAutoFields();
-        }
-        else if ( object.getUid() == null )
-        {
-            object.setUid( CodeGenerator.generateCode() );
-        }
-    }
-
-    /**
-     * 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
-     * is available.
-     *
-     * @param object Object to get display name for
-     * @param scheme Current idScheme
-     * @return A usable display name
-     */
-    protected String getDisplayName( IdentifiableObject object, IdScheme scheme )
-    {
-        if ( scheme.isUidScheme() )
-        {
-            if ( object.getUid() != null )
-            {
-                return object.getUid();
-            }
-        }
-        else if ( scheme.isNameScheme() )
-        {
-            if ( object.getName() != null )
-            {
-                return object.getName();
-            }
-        }
-        else if ( scheme.isCodeScheme() )
-        {
-            if ( object.getCode() != null )
-            {
-                return object.getCode();
-            }
-        }
-
-        return object.getClass().getName();
-    }
-}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java	2012-04-11 15:11:09 +0000
@@ -0,0 +1,571 @@
+package org.hisp.dhis.dxf2.metadata.importers;
+
+/*
+ * Copyright (c) 2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.*;
+import org.hisp.dhis.dxf2.importsummary.ImportConflict;
+import org.hisp.dhis.dxf2.importsummary.ImportCount;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.dxf2.metadata.Importer;
+import org.hisp.dhis.system.util.ReflectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.Field;
+import java.util.*;
+
+/**
+ * Abstract importer that can handle IdentifiableObject and NameableObject.
+ *
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public abstract class AbstractImporter<T extends BaseIdentifiableObject>
+    implements Importer<T>
+{
+    private static final Log log = LogFactory.getLog( AbstractImporter.class );
+
+    //-------------------------------------------------------------------------------------------------------
+    // Dependencies
+    //-------------------------------------------------------------------------------------------------------
+
+    @Autowired
+    protected IdentifiableObjectManager manager;
+
+    //-------------------------------------------------------------------------------------------------------
+    // Current import counts
+    //-------------------------------------------------------------------------------------------------------
+
+    protected int imports;
+
+    protected int updates;
+
+    protected int ignores;
+
+    //-------------------------------------------------------------------------------------------------------
+    // Mappings from identifier (uid, name, code) to a db object.
+    //
+    // WARNING: These maps might be out-of-date, depending on if new inserts has been made after the were
+    //          fetched.
+    //-------------------------------------------------------------------------------------------------------
+
+    protected Map<String, T> uidMap;
+
+    protected Map<String, T> codeMap;
+
+    protected Map<String, T> nameMap;
+
+    protected Map<String, T> shortNameMap;
+
+    protected Map<String, T> alternativeNameMap;
+
+    //-------------------------------------------------------------------------------------------------------
+    // Generic implementations of newObject and updatedObject
+    //-------------------------------------------------------------------------------------------------------
+
+    /**
+     * Called every time a new object is to be imported.
+     *
+     * @param object  Object to import
+     * @param options Current import options
+     * @return An ImportConflict instance if there was a conflict, otherwise null
+     */
+    protected ImportConflict newObject( T object, ImportOptions options )
+    {
+        if ( options.isDryRun() )
+        {
+            return null;
+        }
+
+        log.info( "Trying to save new object with UID: " + object.getUid() );
+
+        findAndUpdateCollections( object );
+        //manager.save( object );
+        //updateIdMaps( object );
+
+        log.info( "Save successful." );
+
+        return null;
+    }
+
+    /**
+     * Update object from old => new.
+     *
+     * @param object    Object to import
+     * @param oldObject The current version of the object
+     * @param options   Current import options
+     * @return An ImportConflict instance if there was a conflict, otherwise null
+     */
+    protected ImportConflict updatedObject( T object, T oldObject, ImportOptions options )
+    {
+        if ( options.isDryRun() )
+        {
+            return null;
+        }
+
+        log.info( "Trying to update object with UID: " + oldObject.getUid() );
+
+        findAndUpdateCollections( object );
+        // oldObject.mergeWith( object );
+        // manager.update( oldObject );
+
+        log.info( "Update successful." );
+
+        return null;
+    }
+
+    private void findAndUpdateCollections( T object )
+    {
+        Field[] fields = object.getClass().getDeclaredFields();
+
+        for ( Field field : fields )
+        {
+            if ( ReflectionUtils.isType( field, IdentifiableObject.class ) )
+            {
+                IdentifiableObject identifiableObject = ReflectionUtils.invokeGetterMethod( field.getName(), object );
+                // we now have the identifiableObject, and can make sure that the reference is OK
+                log.info( identifiableObject );
+            }
+            else
+            {
+                boolean b = ReflectionUtils.isCollection( field.getName(), object, IdentifiableObject.class );
+
+                if ( b )
+                {
+                    Collection<IdentifiableObject> identifiableObjects = ReflectionUtils.invokeGetterMethod( field.getName(), object );
+                    // we now have the collection, and can make sure that references are OK
+                    log.info( identifiableObjects );
+                }
+            }
+        }
+    }
+
+    /**
+     * Current object name, used to fill name part of a ImportConflict
+     *
+     * @return Name of object
+     */
+    protected abstract String getObjectName();
+
+    //-------------------------------------------------------------------------------------------------------
+    // Importer<T> Implementation
+    //-------------------------------------------------------------------------------------------------------
+
+    @Override
+    public List<ImportConflict> importObjects( List<T> objects, ImportOptions options )
+    {
+        List<ImportConflict> conflicts = new ArrayList<ImportConflict>();
+
+        if ( objects.isEmpty() )
+        {
+            return conflicts;
+        }
+
+        reset( objects.get( 0 ) );
+
+        for ( T object : objects )
+        {
+            ImportConflict importConflict = importObjectLocal( object, options );
+
+            if ( importConflict != null )
+            {
+                conflicts.add( importConflict );
+            }
+        }
+
+        return conflicts;
+    }
+
+    @Override
+    public ImportConflict importObject( T object, ImportOptions options )
+    {
+        if ( object != null )
+        {
+            reset( object );
+        }
+
+        return importObjectLocal( object, options );
+    }
+
+    @Override
+    public ImportCount getCurrentImportCount()
+    {
+        ImportCount importCount = new ImportCount( getObjectName() );
+
+        importCount.setImports( imports );
+        importCount.setUpdates( updates );
+        importCount.setIgnores( ignores );
+
+        return importCount;
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // Internal methods
+    //-------------------------------------------------------------------------------------------------------
+
+    private void reset( T type )
+    {
+        imports = 0;
+        updates = 0;
+        ignores = 0;
+
+        uidMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.UID );
+        codeMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.CODE );
+        nameMap = manager.getIdMap( (Class<T>) type.getClass(), IdentifiableObject.IdentifiableProperty.NAME );
+
+        if ( NameableObject.class.isInstance( type ) )
+        {
+            shortNameMap = (Map<String, T>) manager.getIdMap( (Class<? extends NameableObject>) type.getClass(), NameableObject.NameableProperty.SHORT_NAME );
+            alternativeNameMap = (Map<String, T>) manager.getIdMap( (Class<? extends NameableObject>) type.getClass(), NameableObject.NameableProperty.ALTERNATIVE_NAME );
+        }
+
+        log.info( "shortNameMap: " + shortNameMap );
+        log.info( "alternativeNameMap: " + alternativeNameMap );
+    }
+
+    private ImportConflict importObjectLocal( T object, ImportOptions options )
+    {
+        ImportConflict conflict = validateIdentifiableObject( object, options );
+
+        if ( conflict == null )
+        {
+            conflict = startImport( object, options );
+        }
+
+        if ( conflict != null )
+        {
+            ignores++;
+        }
+
+        return conflict;
+    }
+
+    private ImportConflict startImport( T object, ImportOptions options )
+    {
+        T oldObject = getObject( object );
+        ImportConflict conflict;
+
+        if ( options.getImportStrategy().isNewStrategy() )
+        {
+            prepareIdentifiableObject( object );
+            conflict = newObject( object, options );
+
+            if ( conflict != null )
+            {
+                return conflict;
+            }
+
+            imports++;
+        }
+        else if ( options.getImportStrategy().isUpdatesStrategy() )
+        {
+            conflict = updatedObject( object, oldObject, options );
+
+            if ( conflict != null )
+            {
+                return conflict;
+            }
+
+            updates++;
+        }
+        else if ( options.getImportStrategy().isNewAndUpdatesStrategy() )
+        {
+            if ( oldObject != null )
+            {
+                conflict = updatedObject( object, oldObject, options );
+
+                if ( conflict != null )
+                {
+                    return conflict;
+                }
+
+                updates++;
+            }
+            else
+            {
+                prepareIdentifiableObject( object );
+                conflict = newObject( object, options );
+
+                if ( conflict != null )
+                {
+                    return conflict;
+                }
+
+                imports++;
+            }
+        }
+
+        return null;
+    }
+
+    private ImportConflict validateIdentifiableObject( T object, ImportOptions options )
+    {
+        T uidObject = uidMap.get( object.getUid() );
+        T codeObject = codeMap.get( object.getCode() );
+        T nameObject = nameMap.get( object.getName() );
+
+        T shortNameObject = null;
+        T alternativeNameObject = null;
+
+        if ( NameableObject.class.isInstance( object ) )
+        {
+            NameableObject nameableObject = (NameableObject) object;
+
+            shortNameObject = shortNameMap.get( nameableObject.getShortName() );
+            alternativeNameObject = alternativeNameMap.get( nameableObject.getAlternativeName() );
+        }
+
+        ImportConflict conflict = null;
+
+        if ( options.getImportStrategy().isNewStrategy() )
+        {
+            conflict = validateForNewStrategy( object, options );
+        }
+        else if ( options.getImportStrategy().isUpdatesStrategy() )
+        {
+            conflict = validateForUpdatesStrategy( object, options );
+        }
+        else if ( options.getImportStrategy().isNewAndUpdatesStrategy() )
+        {
+            // if we have a match on at least one of the objects, then assume update
+            if ( uidObject != null || codeObject != null || nameObject != null || shortNameObject != null || alternativeNameObject != null )
+            {
+                conflict = validateForUpdatesStrategy( object, options );
+            }
+            else
+            {
+                conflict = validateForNewStrategy( object, options );
+            }
+        }
+
+        return conflict;
+    }
+
+    private ImportConflict validateForUpdatesStrategy( T object, ImportOptions options )
+    {
+        T uidObject = uidMap.get( object.getUid() );
+        T codeObject = codeMap.get( object.getCode() );
+        T nameObject = nameMap.get( object.getName() );
+
+        T shortNameObject = null;
+        T alternativeNameObject = null;
+
+        if ( NameableObject.class.isInstance( object ) )
+        {
+            NameableObject nameableObject = (NameableObject) object;
+
+            shortNameObject = shortNameMap.get( nameableObject.getShortName() );
+            alternativeNameObject = alternativeNameMap.get( nameableObject.getAlternativeName() );
+        }
+
+        ImportConflict conflict = null;
+
+        Set<T> nonNullObjects = new HashSet<T>();
+
+        if ( uidObject != null )
+        {
+            nonNullObjects.add( uidObject );
+        }
+
+        if ( codeObject != null )
+        {
+            nonNullObjects.add( codeObject );
+        }
+
+        if ( nameObject != null )
+        {
+            nonNullObjects.add( nameObject );
+        }
+
+        if ( shortNameObject != null )
+        {
+            nonNullObjects.add( shortNameObject );
+        }
+
+        if ( alternativeNameObject != null )
+        {
+            nonNullObjects.add( alternativeNameObject );
+        }
+
+        if ( nonNullObjects.isEmpty() )
+        {
+            conflict = reportLookupConflict( object, options );
+        }
+        else if ( nonNullObjects.size() > 1 )
+        {
+            conflict = reportMoreThanOneConflict( object, options );
+        }
+
+        return conflict;
+    }
+
+    private ImportConflict validateForNewStrategy( T object, ImportOptions options )
+    {
+        T uidObject = uidMap.get( object.getUid() );
+        T codeObject = codeMap.get( object.getCode() );
+        T nameObject = nameMap.get( object.getName() );
+
+        T shortNameObject = null;
+        T alternativeNameObject = null;
+
+        if ( NameableObject.class.isInstance( object ) )
+        {
+            NameableObject nameableObject = (NameableObject) object;
+
+            shortNameObject = shortNameMap.get( nameableObject.getShortName() );
+            alternativeNameObject = alternativeNameMap.get( nameableObject.getAlternativeName() );
+        }
+
+        ImportConflict conflict = null;
+
+        if ( uidObject != null || codeObject != null || nameObject != null || shortNameObject != null || alternativeNameObject != null )
+        {
+            conflict = reportConflict( object, options );
+        }
+
+        return conflict;
+    }
+
+    private ImportConflict reportLookupConflict( IdentifiableObject object, ImportOptions options )
+    {
+        return new ImportConflict( getDisplayName( object ), "Object does not exist." );
+    }
+
+    private ImportConflict reportMoreThanOneConflict( IdentifiableObject object, ImportOptions options )
+    {
+        return new ImportConflict( getDisplayName( object ), "More than one object matches identifiers." );
+    }
+
+    private ImportConflict reportConflict( IdentifiableObject object, ImportOptions options )
+    {
+        return new ImportConflict( getDisplayName( object ), "Object already exists." );
+    }
+
+    private T getObject( T object )
+    {
+        T matchedObject = uidMap.get( object.getUid() );
+
+        if ( matchedObject != null )
+        {
+            return matchedObject;
+        }
+
+        matchedObject = codeMap.get( object.getCode() );
+
+        if ( matchedObject != null )
+        {
+            return matchedObject;
+        }
+
+        matchedObject = nameMap.get( object.getName() );
+
+        if ( matchedObject != null )
+        {
+            return matchedObject;
+        }
+
+        if ( NameableObject.class.isInstance( object ) )
+        {
+            NameableObject nameableObject = (NameableObject) object;
+
+            matchedObject = shortNameMap.get( nameableObject.getShortName() );
+
+            if ( matchedObject != null )
+            {
+                return matchedObject;
+            }
+
+            matchedObject = alternativeNameMap.get( nameableObject.getAlternativeName() );
+
+            if ( matchedObject != null )
+            {
+                return matchedObject;
+            }
+        }
+
+        return matchedObject;
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // Protected methods
+    //-------------------------------------------------------------------------------------------------------
+
+    protected void updateIdMaps( T object )
+    {
+        if ( object.getUid() != null )
+        {
+            uidMap.put( object.getUid(), object );
+        }
+
+        if ( object.getCode() != null )
+        {
+            codeMap.put( object.getCode(), object );
+        }
+
+        if ( object.getName() != null )
+        {
+            nameMap.put( object.getName(), object );
+        }
+
+        if ( NameableObject.class.isInstance( object ) )
+        {
+            NameableObject nameableObject = (NameableObject) object;
+
+            if ( nameableObject.getShortName() != null )
+            {
+                shortNameMap.put( nameableObject.getShortName(), object );
+            }
+
+            if ( nameableObject.getAlternativeName() != null )
+            {
+                alternativeNameMap.put( nameableObject.getAlternativeName(), object );
+            }
+        }
+    }
+
+    protected void prepareIdentifiableObject( BaseIdentifiableObject object )
+    {
+        if ( object.getUid() == null && object.getLastUpdated() == null )
+        {
+            object.setAutoFields();
+        }
+        else if ( object.getUid() == null )
+        {
+            object.setUid( CodeGenerator.generateCode() );
+        }
+    }
+
+    /**
+     * @param object Object to get display name for
+     * @return A usable display name
+     */
+    protected String getDisplayName( IdentifiableObject object )
+    {
+        return object.getClass().getName();
+    }
+}

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/ConstantImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/ConstantImporter.java	2012-04-07 09:17:15 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/ConstantImporter.java	2012-04-11 15:11:09 +0000
@@ -37,7 +37,7 @@
  */
 @Component
 public class ConstantImporter
-    extends AbstractIdentifiableObjectImporter<Constant>
+    extends AbstractImporter<Constant>
 {
     private static final Log log = LogFactory.getLog( ConstantImporter.class );
 

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java	2012-04-11 11:33:43 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/IndicatorImporter.java	2012-04-11 15:11:09 +0000
@@ -37,7 +37,7 @@
  */
 @Component
 public class IndicatorImporter
-    extends AbstractIdentifiableObjectImporter<Indicator>
+    extends AbstractImporter<Indicator>
 {
     private static final Log log = LogFactory.getLog( IndicatorImporter.class );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-04-07 09:02:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2012-04-11 15:11:09 +0000
@@ -27,17 +27,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
+import org.hisp.dhis.common.NameableObject.NameableProperty;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.PostConstruct;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-import javax.annotation.PostConstruct;
-
-import org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
 /**
  * @author Lars Helge Overland
  */
@@ -45,16 +45,16 @@
 public class DefaultIdentifiableObjectManager
     implements IdentifiableObjectManager
 {
+    @Autowired
     private Set<GenericIdentifiableObjectStore<IdentifiableObject>> objectStores;
 
     @Autowired
-    public void setObjectStores( Set<GenericIdentifiableObjectStore<IdentifiableObject>> objectStores )
-    {
-        this.objectStores = objectStores;
-    }
+    private Set<GenericNameableObjectStore<NameableObject>> nameableObjectStores;
 
     private Map<Class<IdentifiableObject>, GenericIdentifiableObjectStore<IdentifiableObject>> objectStoreMap;
 
+    private Map<Class<NameableObject>, GenericNameableObjectStore<NameableObject>> nameableObjectStoreMap;
+
     @PostConstruct
     public void init()
     {
@@ -64,6 +64,13 @@
         {
             objectStoreMap.put( store.getClazz(), store );
         }
+
+        nameableObjectStoreMap = new HashMap<Class<NameableObject>, GenericNameableObjectStore<NameableObject>>();
+
+        for ( GenericNameableObjectStore<NameableObject> store : nameableObjectStores )
+        {
+            nameableObjectStoreMap.put( store.getClazz(), store );
+        }
     }
 
     public void save( IdentifiableObject object )
@@ -80,8 +87,8 @@
     {
         objectStoreMap.get( clazz ).getByUid( uid );
     }
-    
-    @SuppressWarnings("unchecked")
+
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAll( Class<T> clazz )
     {
         return (Collection<T>) objectStoreMap.get( clazz ).getAll();
@@ -136,6 +143,36 @@
         return map;
     }
 
+    @Override
+    public <T extends NameableObject> Map<String, T> getIdMap( Class<T> clazz, NameableProperty property )
+    {
+        Map<String, T> map = new HashMap<String, T>();
+
+        GenericNameableObjectStore<T> store = (GenericNameableObjectStore<T>) nameableObjectStoreMap.get( clazz );
+
+        Collection<T> objects = store.getAll();
+
+        for ( T object : objects )
+        {
+            if ( property == NameableProperty.SHORT_NAME )
+            {
+                if ( object.getShortName() != null )
+                {
+                    map.put( object.getShortName(), object );
+                }
+            }
+            else if ( property == NameableProperty.ALTERNATIVE_NAME )
+            {
+                if ( object.getAlternativeName() != null )
+                {
+                    map.put( object.getAlternativeName(), object );
+                }
+            }
+        }
+
+        return map;
+    }
+
     @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T getObject( Class<T> clazz, IdentifiableProperty property, String id )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-04-07 09:22:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-04-11 15:11:09 +0000
@@ -40,11 +40,8 @@
 import org.hisp.dhis.api.utils.ContextUtils;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.hisp.dhis.dxf2.metadata.DXF2;
-import org.hisp.dhis.dxf2.metadata.ExportOptions;
-import org.hisp.dhis.dxf2.metadata.ExportService;
-import org.hisp.dhis.dxf2.metadata.ImportOptions;
-import org.hisp.dhis.dxf2.metadata.ImportService;
+import org.hisp.dhis.dxf2.metadata.*;
+import org.hisp.dhis.dxf2.metadata.MetaData;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -76,7 +73,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public String export( ExportOptions exportOptions, Model model )
     {
-        DXF2 dxf2 = exportService.getMetaData( exportOptions );
+        MetaData dxf2 = exportService.getMetaData( exportOptions );
 
         model.addAttribute( "model", dxf2 );
         model.addAttribute( "view", "export" );
@@ -88,7 +85,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportZippedXML( ExportOptions exportOptions, HttpServletResponse response ) throws IOException, JAXBException
     {
-        DXF2 dxf2 = exportService.getMetaData( exportOptions );
+        MetaData dxf2 = exportService.getMetaData( exportOptions );
 
         response.setContentType( ContextUtils.CONTENT_TYPE_ZIP );
         response.addHeader( "Content-Disposition", "attachment; filename=\"export.xml.zip\"" );
@@ -104,7 +101,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_EXPORT')" )
     public void exportZippedJSON( ExportOptions exportOptions, HttpServletResponse response ) throws IOException, JAXBException
     {
-        DXF2 dxf2 = exportService.getMetaData( exportOptions );
+        MetaData dxf2 = exportService.getMetaData( exportOptions );
 
         response.setContentType( ContextUtils.CONTENT_TYPE_ZIP );
         response.addHeader( "Content-Disposition", "attachment; filename=\"export.json.zip\"" );
@@ -124,7 +121,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException
     {
-        DXF2 dxf2 = JacksonUtils.fromXml( request.getInputStream(), DXF2.class );
+        MetaData dxf2 = JacksonUtils.fromXml( request.getInputStream(), MetaData.class );
         System.err.println( dxf2 );
 
         ImportSummary summary = importService.importDxf2( dxf2, importOptions );
@@ -137,7 +134,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
     public void importJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        DXF2 dxf2 = JacksonUtils.fromJson( request.getInputStream(), DXF2.class );
+        MetaData dxf2 = JacksonUtils.fromJson( request.getInputStream(), MetaData.class );
         System.err.println( dxf2 );
 
         ImportSummary summary = importService.importDxf2( dxf2, importOptions );
@@ -153,7 +150,7 @@
         ZipInputStream zip = new ZipInputStream( new BufferedInputStream( request.getInputStream() ) );
         ZipEntry entry = zip.getNextEntry();
 
-        DXF2 dxf2 = JacksonUtils.fromXml( zip, DXF2.class );
+        MetaData dxf2 = JacksonUtils.fromXml( zip, MetaData.class );
         System.err.println( dxf2 );
 
         ImportSummary summary = importService.importDxf2( dxf2, importOptions );
@@ -169,7 +166,7 @@
         ZipInputStream zip = new ZipInputStream( request.getInputStream() );
         ZipEntry entry = zip.getNextEntry();
 
-        DXF2 dxf2 = JacksonUtils.fromJson( zip, DXF2.class );
+        MetaData dxf2 = JacksonUtils.fromJson( zip, MetaData.class );
         System.err.println( dxf2 );
 
         ImportSummary summary = importService.importDxf2( dxf2, importOptions );