=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2012-04-02 17:23:48 +0000 @@ -114,7 +114,7 @@ @JsonProperty( value = "internalId" ) @JsonView( {DetailedView.class, IdentifiableObjectView.class, ExportView.class} ) - @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( isAttribute = true ) public int getId() { return id; @@ -126,7 +126,7 @@ } @JsonProperty( value = "id" ) - @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( isAttribute = true ) public String getUid() { return uid; @@ -139,7 +139,7 @@ @JsonProperty @JsonView( {DetailedView.class, IdentifiableObjectView.class, ExportView.class} ) - @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( isAttribute = true ) public String getCode() { return code; @@ -152,7 +152,7 @@ @JsonProperty @JsonView( {DetailedView.class, IdentifiableObjectView.class, ExportView.class} ) - @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( isAttribute = true ) public String getName() { return name; @@ -165,7 +165,7 @@ @JsonProperty @JsonView( {DetailedView.class, IdentifiableObjectView.class, ExportView.class} ) - @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( isAttribute = true ) public Date getLastUpdated() { return lastUpdated; @@ -229,10 +229,10 @@ * @param objects the NameableObjects to put in the map * @return the map */ - public static Map getCodeMap( Collection objects ) + public static Map getCodeMap( Collection objects ) { Map map = new HashMap(); - for ( NameableObject object : objects ) + for ( BaseIdentifiableObject object : objects ) { String code = object.getCode(); int internalId = object.getId(); @@ -241,4 +241,36 @@ } return map; } + + /** + * Get a map of names to internal identifiers + * + * @param objects the NameableObjects to put in the map + * @return the map + */ + public static Map getNameMap( Collection objects ) + { + Map map = new HashMap(); + for ( BaseIdentifiableObject object : objects ) + { + String name = object.getName(); + int internalId = object.getId(); + + map.put( name, internalId ); + } + return map; + } + + @Override + public String toString() + { + return "IdentifiableObject{" + + "id=" + id + + ", uid='" + uid + '\'' + + ", code='" + code + '\'' + + ", name='" + name + '\'' + + ", lastUpdated=" + lastUpdated + + ", displayName='" + displayName + '\'' + + '}'; + } } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-01 12:17:55 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-02 17:23:48 +0000 @@ -187,19 +187,19 @@ if ( dataElement == null ) { - summary.getNoneExistingIdentifiers().add( new ImportConflict( DataElement.class.getSimpleName(), dataValue.getDataElement() ) ); + summary.getConflicts().add( new ImportConflict( DataElement.class.getSimpleName(), dataValue.getDataElement() ) ); continue; } if ( period == null ) { - summary.getNoneExistingIdentifiers().add( new ImportConflict( Period.class.getSimpleName(), dataValue.getPeriod() ) ); + summary.getConflicts().add( new ImportConflict( Period.class.getSimpleName(), dataValue.getPeriod() ) ); continue; } if ( orgUnit == null ) { - summary.getNoneExistingIdentifiers().add( new ImportConflict( OrganisationUnit.class.getSimpleName(), dataValue.getOrgUnit() ) ); + summary.getConflicts().add( new ImportConflict( OrganisationUnit.class.getSimpleName(), dataValue.getOrgUnit() ) ); continue; } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java 2012-03-29 09:59:05 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java 2012-04-02 17:23:48 +0000 @@ -35,7 +35,7 @@ public class ImportConflict { private String object; - + private String value; public ImportConflict( String object, String value ) @@ -43,9 +43,9 @@ this.object = object; this.value = value; } - + @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public String getObject() { return object; @@ -57,7 +57,7 @@ } @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public String getValue() { return value; @@ -67,4 +67,13 @@ { this.value = value; } + + @Override + public String toString() + { + return "ImportConflict{" + + "object='" + object + '\'' + + ", value='" + value + '\'' + + '}'; + } } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java 2012-03-29 12:02:12 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java 2012-04-02 17:23:48 +0000 @@ -35,11 +35,11 @@ public class ImportCount { private String object; - + private int imports; - + private int updates; - + private int ignores; public ImportCount( String object, int imports, int updates, int ignores ) @@ -49,9 +49,9 @@ this.updates = updates; this.ignores = ignores; } - + @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public String getObject() { return object; @@ -63,7 +63,7 @@ } @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public int getImports() { return imports; @@ -75,7 +75,7 @@ } @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public int getUpdates() { return updates; @@ -87,7 +87,7 @@ } @JsonProperty - @JacksonXmlProperty( isAttribute=true ) + @JacksonXmlProperty( isAttribute = true ) public int getIgnores() { return ignores; @@ -96,5 +96,16 @@ public void setIgnores( int ignores ) { this.ignores = ignores; - } + } + + @Override + public String toString() + { + return "ImportCount{" + + "object='" + object + '\'' + + ", imports=" + imports + + ", updates=" + updates + + ", ignores=" + ignores + + '}'; + } } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java 2012-03-29 16:45:18 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java 2012-04-02 17:23:48 +0000 @@ -27,27 +27,27 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.List; - 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 java.util.ArrayList; +import java.util.List; + @JacksonXmlRootElement( localName = "importSummary" ) public class ImportSummary { private List counts = new ArrayList(); - private List noneExistingIdentifiers = new ArrayList(); - + private List conflicts = new ArrayList(); + private String dataSetComplete; - + public void increaseImportCount( Class clazz ) { } - + @JsonProperty @JacksonXmlElementWrapper @JacksonXmlProperty @@ -64,14 +64,14 @@ @JsonProperty @JacksonXmlElementWrapper @JacksonXmlProperty - public List getNoneExistingIdentifiers() + public List getConflicts() { - return noneExistingIdentifiers; + return conflicts; } - public void setNoneExistingIdentifiers( List noneExistingIdentifiers ) + public void setConflicts( List conflicts ) { - this.noneExistingIdentifiers = noneExistingIdentifiers; + this.conflicts = conflicts; } @JsonProperty @@ -85,4 +85,14 @@ { this.dataSetComplete = dataSetComplete; } + + @Override + public String toString() + { + return "ImportSummary{" + + "counts=" + counts + + ", noneExistingIdentifiers=" + conflicts + + ", dataSetComplete='" + dataSetComplete + '\'' + + '}'; + } } === modified 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-03-30 10:53:18 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DXF2.java 2012-04-02 17:23:48 +0000 @@ -63,8 +63,8 @@ import org.hisp.dhis.validation.ValidationRule; import org.hisp.dhis.validation.ValidationRuleGroup; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; /** * @author Morten Olav Hansen @@ -72,547 +72,590 @@ @JacksonXmlRootElement( localName = "dxf2", namespace = Dxf2Namespace.NAMESPACE ) public class DXF2 { - private List attributeTypes = new ArrayList(); - - private List users = new ArrayList(); - - private List userAuthorityGroups = new ArrayList(); - - private List userGroups = new ArrayList(); - - private List messageConversations = new ArrayList(); - - private List dataElements = new ArrayList(); - - private List optionSets = new ArrayList(); - - private List dataElementGroups = new ArrayList(); - - private List dataElementGroupSets = new ArrayList(); - - private List concepts = new ArrayList(); - - private List categories = new ArrayList(); - - private List categoryOptions = new ArrayList(); - - private List categoryCombos = new ArrayList(); - - private List categoryOptionCombos = new ArrayList(); - - private List indicators = new ArrayList(); - - private List indicatorGroups = new ArrayList(); - - private List indicatorGroupSets = new ArrayList(); - - private List indicatorTypes = new ArrayList(); - - private List organisationUnits = new ArrayList(); - - private List organisationUnitGroups = new ArrayList(); - - private List organisationUnitGroupSets = new ArrayList(); - - private List organisationUnitLevels = new ArrayList(); - - private List dataSets = new ArrayList(); - - private List validationRules = new ArrayList(); - - private List validationRuleGroups = new ArrayList(); - - private List sqlViews = new ArrayList(); - - private List charts = new ArrayList(); - - private List reports = new ArrayList(); - - private List reportTables = new ArrayList(); - - private List documents = new ArrayList(); - - private List constants = new ArrayList(); - - private List maps = new ArrayList(); - - private List mapLegends = new ArrayList(); - - private List mapLegendSets = new ArrayList(); - - private List mapLayers = new ArrayList(); - - private List dataDictionaries = new ArrayList(); + private Set attributeTypes = new HashSet(); + + private Set users = new HashSet(); + + private Set userAuthorityGroups = new HashSet(); + + private Set userGroups = new HashSet(); + + private Set messageConversations = new HashSet(); + + private Set dataElements = new HashSet(); + + private Set optionSets = new HashSet(); + + private Set dataElementGroups = new HashSet(); + + private Set dataElementGroupSets = new HashSet(); + + private Set concepts = new HashSet(); + + private Set categories = new HashSet(); + + private Set categoryOptions = new HashSet(); + + private Set categoryCombos = new HashSet(); + + private Set categoryOptionCombos = new HashSet(); + + private Set indicators = new HashSet(); + + private Set indicatorGroups = new HashSet(); + + private Set indicatorGroupSets = new HashSet(); + + private Set indicatorTypes = new HashSet(); + + private Set organisationUnits = new HashSet(); + + private Set organisationUnitGroups = new HashSet(); + + private Set organisationUnitGroupSets = new HashSet(); + + private Set organisationUnitLevels = new HashSet(); + + private Set dataSets = new HashSet(); + + private Set validationRules = new HashSet(); + + private Set validationRuleGroups = new HashSet(); + + private Set sqlViews = new HashSet(); + + private Set charts = new HashSet(); + + private Set reports = new HashSet(); + + private Set reportTables = new HashSet(); + + private Set documents = new HashSet(); + + private Set constants = new HashSet(); + + private Set maps = new HashSet(); + + private Set mapLegends = new HashSet(); + + private Set mapLegendSets = new HashSet(); + + private Set mapLayers = new HashSet(); + + private Set dataDictionaries = new HashSet(); public DXF2() { } @JsonProperty - @JacksonXmlElementWrapper( localName = "attributeTypes" ) - @JacksonXmlProperty( localName = "attributeType" ) - public List getAttributeTypes() + @JacksonXmlElementWrapper( localName = "attributeTypes", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "attributeType", namespace = Dxf2Namespace.NAMESPACE ) + public Set getAttributeTypes() { return attributeTypes; } - public void setAttributeTypes( List attributeTypes ) + public void setAttributeTypes( Set attributeTypes ) { this.attributeTypes = attributeTypes; } @JsonProperty - @JacksonXmlElementWrapper( localName = "users" ) - @JacksonXmlProperty( localName = "user" ) - public List getUsers() + @JacksonXmlElementWrapper( localName = "users", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "user", namespace = Dxf2Namespace.NAMESPACE ) + public Set getUsers() { return users; } - public void setUsers( List users ) + public void setUsers( Set users ) { this.users = users; } @JsonProperty - @JacksonXmlElementWrapper( localName = "userAuthorityGroups" ) - @JacksonXmlProperty( localName = "userAuthorityGroup" ) - public List getUserAuthorityGroups() + @JacksonXmlElementWrapper( localName = "userAuthorityGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "userAuthorityGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getUserAuthorityGroups() { return userAuthorityGroups; } - public void setUserAuthorityGroups( List userAuthorityGroups ) + public void setUserAuthorityGroups( Set userAuthorityGroups ) { this.userAuthorityGroups = userAuthorityGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "userGroups" ) - @JacksonXmlProperty( localName = "userGroup" ) - public List getUserGroups() + @JacksonXmlElementWrapper( localName = "userGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "userGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getUserGroups() { return userGroups; } - public void setUserGroups( List userGroups ) + public void setUserGroups( Set userGroups ) { this.userGroups = userGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "messageConversations" ) - @JacksonXmlProperty( localName = "messageConversation" ) - public List getMessageConversations() + @JacksonXmlElementWrapper( localName = "messageConversations", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "messageConversation", namespace = Dxf2Namespace.NAMESPACE ) + public Set getMessageConversations() { return messageConversations; } - public void setMessageConversations( List messageConversations ) + public void setMessageConversations( Set messageConversations ) { this.messageConversations = messageConversations; } @JsonProperty - @JacksonXmlElementWrapper( localName = "dataElements" ) - @JacksonXmlProperty( localName = "dataElement" ) - public List getDataElements() + @JacksonXmlElementWrapper( localName = "dataElements", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "dataElement", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDataElements() { return dataElements; } - public void setDataElements( List dataElements ) + public void setDataElements( Set dataElements ) { this.dataElements = dataElements; } @JsonProperty - @JacksonXmlElementWrapper( localName = "optionSets" ) - @JacksonXmlProperty( localName = "optionSet" ) - public List getOptionSets() + @JacksonXmlElementWrapper( localName = "optionSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "optionSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getOptionSets() { return optionSets; } - public void setOptionSets( List optionSets ) + public void setOptionSets( Set optionSets ) { this.optionSets = optionSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "dataElementGroups" ) - @JacksonXmlProperty( localName = "dataElementGroup" ) - public List getDataElementGroups() + @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "dataElementGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDataElementGroups() { return dataElementGroups; } - public void setDataElementGroups( List dataElementGroups ) + public void setDataElementGroups( Set dataElementGroups ) { this.dataElementGroups = dataElementGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "dataElementGroupSets" ) - @JacksonXmlProperty( localName = "dataElementGroupSet" ) - public List getDataElementGroupSets() + @JacksonXmlElementWrapper( localName = "dataElementGroupSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "dataElementGroupSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDataElementGroupSets() { return dataElementGroupSets; } - public void setDataElementGroupSets( List dataElementGroupSets ) + public void setDataElementGroupSets( Set dataElementGroupSets ) { this.dataElementGroupSets = dataElementGroupSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "concepts" ) - @JacksonXmlProperty( localName = "concept" ) - public List getConcepts() + @JacksonXmlElementWrapper( localName = "concepts", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "concept", namespace = Dxf2Namespace.NAMESPACE ) + public Set getConcepts() { return concepts; } - public void setConcepts( List concepts ) + public void setConcepts( Set concepts ) { this.concepts = concepts; } @JsonProperty - @JacksonXmlElementWrapper( localName = "categories" ) - @JacksonXmlProperty( localName = "category" ) - public List getCategories() + @JacksonXmlElementWrapper( localName = "categories", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "category", namespace = Dxf2Namespace.NAMESPACE ) + public Set getCategories() { return categories; } - public void setCategories( List categories ) + public void setCategories( Set categories ) { this.categories = categories; } @JsonProperty - @JacksonXmlElementWrapper( localName = "categoryOptions" ) - @JacksonXmlProperty( localName = "categoryOption" ) - public List getCategoryOptions() + @JacksonXmlElementWrapper( localName = "categoryOptions", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "categoryOption", namespace = Dxf2Namespace.NAMESPACE ) + public Set getCategoryOptions() { return categoryOptions; } - public void setCategoryOptions( List categoryOptions ) + public void setCategoryOptions( Set categoryOptions ) { this.categoryOptions = categoryOptions; } @JsonProperty - @JacksonXmlElementWrapper( localName = "categoryCombos" ) - @JacksonXmlProperty( localName = "categoryCombo" ) - public List getCategoryCombos() + @JacksonXmlElementWrapper( localName = "categoryCombos", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "categoryCombo", namespace = Dxf2Namespace.NAMESPACE ) + public Set getCategoryCombos() { return categoryCombos; } - public void setCategoryCombos( List categoryCombos ) + public void setCategoryCombos( Set categoryCombos ) { this.categoryCombos = categoryCombos; } @JsonProperty - @JacksonXmlElementWrapper( localName = "categoryOptionCombos" ) - @JacksonXmlProperty( localName = "categoryOptionCombo" ) - public List getCategoryOptionCombos() + @JacksonXmlElementWrapper( localName = "categoryOptionCombos", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "categoryOptionCombo", namespace = Dxf2Namespace.NAMESPACE ) + public Set getCategoryOptionCombos() { return categoryOptionCombos; } - public void setCategoryOptionCombos( List categoryOptionCombos ) + public void setCategoryOptionCombos( Set categoryOptionCombos ) { this.categoryOptionCombos = categoryOptionCombos; } @JsonProperty - @JacksonXmlElementWrapper( localName = "indicators" ) - @JacksonXmlProperty( localName = "indicator" ) - public List getIndicators() + @JacksonXmlElementWrapper( localName = "indicators", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "indicator", namespace = Dxf2Namespace.NAMESPACE ) + public Set getIndicators() { return indicators; } - public void setIndicators( List indicators ) + public void setIndicators( Set indicators ) { this.indicators = indicators; } @JsonProperty - @JacksonXmlElementWrapper( localName = "indicatorGroups" ) - @JacksonXmlProperty( localName = "indicatorGroup" ) - public List getIndicatorGroups() + @JacksonXmlElementWrapper( localName = "indicatorGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "indicatorGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getIndicatorGroups() { return indicatorGroups; } - public void setIndicatorGroups( List indicatorGroups ) + public void setIndicatorGroups( Set indicatorGroups ) { this.indicatorGroups = indicatorGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "indicatorGroupSets" ) - @JacksonXmlProperty( localName = "indicatorGroupSet" ) - public List getIndicatorGroupSets() + @JacksonXmlElementWrapper( localName = "indicatorGroupSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "indicatorGroupSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getIndicatorGroupSets() { return indicatorGroupSets; } - public void setIndicatorGroupSets( List indicatorGroupSets ) + public void setIndicatorGroupSets( Set indicatorGroupSets ) { this.indicatorGroupSets = indicatorGroupSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "indicatorTypes" ) - @JacksonXmlProperty( localName = "indicatorType" ) - public List getIndicatorTypes() + @JacksonXmlElementWrapper( localName = "indicatorTypes", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "indicatorType", namespace = Dxf2Namespace.NAMESPACE ) + public Set getIndicatorTypes() { return indicatorTypes; } - public void setIndicatorTypes( List indicatorTypes ) + public void setIndicatorTypes( Set indicatorTypes ) { this.indicatorTypes = indicatorTypes; } @JsonProperty - @JacksonXmlElementWrapper( localName = "organisationUnits" ) - @JacksonXmlProperty( localName = "organisationUnit" ) - public List getOrganisationUnits() + @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "organisationUnit", namespace = Dxf2Namespace.NAMESPACE ) + public Set getOrganisationUnits() { return organisationUnits; } - public void setOrganisationUnits( List organisationUnits ) + public void setOrganisationUnits( Set organisationUnits ) { this.organisationUnits = organisationUnits; } @JsonProperty - @JacksonXmlElementWrapper( localName = "organisationUnitGroups" ) - @JacksonXmlProperty( localName = "organisationUnitGroup" ) - public List getOrganisationUnitGroups() + @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getOrganisationUnitGroups() { return organisationUnitGroups; } - public void setOrganisationUnitGroups( List organisationUnitGroups ) + public void setOrganisationUnitGroups( Set organisationUnitGroups ) { this.organisationUnitGroups = organisationUnitGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "organisationUnitGroupSets" ) - @JacksonXmlProperty( localName = "organisationUnitGroupSet" ) - public List getOrganisationUnitGroupSets() + @JacksonXmlElementWrapper( localName = "organisationUnitGroupSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "organisationUnitGroupSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getOrganisationUnitGroupSets() { return organisationUnitGroupSets; } - public void setOrganisationUnitGroupSets( List organisationUnitGroupSets ) + public void setOrganisationUnitGroupSets( Set organisationUnitGroupSets ) { this.organisationUnitGroupSets = organisationUnitGroupSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "organisationUnitLevels" ) - @JacksonXmlProperty( localName = "organisationUnitLevel" ) - public List getOrganisationUnitLevels() + @JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "organisationUnitLevel", namespace = Dxf2Namespace.NAMESPACE ) + public Set getOrganisationUnitLevels() { return organisationUnitLevels; } - public void setOrganisationUnitLevels( List organisationUnitLevels ) + public void setOrganisationUnitLevels( Set organisationUnitLevels ) { this.organisationUnitLevels = organisationUnitLevels; } @JsonProperty - @JacksonXmlElementWrapper( localName = "dataSets" ) - @JacksonXmlProperty( localName = "dataSet" ) - public List getDataSets() + @JacksonXmlElementWrapper( localName = "dataSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "dataSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDataSets() { return dataSets; } - public void setDataSets( List dataSets ) + public void setDataSets( Set dataSets ) { this.dataSets = dataSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "validationRules" ) - @JacksonXmlProperty( localName = "validationRule" ) - public List getValidationRules() + @JacksonXmlElementWrapper( localName = "validationRules", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "validationRule", namespace = Dxf2Namespace.NAMESPACE ) + public Set getValidationRules() { return validationRules; } - public void setValidationRules( List validationRules ) + public void setValidationRules( Set validationRules ) { this.validationRules = validationRules; } @JsonProperty - @JacksonXmlElementWrapper( localName = "validationRuleGroups" ) - @JacksonXmlProperty( localName = "validationRuleGroup" ) - public List getValidationRuleGroups() + @JacksonXmlElementWrapper( localName = "validationRuleGroups", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "validationRuleGroup", namespace = Dxf2Namespace.NAMESPACE ) + public Set getValidationRuleGroups() { return validationRuleGroups; } - public void setValidationRuleGroups( List validationRuleGroups ) + public void setValidationRuleGroups( Set validationRuleGroups ) { this.validationRuleGroups = validationRuleGroups; } @JsonProperty - @JacksonXmlElementWrapper( localName = "sqlViews" ) - @JacksonXmlProperty( localName = "sqlView" ) - public List getSqlViews() + @JacksonXmlElementWrapper( localName = "sqlViews", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "sqlView", namespace = Dxf2Namespace.NAMESPACE ) + public Set getSqlViews() { return sqlViews; } - public void setSqlViews( List sqlViews ) + public void setSqlViews( Set sqlViews ) { this.sqlViews = sqlViews; } @JsonProperty - @JacksonXmlElementWrapper( localName = "charts" ) - @JacksonXmlProperty( localName = "chart" ) - public List getCharts() + @JacksonXmlElementWrapper( localName = "charts", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "chart", namespace = Dxf2Namespace.NAMESPACE ) + public Set getCharts() { return charts; } - public void setCharts( List charts ) + public void setCharts( Set charts ) { this.charts = charts; } @JsonProperty - @JacksonXmlElementWrapper( localName = "reports" ) - @JacksonXmlProperty( localName = "report" ) - public List getReports() + @JacksonXmlElementWrapper( localName = "reports", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "report", namespace = Dxf2Namespace.NAMESPACE ) + public Set getReports() { return reports; } - public void setReports( List reports ) + public void setReports( Set reports ) { this.reports = reports; } @JsonProperty - @JacksonXmlElementWrapper( localName = "reportTables" ) - @JacksonXmlProperty( localName = "reportTable" ) - public List getReportTables() + @JacksonXmlElementWrapper( localName = "reportTables", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "reportTable", namespace = Dxf2Namespace.NAMESPACE ) + public Set getReportTables() { return reportTables; } - public void setReportTables( List reportTables ) + public void setReportTables( Set reportTables ) { this.reportTables = reportTables; } @JsonProperty - @JacksonXmlElementWrapper( localName = "documents" ) - @JacksonXmlProperty( localName = "document" ) - public List getDocuments() + @JacksonXmlElementWrapper( localName = "documents", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "document", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDocuments() { return documents; } - public void setDocuments( List documents ) + public void setDocuments( Set documents ) { this.documents = documents; } @JsonProperty - @JacksonXmlElementWrapper( localName = "constants" ) - @JacksonXmlProperty( localName = "constant" ) - public List getConstants() + @JacksonXmlElementWrapper( localName = "constants", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "constant", namespace = Dxf2Namespace.NAMESPACE ) + public Set getConstants() { return constants; } - public void setConstants( List constants ) + public void setConstants( Set constants ) { this.constants = constants; } @JsonProperty - @JacksonXmlElementWrapper( localName = "maps" ) - @JacksonXmlProperty( localName = "map" ) - public List getMaps() + @JacksonXmlElementWrapper( localName = "maps", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "map", namespace = Dxf2Namespace.NAMESPACE ) + public Set getMaps() { return maps; } - public void setMaps( List maps ) + public void setMaps( Set maps ) { this.maps = maps; } @JsonProperty - @JacksonXmlElementWrapper( localName = "mapLegends" ) - @JacksonXmlProperty( localName = "mapLegend" ) - public List getMapLegends() + @JacksonXmlElementWrapper( localName = "mapLegends", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "mapLegend", namespace = Dxf2Namespace.NAMESPACE ) + public Set getMapLegends() { return mapLegends; } - public void setMapLegends( List mapLegends ) + public void setMapLegends( Set mapLegends ) { this.mapLegends = mapLegends; } @JsonProperty - @JacksonXmlElementWrapper( localName = "mapLegendSets" ) - @JacksonXmlProperty( localName = "mapLegendSet" ) - public List getMapLegendSets() + @JacksonXmlElementWrapper( localName = "mapLegendSets", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "mapLegendSet", namespace = Dxf2Namespace.NAMESPACE ) + public Set getMapLegendSets() { return mapLegendSets; } - public void setMapLegendSets( List mapLegendSets ) + public void setMapLegendSets( Set mapLegendSets ) { this.mapLegendSets = mapLegendSets; } @JsonProperty - @JacksonXmlElementWrapper( localName = "mapLayers" ) - @JacksonXmlProperty( localName = "mapLayer" ) - public List getMapLayers() + @JacksonXmlElementWrapper( localName = "mapLayers", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "mapLayer", namespace = Dxf2Namespace.NAMESPACE ) + public Set getMapLayers() { return mapLayers; } - public void setMapLayers( List mapLayers ) + public void setMapLayers( Set mapLayers ) { this.mapLayers = mapLayers; } @JsonProperty - @JacksonXmlElementWrapper( localName = "dataDictionaries" ) - @JacksonXmlProperty( localName = "dataDictionary" ) - public List getDataDictionaries() + @JacksonXmlElementWrapper( localName = "dataDictionaries", namespace = Dxf2Namespace.NAMESPACE ) + @JacksonXmlProperty( localName = "dataDictionary", namespace = Dxf2Namespace.NAMESPACE ) + public Set getDataDictionaries() { return dataDictionaries; } - public void setDataDictionaries( List dataDictionaries ) + public void setDataDictionaries( Set 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-01 12:24:57 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java 2012-04-02 17:23:48 +0000 @@ -27,8 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; - import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.chart.Chart; @@ -39,58 +37,36 @@ import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.datadictionary.DataDictionary; import org.hisp.dhis.datadictionary.DataDictionaryService; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategory; -import org.hisp.dhis.dataelement.DataElementCategoryCombo; -import org.hisp.dhis.dataelement.DataElementCategoryOption; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementGroupSet; -import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataelement.*; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.document.Document; import org.hisp.dhis.document.DocumentService; -import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorGroup; -import org.hisp.dhis.indicator.IndicatorGroupSet; -import org.hisp.dhis.indicator.IndicatorService; -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.mapping.MappingService; +import org.hisp.dhis.indicator.*; +import org.hisp.dhis.mapping.*; import org.hisp.dhis.option.OptionService; import org.hisp.dhis.option.OptionSet; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitGroup; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.hisp.dhis.organisationunit.OrganisationUnitLevel; -import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.organisationunit.*; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.sqlview.SqlView; import org.hisp.dhis.sqlview.SqlViewService; -import org.hisp.dhis.user.User; -import org.hisp.dhis.user.UserAuthorityGroup; -import org.hisp.dhis.user.UserGroup; -import org.hisp.dhis.user.UserGroupService; -import org.hisp.dhis.user.UserService; +import org.hisp.dhis.user.*; import org.hisp.dhis.validation.ValidationRule; import org.hisp.dhis.validation.ValidationRuleGroup; import org.hisp.dhis.validation.ValidationRuleService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashSet; /** * @author Morten Olav Hansen */ -@Component +@Service public class DefaultExportService implements ExportService { @@ -167,177 +143,177 @@ if ( exportOptions.isAttributeTypes() ) { - dxf2.setAttributeTypes( new ArrayList( attributeService.getAllAttributes() ) ); + dxf2.setAttributeTypes( new HashSet( attributeService.getAllAttributes() ) ); } if ( exportOptions.isUsers() ) { - dxf2.setUsers( new ArrayList( userService.getAllUsers() ) ); + dxf2.setUsers( new HashSet( userService.getAllUsers() ) ); } if ( exportOptions.isUserAuthorityGroups() ) { - dxf2.setUserAuthorityGroups( new ArrayList( userService.getAllUserAuthorityGroups() ) ); + dxf2.setUserAuthorityGroups( new HashSet( userService.getAllUserAuthorityGroups() ) ); } if ( exportOptions.isUserGroups() ) { - dxf2.setUserGroups( new ArrayList( userGroupService.getAllUserGroups() ) ); + dxf2.setUserGroups( new HashSet( userGroupService.getAllUserGroups() ) ); } if ( exportOptions.isConstants() ) { - dxf2.setConstants( new ArrayList( constantService.getAllConstants() ) ); + dxf2.setConstants( new HashSet( constantService.getAllConstants() ) ); } if ( exportOptions.isConcepts() ) { - dxf2.setConcepts( new ArrayList( conceptService.getAllConcepts() ) ); + dxf2.setConcepts( new HashSet( conceptService.getAllConcepts() ) ); } if ( exportOptions.isDataElements() ) { - dxf2.setDataElements( new ArrayList( dataElementService.getAllDataElements() ) ); + dxf2.setDataElements( new HashSet( dataElementService.getAllDataElements() ) ); } if ( exportOptions.isOptionSets() ) { - dxf2.setOptionSets( new ArrayList( optionService.getAllOptionSets() ) ); + dxf2.setOptionSets( new HashSet( optionService.getAllOptionSets() ) ); } if ( exportOptions.isDataElementGroups() ) { - dxf2.setDataElementGroups( new ArrayList( dataElementService.getAllDataElementGroups() ) ); + dxf2.setDataElementGroups( new HashSet( dataElementService.getAllDataElementGroups() ) ); } if ( exportOptions.isDataElementGroupSets() ) { - dxf2.setDataElementGroupSets( new ArrayList( dataElementService.getAllDataElementGroupSets() ) ); + dxf2.setDataElementGroupSets( new HashSet( dataElementService.getAllDataElementGroupSets() ) ); } if ( exportOptions.isCategories() ) { - dxf2.setCategories( new ArrayList( dataElementCategoryService.getAllDataElementCategories() ) ); + dxf2.setCategories( new HashSet( dataElementCategoryService.getAllDataElementCategories() ) ); } if ( exportOptions.isCategoryOptions() ) { - dxf2.setCategoryOptions( new ArrayList( dataElementCategoryService.getAllDataElementCategoryOptions() ) ); + dxf2.setCategoryOptions( new HashSet( dataElementCategoryService.getAllDataElementCategoryOptions() ) ); } if ( exportOptions.isCategoryCombos() ) { - dxf2.setCategoryCombos( new ArrayList( dataElementCategoryService.getAllDataElementCategoryCombos() ) ); + dxf2.setCategoryCombos( new HashSet( dataElementCategoryService.getAllDataElementCategoryCombos() ) ); } if ( exportOptions.isCategoryOptionCombos() ) { - dxf2.setCategoryOptionCombos( new ArrayList( dataElementCategoryService.getAllDataElementCategoryOptionCombos() ) ); + dxf2.setCategoryOptionCombos( new HashSet( dataElementCategoryService.getAllDataElementCategoryOptionCombos() ) ); } if ( exportOptions.isIndicators() ) { - dxf2.setIndicators( new ArrayList( indicatorService.getAllIndicators() ) ); + dxf2.setIndicators( new HashSet( indicatorService.getAllIndicators() ) ); } if ( exportOptions.isIndicatorGroups() ) { - dxf2.setIndicatorGroups( new ArrayList( indicatorService.getAllIndicatorGroups() ) ); + dxf2.setIndicatorGroups( new HashSet( indicatorService.getAllIndicatorGroups() ) ); } if ( exportOptions.isIndicatorGroupSets() ) { - dxf2.setIndicatorGroupSets( new ArrayList( indicatorService.getAllIndicatorGroupSets() ) ); + dxf2.setIndicatorGroupSets( new HashSet( indicatorService.getAllIndicatorGroupSets() ) ); } if ( exportOptions.isIndicatorTypes() ) { - dxf2.setIndicatorTypes( new ArrayList( indicatorService.getAllIndicatorTypes() ) ); + dxf2.setIndicatorTypes( new HashSet( indicatorService.getAllIndicatorTypes() ) ); } if ( exportOptions.isOrganisationUnits() ) { - dxf2.setOrganisationUnits( new ArrayList( organisationUnitService.getAllOrganisationUnits() ) ); + dxf2.setOrganisationUnits( new HashSet( organisationUnitService.getAllOrganisationUnits() ) ); } if ( exportOptions.isOrganisationUnitLevels() ) { - dxf2.setOrganisationUnitLevels( new ArrayList( organisationUnitService.getOrganisationUnitLevels() ) ); + dxf2.setOrganisationUnitLevels( new HashSet( organisationUnitService.getOrganisationUnitLevels() ) ); } if ( exportOptions.isOrganisationUnitGroups() ) { - dxf2.setOrganisationUnitGroups( new ArrayList( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); + dxf2.setOrganisationUnitGroups( new HashSet( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); } if ( exportOptions.isOrganisationUnitGroupSets() ) { - dxf2.setOrganisationUnitGroupSets( new ArrayList( organisationUnitGroupService.getAllOrganisationUnitGroupSets() ) ); + dxf2.setOrganisationUnitGroupSets( new HashSet( organisationUnitGroupService.getAllOrganisationUnitGroupSets() ) ); } if ( exportOptions.isDataSets() ) { - dxf2.setDataSets( new ArrayList( dataSetService.getAllDataSets() ) ); + dxf2.setDataSets( new HashSet( dataSetService.getAllDataSets() ) ); } if ( exportOptions.isValidationRules() ) { - dxf2.setValidationRules( new ArrayList( validationRuleService.getAllValidationRules() ) ); + dxf2.setValidationRules( new HashSet( validationRuleService.getAllValidationRules() ) ); } if ( exportOptions.isValidationRuleGroups() ) { - dxf2.setValidationRuleGroups( new ArrayList( validationRuleService.getAllValidationRuleGroups() ) ); + dxf2.setValidationRuleGroups( new HashSet( validationRuleService.getAllValidationRuleGroups() ) ); } if ( exportOptions.isSqlViews() ) { - dxf2.setSqlViews( new ArrayList( sqlViewService.getAllSqlViews() ) ); + dxf2.setSqlViews( new HashSet( sqlViewService.getAllSqlViews() ) ); } if ( exportOptions.isDocuments() ) { - dxf2.setDocuments( new ArrayList( documentService.getAllDocuments() ) ); + dxf2.setDocuments( new HashSet( documentService.getAllDocuments() ) ); } if ( exportOptions.isReportTables() ) { - dxf2.setReportTables( new ArrayList( reportTableService.getAllReportTables() ) ); + dxf2.setReportTables( new HashSet( reportTableService.getAllReportTables() ) ); } if ( exportOptions.isReports() ) { - dxf2.setReports( new ArrayList( reportService.getAllReports() ) ); + dxf2.setReports( new HashSet( reportService.getAllReports() ) ); } if ( exportOptions.isCharts() ) { - dxf2.setCharts( new ArrayList( chartService.getAllCharts() ) ); + dxf2.setCharts( new HashSet( chartService.getAllCharts() ) ); } if ( exportOptions.isMaps() ) { - dxf2.setMaps( new ArrayList( mappingService.getAllMapViews() ) ); + dxf2.setMaps( new HashSet( mappingService.getAllMapViews() ) ); } if ( exportOptions.isMapLegends() ) { - dxf2.setMapLegends( new ArrayList( mappingService.getAllMapLegends() ) ); + dxf2.setMapLegends( new HashSet( mappingService.getAllMapLegends() ) ); } if ( exportOptions.isMapLegendSets() ) { - dxf2.setMapLegendSets( new ArrayList( mappingService.getAllMapLegendSets() ) ); + dxf2.setMapLegendSets( new HashSet( mappingService.getAllMapLegendSets() ) ); } if ( exportOptions.isMapLayers() ) { - dxf2.setMapLayers( new ArrayList( mappingService.getAllMapLayers() ) ); + dxf2.setMapLayers( new HashSet( mappingService.getAllMapLayers() ) ); } if ( exportOptions.isDataDictionaries() ) { - dxf2.setDataDictionaries( new ArrayList( dataDictionaryService.getAllDataDictionaries() ) ); + dxf2.setDataDictionaries( new HashSet( dataDictionaryService.getAllDataDictionaries() ) ); } return dxf2; === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java 2012-04-02 17:23:48 +0000 @@ -0,0 +1,151 @@ +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. + */ + +import org.hisp.dhis.attribute.AttributeService; +import org.hisp.dhis.chart.ChartService; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.common.NameableObject; +import org.hisp.dhis.concept.ConceptService; +import org.hisp.dhis.constant.Constant; +import org.hisp.dhis.constant.ConstantService; +import org.hisp.dhis.datadictionary.DataDictionaryService; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.document.DocumentService; +import org.hisp.dhis.dxf2.importsummary.ImportConflict; +import org.hisp.dhis.dxf2.importsummary.ImportSummary; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.mapping.MappingService; +import org.hisp.dhis.option.OptionService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.report.ReportService; +import org.hisp.dhis.reporttable.ReportTableService; +import org.hisp.dhis.sqlview.SqlViewService; +import org.hisp.dhis.user.UserGroupService; +import org.hisp.dhis.user.UserService; +import org.hisp.dhis.validation.ValidationRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Morten Olav Hansen + */ +@Transactional +@Service +public class DefaultImportService + implements ImportService +{ + //------------------------------------------------------------------------------------------------------- + // Dependencies + //------------------------------------------------------------------------------------------------------- +/* + @Autowired + private AttributeService attributeService; + + @Autowired + private UserService userService; + + @Autowired + private UserGroupService userGroupService; + + @Autowired + private DataElementService dataElementService; + + @Autowired + private OptionService optionService; + + @Autowired + private ConceptService conceptService; + + @Autowired + private DataElementCategoryService dataElementCategoryService; + + @Autowired + private IndicatorService indicatorService; + + @Autowired + private OrganisationUnitService organisationUnitService; + + @Autowired + private OrganisationUnitGroupService organisationUnitGroupService; + + @Autowired + private DataSetService dataSetService; + + @Autowired + private ValidationRuleService validationRuleService; + + @Autowired + private SqlViewService sqlViewService; + + @Autowired + private ChartService chartService; + + @Autowired + private ReportService reportService; + + @Autowired + private ReportTableService reportTableService; + + @Autowired + private DocumentService documentService; + + @Autowired + private ConstantService constantService; + + @Autowired + private MappingService mappingService; + + @Autowired + private DataDictionaryService dataDictionaryService; +*/ + + //------------------------------------------------------------------------------------------------------- + // ImportService Implementation + //------------------------------------------------------------------------------------------------------- + + @Override + public ImportSummary importDxf2( DXF2 dxf2 ) + { + return importDxf2WithImportOptions( dxf2, ImportOptions.getDefaultImportOptions() ); + } + + @Override + public ImportSummary importDxf2WithImportOptions( DXF2 dxf2, ImportOptions importOptions ) + { + return new ImportSummary(); + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/IdScheme.java 2012-04-02 17:23:48 +0000 @@ -0,0 +1,89 @@ +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 + */ +public class IdScheme +{ + public static String UID_SCHEME = "uid"; + public static String CODE_SCHEME = "code"; + public static 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 ); + codeScheme = scheme.equals( IdScheme.CODE_SCHEME ); + nameScheme = scheme.equals( IdScheme.NAME_SCHEME ); + } + } + + public boolean isUidScheme() + { + return uidScheme; + } + + public boolean isCodeScheme() + { + return codeScheme; + } + + public boolean isNameScheme() + { + return nameScheme; + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java 2012-04-02 17:23:48 +0000 @@ -0,0 +1,91 @@ +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 + */ +public class ImportOptions +{ + private boolean dryRun = false; + + private IdScheme idScheme = IdScheme.getDefaultIdScheme(); + + private ImportStrategy importStrategy; + + private static ImportOptions defaultImportOptions = new ImportOptions( IdScheme.getDefaultIdScheme(), + ImportStrategy.getDefaultImportStrategy() ); + + public static ImportOptions getDefaultImportOptions() + { + return defaultImportOptions; + } + + public ImportOptions() + { + this.idScheme = IdScheme.getDefaultIdScheme(); + this.importStrategy = ImportStrategy.getDefaultImportStrategy(); + } + + public ImportOptions( IdScheme idScheme, ImportStrategy importStrategy ) + { + this.idScheme = idScheme; + this.importStrategy = importStrategy; + } + + public boolean isDryRun() + { + return dryRun; + } + + public void setDryRun( boolean dryRun ) + { + this.dryRun = dryRun; + } + + public IdScheme getIdScheme() + { + return idScheme; + } + + public void setIdScheme( IdScheme idScheme ) + { + this.idScheme = idScheme; + } + + public ImportStrategy getImportStrategy() + { + return importStrategy; + } + + public void setImportStrategy( ImportStrategy importStrategy ) + { + this.importStrategy = importStrategy; + } +} === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportService.java 2012-04-02 17:23:48 +0000 @@ -0,0 +1,42 @@ +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. + */ + +import org.hisp.dhis.dxf2.importsummary.ImportSummary; +import org.springframework.stereotype.Service; + +/** + * @author Morten Olav Hansen + */ +@Service +public interface ImportService +{ + ImportSummary importDxf2( DXF2 dxf2 ); + + ImportSummary importDxf2WithImportOptions( DXF2 dxf2, ImportOptions importOptions ); +} === added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportStrategy.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportStrategy.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportStrategy.java 2012-04-02 17:23:48 +0000 @@ -0,0 +1,89 @@ +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 + */ +public class ImportStrategy +{ + public static String NEW_AND_UPDATES_STRATEGY = "newAndUpdates"; + public static String UPDATES_STRATEGY = "updates"; + public static String NEW_STRATEGY = "new"; + + private String strategy; + + private boolean newAndUpdatesStrategy; + + private boolean updatesStrategy; + + private boolean newStrategy; + + public static ImportStrategy getDefaultImportStrategy() + { + return new ImportStrategy( ImportStrategy.NEW_AND_UPDATES_STRATEGY ); + } + + public ImportStrategy( String strategy ) + { + setStrategy( strategy ); + } + + public String getStrategy() + { + return strategy; + } + + public void setStrategy( String strategy ) + { + this.strategy = strategy; + + if ( strategy != null ) + { + newAndUpdatesStrategy = strategy.equals( ImportStrategy.NEW_AND_UPDATES_STRATEGY ); + updatesStrategy = strategy.equals( ImportStrategy.UPDATES_STRATEGY ); + newStrategy = strategy.equals( ImportStrategy.NEW_STRATEGY ); + } + } + + public boolean isNewAndUpdatesStrategy() + { + return newAndUpdatesStrategy; + } + + public boolean isUpdatesStrategy() + { + return updatesStrategy; + } + + public boolean isNewStrategy() + { + return newStrategy; + } +} === modified file 'dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml 2012-04-01 12:04:14 +0000 +++ dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml 2012-04-02 17:23:48 +0000 @@ -9,6 +9,6 @@ class="org.hisp.dhis.dxf2.datavalueset.DefaultDataValueSetService" /> + class="org.hisp.dhis.dxf2.datavalueset.SpringDataValueSetStore" /> === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/constant/hibernate/Constant.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/constant/hibernate/Constant.hbm.xml 2011-11-03 01:02:13 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/constant/hibernate/Constant.hbm.xml 2012-04-02 17:23:48 +0000 @@ -14,7 +14,7 @@ &identifiableProperties; - + === 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-03-30 10:53:18 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java 2012-04-02 17:23:48 +0000 @@ -29,11 +29,11 @@ import org.hisp.dhis.api.utils.ContextUtils; import org.hisp.dhis.common.view.ExportView; -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.importsummary.ImportSummary; +import org.hisp.dhis.dxf2.metadata.*; import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -60,6 +60,9 @@ @Autowired private ExportService exportService; + @Autowired + private ImportService importService; + //------------------------------------------------------------------------------------------------------- // Export //------------------------------------------------------------------------------------------------------- @@ -114,102 +117,59 @@ @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/*"} ) @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" ) - public void importXml( HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException + public void importXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException { DXF2 dxf2 = JacksonUtils.fromXml( request.getInputStream(), DXF2.class ); - - print( dxf2 ); + System.err.println( dxf2 ); + + ImportSummary summary = importService.importDxf2WithImportOptions( dxf2, importOptions ); + + response.setContentType( MediaType.APPLICATION_XML.toString() ); + JacksonUtils.toXml( response.getOutputStream(), summary ); } @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.POST, headers = {"Content-Type=application/json"} ) @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" ) - public void importJson( HttpServletResponse response, HttpServletRequest request ) throws IOException + public void importJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException { DXF2 dxf2 = JacksonUtils.fromJson( request.getInputStream(), DXF2.class ); - - print( dxf2 ); + System.err.println( dxf2 ); + + ImportSummary summary = importService.importDxf2WithImportOptions( dxf2, importOptions ); + + response.setContentType( MediaType.APPLICATION_JSON.toString() ); + JacksonUtils.toJson( response.getOutputStream(), summary ); } @RequestMapping( value = MetaDataController.RESOURCE_PATH + ".zip", method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} ) @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" ) - public void importZippedXml( HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException + public void importZippedXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws JAXBException, IOException { ZipInputStream zip = new ZipInputStream( new BufferedInputStream( request.getInputStream() ) ); ZipEntry entry = zip.getNextEntry(); - System.err.println( "(xml) Reading from file : " + entry.getName() ); - DXF2 dxf2 = JacksonUtils.fromXml( zip, DXF2.class ); - - print( dxf2 ); + System.err.println( dxf2 ); + + ImportSummary summary = importService.importDxf2WithImportOptions( dxf2, importOptions ); + + response.setContentType( MediaType.APPLICATION_XML.toString() ); + JacksonUtils.toXml( response.getOutputStream(), summary ); } @RequestMapping( value = MetaDataController.RESOURCE_PATH + ".zip", method = RequestMethod.POST, headers = {"Content-Type=application/json"} ) @PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" ) - public void importZippedJson( HttpServletResponse response, HttpServletRequest request ) throws IOException + public void importZippedJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException { ZipInputStream zip = new ZipInputStream( request.getInputStream() ); ZipEntry entry = zip.getNextEntry(); - System.err.println( "(json) Reading from file : " + entry.getName() ); DXF2 dxf2 = JacksonUtils.fromJson( zip, DXF2.class ); - - print( dxf2 ); - } - - - //------------------------------------------------------------------------------------------------------- - // Helpers - //------------------------------------------------------------------------------------------------------- - - private void print( DXF2 dxf2 ) - { - System.err.println( "AttributeTypes: " + dxf2.getAttributeTypes().size() ); - - System.err.println( "Users: " + dxf2.getUsers().size() ); - System.err.println( "UserGroups: " + dxf2.getUserGroups().size() ); - System.err.println( "UserAuthorityGroups: " + dxf2.getUserAuthorityGroups().size() ); - - System.err.println( "Documents: " + dxf2.getDocuments().size() ); - System.err.println( "Reports: " + dxf2.getReports().size() ); - System.err.println( "ReportTables: " + dxf2.getReportTables().size() ); - System.err.println( "Charts: " + dxf2.getCharts().size() ); - - System.err.println( "Maps: " + dxf2.getMaps().size() ); - System.err.println( "MapLegends: " + dxf2.getMapLegends().size() ); - System.err.println( "MapLegendSets: " + dxf2.getMapLegendSets().size() ); - System.err.println( "MapLayers: " + dxf2.getMapLayers().size() ); - - System.err.println( "Constants: " + dxf2.getConstants().size() ); - System.err.println( "Concepts: " + dxf2.getConcepts().size() ); - - System.err.println( "SqlViews: " + dxf2.getSqlViews().size() ); - - System.err.println( "DataElements: " + dxf2.getDataElements().size() ); - System.err.println( "OptionSets: " + dxf2.getOptionSets().size() ); - System.err.println( "DataElementGroups: " + dxf2.getDataElementGroups().size() ); - System.err.println( "DataElementGroupSets: " + dxf2.getDataElementGroupSets().size() ); - - System.err.println( "Categories: " + dxf2.getCategories().size() ); - System.err.println( "CategoryOptions: " + dxf2.getCategoryOptions().size() ); - System.err.println( "CategoryCombos: " + dxf2.getCategoryCombos().size() ); - System.err.println( "CategoryOptionCombos: " + dxf2.getCategoryOptionCombos().size() ); - - System.err.println( "DataSets: " + dxf2.getDataSets().size() ); - - System.err.println( "Indicators:" + dxf2.getIndicators().size() ); - System.err.println( "IndicatorGroups:" + dxf2.getIndicatorGroups().size() ); - System.err.println( "IndicatorGroupSets:" + dxf2.getIndicatorGroupSets().size() ); - System.err.println( "IndicatorTypes:" + dxf2.getIndicatorTypes().size() ); - - System.err.println( "OrganisationUnits: " + dxf2.getOrganisationUnits().size() ); - System.err.println( "OrganisationUnitGroups: " + dxf2.getOrganisationUnitGroups().size() ); - System.err.println( "OrganisationUnitGroupSets: " + dxf2.getOrganisationUnitGroupSets().size() ); - System.err.println( "OrganisationUnitLevels: " + dxf2.getOrganisationUnitLevels().size() ); - - System.err.println( "ValidationRules: " + dxf2.getValidationRules().size() ); - System.err.println( "ValidationRuleGroups: " + dxf2.getValidationRuleGroups().size() ); - - System.err.println( "DataDictionaries: " + dxf2.getDataDictionaries().size() ); + System.err.println( dxf2 ); + + ImportSummary summary = importService.importDxf2WithImportOptions( dxf2, importOptions ); + + response.setContentType( MediaType.APPLICATION_JSON.toString() ); + JacksonUtils.toJson( response.getOutputStream(), summary ); } }