dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04246
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1403: Improved handling of dataelement/category and datavalue/categoryoptincombo in dhis14 xml import
------------------------------------------------------------
revno: 1403
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-02-08 08:04:26 +0100
message:
Improved handling of dataelement/category and datavalue/categoryoptincombo in dhis14 xml import
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2009-11-07 14:09:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2010-02-08 07:04:26 +0000
@@ -33,6 +33,7 @@
import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanToDhis14;
import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertTypeToDhis14;
import static org.hisp.dhis.system.util.ConversionUtils.parseInt;
+import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
import java.util.Collection;
import java.util.HashSet;
@@ -43,6 +44,7 @@
import org.hisp.dhis.dataelement.CalculatedDataElement;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.importexport.ExportParams;
@@ -96,6 +98,8 @@
// Properties
// -------------------------------------------------------------------------
+ private DataElementCategoryService categoryService;
+
private Map<Integer, String> expressionMap;
// -------------------------------------------------------------------------
@@ -118,11 +122,13 @@
*/
public DataElementConverter( ImportObjectService importObjectService,
DataElementService dataElementService,
+ DataElementCategoryService categoryService,
Map<Integer, String> expressionMap,
ImportAnalyser importAnalyser )
{
this.importObjectService = importObjectService;
this.dataElementService = dataElementService;
+ this.categoryService = categoryService;
this.expressionMap = expressionMap;
this.importAnalyser = importAnalyser;
}
@@ -130,7 +136,7 @@
// -------------------------------------------------------------------------
// AbstractDataElementConverter implementation
// -------------------------------------------------------------------------
-
+
@Override
protected DataElement getMatching( DataElement object )
{
@@ -197,7 +203,7 @@
final boolean calculated = convertBooleanFromDhis14( values.get( FIELD_CALCULATED ) );
- final DataElementCategoryCombo categoryCombo = new DataElementCategoryCombo();
+ final DataElementCategoryCombo categoryCombo = categoryService.getDataElementCategoryComboByName( DEFAULT_CATEGORY_COMBO_NAME );
if ( calculated )
{
@@ -214,7 +220,6 @@
element.setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
element.setSortOrder( parseInt( values.get( FIELD_SORT_ORDER ) ) );
element.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
- element.getCategoryCombo().setId( 1 ); //TODO hack
element.setSaved( convertBooleanFromDhis14( values.get( FIELD_SAVE_CALCULATED ) ) );
element.setExpression( new Expression( expressionMap.get( element.getId() ), null, new HashSet<DataElement>() ) );
@@ -237,7 +242,6 @@
element.setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
element.setSortOrder( parseInt( values.get( FIELD_SORT_ORDER ) ) );
element.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
- element.getCategoryCombo().setId( 1 ); //TODO hack
NameMappingUtil.addDataElementAggregationOperatorMapping( element.getId(), element.getAggregationOperator() );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2009-11-23 12:22:51 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2010-02-08 07:04:26 +0000
@@ -35,6 +35,7 @@
import org.amplecode.quick.BatchHandler;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.importexport.CSVConverter;
@@ -57,6 +58,8 @@
{
private static final String SEPARATOR = ",";
+ private DataElementCategoryService categoryService;
+
// -------------------------------------------------------------------------
// Properties
// -------------------------------------------------------------------------
@@ -74,11 +77,13 @@
*/
public DataValueConverter( BatchHandler<ImportDataValue> importDataValueBatchHandler,
DataValueService dataValueService,
+ DataElementCategoryService categoryService,
ImportObjectService importObjectService,
ImportParams params )
{
this.importDataValueBatchHandler = importDataValueBatchHandler;
this.dataValueService = dataValueService;
+ this.categoryService = categoryService;
this.importObjectService = importObjectService;
this.params = params;
this.dataElementMapping = new MimicingHashMap<Object, Integer>();
@@ -103,9 +108,7 @@
final DataElement dataElement = new DataElement();
final Period period = new Period();
final OrganisationUnit organisationUnit = new OrganisationUnit();
- final DataElementCategoryOptionCombo categoryOptionCombo = new DataElementCategoryOptionCombo();
-
- categoryOptionCombo.setId( 1 );
+ final DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
try
{
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java 2009-11-26 10:38:53 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java 2010-02-08 07:04:26 +0000
@@ -234,7 +234,8 @@
XMLConverter categoryComboConverter = new DataElementCategoryComboConverter( importObjectService, categoryService );
XMLConverter categoryOptionComboConverter = new DataElementCategoryOptionComboConverter( importObjectService, categoryService );
XMLConverter calculatedDataElementAssociationConverter = new CalculatedDataElementAssociationConverter( expressionMap );
- XMLConverter dataElementConverter = new DataElementConverter( importObjectService, dataElementService, expressionMap, importAnalyser );
+ XMLConverter dataElementConverter = new DataElementConverter(
+ importObjectService, dataElementService, categoryService, expressionMap, importAnalyser );
XMLConverter indicatorTypeConverter = new IndicatorTypeConverter( importObjectService, indicatorService );
XMLConverter indicatorConverter = new IndicatorConverter( importObjectService, indicatorService, importAnalyser );
XMLConverter organisationUnitConverter = new OrganisationUnitConverter( importObjectService, organisationUnitService, importAnalyser );
@@ -296,6 +297,7 @@
CSVConverter dataValueConverter = new DataValueConverter( importDataValueBatchHandler,
dataValueService,
+ categoryService,
importObjectService,
params );