Skip to content

Instantly share code, notes, and snippets.

@mukulu
Created May 2, 2011 08:30
Show Gist options
  • Save mukulu/951306 to your computer and use it in GitHub Desktop.
Save mukulu/951306 to your computer and use it in GitHub Desktop.
AttributeOptionsConverter Fails to import data
/*
* 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.
*/
package org.hisp.dhis.hr;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import org.hisp.dhis.common.IdentifiableObject;
/**
* @author Wilfred Felix Senyoni
* @version $Id$
*/
@SuppressWarnings( "serial" )
public class AttributeOptions
extends IdentifiableObject implements Serializable
{
private int id;
private String value;
private Attribute attribute;
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
public AttributeOptions()
{
}
public AttributeOptions(String value, Attribute attribute)
{
this.value = value;
this.attribute = attribute;
}
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
@Override
public int hashCode()
{
return value.hashCode();
}
@Override
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null )
{
return false;
}
if ( !(o instanceof AttributeOptions) )
{
return false;
}
final AttributeOptions other = (AttributeOptions) o;
return value.equals( other.getValue() );
}
@Override
public String toString()
{
return "[" + value + "]";
}
// -------------------------------------------------------------------------
// Getters and setters
// ----------------------------------------------------------------------
public int getId()
{
return id;
}
public void setId( int id )
{
this.id = id;
}
public String getValue()
{
return value;
}
public void setValue( String value )
{
this.value = value;
}
public Attribute getAttribute()
{
return attribute;
}
public void setAttribute( Attribute attribute )
{
this.attribute = attribute;
}
}
package org.hisp.dhis.jdbc.batchhandler;
/*
* 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.amplecode.quick.JdbcConfiguration;
import org.amplecode.quick.batchhandler.AbstractBatchHandler;
import org.hisp.dhis.hr.AttributeOptions;
/**
* @author John Francis Mukulu <[email protected]>
* @version $Id: AtatributeBatchHandler.java 5242 $
*/
public class AttributeOptionsBatchHandler
extends AbstractBatchHandler<AttributeOptions>
{
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
public AttributeOptionsBatchHandler( JdbcConfiguration config )
{
super( config, false, false );
}
// -------------------------------------------------------------------------
// AbstractBatchHandler implementation
// -------------------------------------------------------------------------
protected void setTableName()
{
statementBuilder.setTableName( "hr_attribute_options" );
}
@Override
protected void setAutoIncrementColumn()
{
statementBuilder.setAutoIncrementColumn( "attributeoptionid" );
}
@Override
protected void setIdentifierColumns()
{
statementBuilder.setIdentifierColumn( "attributeoptionid" );
}
@Override
protected void setIdentifierValues( AttributeOptions attributeOptions )
{
statementBuilder.setIdentifierValue( attributeOptions.getId() );
}
protected void setUniqueColumns()
{
statementBuilder.setUniqueColumn( "value" );
}
protected void setUniqueValues( AttributeOptions attributeOptions )
{
statementBuilder.setUniqueValue( attributeOptions.getValue() );
}
protected void setColumns()
{
statementBuilder.setColumn( "value" );
statementBuilder.setColumn( "attributeid" );
}
protected void setValues( AttributeOptions attributeOptions )
{
statementBuilder.setValue( attributeOptions.getName() );
statementBuilder.setValue( attributeOptions.getUuid() );
}
}
package org.hisp.dhis.importexport.dxf.converter;
/*
* Copyright (c) 2004-2010, University of Oslo, University Of Dar es salaam
* 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 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.hr.Attribute;
import org.hisp.dhis.hr.AttributeOptions;
import org.hisp.dhis.hr.AttributeOptionsService;
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.AttributeOptionsImporter;
/**
* @author John Francis Mukulu <[email protected]>
* @version $Id$
*/
public class AttributeOptionsConverter
extends AttributeOptionsImporter implements XMLConverter
{
public static final String COLLECTION_NAME = "fieldOptions";
public static final String ELEMENT_NAME = "fieldOption";
private static final String FIELD_ATTRIBUTE_OPTION_ID = "fieldOptionId";
private static final String FIELD_ATTRIBUTE_ID = "fieldId";
private static final String FIELD_VALUE = "value";
// -------------------------------------------------------------------------
// Properties
// -------------------------------------------------------------------------
private Map<Object, Integer> attributeMapping;
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
/**
* Constructor for write operations.
*/
public AttributeOptionsConverter( AttributeOptionsService attributeOptionsService )
{
this.attributeOptionsService = attributeOptionsService;
}
/**
* Constructor for read operations.
*
* @param batchHandler the batchHandler to use.
* @param importObjectService the importObjectService to use.
* @param categoryService the dataElementCategoryService to use.
*/
public AttributeOptionsConverter( BatchHandler<AttributeOptions> batchHandler,
ImportObjectService importObjectService,
Map<Object, Integer> attributeMapping,
AttributeOptionsService attributeOptionsService )
{
this.batchHandler = batchHandler;
this.importObjectService = importObjectService;
this.attributeMapping = attributeMapping;
this.attributeOptionsService = attributeOptionsService;
}
// -------------------------------------------------------------------------
// XMLConverter implementation
// -------------------------------------------------------------------------
public void write( XMLWriter writer, ExportParams params )
{
Collection<AttributeOptions> attributeOptions = attributeOptionsService.getAllAttributeOptions();
if ( attributeOptions != null && attributeOptions.size() > 0 )
{
writer.openElement( COLLECTION_NAME );
for ( AttributeOptions attributeOption : attributeOptions )
{
writer.openElement( ELEMENT_NAME );
writer.writeElement( FIELD_ATTRIBUTE_OPTION_ID, String.valueOf( attributeOption.getId() ) );
writer.writeElement( FIELD_ATTRIBUTE_ID, String.valueOf( attributeOption.getAttribute().getId() ) );
writer.writeElement( FIELD_VALUE, attributeOption.getValue() );
writer.closeElement();
}
writer.closeElement();
}
}
public void read( XMLReader reader, ImportParams params )
{
while ( reader.moveToStartElement( ELEMENT_NAME, COLLECTION_NAME ) )
{
final Map<String, String> values = reader.readElements( ELEMENT_NAME );
final AttributeOptions attributeOptions = new AttributeOptions();
final Attribute attribute = new Attribute();
attributeOptions.setAttribute(attribute);
log.debug( "Reading Attribute Options id.");
attributeOptions.setId( Integer.parseInt( values.get( FIELD_ATTRIBUTE_ID ) ) );
log.debug( "Attribute Options values");
attribute.setId( attributeMapping.get( Integer.parseInt( values.get(FIELD_ATTRIBUTE_ID ) ) ) );
attributeOptions.getAttribute().setId( attributeMapping.get( Integer.parseInt( values.get( FIELD_ATTRIBUTE_ID ) ) ) );
log.debug( "Reading Attribute Options value.");
attributeOptions.setValue(values.get(FIELD_VALUE));
importObject( attributeOptions, params );
}
}
}
package org.hisp.dhis.importexport.dxf.converter;
/*
* Copyright (c) 2004-2005, 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 static org.apache.commons.lang.StringUtils.defaultIfEmpty;
import javax.xml.namespace.QName;
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
import org.amplecode.staxwax.reader.XMLReader;
import org.amplecode.staxwax.writer.XMLWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.cache.HibernateCacheManager;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.ProcessState;
import org.hisp.dhis.concept.Concept;
import org.hisp.dhis.concept.ConceptService;
import org.hisp.dhis.datadictionary.DataDictionary;
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.hr.AttributeGroup;
import org.hisp.dhis.hr.AttributeGroupService;
import org.hisp.dhis.hr.AttributeOptionGroup;
import org.hisp.dhis.hr.AttributeOptionGroupService;
import org.hisp.dhis.hr.AttributeOptions;
import org.hisp.dhis.hr.AttributeOptionsService;
import org.hisp.dhis.hr.AttributeService;
import org.hisp.dhis.hr.DataValuesService;
import org.hisp.dhis.hr.HistoryService;
import org.hisp.dhis.hr.HrDataSet;
import org.hisp.dhis.hr.HrDataSetService;
import org.hisp.dhis.hr.PersonService;
import org.hisp.dhis.hr.TrainingService;
import org.hisp.dhis.importexport.ExportParams;
import org.hisp.dhis.importexport.GroupMemberAssociation;
import org.hisp.dhis.importexport.ImportDataValue;
import org.hisp.dhis.importexport.ImportObjectService;
import org.hisp.dhis.importexport.ImportParams;
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.analysis.DefaultImportAnalyser;
import org.hisp.dhis.importexport.analysis.ImportAnalyser;
import org.hisp.dhis.importexport.invoker.ConverterInvoker;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
import org.hisp.dhis.importexport.mapping.ObjectMappingGenerator;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.jdbc.batchhandler.AttributeAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AttributeGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AttributeOptionGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AttributeOptionsAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AttributeOptionsBatchHandler;
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.ConceptBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryDataElementBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryIndicatorBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryComboBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryOptionBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetSourceAssociationBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.GroupSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.GroupSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.HrDataSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.HrDataSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.ImportDataValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorTypeBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitGroupMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.PeriodBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.ReportTableBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.SourceBatchHandler;
import org.hisp.dhis.olap.OlapURLService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.report.ReportService;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
import org.hisp.dhis.source.Source;
import org.hisp.dhis.validation.ValidationRuleService;
/**
* DXFConverter class This does NOT implement XMLConverter, because we need to
* pass ProcessState in read() method.
*
* @author bobj
* @version created 13-Feb-2010
*/
public class DXFConverter
{
public static final String DXFROOT = "dxf";
public static final String ATTRIBUTE_MINOR_VERSION = "minorVersion";
public static final String ATTRIBUTE_EXPORTED = "exported";
public static final String NAMESPACE_10 = "http://dhis2.org/schema/dxf/1.0";
public static final String MINOR_VERSION_10 = "1.0";
public static final String MINOR_VERSION_11 = "1.1";
public static final String MINOR_VERSION_12 = "1.2";
private final Log log = LogFactory.getLog( DXFConverter.class );
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
private ImportObjectService importObjectService;
public void setImportObjectService( ImportObjectService importObjectService )
{
this.importObjectService = importObjectService;
}
private ConceptService conceptService;
public void setConceptService( ConceptService conceptService )
{
this.conceptService = conceptService;
}
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
}
private DataElementCategoryService categoryService;
public void setCategoryService( DataElementCategoryService categoryService )
{
this.categoryService = categoryService;
}
private IndicatorService indicatorService;
public void setIndicatorService( IndicatorService indicatorService )
{
this.indicatorService = indicatorService;
}
private DataDictionaryService dataDictionaryService;
public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
{
this.dataDictionaryService = dataDictionaryService;
}
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
}
// ------------------------------------
// Hr Dependencies
// ------------------------------------
private HrDataSetService hrDataSetService;
public void setHrDataSetService( HrDataSetService hrDataSetService )
{
this.hrDataSetService = hrDataSetService;
}
private AttributeService attributeService;
public void setAttributeService( AttributeService attributeService )
{
this.attributeService = attributeService;
}
private AttributeOptionsService attributeOptionsService;
public void setAttributeOptionsService( AttributeOptionsService attributeOptionsService )
{
this.attributeOptionsService = attributeOptionsService;
}
private AttributeOptionGroupService attributeOptionGroupService;
public void setAttributeOptionGroupService( AttributeOptionGroupService attributeOptionGroupService )
{
this.attributeOptionGroupService = attributeOptionGroupService;
}
private PersonService personService;
public void setPersonService( PersonService personService )
{
this.personService = personService;
}
private HistoryService historyService;
public void setHistoryService( HistoryService historyService )
{
this.historyService = historyService;
}
private TrainingService trainingService;
public void setTrainingService( TrainingService traininigService )
{
this.trainingService = trainingService;
}
private DataValuesService dataValuesService;
public void setDataValuesService( DataValuesService dataValuesService )
{
this.dataValuesService = dataValuesService;
}
private AttributeGroupService attributeGroupService;
public void setAttributeGroupService( AttributeGroupService attributeGroupService )
{
this.attributeGroupService = attributeGroupService;
}
//------------------------------------------------
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
}
private OrganisationUnitGroupService organisationUnitGroupService;
public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
{
this.organisationUnitGroupService = organisationUnitGroupService;
}
private PeriodService periodService;
public void setPeriodService( PeriodService periodService )
{
this.periodService = periodService;
}
private ExpressionService expressionService;
public void setExpressionService( ExpressionService expressionService )
{
this.expressionService = expressionService;
}
private ValidationRuleService validationRuleService;
public void setValidationRuleService( ValidationRuleService validationRuleService )
{
this.validationRuleService = validationRuleService;
}
private ReportService reportService;
public void setReportService( ReportService reportService )
{
this.reportService = reportService;
}
private ReportTableService reportTableService;
public void setReportTableService( ReportTableService reportTableService )
{
this.reportTableService = reportTableService;
}
private ChartService chartService;
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
}
private OlapURLService olapURLService;
public void setOlapURLService( OlapURLService olapURLService )
{
this.olapURLService = olapURLService;
}
private AggregatedDataValueService aggregatedDataValueService;
public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
{
this.aggregatedDataValueService = aggregatedDataValueService;
}
private BatchHandlerFactory batchHandlerFactory;
public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
{
this.batchHandlerFactory = batchHandlerFactory;
}
private ObjectMappingGenerator objectMappingGenerator;
public void setObjectMappingGenerator( ObjectMappingGenerator objectMappingGenerator )
{
this.objectMappingGenerator = objectMappingGenerator;
}
private HibernateCacheManager cacheManager;
public void setCacheManager( HibernateCacheManager cacheManager )
{
this.cacheManager = cacheManager;
}
private ConverterInvoker converterInvoker;
public void setConverterInvoker( ConverterInvoker converterInvoker )
{
this.converterInvoker = converterInvoker;
}
public void write( XMLWriter writer, ExportParams params, ProcessState state )
{
throw new UnsupportedOperationException( "Not supported yet." );
}
public void read( XMLReader reader, ImportParams params, ProcessState state )
{
ImportAnalyser importAnalyser = new DefaultImportAnalyser( expressionService );
NameMappingUtil.clearMapping();
if ( params.isPreview() )
{
importObjectService.deleteImportObjects();
log.info( "Deleted previewed objects" );
}
if ( !reader.moveToStartElement( DXFROOT, DXFROOT ) )
{
throw new RuntimeException( "Couldn't find dxf root element" );
}
QName rootName = reader.getElementQName();
params.setNamespace( defaultIfEmpty( rootName.getNamespaceURI(), NAMESPACE_10 ) );
String version = reader.getAttributeValue( ATTRIBUTE_MINOR_VERSION );
params.setMinorVersion( version != null ? version : MINOR_VERSION_10 );
log.debug( "Importing dxf1 minor version " + version );
while ( reader.next() )
{
if ( reader.isStartElement( ConceptConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_concepts" );
BatchHandler<Concept> batchHandler = batchHandlerFactory.createBatchHandler( ConceptBatchHandler.class )
.init();
XMLConverter converter = new ConceptConverter( batchHandler, importObjectService, conceptService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported Concepts" );
}
else if ( reader.isStartElement( DataElementCategoryOptionConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_options" );
BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementCategoryOptionBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryOptionConverter( batchHandler, importObjectService,
categoryService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementCategoryOptions" );
}
else if ( reader.isStartElement( DataElementCategoryConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_categories" );
BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementCategoryBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryConverter( batchHandler, importObjectService,
categoryService, conceptService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementCategories" );
}
else if ( reader.isStartElement( DataElementCategoryComboConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_combos" );
BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementCategoryComboBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryComboConverter( batchHandler, importObjectService,
categoryService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementCategoryCombos" );
}
else if ( reader.isStartElement( DataElementCategoryOptionComboConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_option_combos" );
XMLConverter converter = new DataElementCategoryOptionComboConverter( importObjectService,
objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), objectMappingGenerator
.getCategoryOptionMapping( params.skipMapping() ), categoryService );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported DataElementCategoryOptionCombos" );
}
else if ( reader.isStartElement( CategoryCategoryOptionAssociationConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
CategoryCategoryOptionAssociationBatchHandler.class ).init();
XMLConverter converter = new CategoryCategoryOptionAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getCategoryMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryOptionMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported CategoryCategoryOption associations" );
}
else if ( reader.isStartElement( CategoryComboCategoryAssociationConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_category_combo_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
CategoryComboCategoryAssociationBatchHandler.class ).init();
XMLConverter converter = new CategoryComboCategoryAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported CategoryComboCategory associations" );
}
else if ( reader.isStartElement( DataElementConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_elements" );
BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementBatchHandler.class ).init();
XMLConverter converter = new DataElementConverter( batchHandler, importObjectService,
objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), dataElementService,
importAnalyser );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElements" );
}
// ------------------------------------------------------
// Hr -if clauses
// ------------------------------------------------------
else if ( reader.isStartElement( AttributeGroupConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_attribute_group" );
BatchHandler<AttributeGroup> batchHandler = batchHandlerFactory.createBatchHandler(
AttributeGroupBatchHandler.class ).init();
XMLConverter converter = new AttributeGroupConverter( batchHandler, importObjectService,
attributeGroupService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported AttributeGroups" );
}
else if ( reader.isStartElement( AttributeOptionGroupConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_attribute_option_group" );
BatchHandler<AttributeOptionGroup> batchHandler = batchHandlerFactory.createBatchHandler(
AttributeOptionGroupBatchHandler.class ).init();
XMLConverter converter = new AttributeOptionGroupConverter( batchHandler, importObjectService,
attributeOptionGroupService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported AttributeOptionGroups" );
}
else if ( reader.isStartElement( AttributeAssociationConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_attribute_group_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
AttributeAssociationBatchHandler.class ).init();
XMLConverter converter = new AttributeAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getAttributeGroupMapping( params.skipMapping() ),
objectMappingGenerator.getAttributeMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported Attribute associations" );
}
else if ( reader.isStartElement( AttributeOptionsAssociationConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_attribute_group_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
AttributeOptionsAssociationBatchHandler.class ).init();
XMLConverter converter = new AttributeOptionsAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getAttributeOptionGroupMapping( params.skipMapping() ),
objectMappingGenerator.getAttributeOptionsMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported AttributeOptions associations" );
}
else if ( reader.isStartElement( DataValueConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_values" );
BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler(
DataValueBatchHandler.class ).init();
BatchHandler<ImportDataValue> importDataValueBatchHandler = batchHandlerFactory.createBatchHandler(
ImportDataValueBatchHandler.class ).init();
XMLConverter converter = new DataValueConverter( batchHandler, importDataValueBatchHandler,
aggregatedDataValueService, importObjectService, params, objectMappingGenerator
.getDataElementMapping( params.skipMapping() ), objectMappingGenerator.getPeriodMapping( params
.skipMapping() ), objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
importDataValueBatchHandler.flush();
log.info( "Imported DataValues" );
}
else if ( reader.isStartElement( AttributeOptionsConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_attribute_options" );
BatchHandler<AttributeOptions> batchHandler = batchHandlerFactory.createBatchHandler(
AttributeOptionsBatchHandler.class ).init();
XMLConverter converter = new AttributeOptionsConverter( batchHandler, importObjectService,
objectMappingGenerator.getAttributeOptionsMapping( params.skipMapping() ), attributeOptionsService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported AttributeOptionss" );
}
else if ( reader.isStartElement( HrDataSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_hr_datasets" );
BatchHandler<HrDataSet> batchHandler = batchHandlerFactory.createBatchHandler( HrDataSetBatchHandler.class )
.init();
XMLConverter converter = new HrDataSetConverter( batchHandler, importObjectService, hrDataSetService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported HrDataSets" );
}
/*
else if ( reader.isStartElement( HrDataSetMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_hr_dataset_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
HrDataSetMemberBatchHandler.class ).init();
XMLConverter converter = new HrDataSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getAttributeMapping( params.skipMapping() ), objectMappingGenerator
.getHrDataSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported HrDataSet members" );
}
*/
// ------------------------------------------------------
else if ( reader.isStartElement( CalculatedDataElementConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_calculated_data_elements" );
XMLConverter converter = new CalculatedDataElementConverter( importObjectService, dataElementService,
expressionService, objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), objectMappingGenerator
.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported CalculatedDataElements" );
}
else if ( reader.isStartElement( DataElementGroupConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_groups" );
BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementGroupBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupConverter( batchHandler, importObjectService,
dataElementService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementGroups" );
}
else if ( reader.isStartElement( DataElementGroupMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_group_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementGroupMemberBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataElementMapping( params.skipMapping() ), objectMappingGenerator
.getDataElementGroupMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementGroup members" );
}
else if ( reader.isStartElement( DataElementGroupSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_group_sets" );
BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementGroupSetBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupSetConverter( batchHandler, importObjectService,
dataElementService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementGroupSets" );
}
else if ( reader.isStartElement( DataElementGroupSetMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_element_group_set_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataElementGroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataElementGroupMapping( params.skipMapping() ), objectMappingGenerator
.getDataElementGroupSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataElementGroupSet members" );
}
else if ( reader.isStartElement( IndicatorTypeConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicator_types" );
BatchHandler<IndicatorType> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorTypeBatchHandler.class ).init();
XMLConverter converter = new IndicatorTypeConverter( batchHandler, importObjectService,
indicatorService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported IndicatorTypes" );
}
else if ( reader.isStartElement( IndicatorConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicators" );
BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorBatchHandler.class ).init();
XMLConverter converter = new IndicatorConverter( batchHandler, importObjectService, indicatorService,
expressionService, objectMappingGenerator.getIndicatorTypeMapping( params.skipMapping() ),
objectMappingGenerator.getDataElementMapping( params.skipMapping() ), objectMappingGenerator
.getCategoryOptionComboMapping( params.skipMapping() ), importAnalyser );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported Indicators" );
}
else if ( reader.isStartElement( IndicatorGroupConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicator_groups" );
BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorGroupBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupConverter( batchHandler, importObjectService,
indicatorService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported IndicatorGroups" );
}
else if ( reader.isStartElement( IndicatorGroupMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicator_group_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorGroupMemberBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getIndicatorMapping( params.skipMapping() ), objectMappingGenerator
.getIndicatorGroupMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported IndicatorGroup members" );
}
else if ( reader.isStartElement( IndicatorGroupSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicator_group_sets" );
BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorGroupSetBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupSetConverter( batchHandler, importObjectService,
indicatorService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported IndicatorGroupSets" );
}
else if ( reader.isStartElement( IndicatorGroupSetMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_indicator_group_set_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
IndicatorGroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getIndicatorGroupMapping( params.skipMapping() ), objectMappingGenerator
.getIndicatorGroupSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported IndicatorGroupSet members" );
}
else if ( reader.isStartElement( DataDictionaryConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_dictionaries" );
BatchHandler<DataDictionary> batchHandler = batchHandlerFactory.createBatchHandler(
DataDictionaryBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryConverter( batchHandler, importObjectService,
dataDictionaryService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataDictionaries" );
}
else if ( reader.isStartElement( DataDictionaryDataElementConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_dictionary_data_elements" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataDictionaryDataElementBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryDataElementConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ), objectMappingGenerator
.getDataElementMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataDictionary DataElements" );
}
else if ( reader.isStartElement( DataDictionaryIndicatorConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_dictionary_indicators" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataDictionaryIndicatorBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryIndicatorConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ), objectMappingGenerator
.getIndicatorMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataDictionary Indicators" );
}
else if ( reader.isStartElement( DataSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_sets" );
BatchHandler<DataSet> batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class )
.init();
XMLConverter converter = new DataSetConverter( batchHandler, importObjectService, dataSetService,
objectMappingGenerator.getPeriodTypeMapping() );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataSets" );
}
else if ( reader.isStartElement( DataSetMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_set_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataSetMemberBatchHandler.class ).init();
XMLConverter converter = new DataSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataElementMapping( params.skipMapping() ), objectMappingGenerator
.getDataSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataSet members" );
}
else if ( reader.isStartElement( OrganisationUnitConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_units" );
BatchHandler<Source> sourceBatchHandler = batchHandlerFactory.createBatchHandler(
SourceBatchHandler.class ).init();
BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler(
OrganisationUnitBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitConverter( batchHandler, sourceBatchHandler,
importObjectService, organisationUnitService, importAnalyser );
converterInvoker.invokeRead( converter, reader, params );
sourceBatchHandler.flush();
batchHandler.flush();
log.info( "Imported OrganisationUnits" );
}
else if ( reader.isStartElement( OrganisationUnitRelationshipConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_relationships" );
BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler(
OrganisationUnitBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitRelationshipConverter( batchHandler, importObjectService,
organisationUnitService, objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported OrganisationUnit relationships" );
}
else if ( reader.isStartElement( OrganisationUnitGroupConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_groups" );
BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory.createBatchHandler(
OrganisationUnitGroupBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitGroupConverter( batchHandler, importObjectService,
organisationUnitGroupService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported OrganisationUnitGroups" );
}
else if ( reader.isStartElement( OrganisationUnitGroupMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_group_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
OrganisationUnitGroupMemberBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ), objectMappingGenerator
.getOrganisationUnitGroupMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported OrganisationUnitGroup members" );
}
else if ( reader.isStartElement( GroupSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_group_sets" );
BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
GroupSetBatchHandler.class ).init();
XMLConverter converter = new GroupSetConverter( batchHandler, importObjectService,
organisationUnitGroupService );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported OrganisationUnitGroupSets" );
}
else if ( reader.isStartElement( GroupSetMemberConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_group_set_members" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
GroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new GroupSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getOrganisationUnitGroupMapping( params.skipMapping() ),
objectMappingGenerator.getOrganisationUnitGroupSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported OrganisationUnitGroupSet members" );
}
else if ( reader.isStartElement( OrganisationUnitLevelConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_organisation_unit_levels" );
XMLConverter converter = new OrganisationUnitLevelConverter( organisationUnitService,
importObjectService );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported OrganisationUnitLevels" );
}
else if ( reader.isStartElement( DataSetSourceAssociationConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_set_source_associations" );
BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
DataSetSourceAssociationBatchHandler.class ).init();
XMLConverter converter = new DataSetSourceAssociationConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataSetMapping( params.skipMapping() ), objectMappingGenerator
.getOrganisationUnitMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported DataSet Source associations" );
}
else if ( reader.isStartElement( ValidationRuleConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_validation_rules" );
XMLConverter converter = new ValidationRuleConverter( importObjectService, validationRuleService,
expressionService, objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported ValidationRules" );
}
else if ( reader.isStartElement( PeriodConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_periods" );
BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class )
.init();
XMLConverter converter = new PeriodConverter( batchHandler, importObjectService, periodService,
objectMappingGenerator.getPeriodTypeMapping() );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported Periods" );
}
else if ( reader.isStartElement( ReportConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_reports" );
XMLConverter converter = new ReportConverter( reportService, importObjectService );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported Reports" );
}
else if ( reader.isStartElement( ReportTableConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_report_tables" );
BatchHandler<ReportTable> batchHandler = batchHandlerFactory.createBatchHandler(
ReportTableBatchHandler.class ).init();
XMLConverter converter = new ReportTableConverter( reportTableService, importObjectService,
dataElementService, categoryService, indicatorService, dataSetService, periodService,
organisationUnitService, objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), objectMappingGenerator
.getIndicatorMapping( params.skipMapping() ), objectMappingGenerator.getDataSetMapping( params
.skipMapping() ), objectMappingGenerator.getPeriodMapping( params.skipMapping() ),
objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported ReportTables" );
}
else if ( reader.isStartElement( ChartConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_charts" );
XMLConverter converter = new ChartConverter( chartService, importObjectService, indicatorService,
periodService, organisationUnitService, objectMappingGenerator.getIndicatorMapping( params
.skipMapping() ), objectMappingGenerator.getPeriodMapping( params.skipMapping() ),
objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported Charts" );
}
else if ( reader.isStartElement( OlapUrlConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_olap_urls" );
XMLConverter converter = new OlapUrlConverter( importObjectService, olapURLService );
converterInvoker.invokeRead( converter, reader, params );
log.info( "Imported OlapURLs" );
}
else if ( reader.isStartElement( CompleteDataSetRegistrationConverter.COLLECTION_NAME )
&& params.isDataValues() )
{
state.setMessage( "importing_complete_data_set_registrations" );
BatchHandler<CompleteDataSetRegistration> batchHandler = batchHandlerFactory.createBatchHandler(
CompleteDataSetRegistrationBatchHandler.class ).init();
XMLConverter converter = new CompleteDataSetRegistrationConverter( batchHandler, importObjectService,
params, objectMappingGenerator.getDataSetMapping( params.skipMapping() ), objectMappingGenerator
.getPeriodMapping( params.skipMapping() ), objectMappingGenerator
.getOrganisationUnitMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
log.info( "Imported CompleteDataSetRegistrations" );
}
else if ( reader.isStartElement( DataValueConverter.COLLECTION_NAME ) && params.isDataValues() )
{
state.setMessage( "importing_data_values" );
BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler(
DataValueBatchHandler.class ).init();
BatchHandler<ImportDataValue> importDataValueBatchHandler = batchHandlerFactory.createBatchHandler(
ImportDataValueBatchHandler.class ).init();
XMLConverter converter = new DataValueConverter( batchHandler, importDataValueBatchHandler,
aggregatedDataValueService, importObjectService, params, objectMappingGenerator
.getDataElementMapping( params.skipMapping() ), objectMappingGenerator.getPeriodMapping( params
.skipMapping() ), objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ),
objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
batchHandler.flush();
importDataValueBatchHandler.flush();
log.info( "Imported DataValues" );
}
}
if ( params.isAnalysis() )
{
state.setOutput( importAnalyser.getImportAnalysis() );
}
NameMappingUtil.clearMapping();
cacheManager.clearCache();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment