dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09277
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2417: Applied patch from Tran on import of dataentryform
------------------------------------------------------------
revno: 2417
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-23 12:56:44 +0100
message:
Applied patch from Tran on import of dataentryform
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberType.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.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/converter/DataElementCategoryConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.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/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-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java
dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultIndentingXMLStreamWriter.java
dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultLineBreakingXMLStreamWriter.java
dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java
dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/XMLWriter.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.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-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2010-09-13 11:06:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2010-12-23 11:56:44 +0000
@@ -32,11 +32,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.hisp.dhis.common.ImportableObject;
+
/**
* @author Bharath Kumar
*/
public class DataEntryForm
- implements Serializable
+ implements Serializable, ImportableObject
{
public static final Pattern INPUT_PATTERN = Pattern.compile( "value\\[\\d+\\]\\.value:value\\[\\d+\\]\\.value" );
public static final Pattern OPERAND_PATTERN = Pattern.compile( "\\d+" );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2010-09-13 11:06:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2010-12-23 11:56:44 +0000
@@ -86,6 +86,8 @@
*/
Collection<DataEntryForm> getAllDataEntryForms();
+ Collection<DataEntryForm> getDataEntryForms( final Collection<Integer> identifiers );
+
/**
* Prepare DataEntryForm code
*
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberType.java 2010-07-30 12:59:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/importexport/GroupMemberType.java 2010-12-23 11:56:44 +0000
@@ -44,7 +44,9 @@
DATADICTIONARY_INDICATOR,
DATASET,
DATASET_SOURCE,
+ DATASET_DATAENTRYFORM,
ORGANISATIONUNITGROUP,
ORGANISATIONUNITGROUPSET,
- ORGANISATIONUNITRELATIONSHIP
+ ORGANISATIONUNITRELATIONSHIP,
+ DATAENTRYFORM
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2010-10-14 08:14:12 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2010-12-23 11:56:44 +0000
@@ -32,6 +32,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.hisp.dhis.system.util.Filter;
+import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -181,4 +183,18 @@
return dataEntryFormStore.listDisctinctDataEntryFormByDataSetIds( dataSetIds );
}
+
+ public Collection<DataEntryForm> getDataEntryForms( final Collection<Integer> identifiers ){
+
+ Collection<DataEntryForm> dataEntryForms = getAllDataEntryForms();
+
+ return identifiers == null ? dataEntryForms : FilterUtils.filter( dataEntryForms, new Filter<DataEntryForm>()
+ {
+ public boolean retain( DataEntryForm object )
+ {
+ return identifiers.contains( object.getId() );
+ }
+ } );
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java 2010-07-28 13:44:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ExportParams.java 2010-12-23 11:56:44 +0000
@@ -101,6 +101,8 @@
private Collection<Integer> olapUrls = new ArrayList<Integer>();
+ private Collection<Integer> dataEntryForms = new ArrayList<Integer>();
+
private I18n i18n;
private I18nFormat format;
@@ -465,4 +467,16 @@
{
this.olapUrls = olapUrls;
}
+
+
+ public Collection<Integer> getDataEntryForms()
+ {
+ return dataEntryForms;
+ }
+
+ public void setDataEntryForms( Collection<Integer> dataEntryForms )
+ {
+ this.dataEntryForms = dataEntryForms;
+ }
+
}
=== 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 2010-07-30 12:59:39 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportObjectManager.java 2010-12-23 11:56:44 +0000
@@ -110,4 +110,6 @@
void importCompleteDataSetRegistrations();
void importDataValues();
+
+ void importDataEntryForms();
}
=== 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 2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java 2010-12-23 11:56:44 +0000
@@ -53,6 +53,8 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -89,6 +91,7 @@
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.DataEntryFormBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetMemberBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetSourceAssociationBatchHandler;
@@ -123,21 +126,26 @@
import org.hisp.dhis.validation.ValidationRuleService;
/**
- * DXFConverter class
- * This does NOT implement XMLConverter, because we need to pass ProcessState
- * in read() method.
- *
+ * 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 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 );
@@ -231,7 +239,7 @@
}
private ReportService reportService;
-
+
public void setReportService( ReportService reportService )
{
this.reportService = reportService;
@@ -245,7 +253,7 @@
}
private ChartService chartService;
-
+
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
@@ -293,6 +301,13 @@
this.converterInvoker = converterInvoker;
}
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
public void write( XMLWriter writer, ExportParams params, ProcessState state )
{
throw new UnsupportedOperationException( "Not supported yet." );
@@ -301,7 +316,7 @@
public void read( XMLReader reader, ImportParams params, ProcessState state )
{
ImportAnalyser importAnalyser = new DefaultImportAnalyser( expressionService );
-
+
NameMappingUtil.clearMapping();
if ( params.isPreview() )
@@ -310,14 +325,14 @@
log.info( "Deleted previewed objects" );
}
-
- if (!reader.moveToStartElement( DXFROOT, DXFROOT)) {
- throw new RuntimeException("Couldn't find dxf root element");
+ 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 );
+ String version = reader.getAttributeValue( ATTRIBUTE_MINOR_VERSION );
params.setMinorVersion( version != null ? version : MINOR_VERSION_10 );
log.debug( "Importing dxf1 minor version " + version );
@@ -327,11 +342,10 @@
{
state.setMessage( "importing_concepts" );
- BatchHandler<Concept> batchHandler = batchHandlerFactory
- .createBatchHandler( ConceptBatchHandler.class ).init();
+ BatchHandler<Concept> batchHandler = batchHandlerFactory.createBatchHandler( ConceptBatchHandler.class )
+ .init();
- XMLConverter converter = new ConceptConverter( batchHandler, importObjectService,
- conceptService );
+ XMLConverter converter = new ConceptConverter( batchHandler, importObjectService, conceptService );
converterInvoker.invokeRead( converter, reader, params );
@@ -343,8 +357,8 @@
{
state.setMessage( "importing_data_element_category_options" );
- BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementCategoryOptionBatchHandler.class ).init();
+ BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryOptionBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryOptionConverter( batchHandler, importObjectService,
categoryService );
@@ -359,8 +373,8 @@
{
state.setMessage( "importing_data_element_categories" );
- BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementCategoryBatchHandler.class ).init();
+ BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryConverter( batchHandler, importObjectService,
categoryService, conceptService );
@@ -375,8 +389,8 @@
{
state.setMessage( "importing_data_element_category_combos" );
- BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementCategoryComboBatchHandler.class ).init();
+ BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryComboBatchHandler.class ).init();
XMLConverter converter = new DataElementCategoryComboConverter( batchHandler, importObjectService,
categoryService );
@@ -403,8 +417,8 @@
{
state.setMessage( "importing_data_element_category_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( CategoryCategoryOptionAssociationBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ CategoryCategoryOptionAssociationBatchHandler.class ).init();
XMLConverter converter = new CategoryCategoryOptionAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getCategoryMapping( params.skipMapping() ),
@@ -420,8 +434,8 @@
{
state.setMessage( "importing_data_element_category_combo_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( CategoryComboCategoryAssociationBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ CategoryComboCategoryAssociationBatchHandler.class ).init();
XMLConverter converter = new CategoryComboCategoryAssociationConverter( batchHandler,
importObjectService, objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
@@ -437,11 +451,12 @@
{
state.setMessage( "importing_data_elements" );
- BatchHandler<DataElement> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementBatchHandler.class ).init();
+ BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementBatchHandler.class ).init();
XMLConverter converter = new DataElementConverter( batchHandler, importObjectService,
- objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), dataElementService, importAnalyser );
+ objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), dataElementService,
+ importAnalyser );
converterInvoker.invokeRead( converter, reader, params );
@@ -453,12 +468,11 @@
{
state.setMessage( "importing_data_elements" );
- BatchHandler<DataElement> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementBatchHandler.class ).init();
+ BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementBatchHandler.class ).init();
- XMLConverter converter = new ExtendedDataElementConverter( batchHandler,
- importObjectService, objectMappingGenerator
- .getCategoryComboMapping( params.skipMapping() ), dataElementService );
+ XMLConverter converter = new ExtendedDataElementConverter( batchHandler, importObjectService,
+ objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ), dataElementService );
converterInvoker.invokeRead( converter, reader, params );
@@ -483,8 +497,8 @@
{
state.setMessage( "importing_data_element_groups" );
- BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementGroupBatchHandler.class ).init();
+ BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupConverter( batchHandler, importObjectService,
dataElementService );
@@ -499,8 +513,8 @@
{
state.setMessage( "importing_data_element_group_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( DataElementGroupMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupMemberBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataElementMapping( params.skipMapping() ), objectMappingGenerator
@@ -516,10 +530,11 @@
{
state.setMessage( "importing_data_element_group_sets" );
- BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.
- createBatchHandler( DataElementGroupSetBatchHandler.class ).init();
+ BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupSetBatchHandler.class ).init();
- XMLConverter converter = new DataElementGroupSetConverter( batchHandler, importObjectService, dataElementService );
+ XMLConverter converter = new DataElementGroupSetConverter( batchHandler, importObjectService,
+ dataElementService );
converterInvoker.invokeRead( converter, reader, params );
@@ -531,12 +546,12 @@
{
state.setMessage( "importing_data_element_group_set_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.
- createBatchHandler( DataElementGroupSetMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new DataElementGroupSetMemberConverter( batchHandler, importObjectService,
- objectMappingGenerator.getDataElementGroupMapping( params.skipMapping() ),
- objectMappingGenerator.getDataElementGroupSetMapping( params.skipMapping() ) );
+ objectMappingGenerator.getDataElementGroupMapping( params.skipMapping() ), objectMappingGenerator
+ .getDataElementGroupSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
@@ -548,8 +563,8 @@
{
state.setMessage( "importing_indicator_types" );
- BatchHandler<IndicatorType> batchHandler = batchHandlerFactory
- .createBatchHandler( IndicatorTypeBatchHandler.class ).init();
+ BatchHandler<IndicatorType> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorTypeBatchHandler.class ).init();
XMLConverter converter = new IndicatorTypeConverter( batchHandler, importObjectService,
indicatorService );
@@ -564,8 +579,8 @@
{
state.setMessage( "importing_indicators" );
- BatchHandler<Indicator> batchHandler = batchHandlerFactory
- .createBatchHandler( IndicatorBatchHandler.class ).init();
+ BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorBatchHandler.class ).init();
XMLConverter converter = new IndicatorConverter( batchHandler, importObjectService, indicatorService,
expressionService, objectMappingGenerator.getIndicatorTypeMapping( params.skipMapping() ),
@@ -582,14 +597,13 @@
{
state.setMessage( "importing_indicators" );
- BatchHandler<Indicator> batchHandler = batchHandlerFactory
- .createBatchHandler( IndicatorBatchHandler.class ).init();
+ BatchHandler<Indicator> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorBatchHandler.class ).init();
- XMLConverter converter = new ExtendedIndicatorConverter( batchHandler,
- importObjectService, indicatorService, expressionService, objectMappingGenerator
- .getIndicatorTypeMapping( params.skipMapping() ), objectMappingGenerator
- .getDataElementMapping( params.skipMapping() ), objectMappingGenerator
- .getCategoryOptionComboMapping( params.skipMapping() ) );
+ XMLConverter converter = new ExtendedIndicatorConverter( batchHandler, importObjectService,
+ indicatorService, expressionService, objectMappingGenerator.getIndicatorTypeMapping( params
+ .skipMapping() ), objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
+ objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
@@ -601,8 +615,8 @@
{
state.setMessage( "importing_indicator_groups" );
- BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory
- .createBatchHandler( IndicatorGroupBatchHandler.class ).init();
+ BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupConverter( batchHandler, importObjectService,
indicatorService );
@@ -617,8 +631,8 @@
{
state.setMessage( "importing_indicator_group_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( IndicatorGroupMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupMemberBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getIndicatorMapping( params.skipMapping() ), objectMappingGenerator
@@ -634,10 +648,11 @@
{
state.setMessage( "importing_indicator_group_sets" );
- BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.
- createBatchHandler( IndicatorGroupSetBatchHandler.class ).init();
+ BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupSetBatchHandler.class ).init();
- XMLConverter converter = new IndicatorGroupSetConverter( batchHandler, importObjectService, indicatorService );
+ XMLConverter converter = new IndicatorGroupSetConverter( batchHandler, importObjectService,
+ indicatorService );
converterInvoker.invokeRead( converter, reader, params );
@@ -649,12 +664,12 @@
{
state.setMessage( "importing_indicator_group_set_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.
- createBatchHandler( IndicatorGroupSetMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new IndicatorGroupSetMemberConverter( batchHandler, importObjectService,
- objectMappingGenerator.getIndicatorGroupMapping( params.skipMapping() ),
- objectMappingGenerator.getIndicatorGroupSetMapping( params.skipMapping() ) );
+ objectMappingGenerator.getIndicatorGroupMapping( params.skipMapping() ), objectMappingGenerator
+ .getIndicatorGroupSetMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
@@ -666,8 +681,8 @@
{
state.setMessage( "importing_data_dictionaries" );
- BatchHandler<DataDictionary> batchHandler = batchHandlerFactory
- .createBatchHandler( DataDictionaryBatchHandler.class ).init();
+ BatchHandler<DataDictionary> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataDictionaryBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryConverter( batchHandler, importObjectService,
dataDictionaryService );
@@ -682,8 +697,8 @@
{
state.setMessage( "importing_data_dictionary_data_elements" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( DataDictionaryDataElementBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataDictionaryDataElementBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryDataElementConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ), objectMappingGenerator
@@ -699,8 +714,8 @@
{
state.setMessage( "importing_data_dictionary_indicators" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( DataDictionaryIndicatorBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataDictionaryIndicatorBatchHandler.class ).init();
XMLConverter converter = new DataDictionaryIndicatorConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ), objectMappingGenerator
@@ -712,14 +727,31 @@
log.info( "Imported DataDictionary Indicators" );
}
+ else if ( reader.isStartElement( DataEntryFormConverter.COLLECTION_NAME ) )
+ {
+ state.setMessage( "importing_data_entry_forms" );
+
+ BatchHandler<DataEntryForm> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataEntryFormBatchHandler.class ).init();
+
+ XMLConverter converter = new DataEntryFormConverter( batchHandler, importObjectService,
+ dataEntryFormService, dataElementService, categoryService );
+
+ converterInvoker.invokeRead( converter, reader, params );
+
+ batchHandler.flush();
+
+ log.info( "Imported DataEntryForms" );
+ }
else if ( reader.isStartElement( DataSetConverter.COLLECTION_NAME ) )
{
state.setMessage( "importing_data_sets" );
- BatchHandler<DataSet> batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class ).init();
+ BatchHandler<DataSet> batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class )
+ .init();
XMLConverter converter = new DataSetConverter( batchHandler, importObjectService, dataSetService,
- objectMappingGenerator.getPeriodTypeMapping() );
+ objectMappingGenerator.getPeriodTypeMapping(), objectMappingGenerator.getDataEntryFormMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
@@ -731,8 +763,8 @@
{
state.setMessage( "importing_data_set_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( DataSetMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataSetMemberBatchHandler.class ).init();
XMLConverter converter = new DataSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataElementMapping( params.skipMapping() ), objectMappingGenerator
@@ -748,10 +780,10 @@
{
state.setMessage( "importing_organisation_units" );
- BatchHandler<Source> sourceBatchHandler = batchHandlerFactory
- .createBatchHandler( SourceBatchHandler.class ).init();
- BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory
- .createBatchHandler( OrganisationUnitBatchHandler.class ).init();
+ 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 );
@@ -767,8 +799,8 @@
{
state.setMessage( "importing_organisation_unit_relationships" );
- BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory
- .createBatchHandler( OrganisationUnitBatchHandler.class ).init();
+ BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitRelationshipConverter( batchHandler, importObjectService,
organisationUnitService, objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
@@ -783,8 +815,8 @@
{
state.setMessage( "importing_organisation_unit_groups" );
- BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory
- .createBatchHandler( OrganisationUnitGroupBatchHandler.class ).init();
+ BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitGroupBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitGroupConverter( batchHandler, importObjectService,
organisationUnitGroupService );
@@ -799,8 +831,8 @@
{
state.setMessage( "importing_organisation_unit_group_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( OrganisationUnitGroupMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitGroupMemberBatchHandler.class ).init();
XMLConverter converter = new OrganisationUnitGroupMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ), objectMappingGenerator
@@ -816,8 +848,8 @@
{
state.setMessage( "importing_organisation_unit_group_sets" );
- BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory
- .createBatchHandler( GroupSetBatchHandler.class ).init();
+ BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ GroupSetBatchHandler.class ).init();
XMLConverter converter = new GroupSetConverter( batchHandler, importObjectService,
organisationUnitGroupService );
@@ -832,8 +864,8 @@
{
state.setMessage( "importing_organisation_unit_group_set_members" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( GroupSetMemberBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ GroupSetMemberBatchHandler.class ).init();
XMLConverter converter = new GroupSetMemberConverter( batchHandler, importObjectService,
objectMappingGenerator.getOrganisationUnitGroupMapping( params.skipMapping() ),
@@ -860,8 +892,8 @@
{
state.setMessage( "importing_data_set_source_associations" );
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
- .createBatchHandler( DataSetSourceAssociationBatchHandler.class ).init();
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataSetSourceAssociationBatchHandler.class ).init();
XMLConverter converter = new DataSetSourceAssociationConverter( batchHandler, importObjectService,
objectMappingGenerator.getDataSetMapping( params.skipMapping() ), objectMappingGenerator
@@ -889,7 +921,8 @@
{
state.setMessage( "importing_periods" );
- BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class ).init();
+ BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class )
+ .init();
XMLConverter converter = new PeriodConverter( batchHandler, importObjectService, periodService,
objectMappingGenerator.getPeriodTypeMapping() );
@@ -903,28 +936,27 @@
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();
+ BatchHandler<ReportTable> batchHandler = batchHandlerFactory.createBatchHandler(
+ ReportTableBatchHandler.class ).init();
XMLConverter converter = new ReportTableConverter( reportTableService, importObjectService,
- dataElementService, categoryService, indicatorService, dataSetService, periodService, organisationUnitService,
- objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
+ dataElementService, categoryService, indicatorService, dataSetService, periodService,
+ organisationUnitService, objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
objectMappingGenerator.getDataElementGroupSetMapping( params.skipMapping() ),
- objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
- objectMappingGenerator.getIndicatorMapping( params.skipMapping() ),
- objectMappingGenerator.getDataSetMapping( params.skipMapping() ),
- objectMappingGenerator.getPeriodMapping( 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 );
@@ -936,15 +968,14 @@
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() ),
+
+ 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 ) )
@@ -962,8 +993,8 @@
{
state.setMessage( "importing_complete_data_set_registrations" );
- BatchHandler<CompleteDataSetRegistration> batchHandler = batchHandlerFactory
- .createBatchHandler( CompleteDataSetRegistrationBatchHandler.class ).init();
+ BatchHandler<CompleteDataSetRegistration> batchHandler = batchHandlerFactory.createBatchHandler(
+ CompleteDataSetRegistrationBatchHandler.class ).init();
XMLConverter converter = new CompleteDataSetRegistrationConverter( batchHandler, importObjectService,
params, objectMappingGenerator.getDataSetMapping( params.skipMapping() ), objectMappingGenerator
@@ -980,17 +1011,16 @@
{
state.setMessage( "importing_data_values" );
- BatchHandler<DataValue> batchHandler = batchHandlerFactory
- .createBatchHandler( DataValueBatchHandler.class ).init();
- BatchHandler<ImportDataValue> importDataValueBatchHandler = batchHandlerFactory
- .createBatchHandler( ImportDataValueBatchHandler.class ).init();
+ 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() ) );
+ .getDataElementMapping( params.skipMapping() ), objectMappingGenerator.getPeriodMapping( params
+ .skipMapping() ), objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ),
+ objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
converterInvoker.invokeRead( converter, reader, params );
@@ -1000,6 +1030,7 @@
log.info( "Imported DataValues" );
}
+
}
if ( params.isAnalysis() )
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryConverter.java 2010-11-12 08:13:46 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryConverter.java 2010-12-23 11:56:44 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.MINOR_VERSION_11;
import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.MINOR_VERSION_12;
import java.util.Collection;
@@ -139,19 +138,12 @@
category.setId( Integer.parseInt( values.get( FIELD_ID ) ) );
category.setName( values.get( FIELD_NAME ) );
- if ( params.minorVersionGreaterOrEqual( MINOR_VERSION_12 ) )
+ if ( params.minorVersionGreaterOrEqual( MINOR_VERSION_12 ) && values.get( FIELD_CONCEPT_ID ) != null )
{
log.debug( "reading category dxf version >1.2" );
int conceptid = Integer.parseInt( values.get( FIELD_CONCEPT_ID ) );
String conceptName = conceptMap.get( conceptid );
category.setConcept( conceptService.getConceptByName( conceptName ) );
-
- }
- else if ( params.getMinorVersion().equals( MINOR_VERSION_11 ) )
- {
- log.debug( "reading category dxf version 1.1" );
- // TODO: read concept from conceptname
- category.setConcept( defaultConcept );
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java 2010-09-13 10:47:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataSetConverter.java 2010-12-23 11:56:44 +0000
@@ -33,6 +33,8 @@
import org.amplecode.quick.BatchHandler;
import org.amplecode.staxwax.reader.XMLReader;
import org.amplecode.staxwax.writer.XMLWriter;
+import org.apache.commons.lang.StringUtils;
+import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.importexport.ExportParams;
@@ -43,14 +45,13 @@
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.PeriodType;
-import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.MINOR_VERSION_11;
-
/**
* @author Lars Helge Overland
* @version $Id: DataSetConverter.java 6455 2008-11-24 08:59:37Z larshelg $
*/
public class DataSetConverter
- extends DataSetImporter implements XMLConverter
+ extends DataSetImporter
+ implements XMLConverter
{
public static final String COLLECTION_NAME = "dataSets";
public static final String ELEMENT_NAME = "dataSet";
@@ -60,13 +61,17 @@
private static final String FIELD_SHORT_NAME = "shortName";
private static final String FIELD_CODE = "code";
private static final String FIELD_PERIOD_TYPE = "periodType";
+ private static final String FIELD_DATA_ENTRY_FORM_ID = "dataEntryForm";
+
+ private static final String BLANK = "";
// -------------------------------------------------------------------------
// Properties
// -------------------------------------------------------------------------
private Map<String, Integer> periodTypeMapping;
-
+ private Map<Object, Integer> dataEntryFormMapping;
+
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
@@ -75,10 +80,10 @@
* Constructor for write operations.
*/
public DataSetConverter( DataSetService dataSetService )
- {
+ {
this.dataSetService = dataSetService;
}
-
+
/**
* Constructor for read operations.
*
@@ -86,15 +91,14 @@
* @param dataSetStore the dataSetStore to use.
* @param importObjectService the importObjectService to use.
*/
- public DataSetConverter( BatchHandler<DataSet> batchHandler,
- ImportObjectService importObjectService,
- DataSetService dataSetService,
- Map<String, Integer> periodTypeMapping )
+ public DataSetConverter( BatchHandler<DataSet> batchHandler, ImportObjectService importObjectService,
+ DataSetService dataSetService, Map<String, Integer> periodTypeMapping, Map<Object, Integer> dataEntryFormMapping )
{
this.batchHandler = batchHandler;
this.importObjectService = importObjectService;
this.dataSetService = dataSetService;
this.periodTypeMapping = periodTypeMapping;
+ this.dataEntryFormMapping = dataEntryFormMapping;
}
/**
@@ -103,13 +107,12 @@
* @param batchHandler the batchHandler to use.
* @param dataSetStore the dataSetStore to use.
*/
- public DataSetConverter( BatchHandler<DataSet> batchHandler,
- DataSetService dataSetService )
+ public DataSetConverter( BatchHandler<DataSet> batchHandler, DataSetService dataSetService )
{
this.batchHandler = batchHandler;
this.dataSetService = dataSetService;
}
-
+
// -------------------------------------------------------------------------
// XMLConverter implementation
// -------------------------------------------------------------------------
@@ -117,54 +120,55 @@
public void write( XMLWriter writer, ExportParams params )
{
Collection<DataSet> dataSets = dataSetService.getDataSets( params.getDataSets() );
-
+
if ( dataSets != null && dataSets.size() > 0 )
{
writer.openElement( COLLECTION_NAME );
-
+
for ( DataSet dataSet : dataSets )
{
writer.openElement( ELEMENT_NAME );
-
+
writer.writeElement( FIELD_ID, String.valueOf( dataSet.getId() ) );
- writer.writeElement( FIELD_NAME, dataSet.getName() );
- writer.writeElement( FIELD_SHORT_NAME, dataSet.getShortName() );
+ writer.writeCData( FIELD_NAME, dataSet.getName() );
+ writer.writeCData( FIELD_SHORT_NAME, dataSet.getShortName() );
writer.writeElement( FIELD_CODE, dataSet.getCode() );
writer.writeElement( FIELD_PERIOD_TYPE, dataSet.getPeriodType().getName() );
-
+ writer.writeElement( FIELD_DATA_ENTRY_FORM_ID, String
+ .valueOf( dataSet.getDataEntryForm() == null ? BLANK : dataSet.getDataEntryForm().getId() ) );
+
writer.closeElement();
}
-
+
writer.closeElement();
}
}
-
+
public void read( XMLReader reader, ImportParams params )
- {
+ {
while ( reader.moveToStartElement( ELEMENT_NAME, COLLECTION_NAME ) )
{
final DataSet dataSet = new DataSet();
PeriodType periodType = new MonthlyPeriodType();
dataSet.setPeriodType( periodType );
-
- reader.moveToStartElement( FIELD_ID );
- dataSet.setId( Integer.parseInt( reader.getElementValue() ) );
-
- reader.moveToStartElement( FIELD_NAME );
- dataSet.setName( reader.getElementValue() );
- if ( params.minorVersionGreaterOrEqual( MINOR_VERSION_11 ) )
+ final Map<String, String> values = reader.readElements( ELEMENT_NAME );
+
+ dataSet.setId( Integer.parseInt( values.get( FIELD_ID ) ) );
+ dataSet.setName( values.get( FIELD_NAME ) );
+ dataSet.setShortName( values.get( FIELD_SHORT_NAME ) );
+ dataSet.setCode( values.get( FIELD_CODE ) );
+ dataSet.getPeriodType().setId( periodTypeMapping.get( values.get( FIELD_PERIOD_TYPE ) ) );
+
+ String dataEntryFormId = StringUtils.trimToNull( values.get( FIELD_DATA_ENTRY_FORM_ID ) );
+
+ if ( dataEntryFormId != null )
{
- reader.moveToStartElement( FIELD_SHORT_NAME );
- dataSet.setShortName( reader.getElementValue() );
-
- reader.moveToStartElement( FIELD_CODE );
- dataSet.setCode( reader.getElementValue() );
+ DataEntryForm form = new DataEntryForm();
+ dataSet.setDataEntryForm( form );
+ dataSet.getDataEntryForm().setId( dataEntryFormMapping.get( Integer.parseInt( dataEntryFormId ) ) );
}
-
- reader.moveToStartElement( FIELD_PERIOD_TYPE );
- dataSet.getPeriodType().setId( periodTypeMapping.get( reader.getElementValue() ) );
importObject( dataSet, params );
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java 2010-11-23 12:46:20 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java 2010-12-23 11:56:44 +0000
@@ -195,25 +195,27 @@
reader.moveToStartElement( FIELD_FEATURE );
unit.setFeatureType( reader.getAttributeValue( ATTRIBUTE_TYPE ) );
- List<CoordinatesTuple> list = new ArrayList<CoordinatesTuple>();
- while ( reader.moveToStartElement( FIELD_COORDINATES_TUPLE, FIELD_FEATURE ) )
- {
- CoordinatesTuple tuple = new CoordinatesTuple();
- while ( reader.moveToStartElement( FIELD_COORDINATES, FIELD_COORDINATES_TUPLE ) )
- {
- tuple.addCoordinates( reader.getElementValue() );
- }
- list.add( tuple );
- }
-
- if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) )
- {
- unit.setPointCoordinatesFromList( list );
- }
-
- else
- {
- unit.setMultiPolygonCoordinatesFromList( list );
+ if ( unit.getFeatureType() != null )
+ {
+ List<CoordinatesTuple> list = new ArrayList<CoordinatesTuple>();
+ while ( reader.moveToStartElement( FIELD_COORDINATES_TUPLE, FIELD_FEATURE ) )
+ {
+ CoordinatesTuple tuple = new CoordinatesTuple();
+ while ( reader.moveToStartElement( FIELD_COORDINATES, FIELD_COORDINATES_TUPLE ) )
+ {
+ tuple.addCoordinates( reader.getElementValue() );
+ }
+ list.add( tuple );
+ }
+
+ if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) )
+ {
+ unit.setPointCoordinatesFromList( list );
+ }
+ else
+ {
+ unit.setMultiPolygonCoordinatesFromList( list );
+ }
}
reader.moveToStartElement( FIELD_LAST_UPDATED );
=== 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 2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java 2010-12-23 11:56:44 +0000
@@ -52,6 +52,7 @@
import org.hisp.dhis.datadictionary.DataDictionaryService;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.importexport.ExportParams;
@@ -76,6 +77,7 @@
import org.hisp.dhis.importexport.dxf.converter.DataElementGroupMemberConverter;
import org.hisp.dhis.importexport.dxf.converter.DataElementGroupSetConverter;
import org.hisp.dhis.importexport.dxf.converter.DataElementGroupSetMemberConverter;
+import org.hisp.dhis.importexport.dxf.converter.DataEntryFormConverter;
import org.hisp.dhis.importexport.dxf.converter.DataSetConverter;
import org.hisp.dhis.importexport.dxf.converter.DataSetMemberConverter;
import org.hisp.dhis.importexport.dxf.converter.DataSetSourceAssociationConverter;
@@ -110,16 +112,16 @@
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.validation.ValidationRuleService;
-
/**
* @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
{
private static final String ZIP_ENTRY_NAME = "Export.xml";
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -140,7 +142,7 @@
private ConceptService conceptService;
- public void setConceptService(ConceptService conceptService)
+ public void setConceptService( ConceptService conceptService )
{
this.conceptService = conceptService;
}
@@ -151,7 +153,7 @@
{
this.categoryService = categoryService;
}
-
+
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
@@ -165,51 +167,58 @@
{
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;
}
-
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
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 ValidationRuleService validationRuleService;
public void setValidationRuleService( ValidationRuleService validationRuleService )
{
this.validationRuleService = validationRuleService;
}
-
+
private ReportService reportService;
-
+
public void setReportService( ReportService reportService )
{
this.reportService = reportService;
@@ -221,9 +230,9 @@
{
this.reportTableService = reportTableService;
}
-
+
private ChartService chartService;
-
+
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
@@ -238,7 +247,8 @@
private CompleteDataSetRegistrationService completeDataSetRegistrationService;
- public void setCompleteDataSetRegistrationService( CompleteDataSetRegistrationService completeDataSetRegistrationService )
+ public void setCompleteDataSetRegistrationService(
+ CompleteDataSetRegistrationService completeDataSetRegistrationService )
{
this.completeDataSetRegistrationService = completeDataSetRegistrationService;
}
@@ -249,7 +259,7 @@
{
this.aggregatedDataValueService = aggregatedDataValueService;
}
-
+
// -------------------------------------------------------------------------
// ExportService implementation
// -------------------------------------------------------------------------
@@ -259,97 +269,103 @@
try
{
// -----------------------------------------------------------------
- // Pipes are input/output pairs. Data written on the output stream
- // shows up on the input stream at the other end of the pipe.
+ // Pipes are input/output pairs. Data written on the output stream
+ // shows up on the input stream at the other end of the pipe.
// -----------------------------------------------------------------
-
+
PipedOutputStream out = new PipedOutputStream();
-
+
PipedInputStream in = new PipedInputStream( out );
-
+
ZipOutputStream zipOut = new ZipOutputStream( out );
-
+
zipOut.putNextEntry( new ZipEntry( ZIP_ENTRY_NAME ) );
XMLWriter writer = XMLFactory.getPlainXMLWriter( zipOut );
-
- // -----------------------------------------------------------------
- // Writes to one end of the pipe
- // -----------------------------------------------------------------
-
- String[] rootProperties = { ATTRIBUTE_NAMESPACE, NAMESPACE_10, ATTRIBUTE_MINOR_VERSION, MINOR_VERSION_12, ATTRIBUTE_EXPORTED, DateUtils.getMediumDateString() };
-
+
+ // -----------------------------------------------------------------
+ // Writes to one end of the pipe
+ // -----------------------------------------------------------------
+
+ String[] rootProperties = { ATTRIBUTE_NAMESPACE, NAMESPACE_10, ATTRIBUTE_MINOR_VERSION, MINOR_VERSION_12,
+ ATTRIBUTE_EXPORTED, DateUtils.getMediumDateString() };
+
ExportPipeThread thread = new ExportPipeThread( sessionFactory );
-
+
thread.setZipOutputStream( zipOut );
thread.setParams( params );
thread.setWriter( writer );
thread.setRootName( DXFROOT );
thread.setRootProperties( rootProperties );
-
+
thread.registerXMLConverter( new ConceptConverter( conceptService ) );
thread.registerXMLConverter( new DataElementCategoryOptionConverter( categoryService ) );
thread.registerXMLConverter( new DataElementCategoryConverter( categoryService ) );
thread.registerXMLConverter( new DataElementCategoryComboConverter( categoryService ) );
thread.registerXMLConverter( new DataElementCategoryOptionComboConverter( categoryService ) );
-
+
thread.registerXMLConverter( new CategoryCategoryOptionAssociationConverter( categoryService ) );
thread.registerXMLConverter( new CategoryComboCategoryAssociationConverter( categoryService ) );
-
- thread.registerXMLConverter( params.isExtendedMode() ? new ExtendedDataElementConverter( dataElementService ) : new DataElementConverter( dataElementService ) );
+
+ thread
+ .registerXMLConverter( params.isExtendedMode() ? new ExtendedDataElementConverter( dataElementService )
+ : new DataElementConverter( dataElementService ) );
thread.registerXMLConverter( new CalculatedDataElementConverter( dataElementService ) );
thread.registerXMLConverter( new DataElementGroupConverter( dataElementService ) );
thread.registerXMLConverter( new DataElementGroupMemberConverter( dataElementService ) );
thread.registerXMLConverter( new DataElementGroupSetConverter( dataElementService ) );
thread.registerXMLConverter( new DataElementGroupSetMemberConverter( dataElementService ) );
-
+
thread.registerXMLConverter( new IndicatorTypeConverter( indicatorService ) );
- thread.registerXMLConverter( params.isExtendedMode() ? new ExtendedIndicatorConverter( indicatorService ) : new IndicatorConverter( indicatorService ) );
+ thread.registerXMLConverter( params.isExtendedMode() ? new ExtendedIndicatorConverter( indicatorService )
+ : new IndicatorConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorGroupConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorGroupMemberConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorGroupSetConverter( indicatorService ) );
thread.registerXMLConverter( new IndicatorGroupSetMemberConverter( indicatorService ) );
-
+
thread.registerXMLConverter( new DataDictionaryConverter( dataDictionaryService ) );
thread.registerXMLConverter( new DataDictionaryDataElementConverter( dataDictionaryService ) );
thread.registerXMLConverter( new DataDictionaryIndicatorConverter( dataDictionaryService ) );
-
+
+ thread.registerXMLConverter( new DataEntryFormConverter( dataEntryFormService, dataElementService, categoryService ) );
thread.registerXMLConverter( new DataSetConverter( dataSetService ) );
thread.registerXMLConverter( new DataSetMemberConverter( dataSetService, dataElementService ) );
-
+
thread.registerXMLConverter( new OrganisationUnitConverter( organisationUnitService ) );
thread.registerXMLConverter( new OrganisationUnitRelationshipConverter( organisationUnitService ) );
thread.registerXMLConverter( new OrganisationUnitGroupConverter( organisationUnitGroupService ) );
- thread.registerXMLConverter( new OrganisationUnitGroupMemberConverter( organisationUnitGroupService, organisationUnitService ) );
-
+ thread.registerXMLConverter( new OrganisationUnitGroupMemberConverter( organisationUnitGroupService,
+ organisationUnitService ) );
+
thread.registerXMLConverter( new GroupSetConverter( organisationUnitGroupService ) );
thread.registerXMLConverter( new GroupSetMemberConverter( organisationUnitGroupService ) );
thread.registerXMLConverter( new OrganisationUnitLevelConverter( organisationUnitService ) );
-
+
thread.registerXMLConverter( new DataSetSourceAssociationConverter( dataSetService, organisationUnitService ) );
-
- thread.registerXMLConverter( new ValidationRuleConverter( validationRuleService ) );
+
+ thread.registerXMLConverter( new ValidationRuleConverter( validationRuleService ) );
thread.registerXMLConverter( new PeriodConverter( periodService ) );
-
+
thread.registerXMLConverter( new ReportConverter( reportService ) );
thread.registerXMLConverter( new ReportTableConverter( reportTableService ) );
thread.registerXMLConverter( new ChartConverter( chartService ) );
- thread.registerXMLConverter( new OlapUrlConverter( olapURLService ) );
- thread.registerXMLConverter( new CompleteDataSetRegistrationConverter(
- completeDataSetRegistrationService, dataSetService, organisationUnitService, periodService ) );
-
- thread.registerXMLConverter( params.isAggregatedData() ?
- new AggregatedDataValueConverter( aggregatedDataValueService, dataSetService, periodService ) :
- new DataValueConverter( aggregatedDataValueService, statementManager, periodService ) );
-
+ thread.registerXMLConverter( new OlapUrlConverter( olapURLService ) );
+ thread.registerXMLConverter( new CompleteDataSetRegistrationConverter( completeDataSetRegistrationService,
+ dataSetService, organisationUnitService, periodService ) );
+
+ thread.registerXMLConverter( params.isAggregatedData() ? new AggregatedDataValueConverter(
+ aggregatedDataValueService, dataSetService, periodService ) : new DataValueConverter(
+ aggregatedDataValueService, statementManager, periodService ) );
+
thread.start();
-
- // -----------------------------------------------------------------
- // Reads at the other end of the pipe
- // -----------------------------------------------------------------
-
+
+ // -----------------------------------------------------------------
+ // Reads at the other end of the pipe
+ // -----------------------------------------------------------------
+
InputStream bis = new BufferedInputStream( in );
-
+
return bis;
}
catch ( IOException ex )
=== 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 2010-10-29 08:56:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/DefaultObjectMappingGenerator.java 2010-12-23 11:56:44 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
@@ -55,6 +56,7 @@
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryOptionBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupSetBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.DataEntryFormBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.GroupSetBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.IndicatorBatchHandler;
@@ -258,6 +260,18 @@
return getMapping( batchHandler, NameMappingUtil.getDataSetMap(), skipMapping );
}
+
+ // -------------------------------------------------------------------------
+ // Data entry form
+ // -------------------------------------------------------------------------
+
+ public Map<Object, Integer> getDataEntryFormMapping( boolean skipMapping )
+ {
+ BatchHandler<DataEntryForm> batchHandler = batchHandlerFactory.createBatchHandler( DataEntryFormBatchHandler.class );
+
+ return getMapping( batchHandler, NameMappingUtil.getDataEntryFormMap(), skipMapping );
+ }
+
// -------------------------------------------------------------------------
// OrganisationUnit
=== 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-09-17 21:30:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/NameMappingUtil.java 2010-12-23 11:56:44 +0000
@@ -60,7 +60,8 @@
private static ThreadLocal<Map<Object, String>> organisationUnitGroupSetMap = new ThreadLocal<Map<Object, String>>();
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>>();
+
// -------------------------------------------------------------------------
// Control
// -------------------------------------------------------------------------
@@ -87,6 +88,7 @@
organisationUnitGroupSetMap.remove();
reportTableMap.remove();
dataElementAggregationOperatorMap.remove();
+ dataEntryFormMap.remove();
}
// -------------------------------------------------------------------------
@@ -505,11 +507,32 @@
{
return dataElementAggregationOperatorMap.get() != null ? new LoggingHashMap<Object, String>( dataElementAggregationOperatorMap.get() ) : new HashMap<Object, String>();
}
+
+ // -------------------------------------------------------------------------
+ // Category
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adds a map entry with DataElementCategory identifier as key and name as value.
+ */
+ public static void addDataEntryFormMapping( Object dataEntryFormId, String dataEntryFormName )
+ {
+ put( dataEntryFormMap, dataEntryFormId, dataEntryFormName );
+ }
+
+ /**
+ * Returns a Map with all DataElementCategory identifier and name entries.
+ */
+
+ public static Map<Object, String> getDataEntryFormMap()
+ {
+ return dataEntryFormMap.get() != null ? new HashMap<Object, String>( dataEntryFormMap.get() ) : new HashMap<Object, String>();
+ }
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
+
private static void put( ThreadLocal<Map<Object, String>> threadLocal, Object key, String value )
{
Map<Object, String> map = threadLocal.get();
=== 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 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/mapping/ObjectMappingGenerator.java 2010-12-23 11:56:44 +0000
@@ -83,4 +83,6 @@
Map<Period, Integer> getPeriodObjectMapping( boolean skipMapping );
Map<String, Integer> getPeriodTypeMapping();
+
+ Map<Object, Integer> getDataEntryFormMapping( 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 2010-10-29 08:56:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java 2010-12-23 11:56:44 +0000
@@ -51,6 +51,8 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -78,6 +80,7 @@
import org.hisp.dhis.importexport.importer.DataElementGroupImporter;
import org.hisp.dhis.importexport.importer.DataElementGroupSetImporter;
import org.hisp.dhis.importexport.importer.DataElementImporter;
+import org.hisp.dhis.importexport.importer.DataEntryFormImporter;
import org.hisp.dhis.importexport.importer.DataSetImporter;
import org.hisp.dhis.importexport.importer.DataValueImporter;
import org.hisp.dhis.importexport.importer.GroupSetImporter;
@@ -162,13 +165,13 @@
private static final Log log = LogFactory.getLog( DefaultImportObjectManager.class );
private final ImportParams params = new ImportParams( ImportType.IMPORT, ImportStrategy.NEW_AND_UPDATES, true );
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
private BatchHandlerFactory batchHandlerFactory;
-
+
public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
{
this.batchHandlerFactory = batchHandlerFactory;
@@ -180,14 +183,14 @@
{
this.objectMappingGenerator = objectMappingGenerator;
}
-
+
private ImportObjectStore importObjectStore;
public void setImportObjectStore( ImportObjectStore importObjectStore )
{
this.importObjectStore = importObjectStore;
}
-
+
private DataElementCategoryService categoryService;
public void setCategoryService( DataElementCategoryService categoryService )
@@ -201,9 +204,9 @@
{
this.dataElementService = dataElementService;
}
-
+
private DataDictionaryService dataDictionaryService;
-
+
public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
{
this.dataDictionaryService = dataDictionaryService;
@@ -215,7 +218,7 @@
{
this.indicatorService = indicatorService;
}
-
+
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
@@ -229,7 +232,7 @@
{
this.organisationUnitService = organisationUnitService;
}
-
+
private OrganisationUnitGroupService organisationUnitGroupService;
public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
@@ -250,7 +253,7 @@
{
this.olapURLService = olapURLService;
}
-
+
private ExpressionService expressionService;
public void setExpressionService( ExpressionService expressionService )
@@ -264,7 +267,7 @@
{
this.importDataValueService = importDataValueService;
}
-
+
private ReportService reportService;
public void setReportService( ReportService reportService )
@@ -278,9 +281,9 @@
{
this.reportTableService = reportTableService;
}
-
+
private ChartService chartService;
-
+
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
@@ -292,14 +295,21 @@
{
this.periodService = periodService;
}
-
+
private AggregatedDataValueService aggregatedDataValueService;
-
+
public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
{
this.aggregatedDataValueService = aggregatedDataValueService;
}
-
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
// -------------------------------------------------------------------------
// ImportObjectManager implementation
// -------------------------------------------------------------------------
@@ -307,104 +317,111 @@
@Transactional
public void importCategoryOptions()
{
- BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryOptionBatchHandler.class ).init();
-
+ BatchHandler<DataElementCategoryOption> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryOptionBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementCategoryOption.class );
-
- Importer<DataElementCategoryOption> importer = new DataElementCategoryOptionImporter( batchHandler, categoryService );
-
+
+ Importer<DataElementCategoryOption> importer = new DataElementCategoryOptionImporter( batchHandler,
+ categoryService );
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataElementCategoryOption) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataElementCategoryOption.class );
-
+
log.info( "Imported DataElementCategoryOptions" );
}
@Transactional
public void importCategories()
{
- BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryBatchHandler.class ).init();
-
+ BatchHandler<DataElementCategory> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementCategory.class );
Importer<DataElementCategory> importer = new DataElementCategoryImporter( batchHandler, categoryService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataElementCategory) importObject.getObject(), params );
}
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataElementCategory.class );
-
+
log.info( "Imported DataElementCategories" );
}
@Transactional
public void importCategoryCombos()
{
- BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryComboBatchHandler.class ).init();
-
+ BatchHandler<DataElementCategoryCombo> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementCategoryComboBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementCategoryCombo.class );
- Importer<DataElementCategoryCombo> importer = new DataElementCategoryComboImporter( batchHandler, categoryService );
-
+ Importer<DataElementCategoryCombo> importer = new DataElementCategoryComboImporter( batchHandler,
+ categoryService );
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataElementCategoryCombo) importObject.getObject(), params );
}
-
+
batchHandler.flush();
importObjectStore.deleteImportObjects( DataElementCategoryCombo.class );
-
+
log.info( "Imported DataElementCategoryCombos" );
}
@Transactional
- public void importCategoryOptionCombos() //TODO reuse importer
+ public void importCategoryOptionCombos() // TODO reuse importer
{
- Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementCategoryOptionCombo.class );
+ Collection<ImportObject> importObjects = importObjectStore
+ .getImportObjects( DataElementCategoryOptionCombo.class );
Map<Object, Integer> categoryComboMapping = objectMappingGenerator.getCategoryComboMapping( false );
Map<Object, Integer> categoryOptionMapping = objectMappingGenerator.getCategoryOptionMapping( false );
-
+
for ( ImportObject importObject : importObjects )
{
DataElementCategoryOptionCombo object = (DataElementCategoryOptionCombo) importObject.getObject();
-
+
int categoryOptionComboId = object.getId();
-
+
if ( importObject.getStatus() == ImportObjectStatus.UPDATE )
{
- DataElementCategoryOptionCombo compareObject = (DataElementCategoryOptionCombo) importObject.getCompareObject();
-
+ DataElementCategoryOptionCombo compareObject = (DataElementCategoryOptionCombo) importObject
+ .getCompareObject();
+
object.setId( compareObject.getId() );
}
-
+
int categoryComboId = categoryComboMapping.get( object.getCategoryCombo().getId() );
-
+
object.setCategoryCombo( categoryService.getDataElementCategoryCombo( categoryComboId ) );
-
+
List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
-
+
for ( DataElementCategoryOption categoryOption : object.getCategoryOptions() )
{
int categoryOptionId = categoryOptionMapping.get( categoryOption.getId() );
-
+
categoryOptions.add( categoryService.getDataElementCategoryOption( categoryOptionId ) );
}
-
+
object.setCategoryOptions( categoryOptions );
NameMappingUtil.addCategoryOptionComboMapping( categoryOptionComboId, object );
-
+
if ( importObject.getStatus() == ImportObjectStatus.NEW )
{
categoryService.addDataElementCategoryOptionCombo( object );
@@ -416,56 +433,57 @@
}
importObjectStore.deleteImportObjects( DataElementCategoryOptionCombo.class );
-
+
log.info( "Imported DataElementCategoryOptionCombos" );
}
@Transactional
public void importCategoryCategoryOptionAssociations()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( CategoryCategoryOptionAssociationBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.CATEGORY_CATEGORYOPTION,
- objectMappingGenerator.getCategoryMapping( false ),
- objectMappingGenerator.getCategoryOptionMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( CategoryCategoryOptionAssociationBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.CATEGORY_CATEGORYOPTION, objectMappingGenerator
+ .getCategoryMapping( false ), objectMappingGenerator.getCategoryOptionMapping( false ) );
+
log.info( "Imported CategoryCategoryOption associations" );
}
@Transactional
public void importCategoryComboCategoryAssociations()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( CategoryComboCategoryAssociationBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.CATEGORYCOMBO_CATEGORY,
- objectMappingGenerator.getCategoryComboMapping( false ),
- objectMappingGenerator.getCategoryMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( CategoryComboCategoryAssociationBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.CATEGORYCOMBO_CATEGORY, objectMappingGenerator
+ .getCategoryComboMapping( false ), objectMappingGenerator.getCategoryMapping( false ) );
+
log.info( "Imported CategoryComboCategory associations" );
}
@Transactional
public void importDataElements()
{
- BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class ).init();
-
+ BatchHandler<DataElement> batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class )
+ .init();
+
Map<Object, Integer> categoryComboMapping = objectMappingGenerator.getCategoryComboMapping( false );
-
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElement.class );
-
+
Importer<DataElement> importer = new DataElementImporter( batchHandler, dataElementService );
-
+
for ( ImportObject importObject : importObjects )
{
DataElement object = (DataElement) importObject.getObject();
object.getCategoryCombo().setId( categoryComboMapping.get( object.getCategoryCombo().getId() ) );
importer.importObject( object, params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataElement.class );
-
+
log.info( "Imported DataElements" );
}
@@ -479,221 +497,231 @@
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( CalculatedDataElement.class );
Importer<CalculatedDataElement> importer = new CalculatedDataElementImporter( dataElementService );
-
+
for ( ImportObject importObject : importObjects )
{
CalculatedDataElement object = (CalculatedDataElement) importObject.getObject();
object.getCategoryCombo().setId( categoryComboMapping.get( object.getCategoryCombo().getId() ) );
- object.getExpression().setExpression( expressionService.convertExpression(
- object.getExpression().getExpression(), dataElementMapping, categoryOptionComboMapping ) );
- importer.importObject( object, params );
+ object.getExpression().setExpression(
+ expressionService.convertExpression( object.getExpression().getExpression(), dataElementMapping,
+ categoryOptionComboMapping ) );
+ importer.importObject( object, params );
}
-
+
importObjectStore.deleteImportObjects( CalculatedDataElement.class );
-
+
log.info( "Imported CalculatedDataElements" );
}
@Transactional
public void importDataElementGroups()
{
- BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupBatchHandler.class ).init();
-
+ BatchHandler<DataElementGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementGroup.class );
Importer<DataElementGroup> importer = new DataElementGroupImporter( batchHandler, dataElementService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataElementGroup) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataElementGroup.class );
-
+
log.info( "Imported DataElementGroups" );
}
-
+
@Transactional
public void importDataElementGroupMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATAELEMENTGROUP,
- objectMappingGenerator.getDataElementGroupMapping( false ),
- objectMappingGenerator.getDataElementMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementGroupMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATAELEMENTGROUP, objectMappingGenerator
+ .getDataElementGroupMapping( false ), objectMappingGenerator.getDataElementMapping( false ) );
+
log.info( "Imported DataElementGroup members" );
}
-
+
@Transactional
public void importDataElementGroupSets()
{
- BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupSetBatchHandler.class ).init();
-
+ BatchHandler<DataElementGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataElementGroupSetBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataElementGroupSet.class );
-
+
Importer<DataElementGroupSet> importer = new DataElementGroupSetImporter( batchHandler, dataElementService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataElementGroupSet) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataElementGroupSet.class );
-
+
log.info( "Imported DataElementGroupSets" );
}
@Transactional
public void importDataElementGroupSetMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupSetMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATAELEMENTGROUPSET,
- objectMappingGenerator.getDataElementGroupSetMapping( false ),
- objectMappingGenerator.getDataElementGroupMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataElementGroupSetMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATAELEMENTGROUPSET, objectMappingGenerator
+ .getDataElementGroupSetMapping( false ), objectMappingGenerator.getDataElementGroupMapping( false ) );
+
log.info( "Imported DataElementGroupSet members" );
}
@Transactional
public void importIndicatorTypes()
{
- BatchHandler<IndicatorType> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorTypeBatchHandler.class ).init();
-
+ BatchHandler<IndicatorType> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorTypeBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( IndicatorType.class );
Importer<IndicatorType> importer = new IndicatorTypeImporter( batchHandler, indicatorService );
-
+
for ( ImportObject importObject : importObjects )
- {
+ {
importer.importObject( (IndicatorType) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( IndicatorType.class );
-
+
log.info( "Imported IndicatorTypes" );
- }
+ }
@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 );
Map<Object, Integer> categoryOptionComboMapping = objectMappingGenerator.getCategoryOptionComboMapping( false );
-
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Indicator.class );
Importer<Indicator> importer = new IndicatorImporter( batchHandler, indicatorService );
-
+
for ( ImportObject importObject : importObjects )
{
Indicator object = (Indicator) importObject.getObject();
object.getIndicatorType().setId( indicatorTypeMapping.get( object.getIndicatorType().getId() ) );
- object.setNumerator( expressionService.convertExpression( object.getNumerator(), dataElementMapping, categoryOptionComboMapping ) );
- object.setDenominator( expressionService.convertExpression( object.getDenominator(), dataElementMapping, categoryOptionComboMapping ) );
+ object.setNumerator( expressionService.convertExpression( object.getNumerator(), dataElementMapping,
+ categoryOptionComboMapping ) );
+ object.setDenominator( expressionService.convertExpression( object.getDenominator(), dataElementMapping,
+ categoryOptionComboMapping ) );
importer.importObject( object, params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( Indicator.class );
-
+
log.info( "Imported Indicators" );
- }
+ }
@Transactional
public void importIndicatorGroups()
{
- BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupBatchHandler.class ).init();
-
+ BatchHandler<IndicatorGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( IndicatorGroup.class );
Importer<IndicatorGroup> importer = new IndicatorGroupImporter( batchHandler, indicatorService );
-
+
for ( ImportObject importObject : importObjects )
- {
+ {
importer.importObject( (IndicatorGroup) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( IndicatorGroup.class );
-
+
log.info( "Imported IndicatorGroups" );
}
-
+
@Transactional
public void importIndicatorGroupMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.INDICATORGROUP,
- objectMappingGenerator.getIndicatorGroupMapping( false ),
- objectMappingGenerator.getIndicatorMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( IndicatorGroupMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.INDICATORGROUP, objectMappingGenerator
+ .getIndicatorGroupMapping( false ), objectMappingGenerator.getIndicatorMapping( false ) );
+
log.info( "Imported IndicatorGroup members" );
}
-
+
@Transactional
public void importIndicatorGroupSets()
{
- BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupSetBatchHandler.class ).init();
-
+ BatchHandler<IndicatorGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ IndicatorGroupSetBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( IndicatorGroupSet.class );
-
+
Importer<IndicatorGroupSet> importer = new IndicatorGroupSetImporter( batchHandler, indicatorService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (IndicatorGroupSet) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( IndicatorGroupSet.class );
-
+
log.info( "Imported IndicatorGroupSets" );
}
@Transactional
public void importIndicatorGroupSetMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupSetMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.INDICATORGROUPSET,
- objectMappingGenerator.getIndicatorGroupSetMapping( false ),
- objectMappingGenerator.getIndicatorGroupMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( IndicatorGroupSetMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.INDICATORGROUPSET, objectMappingGenerator
+ .getIndicatorGroupSetMapping( false ), objectMappingGenerator.getIndicatorGroupMapping( false ) );
+
log.info( "Imported IndicatorGroupSet members" );
}
@Transactional
public void importDataDictionaries()
{
- BatchHandler<DataDictionary> batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryBatchHandler.class ).init();
-
+ BatchHandler<DataDictionary> batchHandler = batchHandlerFactory.createBatchHandler(
+ DataDictionaryBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataDictionary.class );
-
+
Importer<DataDictionary> importer = new DataDictionaryImporter( batchHandler, dataDictionaryService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (DataDictionary) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataDictionary.class );
-
+
log.info( "Imported DataDictionaries" );
}
@@ -701,79 +729,82 @@
public void importDataSets()
{
BatchHandler<DataSet> batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class ).init();
-
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataSet.class );
-
+
Importer<DataSet> importer = new DataSetImporter( batchHandler, dataSetService );
-
+
for ( ImportObject importObject : importObjects )
{
- importer.importObject( (DataSet) importObject.getObject(), params );
+ importer.importObject( (DataSet) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( DataSet.class );
-
+
log.info( "Imported DataSets" );
}
@Transactional
public void importDataDictionaryDataElements()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryDataElementBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATADICTIONARY_DATAELEMENT,
- objectMappingGenerator.getDataDictionaryMapping( false ),
- objectMappingGenerator.getDataElementMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataDictionaryDataElementBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATADICTIONARY_DATAELEMENT, objectMappingGenerator
+ .getDataDictionaryMapping( false ), objectMappingGenerator.getDataElementMapping( false ) );
+
log.info( "Imported DataDictionary DataElements" );
}
@Transactional
public void importDataDictionaryIndicators()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryIndicatorBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATADICTIONARY_INDICATOR,
- objectMappingGenerator.getDataDictionaryMapping( false ),
- objectMappingGenerator.getIndicatorMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataDictionaryIndicatorBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATADICTIONARY_INDICATOR, objectMappingGenerator
+ .getDataDictionaryMapping( false ), objectMappingGenerator.getIndicatorMapping( false ) );
+
log.info( "Imported DataDictionary Indicators" );
}
@Transactional
public void importDataSetMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataSetMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATASET,
- objectMappingGenerator.getDataSetMapping( false ),
- objectMappingGenerator.getDataElementMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataSetMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATASET, objectMappingGenerator
+ .getDataSetMapping( false ), objectMappingGenerator.getDataElementMapping( false ) );
+
log.info( "Imported DataSet members" );
}
@Transactional
public void importOrganisationUnits()
{
- BatchHandler<Source> sourceBatchHandler = batchHandlerFactory.createBatchHandler( SourceBatchHandler.class ).init();
- BatchHandler<OrganisationUnit> organisationUnitBatchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitBatchHandler.class ).init();
-
+ BatchHandler<Source> sourceBatchHandler = batchHandlerFactory.createBatchHandler( SourceBatchHandler.class )
+ .init();
+ BatchHandler<OrganisationUnit> organisationUnitBatchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OrganisationUnit.class );
-
- Importer<OrganisationUnit> importer = new OrganisationUnitImporter( organisationUnitBatchHandler, sourceBatchHandler, organisationUnitService );
-
+
+ Importer<OrganisationUnit> importer = new OrganisationUnitImporter( organisationUnitBatchHandler,
+ sourceBatchHandler, organisationUnitService );
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (OrganisationUnit) importObject.getObject(), params );
}
-
+
sourceBatchHandler.flush();
organisationUnitBatchHandler.flush();
-
+
importObjectStore.deleteImportObjects( OrganisationUnit.class );
-
+
log.info( "Imported OrganisationUnits" );
}
@@ -781,92 +812,100 @@
public void importOrganisationUnitRelationships()
{
Map<Object, Integer> organisationUnitMapping = objectMappingGenerator.getOrganisationUnitMapping( false );
-
- BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitBatchHandler.class ).init();
-
- Collection<ImportObject> importObjects = importObjectStore.getImportObjects( GroupMemberType.ORGANISATIONUNITRELATIONSHIP );
-
+
+ BatchHandler<OrganisationUnit> batchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitBatchHandler.class ).init();
+
+ Collection<ImportObject> importObjects = importObjectStore
+ .getImportObjects( GroupMemberType.ORGANISATIONUNITRELATIONSHIP );
+
for ( ImportObject importObject : importObjects )
{
GroupMemberAssociation object = (GroupMemberAssociation) importObject.getObject();
-
- OrganisationUnit child = organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( object.getMemberId() ) );
- OrganisationUnit parent = organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( object.getGroupId() ) );
+
+ OrganisationUnit child = organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( object
+ .getMemberId() ) );
+ OrganisationUnit parent = organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( object
+ .getGroupId() ) );
child.setParent( parent );
-
+
batchHandler.updateObject( child );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITRELATIONSHIP );
-
+
log.info( "Imported OrganisationUnit relationships" );
}
@Transactional
public void importOrganisationUnitGroups()
{
- BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupBatchHandler.class ).init();
-
+ BatchHandler<OrganisationUnitGroup> batchHandler = batchHandlerFactory.createBatchHandler(
+ OrganisationUnitGroupBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OrganisationUnitGroup.class );
-
- Importer<OrganisationUnitGroup> importer = new OrganisationUnitGroupImporter( batchHandler, organisationUnitGroupService );
-
+
+ Importer<OrganisationUnitGroup> importer = new OrganisationUnitGroupImporter( batchHandler,
+ organisationUnitGroupService );
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (OrganisationUnitGroup) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( OrganisationUnitGroup.class );
-
+
log.info( "Imported OrganisationUnitGroups" );
}
@Transactional
public void importOrganisationUnitGroupMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.ORGANISATIONUNITGROUP,
- objectMappingGenerator.getOrganisationUnitGroupMapping( false ),
- objectMappingGenerator.getOrganisationUnitMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( OrganisationUnitGroupMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.ORGANISATIONUNITGROUP, objectMappingGenerator
+ .getOrganisationUnitGroupMapping( false ), objectMappingGenerator.getOrganisationUnitMapping( false ) );
+
log.info( "Imported OrganissationUnitGroup members" );
}
@Transactional
public void importOrganisationUnitGroupSets()
{
- BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory.createBatchHandler( GroupSetBatchHandler.class ).init();
-
+ BatchHandler<OrganisationUnitGroupSet> batchHandler = batchHandlerFactory.createBatchHandler(
+ GroupSetBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OrganisationUnitGroupSet.class );
-
+
Importer<OrganisationUnitGroupSet> importer = new GroupSetImporter( batchHandler, organisationUnitGroupService );
-
+
for ( ImportObject importObject : importObjects )
{
- importer.importObject( (OrganisationUnitGroupSet) importObject.getObject(), params );
+ importer.importObject( (OrganisationUnitGroupSet) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( OrganisationUnitGroupSet.class );
-
+
log.info( "Imported OrganisationUnitGroupSets" );
}
@Transactional
public void importOrganisationUnitGroupSetMembers()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( GroupSetMemberBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.ORGANISATIONUNITGROUPSET,
- objectMappingGenerator.getOrganisationUnitGroupSetMapping( false ),
- objectMappingGenerator.getOrganisationUnitGroupMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( GroupSetMemberBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.ORGANISATIONUNITGROUPSET, objectMappingGenerator
+ .getOrganisationUnitGroupSetMapping( false ), objectMappingGenerator
+ .getOrganisationUnitGroupMapping( false ) );
+
log.info( "Imported OrganisationUnitGroupSet members" );
}
@@ -874,28 +913,28 @@
public void importOrganisationUnitLevels()
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OrganisationUnitLevel.class );
-
+
Importer<OrganisationUnitLevel> importer = new OrganisationUnitLevelImporter( organisationUnitService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (OrganisationUnitLevel) importObject.getObject(), params );
}
-
+
importObjectStore.deleteImportObjects( OrganisationUnitLevel.class );
-
- log.info( "Imported OrganisationUnitLevels" );
+
+ log.info( "Imported OrganisationUnitLevels" );
}
@Transactional
public void importDataSetSourceAssociations()
{
- BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory.createBatchHandler( DataSetSourceAssociationBatchHandler.class );
-
- importGroupMemberAssociation( batchHandler, GroupMemberType.DATASET_SOURCE,
- objectMappingGenerator.getDataSetMapping( false ),
- objectMappingGenerator.getOrganisationUnitMapping( false ) );
-
+ BatchHandler<GroupMemberAssociation> batchHandler = batchHandlerFactory
+ .createBatchHandler( DataSetSourceAssociationBatchHandler.class );
+
+ importGroupMemberAssociation( batchHandler, GroupMemberType.DATASET_SOURCE, objectMappingGenerator
+ .getDataSetMapping( false ), objectMappingGenerator.getOrganisationUnitMapping( false ) );
+
log.info( "Imported DataSet Source associations" );
}
@@ -903,16 +942,16 @@
public void importValidationRules()
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( ValidationRule.class );
-
+
Importer<ValidationRule> importer = new ValidationRuleImporter( validationRuleService, expressionService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (ValidationRule) importObject.getObject(), params );
}
-
+
importObjectStore.deleteImportObjects( ValidationRule.class );
-
+
log.info( "Imported ValidationRules" );
}
@@ -920,20 +959,20 @@
public void importPeriods()
{
BatchHandler<Period> batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class ).init();
-
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Period.class );
-
+
Importer<Period> importer = new PeriodImporter( batchHandler, periodService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (Period) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( Period.class );
-
+
log.info( "Imported Periods" );
}
@@ -941,37 +980,38 @@
public void importReports()
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Report.class );
-
+
Importer<Report> importer = new ReportImporter( reportService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (Report) importObject.getObject(), params );
}
-
+
importObjectStore.deleteImportObjects( Report.class );
-
+
log.info( "Imported Reports" );
}
-
+
@Transactional
public void importReportTables()
{
- BatchHandler<ReportTable> batchHandler = batchHandlerFactory.createBatchHandler( ReportTableBatchHandler.class ).init();
-
+ BatchHandler<ReportTable> batchHandler = batchHandlerFactory.createBatchHandler( ReportTableBatchHandler.class )
+ .init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( ReportTable.class );
-
+
Importer<ReportTable> importer = new ReportTableImporter( reportTableService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (ReportTable) importObject.getObject(), params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( ReportTable.class );
-
+
log.info( "Imported ReportTables" );
}
@@ -979,97 +1019,99 @@
public void importCharts()
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Chart.class );
-
+
Importer<Chart> importer = new ChartImporter( chartService );
-
+
for ( ImportObject importObject : importObjects )
{
importer.importObject( (Chart) importObject.getObject(), params );
}
-
+
importObjectStore.deleteImportObjects( Report.class );
-
+
log.info( "Imported Reports" );
}
-
+
@Transactional
public void importOlapURLs()
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( OlapURL.class );
-
+
Importer<OlapURL> importer = new OlapUrlImporter( olapURLService );
-
+
for ( ImportObject importObject : importObjects )
{
- importer.importObject( (OlapURL) importObject.getObject(), params );
+ importer.importObject( (OlapURL) importObject.getObject(), params );
}
-
+
importObjectStore.deleteImportObjects( OlapURL.class );
-
+
log.info( "Imported OlapURLs" );
}
@Transactional
public void importCompleteDataSetRegistrations()
{
- BatchHandler<CompleteDataSetRegistration> batchHandler = batchHandlerFactory.createBatchHandler( CompleteDataSetRegistrationBatchHandler.class ).init();
-
+ BatchHandler<CompleteDataSetRegistration> batchHandler = batchHandlerFactory.createBatchHandler(
+ CompleteDataSetRegistrationBatchHandler.class ).init();
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( CompleteDataSetRegistration.class );
Map<Object, Integer> dataSetMapping = objectMappingGenerator.getDataSetMapping( false );
Map<Object, Integer> periodMapping = objectMappingGenerator.getPeriodMapping( false );
Map<Object, Integer> sourceMapping = objectMappingGenerator.getOrganisationUnitMapping( false );
-
+
Importer<CompleteDataSetRegistration> importer = new CompleteDataSetRegistrationImporter( batchHandler, params );
-
+
for ( ImportObject importObject : importObjects )
{
CompleteDataSetRegistration registration = (CompleteDataSetRegistration) importObject.getObject();
-
+
registration.getDataSet().setId( dataSetMapping.get( registration.getDataSet().getId() ) );
registration.getPeriod().setId( periodMapping.get( registration.getPeriod().getId() ) );
registration.getSource().setId( sourceMapping.get( registration.getSource().getId() ) );
-
+
importer.importObject( registration, params );
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( CompleteDataSetRegistration.class );
-
+
log.info( "Imported CompleteDataSetRegistrations" );
}
@Transactional
public void importDataValues()
{
- BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler( DataValueBatchHandler.class ).init();
-
+ BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler( DataValueBatchHandler.class )
+ .init();
+
Map<Object, Integer> dataElementMapping = objectMappingGenerator.getDataElementMapping( false );
Map<Object, Integer> periodMapping = objectMappingGenerator.getPeriodMapping( false );
Map<Object, Integer> sourceMapping = objectMappingGenerator.getOrganisationUnitMapping( false );
Map<Object, Integer> categoryOptionComboMapping = objectMappingGenerator.getCategoryOptionComboMapping( false );
-
+
Collection<ImportDataValue> importValues = importDataValueService.getImportDataValues( ImportObjectStatus.NEW );
-
+
Importer<DataValue> importer = new DataValueImporter( batchHandler, aggregatedDataValueService, params );
-
+
for ( ImportDataValue importValue : importValues )
{
DataValue value = importValue.getDataValue();
-
+
value.getDataElement().setId( dataElementMapping.get( value.getDataElement().getId() ) );
value.getPeriod().setId( periodMapping.get( value.getPeriod().getId() ) );
value.getSource().setId( sourceMapping.get( value.getSource().getId() ) );
value.getOptionCombo().setId( categoryOptionComboMapping.get( value.getOptionCombo().getId() ) );
-
+
importer.importObject( value, params );
}
-
+
batchHandler.flush();
-
+
importDataValueService.deleteImportDataValues();
-
+
log.info( "Imported DataValues" );
}
@@ -1082,26 +1124,42 @@
Map<Object, Integer> groupMapping, Map<Object, Integer> memberMapping )
{
GroupMemberAssociationVerifier.clear();
-
+
batchHandler.init();
-
+
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( type );
-
+
for ( ImportObject importObject : importObjects )
{
GroupMemberAssociation object = (GroupMemberAssociation) importObject.getObject();
object.setGroupId( groupMapping.get( object.getGroupId() ) );
object.setMemberId( memberMapping.get( object.getMemberId() ) );
-
+
if ( GroupMemberAssociationVerifier.isUnique( object, type ) && !batchHandler.objectExists( object ) )
{
batchHandler.addObject( object );
- }
+ }
}
-
+
batchHandler.flush();
-
+
importObjectStore.deleteImportObjects( type );
}
+
+ public void importDataEntryForms()
+ {
+ Collection<ImportObject> importObjects = importObjectStore.getImportObjects( DataEntryForm.class );
+
+ Importer<DataEntryForm> importer = new DataEntryFormImporter( dataEntryFormService );
+
+ for ( ImportObject importObject : importObjects )
+ {
+ importer.importObject( (DataEntryForm) importObject.getObject(), params );
+ }
+
+ importObjectStore.deleteImportObjects( Report.class );
+
+ log.info( "Imported Reports" );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java 2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectService.java 2010-12-23 11:56:44 +0000
@@ -48,6 +48,8 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -85,7 +87,8 @@
/**
* @author Lars Helge Overland
- * @version $Id: DefaultImportObjectService.java 5946 2008-10-16 15:46:43Z larshelg $
+ * @version $Id: DefaultImportObjectService.java 5946 2008-10-16 15:46:43Z
+ * larshelg $
*/
public class DefaultImportObjectService<T>
implements ImportObjectService
@@ -95,12 +98,12 @@
// -------------------------------------------------------------------------
private ImportObjectStore importObjectStore;
-
+
public void setImportObjectStore( ImportObjectStore importObjectStore )
{
this.importObjectStore = importObjectStore;
}
-
+
private ImportDataValueService importDataValueService;
public void setImportDataValueService( ImportDataValueService importDataValueService )
@@ -121,7 +124,7 @@
{
this.dataElementService = dataElementService;
}
-
+
private IndicatorService indicatorService;
public void setIndicatorService( IndicatorService indicatorService )
@@ -135,14 +138,21 @@
{
this.dataDictionaryService = dataDictionaryService;
}
-
+
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
}
-
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -156,14 +166,14 @@
{
this.organisationUnitGroupService = organisationUnitGroupService;
}
-
+
private ValidationRuleService validationRuleService;
public void setValidationRuleService( ValidationRuleService validationRuleService )
{
this.validationRuleService = validationRuleService;
}
-
+
private ReportService reportService;
public void setReportService( ReportService reportService )
@@ -177,9 +187,9 @@
{
this.reportTableService = reportTableService;
}
-
+
private ChartService chartService;
-
+
public void setChartService( ChartService chartService )
{
this.chartService = chartService;
@@ -191,14 +201,14 @@
{
this.olapURLService = olapURLService;
}
-
+
private DataValueService dataValueService;
public void setDataValueService( DataValueService dataValueService )
{
this.dataValueService = dataValueService;
}
-
+
private HibernateCacheManager cacheManager;
public void setCacheManager( HibernateCacheManager cacheManager )
@@ -218,7 +228,7 @@
public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object )
{
ImportObject importObject = new ImportObject( status, object.getClass().getName(), groupMemberType, object );
-
+
return importObjectStore.addImportObject( importObject );
}
@@ -226,15 +236,17 @@
public int addImportObject( ImportObjectStatus status, ImportableObject object, ImportableObject compareObject )
{
ImportObject importObject = new ImportObject( status, object.getClass().getName(), object, compareObject );
-
+
return importObjectStore.addImportObject( importObject );
}
@Transactional
- public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object, ImportableObject compareObject )
+ public int addImportObject( ImportObjectStatus status, GroupMemberType groupMemberType, ImportableObject object,
+ ImportableObject compareObject )
{
- ImportObject importObject = new ImportObject( status, object.getClass().getName(), groupMemberType, object, compareObject );
-
+ ImportObject importObject = new ImportObject( status, object.getClass().getName(), groupMemberType, object,
+ compareObject );
+
return importObjectStore.addImportObject( importObject );
}
@@ -266,7 +278,7 @@
public void deleteImportObject( int importObjectId )
{
ImportObject importObject = importObjectStore.getImportObject( importObjectId );
-
+
if ( importObject != null )
{
importObjectStore.deleteImportObject( importObject );
@@ -282,115 +294,123 @@
@Transactional
public void deleteImportObjects()
{
- importObjectStore.deleteImportObjects();
+ importObjectStore.deleteImportObjects();
importDataValueService.deleteImportDataValues();
}
-
- //TODO Refactor: this code is not extensible and is error-prone in terms of cascading deletion of associated objects
+
+ // TODO Refactor: this code is not extensible and is error-prone in terms of
+ // cascading deletion of associated objects
@Transactional
public void cascadeDeleteImportObject( int importObjectId )
{
ImportObject importObject = importObjectStore.getImportObject( importObjectId );
-
+
if ( importObject != null )
{
- if ( importObject.getClassName().equals( DataElement.class.getName() ) ||
- importObject.getClassName().equals( CalculatedDataElement.class.getName() ) )
+ if ( importObject.getClassName().equals( DataElement.class.getName() )
+ || importObject.getClassName().equals( CalculatedDataElement.class.getName() ) )
{
- DataElement element = (DataElement) importObject.getObject();
-
- deleteMemberAssociations( GroupMemberType.DATAELEMENTGROUP, element.getId() );
- deleteMemberAssociations( GroupMemberType.DATASET, element.getId() );
+ DataElement element = (DataElement) importObject.getObject();
+
+ deleteMemberAssociations( GroupMemberType.DATAELEMENTGROUP, element.getId() );
+ deleteMemberAssociations( GroupMemberType.DATASET, element.getId() );
deleteMemberAssociations( GroupMemberType.DATADICTIONARY_DATAELEMENT, element.getId() );
-
+
deleteIndicatorsContainingDataElement( element.getId() );
-
+
importDataValueService.deleteImportDataValuesByDataElement( element.getId() );
}
else if ( importObject.getClassName().equals( DataElementGroup.class.getName() ) )
{
DataElementGroup group = (DataElementGroup) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.DATAELEMENTGROUP, group.getId() );
deleteMemberAssociations( GroupMemberType.DATAELEMENTGROUPSET, group.getId() );
}
else if ( importObject.getClassName().equals( DataElementGroupSet.class.getName() ) )
{
DataElementGroupSet groupSet = (DataElementGroupSet) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.DATAELEMENTGROUPSET, groupSet.getId() );
}
else if ( importObject.getClassName().equals( IndicatorType.class.getName() ) )
{
IndicatorType type = (IndicatorType) importObject.getObject();
-
+
deleteIndicatorsWithIndicatorType( type.getId() );
}
else if ( importObject.getClassName().equals( Indicator.class.getName() ) )
{
Indicator indicator = (Indicator) importObject.getObject();
-
- deleteMemberAssociations( GroupMemberType.INDICATORGROUP, indicator.getId() );
+
+ deleteMemberAssociations( GroupMemberType.INDICATORGROUP, indicator.getId() );
deleteMemberAssociations( GroupMemberType.DATADICTIONARY_INDICATOR, indicator.getId() );
}
else if ( importObject.getClassName().equals( IndicatorGroup.class.getName() ) )
{
IndicatorGroup group = (IndicatorGroup) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.INDICATORGROUP, group.getId() );
deleteMemberAssociations( GroupMemberType.INDICATORGROUPSET, group.getId() );
}
else if ( importObject.getClassName().equals( IndicatorGroupSet.class.getName() ) )
{
IndicatorGroupSet groupSet = (IndicatorGroupSet) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.INDICATORGROUPSET, groupSet.getId() );
}
else if ( importObject.getClassName().equals( DataDictionary.class.getName() ) )
{
DataDictionary dictionary = (DataDictionary) importObject.getObject();
-
- deleteGroupAssociations( GroupMemberType.DATADICTIONARY_DATAELEMENT, dictionary.getId() );
+
+ deleteGroupAssociations( GroupMemberType.DATADICTIONARY_DATAELEMENT, dictionary.getId() );
deleteGroupAssociations( GroupMemberType.DATADICTIONARY_INDICATOR, dictionary.getId() );
}
+ else if ( importObject.getClassName().equals( DataEntryForm.class.getName() ) )
+ {
+ DataEntryForm dataEntryForm = (DataEntryForm) importObject.getObject();
+
+ deleteGroupAssociations( GroupMemberType.DATAENTRYFORM, dataEntryForm.getId() );
+ }
else if ( importObject.getClassName().equals( DataSet.class.getName() ) )
{
DataSet dataSet = (DataSet) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.DATASET, dataSet.getId() );
deleteMemberAssociations( GroupMemberType.DATASET_SOURCE, dataSet.getId() );
+ deleteMemberAssociations( GroupMemberType.DATASET_DATAENTRYFORM, dataSet.getId() );
deleteCompleteDataSetRegistrationsByDataSet( dataSet.getId() );
}
else if ( importObject.getClassName().equals( OrganisationUnit.class.getName() ) )
{
OrganisationUnit unit = (OrganisationUnit) importObject.getObject();
-
- deleteMemberAssociations( GroupMemberType.ORGANISATIONUNITGROUP, unit.getId() );
+
+ deleteMemberAssociations( GroupMemberType.ORGANISATIONUNITGROUP, unit.getId() );
deleteGroupAssociations( GroupMemberType.ORGANISATIONUNITRELATIONSHIP, unit.getId() );
deleteMemberAssociations( GroupMemberType.DATASET_SOURCE, unit.getId() );
deleteMemberAssociations( GroupMemberType.ORGANISATIONUNITRELATIONSHIP, unit.getId() );
-
+
deleteCompleteDataSetRegistrationsBySource( unit.getId() );
-
+
importDataValueService.deleteImportDataValuesBySource( unit.getId() );
}
else if ( importObject.getClassName().equals( OrganisationUnitGroup.class.getName() ) )
{
OrganisationUnitGroup group = (OrganisationUnitGroup) importObject.getObject();
-
- deleteGroupAssociations( GroupMemberType.ORGANISATIONUNITGROUP, group.getId() );
+
+ deleteGroupAssociations( GroupMemberType.ORGANISATIONUNITGROUP, group.getId() );
deleteMemberAssociations( GroupMemberType.ORGANISATIONUNITGROUPSET, group.getId() );
}
else if ( importObject.getClassName().equals( OrganisationUnitGroupSet.class.getName() ) )
{
OrganisationUnitGroupSet groupSet = (OrganisationUnitGroupSet) importObject.getObject();
-
+
deleteGroupAssociations( GroupMemberType.ORGANISATIONUNITGROUPSET, groupSet.getId() );
}
}
-
+
deleteImportObject( importObjectId );
}
@@ -398,29 +418,30 @@
public void cascadeDeleteImportObjects( Class<?> clazz )
{
importObjectStore.deleteImportObjects( clazz );
-
+
if ( clazz.equals( DataElement.class ) || clazz.equals( CalculatedDataElement.class ) )
{
- importObjectStore.deleteImportObjects( DataElementCategoryOptionCombo.class );
- importObjectStore.deleteImportObjects( DataElementCategoryCombo.class );
- importObjectStore.deleteImportObjects( DataElementCategory.class );
+ importObjectStore.deleteImportObjects( DataElementCategoryOptionCombo.class );
+ importObjectStore.deleteImportObjects( DataElementCategoryCombo.class );
+ importObjectStore.deleteImportObjects( DataElementCategory.class );
importObjectStore.deleteImportObjects( DataElementCategoryOption.class );
importObjectStore.deleteImportObjects( GroupMemberType.CATEGORY_CATEGORYOPTION );
importObjectStore.deleteImportObjects( GroupMemberType.CATEGORYCOMBO_CATEGORY );
-
+
importObjectStore.deleteImportObjects( GroupMemberType.DATAELEMENTGROUP );
-
+
importObjectStore.deleteImportObjects( DataSet.class );
importObjectStore.deleteImportObjects( GroupMemberType.DATASET );
importObjectStore.deleteImportObjects( GroupMemberType.DATASET_SOURCE );
+ importObjectStore.deleteImportObjects( GroupMemberType.DATASET_DATAENTRYFORM);
importObjectStore.deleteImportObjects( CompleteDataSetRegistration.class );
-
+
importObjectStore.deleteImportObjects( Indicator.class );
importObjectStore.deleteImportObjects( GroupMemberType.INDICATORGROUP );
importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_INDICATOR );
-
+
importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_DATAELEMENT );
-
+
importDataValueService.deleteImportDataValues();
}
else if ( clazz.equals( DataElementGroup.class ) )
@@ -441,7 +462,7 @@
else if ( clazz.equals( Indicator.class ) )
{
importObjectStore.deleteImportObjects( GroupMemberType.INDICATORGROUP );
- importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_INDICATOR );
+ importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_INDICATOR );
}
else if ( clazz.equals( IndicatorGroup.class ) )
{
@@ -454,35 +475,36 @@
}
else if ( clazz.equals( DataDictionary.class ) )
{
- importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_DATAELEMENT );
- importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_INDICATOR );
+ importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_DATAELEMENT );
+ importObjectStore.deleteImportObjects( GroupMemberType.DATADICTIONARY_INDICATOR );
}
else if ( clazz.equals( DataSet.class ) )
{
importObjectStore.deleteImportObjects( GroupMemberType.DATASET );
importObjectStore.deleteImportObjects( GroupMemberType.DATASET_SOURCE );
- importObjectStore.deleteImportObjects( CompleteDataSetRegistration.class );
+ importObjectStore.deleteImportObjects( GroupMemberType.DATASET_DATAENTRYFORM );
+ importObjectStore.deleteImportObjects( CompleteDataSetRegistration.class );
}
else if ( clazz.equals( OrganisationUnit.class ) )
{
- importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITGROUP );
+ importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITGROUP );
importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITRELATIONSHIP );
importObjectStore.deleteImportObjects( GroupMemberType.DATASET_SOURCE );
-
+
importObjectStore.deleteImportObjects( CompleteDataSetRegistration.class );
-
+
importDataValueService.deleteImportDataValues();
}
else if ( clazz.equals( OrganisationUnitGroup.class ) )
{
- importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITGROUP );
+ importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITGROUP );
}
else if ( clazz.equals( OrganisationUnitGroupSet.class ) )
{
importObjectStore.deleteImportObjects( GroupMemberType.ORGANISATIONUNITGROUPSET );
}
}
-
+
// -------------------------------------------------------------------------
// Object
// -------------------------------------------------------------------------
@@ -491,142 +513,146 @@
public void matchObject( int importObjectId, int existingObjectId )
{
ImportObject importObject = importObjectStore.getImportObject( importObjectId );
-
+
Object object = importObject.getObject();
// ---------------------------------------------------------------------
// Updates the name of the import object to the name of the existing
// object.
// ---------------------------------------------------------------------
-
- if ( object.getClass().equals( DataElement.class ) ||
- object.getClass().equals( CalculatedDataElement.class ) )
+
+ if ( object.getClass().equals( DataElement.class ) || object.getClass().equals( CalculatedDataElement.class ) )
{
DataElement element = (DataElement) object;
-
+
element.setName( dataElementService.getDataElement( existingObjectId ).getName() );
}
else if ( object.getClass().equals( DataElementGroup.class ) )
{
DataElementGroup group = (DataElementGroup) object;
-
+
group.setName( dataElementService.getDataElementGroup( existingObjectId ).getName() );
}
else if ( object.getClass().equals( DataElementGroupSet.class ) )
{
DataElementGroupSet groupSet = (DataElementGroupSet) object;
-
+
groupSet.setName( dataElementService.getDataElementGroupSet( existingObjectId ).getName() );
}
else if ( object.getClass().equals( IndicatorType.class ) )
{
IndicatorType type = (IndicatorType) object;
-
+
type.setName( indicatorService.getIndicatorType( existingObjectId ).getName() );
}
else if ( object.getClass().equals( Indicator.class ) )
{
Indicator indicator = (Indicator) object;
-
+
indicator.setName( indicatorService.getIndicator( existingObjectId ).getName() );
}
else if ( object.getClass().equals( IndicatorGroup.class ) )
{
IndicatorGroup group = (IndicatorGroup) object;
-
+
group.setName( indicatorService.getIndicatorGroup( existingObjectId ).getName() );
}
else if ( object.getClass().equals( IndicatorGroupSet.class ) )
{
IndicatorGroupSet groupSet = (IndicatorGroupSet) object;
-
+
groupSet.setName( indicatorService.getIndicatorGroupSet( existingObjectId ).getName() );
}
else if ( object.getClass().equals( DataDictionary.class ) )
{
DataDictionary dictionary = (DataDictionary) object;
-
+
dictionary.setName( dataDictionaryService.getDataDictionary( existingObjectId ).getName() );
}
else if ( object.getClass().equals( DataSet.class ) )
{
DataSet dataSet = (DataSet) object;
-
+
dataSet.setName( dataSetService.getDataSet( existingObjectId ).getName() );
}
else if ( object.getClass().equals( OrganisationUnit.class ) )
{
OrganisationUnit unit = (OrganisationUnit) object;
-
+
unit.setName( organisationUnitService.getOrganisationUnit( existingObjectId ).getName() );
}
else if ( object.getClass().equals( OrganisationUnitGroup.class ) )
{
OrganisationUnitGroup group = (OrganisationUnitGroup) object;
-
+
group.setName( organisationUnitGroupService.getOrganisationUnitGroup( existingObjectId ).getName() );
}
else if ( object.getClass().equals( OrganisationUnitGroupSet.class ) )
{
OrganisationUnitGroupSet groupSet = (OrganisationUnitGroupSet) object;
-
+
groupSet.setName( organisationUnitGroupService.getOrganisationUnitGroupSet( existingObjectId ).getName() );
}
else if ( object.getClass().equals( OrganisationUnitLevel.class ) )
{
OrganisationUnitLevel level = (OrganisationUnitLevel) object;
-
+
level.setName( organisationUnitService.getOrganisationUnitLevel( existingObjectId ).getName() );
}
else if ( object.getClass().equals( ValidationRule.class ) )
{
ValidationRule validationRule = (ValidationRule) object;
-
+
validationRule.setName( validationRuleService.getValidationRule( existingObjectId ).getName() );
}
else if ( object.getClass().equals( Report.class ) )
{
Report report = (Report) object;
-
+
report.setName( reportService.getReport( existingObjectId ).getName() );
}
else if ( object.getClass().equals( ReportTable.class ) )
{
ReportTable reportTable = (ReportTable) object;
-
+
reportTable.setName( reportTableService.getReportTable( existingObjectId ).getName() );
}
else if ( object.getClass().equals( Chart.class ) )
{
Chart chart = (Chart) object;
-
+
chart.setName( chartService.getChart( existingObjectId ).getName() );
}
else if ( object.getClass().equals( OlapURL.class ) )
{
OlapURL url = (OlapURL) object;
-
+
url.setName( olapURLService.getOlapURL( existingObjectId ).getName() );
}
else if ( object.getClass().equals( DataValue.class ) )
{
DataValue dataValue = (DataValue) object;
-
- dataValue = updateDataValue( dataValue, dataValueService.getDataValue(
- dataValue.getSource(), dataValue.getDataElement(), dataValue.getPeriod(), dataValue.getOptionCombo() ) );
- }
-
+
+ dataValue = updateDataValue( dataValue, dataValueService.getDataValue( dataValue.getSource(), dataValue
+ .getDataElement(), dataValue.getPeriod(), dataValue.getOptionCombo() ) );
+ }
+ else if ( object.getClass().equals( DataEntryForm.class ) )
+ {
+ DataEntryForm dataEntryForm = (DataEntryForm) object;
+
+ dataEntryForm.setName( dataEntryFormService.getDataEntryForm( existingObjectId ).getName() );
+ }
// ---------------------------------------------------------------------
// Sets the status of the import object to match, these objects will
// later be ignored on import all but is needed for matching of
// associations.
// ---------------------------------------------------------------------
-
+
importObject.setStatus( ImportObjectStatus.MATCH );
-
+
importObjectStore.updateImportObject( importObject );
}
-
+
// -------------------------------------------------------------------------
// Import
// -------------------------------------------------------------------------
@@ -654,6 +680,7 @@
importObjectManager.importDataDictionaries();
importObjectManager.importDataDictionaryDataElements();
importObjectManager.importDataDictionaryIndicators();
+ importObjectManager.importDataEntryForms();
importObjectManager.importDataSets();
importObjectManager.importDataSetMembers();
importObjectManager.importOrganisationUnits();
@@ -670,11 +697,12 @@
importObjectManager.importReportTables();
importObjectManager.importCharts();
importObjectManager.importOlapURLs();
- importObjectManager.importCompleteDataSetRegistrations();
+ importObjectManager.importCompleteDataSetRegistrations();
importObjectManager.importDataValues();
-
+ importObjectManager.importDataElements();
+
NameMappingUtil.clearMapping();
-
+
cacheManager.clearCache();
}
@@ -685,32 +713,32 @@
private boolean containsIdentifier( String formula, int identifier )
{
if ( formula != null )
- {
+ {
Pattern pattern = Pattern.compile( "(\\[\\d+\\" + SEPARATOR + "\\d+\\])" );
Matcher matcher = pattern.matcher( formula );
-
+
while ( matcher.find() )
{
String match = matcher.group();
-
+
match = match.replaceAll( "[\\[\\]]", "" );
-
- String matchId = match.substring( 0, match.indexOf( SEPARATOR ) );
-
+
+ String matchId = match.substring( 0, match.indexOf( SEPARATOR ) );
+
if ( matchId.equals( String.valueOf( identifier ) ) )
{
return true;
}
}
}
-
+
return false;
}
-
+
// -------------------------------------------------------------------------
// Update - supportive methods
// -------------------------------------------------------------------------
-
+
private DataValue updateDataValue( DataValue original, DataValue update )
{
original.setDataElement( update.getDataElement() );
@@ -721,22 +749,22 @@
original.setTimestamp( update.getTimestamp() );
original.setComment( update.getComment() );
original.setOptionCombo( update.getOptionCombo() );
-
+
return original;
}
-
+
// -------------------------------------------------------------------------
// Cascade delete - supportive methods
// -------------------------------------------------------------------------
-
+
private void deleteMemberAssociations( GroupMemberType groupMemberType, int memberId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( groupMemberType );
-
+
for ( ImportObject importObject : importObjects )
{
GroupMemberAssociation association = (GroupMemberAssociation) importObject.getObject();
-
+
if ( association.getMemberId() == memberId )
{
importObjectStore.deleteImportObject( importObject );
@@ -747,64 +775,65 @@
private void deleteGroupAssociations( GroupMemberType groupMemberType, int groupId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( groupMemberType );
-
+
for ( ImportObject importObject : importObjects )
{
GroupMemberAssociation association = (GroupMemberAssociation) importObject.getObject();
-
+
if ( association.getGroupId() == groupId )
{
importObjectStore.deleteImportObject( importObject );
}
- }
+ }
}
-
+
private void deleteIndicatorsContainingDataElement( int dataElementId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Indicator.class );
-
+
for ( ImportObject importObject : importObjects )
{
Indicator indicator = (Indicator) importObject.getObject();
-
- if ( containsIdentifier( indicator.getNumerator(), dataElementId ) || containsIdentifier( indicator.getDenominator(), dataElementId ) )
+
+ if ( containsIdentifier( indicator.getNumerator(), dataElementId )
+ || containsIdentifier( indicator.getDenominator(), dataElementId ) )
{
importObjectStore.deleteImportObject( importObject );
-
+
deleteMemberAssociations( GroupMemberType.INDICATORGROUP, indicator.getId() );
-
+
deleteMemberAssociations( GroupMemberType.DATADICTIONARY_INDICATOR, indicator.getId() );
- }
- }
+ }
+ }
}
-
+
private void deleteIndicatorsWithIndicatorType( int indicatorTypeId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Indicator.class );
-
+
for ( ImportObject importObject : importObjects )
{
Indicator indicator = (Indicator) importObject.getObject();
-
+
if ( indicator.getIndicatorType().getId() == indicatorTypeId )
{
importObjectStore.deleteImportObject( importObject );
-
+
deleteMemberAssociations( GroupMemberType.INDICATORGROUP, indicator.getId() );
-
+
deleteMemberAssociations( GroupMemberType.DATADICTIONARY_INDICATOR, indicator.getId() );
}
}
}
-
+
private void deleteCompleteDataSetRegistrationsByDataSet( int dataSetId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( CompleteDataSetRegistration.class );
-
+
for ( ImportObject importObject : importObjects )
{
CompleteDataSetRegistration registration = (CompleteDataSetRegistration) importObject.getObject();
-
+
if ( registration.getDataSet().getId() == dataSetId )
{
importObjectStore.deleteImportObject( importObject );
@@ -815,11 +844,11 @@
private void deleteCompleteDataSetRegistrationsBySource( int sourceId )
{
Collection<ImportObject> importObjects = importObjectStore.getImportObjects( CompleteDataSetRegistration.class );
-
+
for ( ImportObject importObject : importObjects )
{
CompleteDataSetRegistration registration = (CompleteDataSetRegistration) importObject.getObject();
-
+
if ( registration.getSource().getId() == sourceId )
{
importObjectStore.deleteImportObject( importObject );
=== 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 2010-12-19 00:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2010-12-23 11:56:44 +0000
@@ -101,6 +101,7 @@
<property name="chartService" ref="org.hisp.dhis.chart.ChartService"/>
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
</bean>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@@ -131,6 +132,7 @@
<property name="olapURLService" ref="org.hisp.dhis.olap.OlapURLService" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="cacheManager" ref="cacheManager"/>
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService"/>
</bean>
<bean id="internal-process-ImportPreview" class="org.hisp.dhis.importexport.ImportPreviewInternalProcess"
@@ -271,6 +273,7 @@
<property name="converterInvoker"
ref="org.hisp.dhis.importexport.invoker.ConverterInvoker" />
<property name="cacheManager" ref="cacheManager"/>
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService"/>
</bean>
<bean id="org.hisp.dhis.importexport.ImportService"
@@ -326,6 +329,7 @@
<property name="completeDataSetRegistrationService"
ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
<property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
</bean>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java 2010-07-30 14:13:32 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java 2010-12-23 11:56:44 +0000
@@ -346,11 +346,13 @@
throws XMLStreamException
{
StringBuffer sb = new StringBuffer();
- while ( reader.isCharacters() )
+
+ while ( reader.isCharacters() || reader.getEventType() == XMLStreamReader2.CDATA )
{
sb.append( reader.getText() );
reader.next();
}
+
return sb.length() == 0 ? null : sb.toString();
}
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultIndentingXMLStreamWriter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultIndentingXMLStreamWriter.java 2010-02-22 09:37:31 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultIndentingXMLStreamWriter.java 2010-12-23 11:56:44 +0000
@@ -32,23 +32,26 @@
/**
* @author Lars Helge Overland
- * @version $Id: DefaultIndentingXMLStreamWriter.java 145 2009-06-29 14:48:33Z larshelg $
+ * @version $Id: DefaultIndentingXMLStreamWriter.java 145 2009-06-29 14:48:33Z
+ * larshelg $
*/
public class DefaultIndentingXMLStreamWriter
implements XMLWriter
{
private static final String LINE_BREAK = "\n";
- private static final char SPACE = ' ';
- private static final int indentStep = 4; //TODO improve
-
- private static int currentIndent = 0;
-
- private XMLWriter writer;
+
+ private static final char SPACE = ' ';
+
+ private static final int indentStep = 4; // TODO improve
+
+ private static int currentIndent = 0;
+
+ private XMLWriter writer;
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
-
+
public DefaultIndentingXMLStreamWriter( XMLWriter writer )
{
this.writer = writer;
@@ -57,21 +60,21 @@
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
+
public String getWhiteSpace( int indent )
{
final StringBuffer buffer = new StringBuffer();
-
+
final int length = indent * indentStep;
-
+
for ( int i = 0; i < length; i++ )
{
buffer.append( SPACE );
}
-
+
return LINE_BREAK + buffer.toString();
}
-
+
// -------------------------------------------------------------------------
// XMLWriter implementation
// -------------------------------------------------------------------------
@@ -84,57 +87,62 @@
public void openElement( String name )
{
writer.writeCharacters( getWhiteSpace( currentIndent++ ) );
-
- writer.openElement( name );
+
+ writer.openElement( name );
}
public void openElement( String name, String... attributeNameValuePairs )
{
writer.writeCharacters( getWhiteSpace( currentIndent++ ) );
-
+
writer.openElement( name, attributeNameValuePairs );
}
public void writeElement( String name, String value )
{
writer.writeCharacters( getWhiteSpace( currentIndent ) );
-
+
writer.writeElement( name, value );
}
public void writeElement( String name, String value, String... attributeNameValuePairs )
{
writer.writeCharacters( getWhiteSpace( currentIndent ) );
-
+
writer.writeElement( name, value, attributeNameValuePairs );
}
-
+
public void writeCharacters( String characters )
{
writer.writeCharacters( characters );
}
-
+
public void writeCData( String cData )
{
writer.writeCData( cData );
}
+ public void writeCData( String name, String cData )
+ {
+ writer.writeCData( name, cData );
+ }
+
public XMLStreamWriter getXmlStreamWriter()
{
return writer.getXmlStreamWriter();
}
-
+
public void closeElement()
{
writer.writeCharacters( getWhiteSpace( --currentIndent ) );
-
+
writer.closeElement();
}
-
+
public void closeDocument()
{
writer.writeCharacters( getWhiteSpace( --currentIndent ) );
-
+
writer.closeDocument();
}
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultLineBreakingXMLStreamWriter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultLineBreakingXMLStreamWriter.java 2010-02-22 09:37:31 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultLineBreakingXMLStreamWriter.java 2010-12-23 11:56:44 +0000
@@ -32,19 +32,20 @@
/**
* @author Lars Helge Overland
- * @version $Id: DefaultIndentingXMLStreamWriter.java 114 2008-11-23 20:17:23Z larshelg $
+ * @version $Id: DefaultIndentingXMLStreamWriter.java 114 2008-11-23 20:17:23Z
+ * larshelg $
*/
public class DefaultLineBreakingXMLStreamWriter
implements XMLWriter
{
private static final String LINE_BREAK = "\n";
-
+
private XMLWriter writer;
-
+
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
-
+
public DefaultLineBreakingXMLStreamWriter( XMLWriter writer )
{
this.writer = writer;
@@ -57,60 +58,65 @@
public void openDocument( String encoding, String version )
{
writer.openDocument( encoding, version );
-
+
writer.writeCharacters( LINE_BREAK );
}
public void openElement( String name )
{
writer.openElement( name );
-
+
writer.writeCharacters( LINE_BREAK );
}
public void openElement( String name, String... attributeNameValuePairs )
{
writer.openElement( name, attributeNameValuePairs );
-
+
writer.writeCharacters( LINE_BREAK );
}
public void writeElement( String name, String value )
{
writer.writeElement( name, value );
-
+
writer.writeCharacters( LINE_BREAK );
}
public void writeElement( String name, String value, String... attributeNameValuePairs )
{
writer.writeElement( name, value, attributeNameValuePairs );
-
+
writer.writeCharacters( LINE_BREAK );
}
-
+
public void writeCharacters( String characters )
{
writer.writeCharacters( characters );
}
-
+
public void writeCData( String cData )
{
writer.writeCData( cData );
}
+ public void writeCData( String name, String cData )
+ {
+ writer.writeCData( name, cData );
+ }
+
public XMLStreamWriter getXmlStreamWriter()
{
return writer.getXmlStreamWriter();
}
-
+
public void closeElement()
{
writer.closeElement();
-
+
writer.writeCharacters( LINE_BREAK );
}
-
+
public void closeDocument()
{
writer.closeDocument();
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java 2010-07-30 14:13:32 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java 2010-12-23 11:56:44 +0000
@@ -160,6 +160,22 @@
throw new RuntimeException( "Failed to write CData: " + cData, ex );
}
}
+
+ public void writeCData( String name, String cData )
+ {
+ try
+ {
+ writer.writeStartElement( verifyNotNull( name ) );
+
+ writer.writeCData( replaceNull( cData ) );
+
+ writer.writeEndElement();
+ }
+ catch ( XMLStreamException ex )
+ {
+ throw new RuntimeException( "Failed to write CData: " + cData, ex );
+ }
+ }
public XMLStreamWriter getXmlStreamWriter()
{
=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/XMLWriter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/XMLWriter.java 2010-02-22 09:37:31 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/XMLWriter.java 2010-12-23 11:56:44 +0000
@@ -93,6 +93,14 @@
void writeCData( String cData );
/**
+ * Writes non-parsed character data to ouput.
+ *
+ * @param name the name of the XML element.
+ * @param cData character data to write.
+ */
+ void writeCData( String name, String cData );
+
+ /**
* Provides the underlying XmlStreamWriter.
*
* @return the underlying XmlStreamWriter.
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java 2010-11-23 16:12:57 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandler.java 2010-12-23 11:56:44 +0000
@@ -41,7 +41,7 @@
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
-
+
public DataSetBatchHandler( JdbcConfiguration config )
{
super( config, false, false );
@@ -55,39 +55,39 @@
{
statementBuilder.setTableName( "dataset" );
}
-
+
@Override
protected void setAutoIncrementColumn()
{
statementBuilder.setAutoIncrementColumn( "datasetid" );
}
-
+
@Override
protected void setIdentifierColumns()
{
statementBuilder.setIdentifierColumn( "datasetid" );
}
-
+
@Override
protected void setIdentifierValues( DataSet dataSet )
- {
+ {
statementBuilder.setIdentifierValue( dataSet.getId() );
}
-
+
protected void setUniqueColumns()
{
statementBuilder.setUniqueColumn( "name" );
statementBuilder.setUniqueColumn( "shortName" );
statementBuilder.setUniqueColumn( "code" );
}
-
+
protected void setUniqueValues( DataSet dataSet )
- {
+ {
statementBuilder.setUniqueValue( dataSet.getName() );
statementBuilder.setUniqueValue( dataSet.getShortName() );
statementBuilder.setUniqueValue( dataSet.getCode() );
}
-
+
protected void setColumns()
{
statementBuilder.setColumn( "name" );
@@ -95,14 +95,16 @@
statementBuilder.setColumn( "code" );
statementBuilder.setColumn( "periodtypeid" );
statementBuilder.setColumn( "sortorder" );
+ statementBuilder.setColumn( "dataEntryForm" );
}
-
+
protected void setValues( DataSet dataSet )
- {
+ {
statementBuilder.setValue( dataSet.getName() );
statementBuilder.setValue( dataSet.getShortName() );
statementBuilder.setValue( dataSet.getCode() );
statementBuilder.setValue( dataSet.getPeriodType().getId() );
statementBuilder.setValue( dataSet.getSortOrder() );
+ statementBuilder.setValue( dataSet.getDataEntryForm() != null ? dataSet.getDataEntryForm().getId() : null );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java 2010-11-12 17:58:03 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java 2010-12-23 11:56:44 +0000
@@ -87,7 +87,7 @@
{
this.format = format;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -98,7 +98,7 @@
{
return inputStream;
}
-
+
private String fileName;
public String getFileName()
@@ -128,7 +128,7 @@
{
this.dataDictionaryMode = dataDictionaryMode;
}
-
+
private boolean dataElements;
public void setDataElements( boolean dataElements )
@@ -142,9 +142,9 @@
{
this.dataElementGroups = dataElementGroups;
}
-
+
private boolean dataElementGroupSets;
-
+
public void setDataElementGroupSets( boolean dataElementGroupSets )
{
this.dataElementGroupSets = dataElementGroupSets;
@@ -156,7 +156,7 @@
{
this.dataDictionaries = dataDictionaries;
}
-
+
private boolean dataSets;
public void setDataSets( boolean dataSets )
@@ -177,7 +177,7 @@
{
this.indicatorGroups = indicatorGroups;
}
-
+
private boolean indicatorGroupSets;
public void setIndicatorGroupSets( boolean indicatorGroupSets )
@@ -205,21 +205,21 @@
{
this.organisationUnitGroupSets = organisationUnitGroupSets;
}
-
+
private boolean organisationUnitLevels;
public void setOrganisationUnitLevels( boolean organisationUnitLevels )
{
this.organisationUnitLevels = organisationUnitLevels;
}
-
+
private boolean validationRules;
public void setValidationRules( boolean validationRules )
{
this.validationRules = validationRules;
}
-
+
private boolean reports;
public void setReports( boolean reports )
@@ -233,9 +233,9 @@
{
this.reportTables = reportTables;
}
-
+
private boolean charts;
-
+
public void setCharts( boolean charts )
{
this.charts = charts;
@@ -255,13 +255,14 @@
public String execute()
throws Exception
{
- importDataValueService.deleteImportDataValues();
+ importDataValueService.deleteImportDataValues();
importObjectService.deleteImportObjects();
-
+
ExportParams params = new ExportParams();
- params.setExtendedMode( dataDictionaryMode != null && dataDictionaryMode.equals( DataDictionaryModeManager.DATADICTIONARY_MODE_EXTENDED ) );
-
+ params.setExtendedMode( dataDictionaryMode != null
+ && dataDictionaryMode.equals( DataDictionaryModeManager.DATADICTIONARY_MODE_EXTENDED ) );
+
if ( dataElements || dataElementGroups || indicators || dataSets || validationRules || reportTables || charts )
{
params.setCategories( null );
@@ -271,29 +272,29 @@
params.setDataElements( null );
params.setCalculatedDataElements( null );
}
-
+
if ( dataElementGroups )
{
params.setDataElementGroups( null );
}
-
+
if ( dataElementGroupSets )
{
params.setDataElementGroupSets( null );
}
-
+
if ( indicators || indicatorGroups || reportTables || charts )
{
params.setIndicators( null );
-
+
params.setIndicatorTypes( null );
}
-
+
if ( indicatorGroups )
{
params.setIndicatorGroups( null );
}
-
+
if ( indicatorGroupSets )
{
params.setIndicatorGroupSets( null );
@@ -303,70 +304,71 @@
{
params.setDataDictionaries( null );
}
-
+
if ( dataSets || reportTables )
{
- params.setDataSets( null );
+ params.setDataEntryForms( null );
+ params.setDataSets( null );
}
-
+
if ( organisationUnits || organisationUnitGroups || reportTables || charts )
{
params.setOrganisationUnits( null );
}
-
+
if ( organisationUnitGroups || organisationUnitGroupSets )
{
- params.setOrganisationUnitGroups( null );
+ params.setOrganisationUnitGroups( null );
}
-
+
if ( organisationUnitGroupSets )
{
params.setOrganisationUnitGroupSets( null );
}
-
+
if ( organisationUnitLevels )
{
params.setOrganisationUnitLevels( null );
}
-
+
if ( validationRules )
{
params.setValidationRules( null );
}
-
+
if ( reports )
{
params.setReports( null );
}
-
+
if ( reportTables )
- {
- params.setReportTables( null );
- params.setPeriods( null ); //TODO Include only relevant periods
+ {
+ params.setReportTables( null );
+ params.setPeriods( null ); // TODO Include only relevant periods
}
-
+
if ( charts )
{
params.setCharts( null );
params.setPeriods( null );
}
-
+
if ( olapUrls )
{
params.setOlapUrls( null );
}
-
+
params.setIncludeDataValues( false );
-
+
params.setI18n( i18n );
params.setFormat( format );
-
+
ExportService exportService = serviceProvider.provide( exportFormat );
-
+
inputStream = exportService.exportData( params );
fileName = FILENAME;
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java 2010-09-03 09:23:06 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java 2010-12-23 11:56:44 +0000
@@ -30,11 +30,10 @@
import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.getCurrentRunningProcessImportFormat;
import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.setCurrentImportFileName;
import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.setCurrentRunningProcessType;
+import static org.hisp.dhis.system.util.ConversionUtils.getList;
import static org.hisp.dhis.util.InternalProcessUtil.PROCESS_KEY_IMPORT;
import static org.hisp.dhis.util.InternalProcessUtil.setCurrentRunningProcess;
-import static org.hisp.dhis.system.util.ConversionUtils.getList;
-
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -246,7 +245,7 @@
// ---------------------------------------------------------------------
// Process
// ---------------------------------------------------------------------
-
+
String importType = importFormat + IMPORT_INTERNAL_PROCESS_ID_POSTFIX;
String owner = currentUserService.getCurrentUsername();
=== 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 2010-12-09 06:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2010-12-23 11:56:44 +0000
@@ -383,4 +383,6 @@
intro_DHIS14_detailed_metadata_export = Do an export of an detailed selection of meta-data. DHIS 1.4 is the predecessor of DHIS 2.
intro_DHIS14_data_export = Do an export of data values or facts. DHIS 1.4 is the predecessor of DHIS 2.
intro_pdf_metadata_export = Portable Document Format (PDF) is a file format for document exchange.
-intro_xls_metadata_export = Excel Spreadsheet (XLS) is a file format with a paper spreadsheet.
\ No newline at end of file
+intro_xls_metadata_export = Excel Spreadsheet (XLS) is a file format with a paper spreadsheet.
+data_entry_forms = Data entry forms
+importing_dataSet_data_entry_form_association = Importing data set - data entry form associations
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java 2010-12-01 08:10:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java 2010-12-23 11:56:44 +0000
@@ -445,6 +445,7 @@
throws Exception
{
Patient patient = new Patient();
+ patient.setFirstName( "" );
patient.setMiddleName( "" );
patient.setLastName( "" );
patient.setOrganisationUnit( orgunit );
@@ -769,7 +770,7 @@
// Check duplication name, birthdate, gender
Collection<Patient> patients = patientService.getPatient( patient.getFirstName(), patient.getMiddleName(),
patient.getLastName(), patient.getBirthDate(), patient.getGender() );
-
+
if ( patients != null && patients.size() > 0 )
{
errPatients.put( row, patient );