=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java 2010-05-12 13:38:28 +0000 @@ -1,8 +1,5 @@ package org.hisp.dhis.common; -import java.io.Serializable; - - /* * Copyright (c) 2004-2010, University of Oslo * All rights reserved. @@ -30,12 +27,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.io.Serializable; + /** * @author Bob Jolliffe * @version $Id$ */ public abstract class IdentifiableObject - implements Serializable + implements ImportableObject, Serializable { /** * The database internal identifier for this Object. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/CategoryComboSizeComparator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/CategoryComboSizeComparator.java 2009-12-11 17:54:58 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/CategoryComboSizeComparator.java 2010-05-12 13:38:28 +0000 @@ -37,13 +37,6 @@ public class CategoryComboSizeComparator implements Comparator { - - /* - * (non-Javadoc) - * - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - @Override public int compare( DataElementCategoryCombo o1, DataElementCategoryCombo o2 ) { return (int) (o1.getOptionCombos().size() - o2.getOptionCombos().size()); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistration.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistration.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistration.java 2010-05-12 13:38:28 +0000 @@ -30,6 +30,7 @@ import java.io.Serializable; import java.util.Date; +import org.hisp.dhis.common.ImportableObject; import org.hisp.dhis.period.Period; import org.hisp.dhis.source.Source; @@ -38,7 +39,7 @@ * @version $Id$ */ public class CompleteDataSetRegistration - implements Serializable + implements ImportableObject, Serializable { private DataSet dataSet; @@ -148,6 +149,11 @@ return toString; } + + public String getName() + { + throw new UnsupportedOperationException(); + } // ------------------------------------------------------------------------- // Getters and setters === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-05-12 13:38:28 +0000 @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Map; +import org.hisp.dhis.common.ImportableObject; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dimension.Dimension; @@ -46,7 +47,7 @@ * @version $Id: DataValue.java 4638 2008-02-25 10:06:47Z larshelg $ */ public class DataValue - implements Serializable, Measure + implements Serializable, Measure, ImportableObject { public static final String TRUE = "true"; public static final String FALSE = "false"; @@ -185,6 +186,11 @@ { return value; } + + public String getName() + { + throw new UnsupportedOperationException(); + } // ------------------------------------------------------------------------- // Logic === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberAssociation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberAssociation.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberAssociation.java 2010-05-12 13:38:28 +0000 @@ -29,13 +29,15 @@ import java.io.Serializable; +import org.hisp.dhis.common.ImportableObject; + /** * @author Lars Helge Overland * @version $Id$ */ public class GroupMemberAssociation - implements Serializable -{ + implements ImportableObject, Serializable +{ private int groupId; private int memberId; @@ -106,7 +108,12 @@ return groupId == other.getGroupId() && memberId == other.getMemberId() && sortOrder == other.getSortOrder(); } - + + public String getName() + { + throw new UnsupportedOperationException(); + } + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ImportObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ImportObject.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/ImportObject.java 2010-05-12 13:38:28 +0000 @@ -2,6 +2,8 @@ import java.io.Serializable; +import org.hisp.dhis.common.ImportableObject; + /* * Copyright (c) 2004-2010, University of Oslo * All rights reserved. @@ -44,9 +46,9 @@ private GroupMemberType groupMemberType; - private Object object; + private ImportableObject object; - private Object compareObject; + private ImportableObject compareObject; // ------------------------------------------------------------------------- // Constructors @@ -56,7 +58,7 @@ { } - public ImportObject( ImportObjectStatus status, String className, Object object ) + public ImportObject( ImportObjectStatus status, String className, ImportableObject object ) { this.status = status; this.className = className; @@ -65,7 +67,7 @@ this.compareObject = null; } - public ImportObject( ImportObjectStatus status, String className, GroupMemberType groupMemberType, Object object ) + public ImportObject( ImportObjectStatus status, String className, GroupMemberType groupMemberType, ImportableObject object ) { this.status = status; this.className = className; @@ -74,7 +76,7 @@ this.compareObject = null; } - public ImportObject( ImportObjectStatus status, String className, Object object, Object compareObject ) + public ImportObject( ImportObjectStatus status, String className, ImportableObject object, ImportableObject compareObject ) { this.status = status; this.className = className; @@ -83,7 +85,7 @@ this.compareObject = compareObject; } - public ImportObject( ImportObjectStatus status, String className, GroupMemberType groupMemberType, Object object, Object compareObject ) + public ImportObject( ImportObjectStatus status, String className, GroupMemberType groupMemberType, ImportableObject object, ImportableObject compareObject ) { this.status = status; this.className = className; @@ -187,22 +189,22 @@ this.groupMemberType = groupMemberType; } - public Object getObject() + public ImportableObject getObject() { return object; } - public void setObject( Object object ) + public void setObject( ImportableObject object ) { this.object = object; } - public Object getCompareObject() + public ImportableObject getCompareObject() { return compareObject; } - public void setCompareObject( Object compareObject ) + public void setCompareObject( ImportableObject compareObject ) { this.compareObject = compareObject; } === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectService.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectService.java 2010-05-12 13:38:28 +0000 @@ -29,6 +29,8 @@ import java.util.Collection; +import org.hisp.dhis.common.ImportableObject; + /** * @author Lars Helge Overland * @version $Id: ImportObjectService.java 5793 2008-10-02 14:14:00Z larshelg $ @@ -48,7 +50,7 @@ * @param groupMemberType the GroupMemberType of the object. * @param object the belonging Object. */ - int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, Object object ); + int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object ); /** * Adds an ImportObject. @@ -57,7 +59,7 @@ * @param object the belonging Object. * @param compareObject the matching Object of the belonging Object. */ - int addImportObject( ImportObjectStatus status, Object object, Object compareObject ); + int addImportObject( ImportObjectStatus status, ImportableObject object, ImportableObject compareObject ); /** * Adds an ImportObject. @@ -67,7 +69,7 @@ * @param object the belonging Object. * @param compareObject the matching Object of the belonging Object. */ - int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, Object object, Object compareObject ); + int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object, ImportableObject compareObject ); /** * Gets the ImportObject with the given identifier. * === removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedDataValueConverter.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedDataValueConverter.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedDataValueConverter.java 1970-01-01 00:00:00 +0000 @@ -1,66 +0,0 @@ -package org.hisp.dhis.importexport.converter; - -/* - * Copyright (c) 2004-2010, 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.aggregation.AggregatedDataValue; -import org.hisp.dhis.importexport.ImportParams; - -/** - * @author Lars Helge Overland - * @version $Id: AbstractAggregatedDataValueConverter.java 4825 2008-04-08 12:46:49Z larshelg $ - */ -public class AbstractAggregatedDataValueConverter - extends AbstractConverter -{ - protected ImportParams params; - - // ------------------------------------------------------------------------- - // Overridden methods - // ------------------------------------------------------------------------- - - protected void importUnique( AggregatedDataValue object ) - { - batchHandler.addObject( object ); - } - - protected void importMatching( AggregatedDataValue object, AggregatedDataValue match ) - { - // Do nothing - } - - protected AggregatedDataValue getMatching( AggregatedDataValue object ) - { - return !params.isSkipCheckMatching() ? ( batchHandler.objectExists( object ) ? object : null ) : null; - } - - protected boolean isIdentical( AggregatedDataValue object, AggregatedDataValue match ) - { - return true; - } -} - === removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedIndicatorValueConverter.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedIndicatorValueConverter.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractAggregatedIndicatorValueConverter.java 1970-01-01 00:00:00 +0000 @@ -1,65 +0,0 @@ -package org.hisp.dhis.importexport.converter; - -/* - * Copyright (c) 2004-2010, 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.aggregation.AggregatedIndicatorValue; -import org.hisp.dhis.importexport.ImportParams; - -/** - * @author Lars Helge Overland - * @version $Id: AbstractAggregatedIndicatorValueConverter.java 4825 2008-04-08 12:46:49Z larshelg $ - */ -public class AbstractAggregatedIndicatorValueConverter - extends AbstractConverter -{ - protected ImportParams params; - - // ------------------------------------------------------------------------- - // Overridden methods - // ------------------------------------------------------------------------- - - protected void importUnique( AggregatedIndicatorValue object ) - { - batchHandler.addObject( object ); - } - - protected void importMatching( AggregatedIndicatorValue object, AggregatedIndicatorValue match ) - { - // Do nothing - } - - protected AggregatedIndicatorValue getMatching( AggregatedIndicatorValue object ) - { - return !params.isSkipCheckMatching() ? ( batchHandler.objectExists( object ) ? object : null ) : null; - } - - protected boolean isIdentical( AggregatedIndicatorValue object, AggregatedIndicatorValue match ) - { - return true; - } -} === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractConverter.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractConverter.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/converter/AbstractConverter.java 2010-05-12 13:38:28 +0000 @@ -33,6 +33,7 @@ import static org.hisp.dhis.importexport.ImportStrategy.NEW_AND_UPDATES; import org.amplecode.quick.BatchHandler; +import org.hisp.dhis.common.ImportableObject; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.importexport.GroupMemberType; import org.hisp.dhis.importexport.ImportDataValue; @@ -45,7 +46,7 @@ * @author Lars Helge Overland * @version $Id: AbstractConverter.java 6298 2008-11-17 17:31:14Z larshelg $ */ -public abstract class AbstractConverter +public abstract class AbstractConverter { protected static final String EMPTY = ""; === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java 2010-04-30 15:38:16 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java 2010-05-12 13:38:28 +0000 @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import org.hisp.dhis.cache.HibernateCacheManager; +import org.hisp.dhis.common.ImportableObject; import org.hisp.dhis.datadictionary.DataDictionary; import org.hisp.dhis.datadictionary.DataDictionaryService; import org.hisp.dhis.dataelement.CalculatedDataElement; @@ -196,7 +197,7 @@ // ------------------------------------------------------------------------- @Transactional - public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, Object object ) + public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object ) { ImportObject importObject = new ImportObject( status, object.getClass().getName(), groupMemberType, object ); @@ -204,7 +205,7 @@ } @Transactional - public int addImportObject( ImportObjectStatus status, Object object, Object compareObject ) + public int addImportObject( ImportObjectStatus status, ImportableObject object, ImportableObject compareObject ) { ImportObject importObject = new ImportObject( status, object.getClass().getName(), object, compareObject ); @@ -212,7 +213,7 @@ } @Transactional - public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, Object object, Object compareObject ) + public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object, ImportableObject compareObject ) { ImportObject importObject = new ImportObject( status, object.getClass().getName(), groupMemberType, object, compareObject ); === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetCompareOptionsAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetCompareOptionsAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetCompareOptionsAction.java 2010-05-12 13:38:28 +0000 @@ -27,6 +27,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.importexport.ImportObject; import org.hisp.dhis.importexport.ImportObjectService; import com.opensymphony.xwork2.ActionSupport; @@ -70,9 +71,9 @@ // Output // ------------------------------------------------------------------------- - private Object importObject; + private ImportObject importObject; - public Object getImportObject() + public ImportObject getImportObject() { return importObject; } === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetMatchOptionsAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetMatchOptionsAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetMatchOptionsAction.java 2010-05-12 13:38:28 +0000 @@ -106,9 +106,9 @@ return importObject; } - private Collection objects; + private Collection objects; - public Collection getObjects() + public Collection getObjects() { return objects; } === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetPreviewOptionsAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetPreviewOptionsAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetPreviewOptionsAction.java 2010-05-12 13:38:28 +0000 @@ -29,7 +29,10 @@ import static org.hisp.dhis.util.SessionUtils.*; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; import org.hisp.dhis.datadictionary.DataDictionary; import org.hisp.dhis.datadictionary.ExtendedDataElement; @@ -39,9 +42,11 @@ import org.hisp.dhis.dataelement.DataElementGroupSet; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.importexport.ImportDataValueService; +import org.hisp.dhis.importexport.ImportObject; import org.hisp.dhis.importexport.ImportObjectService; import org.hisp.dhis.importexport.ImportObjectStatus; import org.hisp.dhis.importexport.action.util.ClassMapUtil; +import org.hisp.dhis.importexport.comparator.ImportObjectComparator; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.IndicatorGroupSet; @@ -379,16 +384,9 @@ return updateDataValues; } - private Collection objects; - - public Collection getObjects() - { - return objects; - } - - public Collection importObjects; - - public Collection getImportObjects() + public List importObjects; + + public List getImportObjects() { return importObjects; } @@ -468,7 +466,9 @@ if ( type != null && status != null ) { - importObjects = importObjectService.getImportObjects( ImportObjectStatus.valueOf( status ), ClassMapUtil.getClass( type ) ); + importObjects = new ArrayList( importObjectService.getImportObjects( ImportObjectStatus.valueOf( status ), ClassMapUtil.getClass( type ) ) ); + + Collections.sort( importObjects, new ImportObjectComparator() ); } return SUCCESS;