dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13066
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4129: Applied patch from Hieu. Implements import-export of constants. Nice work.
------------------------------------------------------------
revno: 4129
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-07-13 13:32:13 +0200
message:
Applied patch from Hieu. Implements import-export of constants. Nice work.
added:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ConstantConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ConstantImporter.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ConstantBatchHandler.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Objects.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectManager.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/AbstractImporter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/ObjectMappingGenerator.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties
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/GetPreviewOptionsAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/import.js
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/matchToExistingForm.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/previewForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Objects.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Objects.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Objects.java 2011-07-13 11:32:13 +0000
@@ -33,6 +33,7 @@
*/
public enum Objects
{
+ CONSTANT,
DATAELEMENT,
EXTENDEDDATAELEMENT,
DATAELEMENTGROUP,
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectManager.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectManager.java 2011-07-13 11:32:13 +0000
@@ -33,6 +33,8 @@
*/
public interface ImportObjectManager
{
+ void importConstants();
+
void importCategoryOptions();
void importCategories();
@@ -106,4 +108,5 @@
void importCompleteDataSetRegistrations();
void importDataValues();
+
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ConstantConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ConstantConverter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ConstantConverter.java 2011-07-13 11:32:13 +0000
@@ -0,0 +1,132 @@
+package org.hisp.dhis.importexport.dxf.converter;
+
+/*
+ * Copyright (c) 2004-2011, 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 <ORGANIZATION> 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 java.util.Collection;
+import java.util.Map;
+
+import org.amplecode.quick.BatchHandler;
+import org.amplecode.staxwax.reader.XMLReader;
+import org.amplecode.staxwax.writer.XMLWriter;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.importexport.ExportParams;
+import org.hisp.dhis.importexport.ImportObjectService;
+import org.hisp.dhis.importexport.ImportParams;
+import org.hisp.dhis.importexport.XMLConverter;
+import org.hisp.dhis.importexport.importer.ConstantImporter;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ConstantConverter
+ extends ConstantImporter
+ implements XMLConverter
+{
+ public static final String COLLECTION_NAME = "constants";
+
+ public static final String ELEMENT_NAME = "constant";
+
+ private static final String FIELD_ID = "id";
+
+ private static final String FIELD_NAME = "name";
+
+ private static final String FIELD_VALUE = "value";
+
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+ /**
+ * Constructor for write operations.
+ *
+ * @param constantService
+ */
+ public ConstantConverter( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
+ /**
+ * Constructor for read operations.
+ *
+ * @param batchHandler the batchHandler to use.
+ * @param importObjectService the importObjectService to use.
+ * @param constantService the constantServiceService to use.
+ */
+ public ConstantConverter( BatchHandler<Constant> batchHandler, ImportObjectService importObjectService,
+ ConstantService constantService )
+ {
+ this.batchHandler = batchHandler;
+ this.importObjectService = importObjectService;
+ this.constantService = constantService;
+ }
+
+ // -------------------------------------------------------------------------
+ // XMLConverter implementation
+ // -------------------------------------------------------------------------
+
+ public void write( XMLWriter writer, ExportParams params )
+ {
+ Collection<Constant> constants = constantService.getAllConstants();
+System.out.println("\nconstants : " + (constants == null ? "is null" : constants));
+ if ( constants != null && constants.size() > 0 )
+ {
+ writer.openElement( COLLECTION_NAME );
+
+ for ( Constant constant : constants )
+ {
+ writer.openElement( ELEMENT_NAME );
+
+ writer.writeElement( FIELD_ID, String.valueOf( constant.getId() ) );
+ writer.writeElement( FIELD_NAME, constant.getName() );
+ writer.writeElement( FIELD_VALUE, String.valueOf( constant.getValue() ) );
+
+ writer.closeElement();
+ }
+
+ writer.closeElement();
+ }
+ }
+
+ public void read( XMLReader reader, ImportParams params )
+ {
+ while ( reader.moveToStartElement( ELEMENT_NAME, COLLECTION_NAME ) )
+ {
+ final Map<String, String> results = reader.readElements( ELEMENT_NAME );
+
+ final Constant constant = new Constant();
+
+ constant.setId( Integer.parseInt( results.get( FIELD_ID ) ) );
+ constant.setName( results.get( FIELD_NAME ) );
+ constant.setValue( Double.parseDouble( results.get( FIELD_VALUE ) ) );
+
+ importObject( constant, params );
+ }
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java 2011-07-13 11:32:13 +0000
@@ -43,6 +43,8 @@
import org.hisp.dhis.common.ProcessState;
import org.hisp.dhis.concept.Concept;
import org.hisp.dhis.concept.ConceptService;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElement;
@@ -78,6 +80,7 @@
import org.hisp.dhis.jdbc.batchhandler.CategoryComboCategoryAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.CompleteDataSetRegistrationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.ConceptBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.ConstantBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryDataElementBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryIndicatorBatchHandler;
@@ -162,6 +165,13 @@
this.conceptService = conceptService;
}
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
@@ -333,6 +343,21 @@
log.info( "Imported Concepts" );
}
+ else if ( reader.isStartElement( ConstantConverter.COLLECTION_NAME ) )
+ {
+ state.setMessage( "importing_constants" );
+
+ BatchHandler<Constant> batchHandler = batchHandlerFactory.createBatchHandler(
+ ConstantBatchHandler.class ).init();
+
+ XMLConverter converter = new ConstantConverter( batchHandler, importObjectService, constantService );
+
+ converterInvoker.invokeRead( converter, reader, params );
+
+ batchHandler.flush();
+
+ log.info( "Imported Constants" );
+ }
else if ( reader.isStartElement( DataElementCategoryOptionConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_options" );
@@ -696,11 +721,12 @@
else if ( reader.isStartElement( OrganisationUnitConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_units" );
-
+
BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler(
OrganisationUnitBatchHandler.class ).init();
- XMLConverter converter = new OrganisationUnitConverter( batchHandler, importObjectService, organisationUnitService, importAnalyser );
+ XMLConverter converter = new OrganisationUnitConverter( batchHandler, importObjectService,
+ organisationUnitService, importAnalyser );
converterInvoker.invokeRead( converter, reader, params );
@@ -944,4 +970,5 @@
cacheManager.clearCache();
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java 2011-07-13 11:32:13 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.concept.ConceptService;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
@@ -63,6 +64,7 @@
import org.hisp.dhis.importexport.dxf.converter.ChartConverter;
import org.hisp.dhis.importexport.dxf.converter.CompleteDataSetRegistrationConverter;
import org.hisp.dhis.importexport.dxf.converter.ConceptConverter;
+import org.hisp.dhis.importexport.dxf.converter.ConstantConverter;
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryConverter;
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryDataElementConverter;
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryIndicatorConverter;
@@ -107,8 +109,7 @@
/**
* @author Lars Helge Overland
- * @version $Id: DefaultDXFExportService.java 5960 2008-10-17 14:07:50Z larshelg
- * $
+ * @version $Id: DefaultDXFExportService.java 5960 2008-10-17 14:07:50Z larshelg $
*/
public class DefaultDXFExportService
implements ExportService
@@ -140,6 +141,13 @@
this.conceptService = conceptService;
}
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
private DataElementCategoryService categoryService;
public void setCategoryService( DataElementCategoryService categoryService )
@@ -292,6 +300,8 @@
thread.registerXMLConverter( new DataElementGroupSetConverter( dataElementService ) );
thread.registerXMLConverter( new DataElementGroupSetMemberConverter( dataElementService ) );
+ thread.registerXMLConverter( new ConstantConverter( constantService ) );
+
thread.registerXMLConverter( new IndicatorTypeConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorGroupConverter( indicatorService ) );
@@ -302,7 +312,7 @@
thread.registerXMLConverter( new DataDictionaryConverter( dataDictionaryService ) );
thread.registerXMLConverter( new DataDictionaryDataElementConverter( dataDictionaryService ) );
thread.registerXMLConverter( new DataDictionaryIndicatorConverter( dataDictionaryService ) );
-
+
thread.registerXMLConverter( new DataSetConverter( dataSetService ) );
thread.registerXMLConverter( new DataSetMemberConverter( dataSetService, dataElementService ) );
@@ -346,4 +356,5 @@
throw new RuntimeException( "Error occured during export to stream", ex );
}
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/AbstractImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/AbstractImporter.java 2010-11-25 08:40:35 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/AbstractImporter.java 2011-07-13 11:32:13 +0000
@@ -74,7 +74,7 @@
{
if ( params.isAnalysis() )
{
- if ( importAnalyser != null ) // Analyser instantiatet only for relevant objects
+ if ( importAnalyser != null ) // Analyzer instantiatet only for relevant objects
{
importAnalyser.addObject( object );
}
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ConstantImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ConstantImporter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/ConstantImporter.java 2011-07-13 11:32:13 +0000
@@ -0,0 +1,110 @@
+package org.hisp.dhis.importexport.importer;
+
+import org.amplecode.quick.BatchHandler;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
+import org.hisp.dhis.importexport.GroupMemberType;
+import org.hisp.dhis.importexport.ImportParams;
+import org.hisp.dhis.importexport.Importer;
+import org.hisp.dhis.importexport.mapping.NameMappingUtil;
+
+/*
+ * Copyright (c) 2004-2011, 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 <ORGANIZATION> 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 Dang Duy Hieu
+ * @version $Id$
+ */
+public class ConstantImporter
+ extends AbstractImporter<Constant>
+ implements Importer<Constant>
+{
+ protected ConstantService constantService;
+
+ public ConstantImporter()
+ {
+ }
+
+ public ConstantImporter( BatchHandler<Constant> batchHandler, ConstantService constantService )
+ {
+ this.batchHandler = batchHandler;
+ this.constantService = constantService;
+ }
+
+ @Override
+ public void importObject( Constant object, ImportParams params )
+ {
+ NameMappingUtil.addConstantMapping( object.getId(), object.getName() );
+
+ read( object, GroupMemberType.NONE, params );
+ }
+
+ @Override
+ protected void importUnique( Constant object )
+ {
+ batchHandler.addObject( object );
+ }
+
+ @Override
+ protected void importMatching( Constant object, Constant match )
+ {
+ throw new UnsupportedOperationException( "Constant can only be unique or duplicate" );
+ }
+
+ @Override
+ protected Constant getMatching( Constant object )
+ {
+ Constant match = constantService.getConstantByName( object.getName() );
+
+ if ( match == null )
+ {
+ match = constantService.getConstant( object.getId() );
+ }
+
+ return match;
+ }
+
+ @Override
+ protected boolean isIdentical( Constant object, Constant existing )
+ {
+ if ( !object.getName().equals( existing.getName() ) )
+ {
+ return false;
+ }
+ if ( object.getId() != existing.getId() )
+ {
+ return false;
+ }
+ if ( object.getValue() != existing.getValue() )
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java 2011-02-22 23:17:50 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java 2011-07-13 11:32:13 +0000
@@ -33,6 +33,7 @@
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
@@ -48,6 +49,7 @@
import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.jdbc.batchhandler.ConceptBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.ConstantBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryBatchHandler;
@@ -77,7 +79,8 @@
/**
* @author Lars Helge Overland
- * @version $Id: DefaultObjectMappingGenerator.java 6425 2008-11-22 00:08:57Z larshelg $
+ * @version $Id: DefaultObjectMappingGenerator.java 6425 2008-11-22 00:08:57Z
+ * larshelg $
*/
public class DefaultObjectMappingGenerator
implements ObjectMappingGenerator
@@ -85,9 +88,9 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private BatchHandlerFactory batchHandlerFactory;
-
+
public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
{
this.batchHandlerFactory = batchHandlerFactory;
@@ -99,11 +102,22 @@
{
this.periodStore = periodStore;
}
-
+
+ // -------------------------------------------------------------------------
+ // Constant
+ // -------------------------------------------------------------------------
+
+ public Map<Object, Integer> getConstantMapping( boolean skipMapping )
+ {
+ BatchHandler<Constant> batchHandler = batchHandlerFactory.createBatchHandler( ConstantBatchHandler.class );
+
+ return getMapping( batchHandler, NameMappingUtil.getConstantMap(), skipMapping );
+ }
+
// -------------------------------------------------------------------------
// Concept
// -------------------------------------------------------------------------
-
+
public Map<Object, Integer> getConceptMapping( boolean skipMapping )
{
BatchHandler<Concept> batchHandler = batchHandlerFactory.createBatchHandler( ConceptBatchHandler.class );
@@ -124,8 +138,9 @@
public Map<Object, Integer> getCategoryMapping( boolean skipMapping )
{
- BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryBatchHandler.class );
-
+ BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementCategoryBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getCategoryMap(), skipMapping );
}
@@ -135,8 +150,9 @@
public Map<Object, Integer> getCategoryComboMapping( boolean skipMapping )
{
- BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryComboBatchHandler.class );
-
+ BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementCategoryComboBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getCategoryComboMap(), skipMapping );
}
@@ -146,8 +162,9 @@
public Map<Object, Integer> getCategoryOptionMapping( boolean skipMapping )
{
- BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryOptionBatchHandler.class );
-
+ BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementCategoryOptionBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getCategoryOptionMap(), skipMapping );
}
@@ -159,7 +176,7 @@
{
return getMapping( NameMappingUtil.getCategoryOptionComboMap(), skipMapping );
}
-
+
// -------------------------------------------------------------------------
// DataElement
// -------------------------------------------------------------------------
@@ -167,7 +184,7 @@
public Map<Object, Integer> getDataElementMapping( boolean skipMapping )
{
BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class );
-
+
return getMapping( batchHandler, NameMappingUtil.getDataElementMap(), skipMapping );
}
@@ -177,8 +194,9 @@
public Map<Object, Integer> getDataElementGroupMapping( boolean skipMapping )
{
- BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupBatchHandler.class );
-
+ BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementGroupBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getDataElementGroupMap(), skipMapping );
}
@@ -188,8 +206,9 @@
public Map<Object, Integer> getDataElementGroupSetMapping( boolean skipMapping )
{
- BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupSetBatchHandler.class );
-
+ BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementGroupSetBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getDataElementGroupSetMap(), skipMapping );
}
@@ -200,7 +219,7 @@
public Map<Object, Integer> getIndicatorMapping( boolean skipMapping )
{
BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class );
-
+
return getMapping( batchHandler, NameMappingUtil.getIndicatorMap(), skipMapping );
}
@@ -210,8 +229,9 @@
public Map<Object, Integer> getIndicatorGroupMapping( boolean skipMapping )
{
- BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupBatchHandler.class );
-
+ BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory
+ .createBatchHandler( IndicatorGroupBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getIndicatorGroupMap(), skipMapping );
}
@@ -221,8 +241,9 @@
public Map<Object, Integer> getIndicatorGroupSetMapping( boolean skipMapping )
{
- BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupSetBatchHandler.class );
-
+ BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory
+ .createBatchHandler( IndicatorGroupSetBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getIndicatorGroupSetMap(), skipMapping );
}
@@ -232,8 +253,9 @@
public Map<Object, Integer> getIndicatorTypeMapping( boolean skipMapping )
{
- BatchHandler<IndicatorType> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorTypeBatchHandler.class );
-
+ BatchHandler<IndicatorType> batchHandler = batchHandlerFactory
+ .createBatchHandler( IndicatorTypeBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getIndicatorTypeMap(), skipMapping );
}
@@ -243,11 +265,12 @@
public Map<Object, Integer> getDataDictionaryMapping( boolean skipMapping )
{
- BatchHandler<DataDictionary> batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryBatchHandler.class );
-
+ BatchHandler<DataDictionary> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataDictionaryBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getDataDictionaryMap(), skipMapping );
}
-
+
// -------------------------------------------------------------------------
// DataSet
// -------------------------------------------------------------------------
@@ -255,17 +278,18 @@
public Map<Object, Integer> getDataSetMapping( boolean skipMapping )
{
BatchHandler<DataSet> batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class );
-
+
return getMapping( batchHandler, NameMappingUtil.getDataSetMap(), skipMapping );
}
-
+
// -------------------------------------------------------------------------
// OrganisationUnit
// -------------------------------------------------------------------------
public Map<Object, Integer> getOrganisationUnitMapping( boolean skipMapping )
{
- BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitBatchHandler.class );
+ BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory
+ .createBatchHandler( OrganisationUnitBatchHandler.class );
return getMapping( batchHandler, NameMappingUtil.getOrganisationUnitMap(), skipMapping );
}
@@ -276,8 +300,9 @@
public Map<Object, Integer> getOrganisationUnitGroupMapping( boolean skipMapping )
{
- BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupBatchHandler.class );
-
+ BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory
+ .createBatchHandler( OrganisationUnitGroupBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getOrganisationUnitGroupMap(), skipMapping );
}
@@ -287,8 +312,9 @@
public Map<Object, Integer> getOrganisationUnitGroupSetMapping( boolean skipMapping )
{
- BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( GroupSetBatchHandler.class );
-
+ BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory
+ .createBatchHandler( GroupSetBatchHandler.class );
+
return getMapping( batchHandler, NameMappingUtil.getGroupSetMap(), skipMapping );
}
@@ -299,72 +325,79 @@
public Map<Object, Integer> getReportTableMapping( boolean skipMapping )
{
BatchHandler<ReportTable> batchHandler = batchHandlerFactory.createBatchHandler( ReportTableBatchHandler.class );
-
+
return getMapping( batchHandler, NameMappingUtil.getReportTableMap(), skipMapping );
}
-
+
// -------------------------------------------------------------------------
// Period
// -------------------------------------------------------------------------
- public Map<Object, Integer> getPeriodMapping( boolean skipMapping ) // Original identifier, new identifier
+ public Map<Object, Integer> getPeriodMapping( boolean skipMapping ) // Original
+ // identifier,
+ // new
+ // identifier
{
BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class );
-
+
batchHandler.init();
-
+
Map<Object, Integer> periodMap = new LoggingHashMap<Object, Integer>();
-
+
Map<Object, Period> mapping = NameMappingUtil.getPeriodMap();
-
+
if ( mapping != null )
{
for ( Map.Entry<Object, Period> map : mapping.entrySet() )
{
- int identifier = skipMapping ? getKey( map.getKey() ) : batchHandler.getObjectIdentifier( map.getValue() );
-
+ int identifier = skipMapping ? getKey( map.getKey() ) : batchHandler.getObjectIdentifier( map
+ .getValue() );
+
verifyIdentifier( identifier, skipMapping, map.getValue().toString() );
-
+
periodMap.put( map.getKey(), identifier );
}
-
+
verifyMap( mapping, periodMap );
}
-
+
batchHandler.flush();
-
+
return periodMap;
}
-
- public Map<Period, Integer> getPeriodObjectMapping( boolean skipMapping ) // Original object, new identifier
+
+ public Map<Period, Integer> getPeriodObjectMapping( boolean skipMapping ) // Original
+ // object,
+ // new
+ // identifier
{
BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class );
-
+
batchHandler.init();
-
+
Map<Period, Integer> periodMap = new LoggingHashMap<Period, Integer>();
-
+
Collection<Period> periods = NameMappingUtil.getPeriodMap().values();
-
+
if ( periods != null )
{
for ( Period period : periods )
{
int identifier = skipMapping ? period.getId() : batchHandler.getObjectIdentifier( period );
-
+
verifyIdentifier( identifier, skipMapping, period.toString() );
-
+
periodMap.put( period, identifier );
}
-
+
if ( periodMap.size() != periods.size() )
{
throw new RuntimeException( "The period mapping contains duplicates" );
}
}
-
+
batchHandler.flush();
-
+
return periodMap;
}
@@ -376,14 +409,14 @@
public Map<String, Integer> getPeriodTypeMapping()
{
Map<String, Integer> periodTypeMap = new LoggingHashMap<String, Integer>();
-
+
Collection<PeriodType> periodTypes = periodStore.getAllPeriodTypes();
-
+
for ( PeriodType type : periodTypes )
{
periodTypeMap.put( type.getName(), type.getId() );
}
-
+
return periodTypeMap;
}
@@ -391,41 +424,44 @@
// Supportive methods
// -------------------------------------------------------------------------
- private Map<Object, Integer> getMapping( BatchHandler<?> batchHandler, Map<Object, String> nameMap, boolean skipMapping )
+ private Map<Object, Integer> getMapping( BatchHandler<?> batchHandler, Map<Object, String> nameMap,
+ boolean skipMapping )
{
batchHandler.init();
Map<Object, Integer> identifierMap = new LoggingHashMap<Object, Integer>();
-
+
if ( nameMap != null )
{
for ( Map.Entry<Object, String> nameMapEntry : nameMap.entrySet() )
{
- int identifier = skipMapping ? getKey( nameMapEntry.getKey() ) : batchHandler.getObjectIdentifier( nameMapEntry.getValue() );
-
+ int identifier = skipMapping ? getKey( nameMapEntry.getKey() ) : batchHandler
+ .getObjectIdentifier( nameMapEntry.getValue() );
+
verifyIdentifier( identifier, skipMapping, nameMapEntry.getValue() );
identifierMap.put( nameMapEntry.getKey(), identifier );
}
-
+
verifyMap( nameMap, identifierMap );
}
-
+
batchHandler.flush();
-
+
return identifierMap;
}
-
- private Map<Object, Integer> getMapping( Map<Object, DataElementCategoryOptionCombo> categoryOptionComboMap, boolean skipMapping )
+
+ private Map<Object, Integer> getMapping( Map<Object, DataElementCategoryOptionCombo> categoryOptionComboMap,
+ boolean skipMapping )
{
Map<Object, Integer> identifierMap = new LoggingHashMap<Object, Integer>();
-
+
if ( categoryOptionComboMap != null )
{
for ( Map.Entry<Object, DataElementCategoryOptionCombo> map : categoryOptionComboMap.entrySet() )
{
int identifier = 0;
-
+
if ( skipMapping )
{
identifier = getKey( map.getKey() );
@@ -433,36 +469,37 @@
else
{
DataElementCategoryOptionCombo temp = map.getValue();
-
- DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( temp );
-
+
+ DataElementCategoryOptionCombo categoryOptionCombo = categoryService
+ .getDataElementCategoryOptionCombo( temp );
+
if ( categoryOptionCombo == null )
{
throw new RuntimeException( "DataElementCategoryOptionCombo does not exist: " + temp );
}
-
- identifier = categoryOptionCombo.getId();
+
+ identifier = categoryOptionCombo.getId();
}
-
+
verifyIdentifier( identifier, skipMapping, "[DataElementCategoryOptionCombo]" );
-
+
identifierMap.put( map.getKey(), identifier );
}
-
+
verifyMap( categoryOptionComboMap, identifierMap );
}
-
+
return identifierMap;
}
-
+
private void verifyIdentifier( Integer identifier, boolean skipMapping, String name )
{
if ( identifier == 0 && !skipMapping )
{
throw new RuntimeException( "The object named '" + name + "' does not exist" );
- }
+ }
}
-
+
private void verifyMap( Map<?, ?> nameMap, Map<?, ?> identifierMap )
{
if ( nameMap.size() != identifierMap.size() )
@@ -470,7 +507,7 @@
throw new RuntimeException( "The name mapping contains duplicate names" );
}
}
-
+
/**
* Return the Integer value of the Object argument. If the Object is not of
* type Integer, -1 is returned.
@@ -478,7 +515,7 @@
private int getKey( Object key )
{
int value = -1;
-
+
try
{
value = Integer.parseInt( String.valueOf( key ) );
@@ -487,7 +524,8 @@
{
// Object is not of type Integer
}
-
+
return value;
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java 2010-12-23 11:56:44 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java 2011-07-13 11:32:13 +0000
@@ -61,6 +61,7 @@
private static ThreadLocal<Map<Object, String>> reportTableMap = new ThreadLocal<Map<Object,String>>();
private static ThreadLocal<Map<Object, String>> dataElementAggregationOperatorMap = new ThreadLocal<Map<Object,String>>();
private static ThreadLocal<Map<Object, String>> dataEntryFormMap = new ThreadLocal<Map<Object,String>>();
+ private static ThreadLocal<Map<Object, String>> constantMap = new ThreadLocal<Map<Object,String>>();
// -------------------------------------------------------------------------
// Control
@@ -89,6 +90,7 @@
reportTableMap.remove();
dataElementAggregationOperatorMap.remove();
dataEntryFormMap.remove();
+ constantMap.remove();
}
// -------------------------------------------------------------------------
@@ -529,6 +531,28 @@
return dataEntryFormMap.get() != null ? new HashMap<Object, String>( dataEntryFormMap.get() ) : new HashMap<Object, String>();
}
+
+ // -------------------------------------------------------------------------
+ // Constant
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a map entry with Constant identifier as key and name as value.
+ */
+ public static void addConstantMapping( Object constantId, String constantName )
+ {
+ put( constantMap , constantId, constantName );
+ }
+
+ /**
+ * Returns a Map with all Constant identifier and name entries.
+ */
+
+ public static Map<Object, String> getConstantMap()
+ {
+ return constantMap.get() != null ? new HashMap<Object, String>( constantMap.get() ) : new HashMap<Object, String>();
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/ObjectMappingGenerator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/ObjectMappingGenerator.java 2011-02-02 17:56:01 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/ObjectMappingGenerator.java 2011-07-13 11:32:13 +0000
@@ -44,6 +44,10 @@
{
String ID = ObjectMappingGenerator.class.getName();
+ Map<Object, Integer> getConceptMapping( boolean skipMapping );
+
+ Map<Object, Integer> getConstantMapping( boolean skipMapping );
+
Map<Object, Integer> getCategoryMapping( boolean skipMapping );
Map<Object, Integer> getCategoryComboMapping( boolean skipMapping );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java 2011-07-13 11:32:13 +0000
@@ -39,6 +39,8 @@
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElement;
@@ -69,6 +71,7 @@
import org.hisp.dhis.importexport.Importer;
import org.hisp.dhis.importexport.importer.ChartImporter;
import org.hisp.dhis.importexport.importer.CompleteDataSetRegistrationImporter;
+import org.hisp.dhis.importexport.importer.ConstantImporter;
import org.hisp.dhis.importexport.importer.DataDictionaryImporter;
import org.hisp.dhis.importexport.importer.DataElementCategoryComboImporter;
import org.hisp.dhis.importexport.importer.DataElementCategoryImporter;
@@ -101,6 +104,7 @@
import org.hisp.dhis.jdbc.batchhandler.CategoryCategoryOptionAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.CategoryComboCategoryAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.CompleteDataSetRegistrationBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.ConstantBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryDataElementBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryIndicatorBatchHandler;
@@ -181,6 +185,13 @@
this.importObjectStore = importObjectStore;
}
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
private DataElementCategoryService categoryService;
public void setCategoryService( DataElementCategoryService categoryService )
@@ -291,6 +302,28 @@
// -------------------------------------------------------------------------
@Transactional
+ public void importConstants()
+ {
+ BatchHandler<Constant> batchHandler = batchHandlerFactory.createBatchHandler( ConstantBatchHandler.class )
+ .init();
+
+ Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Constant.class );
+
+ Importer<Constant> importer = new ConstantImporter( batchHandler, constantService );
+
+ for ( ImportObject importObject : importObjects )
+ {
+ importer.importObject( (Constant) importObject.getObject(), params );
+ }
+
+ batchHandler.flush();
+
+ importObjectStore.deleteImportObjects( Constant.class );
+
+ log.info( "Imported Constants" );
+ }
+
+ @Transactional
public void importCategoryOptions()
{
BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler(
@@ -556,7 +589,8 @@
@Transactional
public void importIndicators()
{
- BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class ).init();
+ BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class )
+ .init();
Map<Object, Integer> indicatorTypeMapping = objectMappingGenerator.getIndicatorTypeMapping( false );
Map<Object, Integer> dataElementMapping = objectMappingGenerator.getDataElementMapping( false );
@@ -739,7 +773,8 @@
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OrganisationUnit.class );
- Importer<OrganisationUnit> importer = new OrganisationUnitImporter( organisationUnitBatchHandler, organisationUnitService );
+ Importer<OrganisationUnit> importer = new OrganisationUnitImporter( organisationUnitBatchHandler,
+ organisationUnitService );
for ( ImportObject importObject : importObjects )
{
@@ -976,7 +1011,7 @@
log.info( "Imported Reports" );
}
-
+
@Transactional
public void importCompleteDataSetRegistrations()
{
@@ -1039,7 +1074,8 @@
importer.importObject( value, params );
importedObjects++;
- } catch ( Exception e )
+ }
+ catch ( Exception e )
{
importedObjects--;
failedObjects++;
@@ -1051,7 +1087,7 @@
importDataValueService.deleteImportDataValues();
- log.info( importReport( importedObjects,failedObjects ) );
+ log.info( importReport( importedObjects, failedObjects ) );
}
// -------------------------------------------------------------------------
@@ -1085,21 +1121,23 @@
importObjectStore.deleteImportObjects( type );
}
- private String importReport(Integer importedObjects, Integer failedObjects)
+ private String importReport( Integer importedObjects, Integer failedObjects )
{
Integer totalObjects = importedObjects + failedObjects;
String importReportString = "";
- if (failedObjects > 0 )
+ if ( failedObjects > 0 )
{
- importReportString = totalObjects.toString() + " values handled.\n" + importedObjects.toString() + " new values successfully imported.\n"
- + failedObjects.toString() + " were not imported due to errors.";
- return importReportString;
+ importReportString = totalObjects.toString() + " values handled.\n" + importedObjects.toString()
+ + " new values successfully imported.\n" + failedObjects.toString()
+ + " were not imported due to errors.";
+ return importReportString;
}
else
{
importReportString = importedObjects.toString() + " values were imported.";
- return importReportString;
+ return importReportString;
}
}
+
}
=== 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 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java 2011-07-13 11:32:13 +0000
@@ -37,6 +37,8 @@
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.ImportableObject;
+import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElement;
@@ -113,6 +115,13 @@
this.importObjectManager = importObjectManager;
}
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
@@ -353,7 +362,7 @@
deleteGroupAssociations( GroupMemberType.DATASET, dataSet.getId() );
deleteMemberAssociations( GroupMemberType.DATASET_SOURCE, dataSet.getId() );
-
+
deleteCompleteDataSetRegistrationsByDataSet( dataSet.getId() );
}
else if ( importObject.getClassName().equals( OrganisationUnit.class.getName() ) )
@@ -491,8 +500,13 @@
// Updates the name of the import object to the name of the existing
// object.
// ---------------------------------------------------------------------
+ if ( object.getClass().equals( Constant.class ) )
+ {
+ Constant constant = (Constant) object;
- if ( object.getClass().equals( DataElement.class ) )
+ constant.setName( constantService.getConstant( existingObjectId ).getName() );
+ }
+ else if ( object.getClass().equals( DataElement.class ) )
{
DataElement element = (DataElement) object;
@@ -601,7 +615,7 @@
dataValue = updateDataValue( dataValue, dataValueService.getDataValue( dataValue.getSource(), dataValue
.getDataElement(), dataValue.getPeriod(), dataValue.getOptionCombo() ) );
}
-
+
// ---------------------------------------------------------------------
// Sets the status of the import object to match, these objects will
// later be ignored on import all but is needed for matching of
@@ -619,6 +633,7 @@
public void importAll()
{
+ importObjectManager.importConstants();
importObjectManager.importCategoryOptions();
importObjectManager.importCategories();
importObjectManager.importCategoryCombos();
@@ -811,4 +826,5 @@
}
}
}
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2011-07-13 11:32:13 +0000
@@ -70,6 +70,7 @@
<property name="batchHandlerFactory" ref="batchHandlerFactory" />
<property name="objectMappingGenerator" ref="org.hisp.dhis.importexport.mapping.ObjectMappingGenerator" />
<property name="importObjectStore" ref="org.hisp.dhis.importexport.ImportObjectStore" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="dataDictionaryService" ref="org.hisp.dhis.datadictionary.DataDictionaryService" />
@@ -95,6 +96,7 @@
<property name="importObjectStore" ref="org.hisp.dhis.importexport.ImportObjectStore" />
<property name="importDataValueService" ref="org.hisp.dhis.importexport.ImportDataValueService" />
<property name="importObjectManager" ref="org.hisp.dhis.importexport.ImportObjectManager" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="dataDictionaryService" ref="org.hisp.dhis.datadictionary.DataDictionaryService" />
@@ -195,6 +197,7 @@
<property name="importObjectService" ref="org.hisp.dhis.importexport.ImportObjectService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="conceptService" ref="org.hisp.dhis.concept.ConceptService" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="dataDictionaryService" ref="org.hisp.dhis.datadictionary.DataDictionaryService" />
@@ -242,6 +245,7 @@
<property name="sessionFactory" ref="sessionFactory" />
<property name="statementManager" ref="statementManager" />
<property name="conceptService" ref="org.hisp.dhis.concept.ConceptService" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
=== added file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ConstantBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ConstantBatchHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ConstantBatchHandler.java 2011-07-13 11:32:13 +0000
@@ -0,0 +1,98 @@
+package org.hisp.dhis.jdbc.batchhandler;
+
+/*
+ * Copyright (c) 2004-2011, 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.amplecode.quick.JdbcConfiguration;
+import org.amplecode.quick.batchhandler.AbstractBatchHandler;
+import org.hisp.dhis.constant.Constant;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ConstantBatchHandler
+ extends AbstractBatchHandler<Constant>
+{
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public ConstantBatchHandler( JdbcConfiguration config )
+ {
+ super( config, false, false );
+ }
+
+ // -------------------------------------------------------------------------
+ // AbstractBatchHandler implementation
+ // -------------------------------------------------------------------------
+
+ protected void setTableName()
+ {
+ statementBuilder.setTableName( "constant" );
+ }
+
+ @Override
+ protected void setAutoIncrementColumn()
+ {
+ statementBuilder.setAutoIncrementColumn( "constantid" );
+ }
+
+ @Override
+ protected void setIdentifierColumns()
+ {
+ statementBuilder.setIdentifierColumn( "constantid" );
+ }
+
+ @Override
+ protected void setIdentifierValues( Constant constant )
+ {
+ statementBuilder.setIdentifierValue( constant.getId() );
+ }
+
+ protected void setUniqueColumns()
+ {
+ statementBuilder.setUniqueColumn( "name" );
+ }
+
+ protected void setUniqueValues( Constant constant )
+ {
+ statementBuilder.setUniqueValue( constant.getName() );
+ }
+
+ protected void setColumns()
+ {
+ statementBuilder.setColumn( "name" );
+ statementBuilder.setColumn( "value" );
+ }
+
+ protected void setValues( Constant constant )
+ {
+ statementBuilder.setValue( constant.getName() );
+ statementBuilder.setValue( constant.getValue() );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2011-07-01 03:36:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2011-07-13 11:32:13 +0000
@@ -495,5 +495,6 @@
#-- Constant ------------------------------------------------------------------#
+constant = Constant
constants = Constants
no_constant_to_select = No constants to select
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2011-07-01 03:36:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2011-07-13 11:32:13 +0000
@@ -434,5 +434,6 @@
#-- Constant ------------------------------------------------------------------#
-constants = Bi\u1ec3u th\u1ee9c H\u1eb1ng
+constant = Bi\u1ec3u th\u1ee9c h\u1eb1ng
+constants = C\u00e1c bi\u1ec3u th\u1ee9c H\u1eb1ng
no_constant_to_select = Kh\u00f4ng c\u00f3 Bi\u1ec3u th\u1ee9c H\u1eb1ng \u0111\u1ec3 ch\u1ecdn
\ No newline at end of file
=== 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 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetMatchOptionsAction.java 2011-07-13 11:32:13 +0000
@@ -28,6 +28,7 @@
*/
import static org.hisp.dhis.common.Objects.CHART;
+import static org.hisp.dhis.common.Objects.CONSTANT;
import static org.hisp.dhis.common.Objects.DATADICTIONARY;
import static org.hisp.dhis.common.Objects.DATAELEMENT;
import static org.hisp.dhis.common.Objects.DATAELEMENTGROUP;
@@ -48,6 +49,7 @@
import java.util.Collection;
import org.hisp.dhis.chart.ChartService;
+import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSetService;
@@ -83,7 +85,7 @@
{
this.objectType = type;
}
-
+
private Integer objectId;
public Integer getObjectId()
@@ -95,7 +97,7 @@
{
this.objectId = id;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -105,15 +107,15 @@
public Object getImportObject()
{
return importObject;
- }
-
+ }
+
private Collection<?> objects;
public Collection<?> getObjects()
{
return objects;
}
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -125,13 +127,20 @@
this.importObjectService = importObjectService;
}
+ private ConstantService constantService;
+
+ public void setConstantService( ConstantService constantService )
+ {
+ this.constantService = constantService;
+ }
+
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
}
-
+
private IndicatorService indicatorService;
public void setIndicatorService( IndicatorService indicatorService )
@@ -145,21 +154,21 @@
{
this.dataDictionaryService = dataDictionaryService;
}
-
+
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
}
-
+
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
}
-
+
private OrganisationUnitGroupService organisationUnitGroupService;
public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
@@ -173,7 +182,7 @@
{
this.validationRuleService = validationRuleService;
}
-
+
private ReportService reportService;
public void setReportService( ReportService reportService )
@@ -187,14 +196,14 @@
{
this.reportTableService = reportTableService;
}
-
+
private ChartService chartService;
-
+
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -203,14 +212,18 @@
throws Exception
{
importObject = importObjectService.getImportObject( Integer.valueOf( objectId ) );
-
- if ( objectType.equals( DATAELEMENT.name() ) )
+
+ if ( objectType.equals( CONSTANT.name() ) )
+ {
+ objects = constantService.getAllConstants();
+ }
+ else if ( objectType.equals( DATAELEMENT.name() ) )
{
objects = dataElementService.getAllDataElements();
}
else if ( objectType.equals( DATAELEMENTGROUP.name() ) )
{
- objects = dataElementService.getAllDataElementGroups();
+ objects = dataElementService.getAllDataElementGroups();
}
else if ( objectType.equals( DATAELEMENTGROUPSET.name() ) )
{
@@ -220,7 +233,7 @@
{
objects = indicatorService.getAllIndicatorTypes();
}
- else if ( objectType.equals( INDICATOR.name() ) )
+ else if ( objectType.equals( INDICATOR.name() ) )
{
objects = indicatorService.getAllIndicators();
}
@@ -272,7 +285,8 @@
{
objects = chartService.getAllCharts();
}
-
+
return SUCCESS;
}
+
}
=== 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 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/GetPreviewOptionsAction.java 2011-07-13 11:32:13 +0000
@@ -40,6 +40,7 @@
import java.util.List;
import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
@@ -81,18 +82,18 @@
{
this.importObjectService = importObjectService;
}
-
+
private ImportDataValueService importDataValueService;
public void setImportDataValueService( ImportDataValueService importDataValueService )
{
this.importDataValueService = importDataValueService;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
-
+
private String type;
public String getType()
@@ -104,7 +105,7 @@
{
this.type = elementType;
}
-
+
private String status;
public String getStatus()
@@ -120,6 +121,13 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
+
+ private Integer newConstants;
+
+ public Integer getNewConstants()
+ {
+ return newConstants;
+ }
private Integer newDataElements;
@@ -127,14 +135,14 @@
{
return newDataElements;
}
-
+
private Integer newCalculatedDataElements;
public Integer getNewCalculatedDataElements()
{
return newCalculatedDataElements;
}
-
+
private Integer newExtendedDataElements;
public Integer getNewExtendedDataElements()
@@ -148,9 +156,9 @@
{
return newDataElementGroups;
}
-
+
private Integer newDataElementGroupSets;
-
+
public Integer getNewDataElementGroupSets()
{
return newDataElementGroupSets;
@@ -176,9 +184,9 @@
{
return newIndicatorGroups;
}
-
+
private Integer newIndicatorGroupSets;
-
+
public Integer getNewIndicatorGroupSets()
{
return newIndicatorGroupSets;
@@ -190,7 +198,7 @@
{
return newDataDictionaries;
}
-
+
private Integer newDataSets;
public Integer getNewDataSets()
@@ -218,21 +226,21 @@
{
return newOrganisationUnitGroupSets;
}
-
+
private Integer newOrganisationUnitLevels;
public Integer getNewOrganisationUnitLevels()
{
return newOrganisationUnitLevels;
}
-
+
private Integer newValidationRules;
public Integer getNewValidationRules()
{
return newValidationRules;
}
-
+
private Integer newReports;
public Integer getNewReports()
@@ -246,9 +254,9 @@
{
return newReportTables;
}
-
+
private Integer newCharts;
-
+
public Integer getNewCharts()
{
return newCharts;
@@ -259,8 +267,8 @@
public Integer getNewOlapUrls()
{
return newOlapUrls;
- }
-
+ }
+
private Integer newDataValues;
public Integer getNewDataValues()
@@ -268,20 +276,27 @@
return newDataValues;
}
+ private Integer updateConstants;
+
+ public Integer getUpdateConstants()
+ {
+ return updateConstants;
+ }
+
private Integer updateDataElements;
public Integer getUpdateDataElements()
{
return updateDataElements;
}
-
+
private Integer updateCalculatedDataElements;
public Integer getUpdateCalculatedDataElements()
{
return updateCalculatedDataElements;
}
-
+
private Integer updateExtendedDataElements;
public Integer getUpdateExtendedDataElements()
@@ -295,9 +310,9 @@
{
return updateDataElementGroups;
}
-
+
private Integer updateDataElementGroupSets;
-
+
public Integer getUpdateDataElementGroupSets()
{
return updateDataElementGroupSets;
@@ -323,9 +338,9 @@
{
return updateIndicatorGroups;
}
-
+
private Integer updateIndicatorGroupSets;
-
+
public Integer getUpdateIndicatorGroupSets()
{
return updateIndicatorGroupSets;
@@ -337,7 +352,7 @@
{
return updateDataDictionaries;
}
-
+
private Integer updateDataSets;
public Integer getUpdateDataSets()
@@ -351,7 +366,7 @@
{
return updateOrganisationUnits;
}
-
+
private Integer updateOrganisationUnitGroups;
public Integer getUpdateOrganisationUnitGroups()
@@ -365,21 +380,21 @@
{
return updateOrganisationUnitGroupSets;
}
-
+
private Integer updateOrganisationUnitLevels;
public Integer getUpdateOrganisationUnitLevels()
{
return updateOrganisationUnitLevels;
}
-
+
private Integer updateValidationRules;
public Integer getUpdateValidationRules()
{
return updateValidationRules;
}
-
+
private Integer updateReports;
public Integer getUpdateReports()
@@ -393,9 +408,9 @@
{
return updateReportTables;
}
-
+
private Integer updateCharts;
-
+
public Integer getUpdateCharts()
{
return updateCharts;
@@ -407,21 +422,21 @@
{
return updateOlapUrls;
}
-
+
private Integer updateDataValues;
public Integer getUpdateDataValues()
{
return updateDataValues;
}
-
+
public List<ImportObject> importObjects;
public List<ImportObject> getImportObjects()
{
return importObjects;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -429,6 +444,7 @@
public String execute()
throws Exception
{
+ newConstants = importObjectService.getImportObjects( NEW, Constant.class ).size();
newDataElements = importObjectService.getImportObjects( NEW, DataElement.class ).size();
newDataElementGroups = importObjectService.getImportObjects( NEW, DataElementGroup.class ).size();
newDataElementGroupSets = importObjectService.getImportObjects( NEW, DataElementGroupSet.class ).size();
@@ -447,7 +463,8 @@
newReportTables = importObjectService.getImportObjects( NEW, ReportTable.class ).size();
newCharts = importObjectService.getImportObjects( NEW, Chart.class ).size();
newDataValues = importDataValueService.getNumberOfImportDataValues( NEW );
-
+
+ updateConstants = importObjectService.getImportObjects( UPDATE, Constant.class ).size();
updateDataElements = importObjectService.getImportObjects( UPDATE, DataElement.class ).size();
updateDataElementGroups = importObjectService.getImportObjects( UPDATE, DataElementGroup.class ).size();
updateDataElementGroupSets = importObjectService.getImportObjects( UPDATE, DataElementGroupSet.class ).size();
@@ -473,7 +490,7 @@
type = type == null ? (String) getSessionVar( KEY_PREVIEW_TYPE ) : type;
status = status == null ? (String) getSessionVar( KEY_PREVIEW_STATUS ) : status;
-
+
setSessionVar( KEY_PREVIEW_TYPE, type );
setSessionVar( KEY_PREVIEW_STATUS, status );
@@ -483,11 +500,13 @@
if ( type != null && status != null )
{
- importObjects = new ArrayList<ImportObject>( importObjectService.getImportObjects( valueOf( status ), ClassMapUtil.getClass( type ) ) );
-
+ importObjects = new ArrayList<ImportObject>( importObjectService.getImportObjects( valueOf( status ),
+ ClassMapUtil.getClass( type ) ) );
+
Collections.sort( importObjects, new ImportObjectComparator() );
}
-
+
return SUCCESS;
}
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java 2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ClassMapUtil.java 2011-07-13 11:32:13 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.common.Objects.CONSTANT;
import static org.hisp.dhis.common.Objects.DATADICTIONARY;
import static org.hisp.dhis.common.Objects.DATAELEMENT;
import static org.hisp.dhis.common.Objects.DATAELEMENTGROUP;
@@ -49,6 +50,7 @@
import java.util.Map;
import org.hisp.dhis.common.Objects;
+import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
@@ -78,6 +80,7 @@
{
classMap = new HashMap<Objects, Class<?>>();
+ classMap.put( CONSTANT, Constant.class );
classMap.put( DATAELEMENT, DataElement.class );
classMap.put( DATAELEMENTGROUP, DataElementGroup.class );
classMap.put( DATAELEMENTGROUPSET, DataElementGroupSet.class );
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2011-07-13 11:32:13 +0000
@@ -79,6 +79,7 @@
<bean id="org.hisp.dhis.importexport.action.imp.GetMatchOptionsAction" class="org.hisp.dhis.importexport.action.imp.GetMatchOptionsAction"
scope="prototype">
<property name="importObjectService" ref="org.hisp.dhis.importexport.ImportObjectService" />
+ <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="dataDictionaryService" ref="org.hisp.dhis.datadictionary.DataDictionaryService" />
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2011-04-04 05:42:40 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2011-07-13 11:32:13 +0000
@@ -220,6 +220,7 @@
import_process_done = Import successful
import_process_failed = Import process failed - See log for details
importing_concepts = Importing concepts
+importing_constants = Importing constants
importing_data_element_category_options = Importing data element category options
importing_data_element_categories = Importing data element categories
importing_data_element_category_combos = Importing data element category combos
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/import.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/import.js 2011-07-13 06:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/import.js 2011-07-13 11:32:13 +0000
@@ -64,7 +64,15 @@
if ( type == "success" )
{
- if ( elementType == "DATAELEMENT" && elementStatus == "NEW" )
+ if ( elementType == "CONSTANT" && elementStatus == "NEW" )
+ {
+ handleField( discardedElements, "newConstantSpan", "newConstantTd" );
+ }
+ else if ( elementType == "CONSTANT" && elementStatus == "UPDATE" )
+ {
+ handleField( discardedElements, "updateConstantSpan", "updateConstantTd" );
+ }
+ else if ( elementType == "DATAELEMENT" && elementStatus == "NEW" )
{
handleField( discardedElements, "newDataElementSpan", "newDataElementTd" );
}
@@ -240,7 +248,12 @@
{
// Set value count to none
- if ( elementType == "DATAELEMENT" )
+ if ( elementType == "CONSTANT" )
+ {
+ clearField( "newConstantTd" );
+ clearField( "updateConstantTd" );
+ }
+ else if ( elementType == "DATAELEMENT" )
{
clearField( "newDataElementTd" );
clearField( "updateDataElementTd" );
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/matchToExistingForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/matchToExistingForm.vm 2011-04-24 12:47:31 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/matchToExistingForm.vm 2011-07-13 11:32:13 +0000
@@ -38,6 +38,12 @@
#displayProperty( "name" $importObject.object.name )
+ #if ( $objectType == "CONSTANT" )
+
+ #displayProperty( "value" $importObject.object.value )
+
+ #end
+
#if ( $objectType == "DATAELEMENT" || $objectType == "CALCULATEDDATAELEMENT" )
#displayProperty( "alternative_name" $importObject.object.alternativeName )
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/previewForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/previewForm.vm 2011-07-13 10:29:08 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/previewForm.vm 2011-07-13 11:32:13 +0000
@@ -43,6 +43,7 @@
<th style="width:108px">$i18n.getString( "update" )</th>
<td style="width:260px"></td>
</tr>
+ #displayObjects( "constant" "Constant" $newConstants $updateConstants )
#displayObjects( "data_element" "DataElement" $newDataElements $updateDataElements )
#displayObjects( "calculated_data_element" "CalculatedDataElement" $newCalculatedDataElements $updateCalculatedDataElements )
#displayObjects( "data_element_group" "DataElementGroup" $newDataElementGroups $updateDataElementGroups )