~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/importer/DefaultDXFImportService.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.importexport.dxf.importer;
 
2
 
 
3
/*
 
4
 * Copyright (c) 2004-2007, University of Oslo
 
5
 * All rights reserved.
 
6
 *
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are met:
 
9
 * * Redistributions of source code must retain the above copyright notice, this
 
10
 *   list of conditions and the following disclaimer.
 
11
 * * Redistributions in binary form must reproduce the above copyright notice,
 
12
 *   this list of conditions and the following disclaimer in the documentation
 
13
 *   and/or other materials provided with the distribution.
 
14
 * * Neither the name of the HISP project nor the names of its contributors may
 
15
 *   be used to endorse or promote products derived from this software without
 
16
 *   specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 
22
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
25
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 */
 
29
 
 
30
import java.io.InputStream;
 
31
import java.util.zip.ZipInputStream;
 
32
 
 
33
import org.amplecode.staxwax.factory.XMLFactory;
 
34
import org.amplecode.staxwax.reader.XMLReader;
 
35
import org.apache.commons.logging.Log;
 
36
import org.apache.commons.logging.LogFactory;
 
37
import org.hisp.dhis.cache.HibernateCacheManager;
 
38
import org.hisp.dhis.datadictionary.DataDictionaryService;
 
39
import org.hisp.dhis.dataelement.DataElementCategoryComboService;
 
40
import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 
41
import org.hisp.dhis.dataelement.DataElementCategoryOptionService;
 
42
import org.hisp.dhis.dataelement.DataElementCategoryService;
 
43
import org.hisp.dhis.dataelement.DataElementService;
 
44
import org.hisp.dhis.dataset.DataSetService;
 
45
import org.hisp.dhis.datavalue.DataValueService;
 
46
import org.hisp.dhis.expression.ExpressionService;
 
47
import org.hisp.dhis.importexport.ImportInternalProcess;
 
48
import org.hisp.dhis.importexport.ImportObjectService;
 
49
import org.hisp.dhis.importexport.ImportParams;
 
50
import org.hisp.dhis.importexport.XMLConverter;
 
51
import org.hisp.dhis.importexport.dxf.converter.CalculatedDataElementConverter;
 
52
import org.hisp.dhis.importexport.dxf.converter.CategoryCategoryOptionAssociationConverter;
 
53
import org.hisp.dhis.importexport.dxf.converter.CategoryComboCategoryAssociationConverter;
 
54
import org.hisp.dhis.importexport.dxf.converter.CompleteDataSetRegistrationConverter;
 
55
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryConverter;
 
56
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryDataElementConverter;
 
57
import org.hisp.dhis.importexport.dxf.converter.DataDictionaryIndicatorConverter;
 
58
import org.hisp.dhis.importexport.dxf.converter.DataElementCategoryComboConverter;
 
59
import org.hisp.dhis.importexport.dxf.converter.DataElementCategoryConverter;
 
60
import org.hisp.dhis.importexport.dxf.converter.DataElementCategoryOptionComboConverter;
 
61
import org.hisp.dhis.importexport.dxf.converter.DataElementCategoryOptionConverter;
 
62
import org.hisp.dhis.importexport.dxf.converter.DataElementConverter;
 
63
import org.hisp.dhis.importexport.dxf.converter.DataElementGroupConverter;
 
64
import org.hisp.dhis.importexport.dxf.converter.DataElementGroupMemberConverter;
 
65
import org.hisp.dhis.importexport.dxf.converter.DataSetConverter;
 
66
import org.hisp.dhis.importexport.dxf.converter.DataSetMemberConverter;
 
67
import org.hisp.dhis.importexport.dxf.converter.DataSetSourceAssociationConverter;
 
68
import org.hisp.dhis.importexport.dxf.converter.DataValueConverter;
 
69
import org.hisp.dhis.importexport.dxf.converter.ExtendedDataElementConverter;
 
70
import org.hisp.dhis.importexport.dxf.converter.ExtendedIndicatorConverter;
 
71
import org.hisp.dhis.importexport.dxf.converter.GroupSetConverter;
 
72
import org.hisp.dhis.importexport.dxf.converter.GroupSetMemberConverter;
 
73
import org.hisp.dhis.importexport.dxf.converter.IndicatorConverter;
 
74
import org.hisp.dhis.importexport.dxf.converter.IndicatorGroupConverter;
 
75
import org.hisp.dhis.importexport.dxf.converter.IndicatorGroupMemberConverter;
 
76
import org.hisp.dhis.importexport.dxf.converter.IndicatorTypeConverter;
 
77
import org.hisp.dhis.importexport.dxf.converter.OlapUrlConverter;
 
78
import org.hisp.dhis.importexport.dxf.converter.OrganisationUnitConverter;
 
79
import org.hisp.dhis.importexport.dxf.converter.OrganisationUnitGroupConverter;
 
80
import org.hisp.dhis.importexport.dxf.converter.OrganisationUnitGroupMemberConverter;
 
81
import org.hisp.dhis.importexport.dxf.converter.OrganisationUnitLevelConverter;
 
82
import org.hisp.dhis.importexport.dxf.converter.OrganisationUnitRelationshipConverter;
 
83
import org.hisp.dhis.importexport.dxf.converter.PeriodConverter;
 
84
import org.hisp.dhis.importexport.dxf.converter.ReportTableCategoryOptionComboConverter;
 
85
import org.hisp.dhis.importexport.dxf.converter.ReportTableConverter;
 
86
import org.hisp.dhis.importexport.dxf.converter.ReportTableDataElementConverter;
 
87
import org.hisp.dhis.importexport.dxf.converter.ReportTableDataSetConverter;
 
88
import org.hisp.dhis.importexport.dxf.converter.ReportTableIndicatorConverter;
 
89
import org.hisp.dhis.importexport.dxf.converter.ReportTableOrganisationUnitConverter;
 
90
import org.hisp.dhis.importexport.dxf.converter.ReportTablePeriodConverter;
 
91
import org.hisp.dhis.importexport.dxf.converter.ValidationRuleConverter;
 
92
import org.hisp.dhis.importexport.locking.LockingManager;
 
93
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
 
94
import org.hisp.dhis.importexport.mapping.ObjectMappingGenerator;
 
95
import org.hisp.dhis.indicator.IndicatorService;
 
96
import org.hisp.dhis.jdbc.BatchHandler;
 
97
import org.hisp.dhis.jdbc.BatchHandlerFactory;
 
98
import org.hisp.dhis.jdbc.batchhandler.CategoryCategoryOptionAssociationBatchHandler;
 
99
import org.hisp.dhis.jdbc.batchhandler.CategoryComboCategoryAssociationBatchHandler;
 
100
import org.hisp.dhis.jdbc.batchhandler.CompleteDataSetRegistrationBatchHandler;
 
101
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryBatchHandler;
 
102
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryDataElementBatchHandler;
 
103
import org.hisp.dhis.jdbc.batchhandler.DataDictionaryIndicatorBatchHandler;
 
104
import org.hisp.dhis.jdbc.batchhandler.DataElementBatchHandler;
 
105
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryBatchHandler;
 
106
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryComboBatchHandler;
 
107
import org.hisp.dhis.jdbc.batchhandler.DataElementCategoryOptionBatchHandler;
 
108
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupBatchHandler;
 
109
import org.hisp.dhis.jdbc.batchhandler.DataElementGroupMemberBatchHandler;
 
110
import org.hisp.dhis.jdbc.batchhandler.DataSetBatchHandler;
 
111
import org.hisp.dhis.jdbc.batchhandler.DataSetMemberBatchHandler;
 
112
import org.hisp.dhis.jdbc.batchhandler.DataSetSourceAssociationBatchHandler;
 
113
import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
 
114
import org.hisp.dhis.jdbc.batchhandler.ExtendedDataElementBatchHandler;
 
115
import org.hisp.dhis.jdbc.batchhandler.GroupSetBatchHandler;
 
116
import org.hisp.dhis.jdbc.batchhandler.GroupSetMemberBatchHandler;
 
117
import org.hisp.dhis.jdbc.batchhandler.ImportDataValueBatchHandler;
 
118
import org.hisp.dhis.jdbc.batchhandler.IndicatorBatchHandler;
 
119
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupBatchHandler;
 
120
import org.hisp.dhis.jdbc.batchhandler.IndicatorGroupMemberBatchHandler;
 
121
import org.hisp.dhis.jdbc.batchhandler.IndicatorTypeBatchHandler;
 
122
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitBatchHandler;
 
123
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitGroupBatchHandler;
 
124
import org.hisp.dhis.jdbc.batchhandler.OrganisationUnitGroupMemberBatchHandler;
 
125
import org.hisp.dhis.jdbc.batchhandler.PeriodBatchHandler;
 
126
import org.hisp.dhis.jdbc.batchhandler.ReportTableBatchHandler;
 
127
import org.hisp.dhis.jdbc.batchhandler.ReportTableCategoryOptionComboBatchHandler;
 
128
import org.hisp.dhis.jdbc.batchhandler.ReportTableDataElementBatchHandler;
 
129
import org.hisp.dhis.jdbc.batchhandler.ReportTableDataSetBatchHandler;
 
130
import org.hisp.dhis.jdbc.batchhandler.ReportTableIndicatorBatchHandler;
 
131
import org.hisp.dhis.jdbc.batchhandler.ReportTableOrganisationUnitBatchHandler;
 
132
import org.hisp.dhis.jdbc.batchhandler.ReportTablePeriodBatchHandler;
 
133
import org.hisp.dhis.jdbc.batchhandler.SourceBatchHandler;
 
134
import org.hisp.dhis.olap.OlapURLService;
 
135
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 
136
import org.hisp.dhis.organisationunit.OrganisationUnitService;
 
137
import org.hisp.dhis.period.PeriodService;
 
138
import org.hisp.dhis.reporttable.ReportTableStore;
 
139
import org.hisp.dhis.system.util.StreamUtils;
 
140
import org.hisp.dhis.validation.ValidationRuleService;
 
141
 
 
142
/**
 
143
 * @author Lars Helge Overland
 
144
 * @version $Id: DefaultDXFImportService.java 6425 2008-11-22 00:08:57Z larshelg $
 
145
 */
 
146
public class DefaultDXFImportService
 
147
    extends ImportInternalProcess
 
148
{
 
149
    private final Log log = LogFactory.getLog( DefaultDXFImportService.class );
 
150
    
 
151
    // -------------------------------------------------------------------------
 
152
    // Dependencies
 
153
    // -------------------------------------------------------------------------
 
154
 
 
155
    private ImportObjectService importObjectService;
 
156
 
 
157
    public void setImportObjectService( ImportObjectService importObjectService )
 
158
    {
 
159
        this.importObjectService = importObjectService;
 
160
    }
 
161
 
 
162
    private DataElementService dataElementService;
 
163
 
 
164
    public void setDataElementService( DataElementService dataElementService )
 
165
    {
 
166
        this.dataElementService = dataElementService;
 
167
    }
 
168
    
 
169
    private DataElementCategoryService categoryService;
 
170
 
 
171
    public void setCategoryService( DataElementCategoryService categoryService )
 
172
    {
 
173
        this.categoryService = categoryService;
 
174
    }
 
175
    
 
176
    private DataElementCategoryOptionService categoryOptionService;
 
177
 
 
178
    public void setCategoryOptionService( DataElementCategoryOptionService categoryOptionService )
 
179
    {
 
180
        this.categoryOptionService = categoryOptionService;
 
181
    }
 
182
 
 
183
    private DataElementCategoryComboService categoryComboService;
 
184
    
 
185
    public void setCategoryComboService( DataElementCategoryComboService categoryComboService )
 
186
    {
 
187
        this.categoryComboService = categoryComboService;
 
188
    }
 
189
    
 
190
    private DataElementCategoryOptionComboService categoryOptionComboService;
 
191
 
 
192
    public void setCategoryOptionComboService( DataElementCategoryOptionComboService categoryOptionComboService )
 
193
    {
 
194
        this.categoryOptionComboService = categoryOptionComboService;
 
195
    }
 
196
 
 
197
    private IndicatorService indicatorService;
 
198
 
 
199
    public void setIndicatorService( IndicatorService indicatorService )
 
200
    {
 
201
        this.indicatorService = indicatorService;
 
202
    }
 
203
    
 
204
    private DataDictionaryService dataDictionaryService;
 
205
 
 
206
    public void setDataDictionaryService( DataDictionaryService dataDictionaryService )
 
207
    {
 
208
        this.dataDictionaryService = dataDictionaryService;
 
209
    }
 
210
    
 
211
    private DataSetService dataSetService;
 
212
 
 
213
    public void setDataSetService( DataSetService dataSetService )
 
214
    {
 
215
        this.dataSetService = dataSetService;
 
216
    }
 
217
    
 
218
    private OrganisationUnitService organisationUnitService;
 
219
 
 
220
    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
 
221
    {
 
222
        this.organisationUnitService = organisationUnitService;
 
223
    }
 
224
    
 
225
    private OrganisationUnitGroupService organisationUnitGroupService;
 
226
 
 
227
    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
 
228
    {
 
229
        this.organisationUnitGroupService = organisationUnitGroupService;
 
230
    }
 
231
    
 
232
    private PeriodService periodService;
 
233
 
 
234
    public void setPeriodService( PeriodService periodService )
 
235
    {
 
236
        this.periodService = periodService;
 
237
    }
 
238
    
 
239
    private ExpressionService expressionService;
 
240
 
 
241
    public void setExpressionService( ExpressionService expressionService )
 
242
    {
 
243
        this.expressionService = expressionService;
 
244
    }
 
245
 
 
246
    private ValidationRuleService validationRuleService;
 
247
 
 
248
    public void setValidationRuleService( ValidationRuleService validationRuleService )
 
249
    {
 
250
        this.validationRuleService = validationRuleService;
 
251
    }
 
252
    
 
253
    private ReportTableStore reportTableStore;
 
254
 
 
255
    public void setReportTableStore( ReportTableStore reportTableStore )
 
256
    {
 
257
        this.reportTableStore = reportTableStore;
 
258
    }
 
259
    
 
260
    private OlapURLService olapURLService;
 
261
 
 
262
    public void setOlapURLService( OlapURLService olapURLService )
 
263
    {
 
264
        this.olapURLService = olapURLService;
 
265
    }
 
266
    
 
267
    private DataValueService dataValueService;
 
268
 
 
269
    public void setDataValueService( DataValueService dataValueService )
 
270
    {
 
271
        this.dataValueService = dataValueService;
 
272
    }
 
273
    
 
274
    private BatchHandlerFactory batchHandlerFactory;
 
275
 
 
276
    public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
 
277
    {
 
278
        this.batchHandlerFactory = batchHandlerFactory;
 
279
    }
 
280
 
 
281
    private ObjectMappingGenerator objectMappingGenerator;
 
282
 
 
283
    public void setObjectMappingGenerator( ObjectMappingGenerator objectMappingGenerator )
 
284
    {
 
285
        this.objectMappingGenerator = objectMappingGenerator;
 
286
    }
 
287
    
 
288
    private LockingManager lockingManager;
 
289
 
 
290
    public void setLockingManager( LockingManager lockingManager )
 
291
    {
 
292
        this.lockingManager = lockingManager;
 
293
    }
 
294
    
 
295
    private HibernateCacheManager cacheManager;
 
296
 
 
297
    public void setCacheManager( HibernateCacheManager cacheManager )
 
298
    {
 
299
        this.cacheManager = cacheManager;
 
300
    }
 
301
 
 
302
    // -------------------------------------------------------------------------
 
303
    // Constructor
 
304
    // -------------------------------------------------------------------------
 
305
 
 
306
    public DefaultDXFImportService()
 
307
    {
 
308
        super();
 
309
    }
 
310
    
 
311
    // -------------------------------------------------------------------------
 
312
    // DXFImportService implementation
 
313
    // -------------------------------------------------------------------------
 
314
 
 
315
    @Override
 
316
    public void importData( ImportParams params, InputStream inputStream )
 
317
    {        
 
318
        if ( params.isPreview() )
 
319
        {
 
320
            importObjectService.deleteImportObjects();
 
321
        }
 
322
        
 
323
        ZipInputStream zipIn = new ZipInputStream ( inputStream );
 
324
        
 
325
        StreamUtils.getNextZipEntry( zipIn );
 
326
        
 
327
        XMLReader reader = XMLFactory.getXMLReader( zipIn );
 
328
        
 
329
        while ( reader.next() )
 
330
        {
 
331
            if ( reader.isStartElement( DataElementCategoryOptionConverter.COLLECTION_NAME ) )
 
332
            {
 
333
                setMessage( "importing_data_element_category_options" );
 
334
                
 
335
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryOptionBatchHandler.class );
 
336
                
 
337
                batchHandler.init();
 
338
                
 
339
                XMLConverter converter = new DataElementCategoryOptionConverter( batchHandler,
 
340
                    importObjectService,
 
341
                    categoryOptionService );
 
342
                
 
343
                converter.read( reader, params );
 
344
                
 
345
                batchHandler.flush();
 
346
                
 
347
                log.info( "Imported DataElementCategoryOptions" );
 
348
            }
 
349
            else if ( reader.isStartElement( DataElementCategoryConverter.COLLECTION_NAME ) )
 
350
            {
 
351
                setMessage( "importing_data_element_categories" );
 
352
                
 
353
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryBatchHandler.class );
 
354
                
 
355
                batchHandler.init();
 
356
                
 
357
                XMLConverter converter = new DataElementCategoryConverter( batchHandler,
 
358
                    importObjectService, 
 
359
                    categoryService );
 
360
 
 
361
                converter.read( reader, params );
 
362
                
 
363
                batchHandler.flush();
 
364
                
 
365
                log.info( "Imported DataElementCategories" );                
 
366
            }
 
367
            else if ( reader.isStartElement( DataElementCategoryComboConverter.COLLECTION_NAME ) )
 
368
            {
 
369
                setMessage( "importing_data_element_category_combos" );
 
370
                
 
371
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryComboBatchHandler.class );
 
372
                
 
373
                batchHandler.init();
 
374
                
 
375
                XMLConverter converter = new DataElementCategoryComboConverter( batchHandler,
 
376
                    importObjectService,
 
377
                    categoryComboService );
 
378
 
 
379
                converter.read( reader, params );
 
380
                
 
381
                batchHandler.flush();
 
382
                
 
383
                log.info( "Imported DataElementCategoryCombos" );                
 
384
            }
 
385
            else if ( reader.isStartElement( DataElementCategoryOptionComboConverter.COLLECTION_NAME ) )
 
386
            {
 
387
                setMessage( "importing_data_element_category_option_combos" );
 
388
                
 
389
                XMLConverter converter = new DataElementCategoryOptionComboConverter( importObjectService,
 
390
                    objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
 
391
                    objectMappingGenerator.getCategoryOptionMapping( params.skipMapping() ),
 
392
                    categoryOptionComboService,
 
393
                    categoryOptionService,
 
394
                    categoryComboService );
 
395
 
 
396
                converter.read( reader, params );
 
397
                
 
398
                log.info( "Imported DataElementCategoryOptionCombos" );       
 
399
            }
 
400
            else if ( reader.isStartElement( CategoryCategoryOptionAssociationConverter.COLLECTION_NAME ) )
 
401
            {
 
402
                setMessage( "importing_data_element_category_members" );
 
403
                
 
404
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( CategoryCategoryOptionAssociationBatchHandler.class );
 
405
 
 
406
                batchHandler.init();
 
407
                
 
408
                XMLConverter converter = new CategoryCategoryOptionAssociationConverter( batchHandler,
 
409
                    importObjectService,
 
410
                    objectMappingGenerator.getCategoryMapping( params.skipMapping() ),
 
411
                    objectMappingGenerator.getCategoryOptionMapping( params.skipMapping() ) );
 
412
                
 
413
                converter.read( reader, params );
 
414
                
 
415
                batchHandler.flush();
 
416
                
 
417
                log.info( "Imported CategoryCategoryOption associations" );
 
418
            }
 
419
            else if ( reader.isStartElement( CategoryComboCategoryAssociationConverter.COLLECTION_NAME ) )
 
420
            {
 
421
                setMessage( "importing_data_element_category_combo_members" );
 
422
                
 
423
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( CategoryComboCategoryAssociationBatchHandler.class );
 
424
 
 
425
                batchHandler.init();
 
426
                
 
427
                XMLConverter converter = new CategoryComboCategoryAssociationConverter( batchHandler,
 
428
                    importObjectService,
 
429
                    objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
 
430
                    objectMappingGenerator.getCategoryMapping( params.skipMapping() ) );
 
431
                
 
432
                converter.read( reader, params );
 
433
                
 
434
                batchHandler.flush();
 
435
                
 
436
                log.info( "Imported CategoryComboCategory associations" );
 
437
            }
 
438
            else if ( reader.isStartElement( DataElementConverter.COLLECTION_NAME ) )
 
439
            {
 
440
                setMessage( "importing_data_elements" );
 
441
                
 
442
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class );
 
443
                
 
444
                batchHandler.init();
 
445
                                
 
446
                XMLConverter converter = new DataElementConverter( batchHandler, 
 
447
                    importObjectService,
 
448
                    objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
 
449
                    dataElementService );
 
450
                
 
451
                converter.read( reader, params );                
 
452
 
 
453
                batchHandler.flush();  
 
454
                
 
455
                log.info( "Imported DataElements" );
 
456
            }
 
457
            else if ( reader.isStartElement( ExtendedDataElementConverter.COLLECTION_NAME ) )
 
458
            {                
 
459
                setMessage( "importing_data_elements" );
 
460
 
 
461
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class );
 
462
                
 
463
                BatchHandler extendedDataElementBatchHandler = batchHandlerFactory.createBatchHandler( ExtendedDataElementBatchHandler.class );
 
464
                
 
465
                extendedDataElementBatchHandler.init();
 
466
                
 
467
                batchHandler.init();
 
468
                
 
469
                XMLConverter converter = new ExtendedDataElementConverter( batchHandler,
 
470
                    extendedDataElementBatchHandler, 
 
471
                    importObjectService,
 
472
                    objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
 
473
                    dataElementService );
 
474
                
 
475
                converter.read( reader, params );
 
476
                
 
477
                extendedDataElementBatchHandler.flush();
 
478
                
 
479
                batchHandler.flush();
 
480
                
 
481
                log.info( "Imported ExtendedDataElements" );
 
482
            }
 
483
            else if ( reader.isStartElement( CalculatedDataElementConverter.COLLECTION_NAME ) )
 
484
            {
 
485
                setMessage( "importing_calculated_data_elements" );
 
486
                
 
487
                XMLConverter converter = new CalculatedDataElementConverter( importObjectService,
 
488
                    dataElementService,
 
489
                    expressionService,
 
490
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
491
                    objectMappingGenerator.getCategoryComboMapping( params.skipMapping() ),
 
492
                    objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
493
                
 
494
                converter.read( reader, params );
 
495
                
 
496
                log.info( "Imported CalculatedDataElements" );
 
497
            }
 
498
            else if ( reader.isStartElement( DataElementGroupConverter.COLLECTION_NAME ) )
 
499
            {                
 
500
                setMessage( "importing_data_element_groups" );
 
501
                
 
502
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupBatchHandler.class );
 
503
                
 
504
                batchHandler.init();
 
505
                
 
506
                XMLConverter converter = new DataElementGroupConverter( batchHandler, importObjectService, dataElementService );
 
507
                                
 
508
                converter.read( reader, params );
 
509
 
 
510
                batchHandler.flush();
 
511
                
 
512
                log.info( "Imported DataElementGroups" );
 
513
            }
 
514
            else if ( reader.isStartElement( DataElementGroupMemberConverter.COLLECTION_NAME ) )
 
515
            {                
 
516
                setMessage( "importing_data_element_group_members" );
 
517
                
 
518
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupMemberBatchHandler.class );
 
519
                
 
520
                batchHandler.init();
 
521
                
 
522
                XMLConverter converter = new DataElementGroupMemberConverter( batchHandler, importObjectService,
 
523
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
524
                    objectMappingGenerator.getDataElementGroupMapping( params.skipMapping() ) );
 
525
                
 
526
                converter.read( reader, params );
 
527
                
 
528
                batchHandler.flush();
 
529
                
 
530
                log.info( "Imported DataElementGroup members" );
 
531
            }
 
532
            else if ( reader.isStartElement( IndicatorTypeConverter.COLLECTION_NAME ) )
 
533
            {                
 
534
                setMessage( "importing_indicator_types" );
 
535
                
 
536
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( IndicatorTypeBatchHandler.class );
 
537
                
 
538
                batchHandler.init();
 
539
                
 
540
                XMLConverter converter = new IndicatorTypeConverter( batchHandler, importObjectService, indicatorService );
 
541
                
 
542
                converter.read( reader, params );
 
543
                
 
544
                batchHandler.flush();
 
545
                
 
546
                log.info( "Imported IndicatorTypes" );
 
547
            }
 
548
            else if ( reader.isStartElement( IndicatorConverter.COLLECTION_NAME ) )
 
549
            {                
 
550
                setMessage( "importing_indicators" );
 
551
                
 
552
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class );
 
553
                
 
554
                batchHandler.init();
 
555
                
 
556
                XMLConverter converter = new IndicatorConverter( batchHandler, 
 
557
                    importObjectService, 
 
558
                    indicatorService,
 
559
                    expressionService,
 
560
                    objectMappingGenerator.getIndicatorTypeMapping( params.skipMapping() ), 
 
561
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
562
                    objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
563
                                
 
564
                converter.read( reader, params );
 
565
 
 
566
                batchHandler.flush();
 
567
                
 
568
                log.info( "Imported Indicators" );
 
569
            }
 
570
            else if ( reader.isStartElement( ExtendedIndicatorConverter.COLLECTION_NAME ) )
 
571
            {
 
572
                setMessage( "importing_indicators" );
 
573
 
 
574
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class );
 
575
                
 
576
                BatchHandler extendedDataElementBatchHandler = batchHandlerFactory.createBatchHandler( ExtendedDataElementBatchHandler.class );
 
577
                
 
578
                extendedDataElementBatchHandler.init();
 
579
                
 
580
                batchHandler.init();
 
581
                
 
582
                XMLConverter converter = new ExtendedIndicatorConverter( batchHandler,
 
583
                    extendedDataElementBatchHandler,
 
584
                    importObjectService, 
 
585
                    indicatorService,
 
586
                    expressionService,
 
587
                    objectMappingGenerator.getIndicatorTypeMapping( params.skipMapping() ), 
 
588
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
589
                    objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
590
                
 
591
                converter.read( reader, params );
 
592
 
 
593
                extendedDataElementBatchHandler.flush();
 
594
                
 
595
                batchHandler.flush();
 
596
                
 
597
                log.info( "Imported ExtendedIndicators" );
 
598
            }
 
599
            else if ( reader.isStartElement( IndicatorGroupConverter.COLLECTION_NAME ) )
 
600
            {
 
601
                setMessage( "importing_indicator_groups" );
 
602
                
 
603
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupBatchHandler.class );
 
604
                
 
605
                batchHandler.init();
 
606
                
 
607
                XMLConverter converter = new IndicatorGroupConverter( batchHandler, importObjectService, indicatorService );
 
608
                
 
609
                converter.read( reader, params );
 
610
                
 
611
                batchHandler.flush();
 
612
                
 
613
                log.info( "Imported IndicatorGroups" );
 
614
            }
 
615
            else if ( reader.isStartElement( IndicatorGroupMemberConverter.COLLECTION_NAME ) )
 
616
            {
 
617
                setMessage( "importing_indicator_group_members" );
 
618
                
 
619
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupMemberBatchHandler.class );
 
620
                
 
621
                batchHandler.init();
 
622
                
 
623
                XMLConverter converter = new IndicatorGroupMemberConverter( batchHandler, importObjectService,
 
624
                    objectMappingGenerator.getIndicatorMapping( params.skipMapping() ),
 
625
                    objectMappingGenerator.getIndicatorGroupMapping( params.skipMapping() ) );
 
626
                
 
627
                converter.read( reader, params );
 
628
                
 
629
                batchHandler.flush();
 
630
                
 
631
                log.info( "Imported IndicatorGroup members" );
 
632
            }
 
633
            else if ( reader.isStartElement( DataDictionaryConverter.COLLECTION_NAME ) )
 
634
            {
 
635
                setMessage( "importing_data_dictionaries" );
 
636
                
 
637
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryBatchHandler.class );
 
638
                
 
639
                batchHandler.init();
 
640
                
 
641
                XMLConverter converter = new DataDictionaryConverter( batchHandler, 
 
642
                    importObjectService,
 
643
                    dataDictionaryService );
 
644
                
 
645
                converter.read( reader, params );
 
646
                
 
647
                batchHandler.flush();
 
648
                
 
649
                log.info( "Imported DataDictionaries" );
 
650
            }
 
651
            else if ( reader.isStartElement( DataDictionaryDataElementConverter.COLLECTION_NAME ) )
 
652
            {
 
653
                setMessage( "importing_data_dictionary_data_elements" );
 
654
                
 
655
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryDataElementBatchHandler.class );
 
656
                
 
657
                batchHandler.init();
 
658
                
 
659
                XMLConverter converter = new DataDictionaryDataElementConverter( batchHandler,
 
660
                    importObjectService,
 
661
                    objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ),
 
662
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ) );
 
663
                
 
664
                converter.read( reader, params );
 
665
                
 
666
                batchHandler.flush();
 
667
                
 
668
                log.info( "Imported DataDictionary DataElements" );
 
669
            }
 
670
            else if ( reader.isStartElement( DataDictionaryIndicatorConverter.COLLECTION_NAME ) )
 
671
            {
 
672
                setMessage( "importing_data_dictionary_indicators" );
 
673
                
 
674
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryIndicatorBatchHandler.class );
 
675
                
 
676
                batchHandler.init();
 
677
                
 
678
                XMLConverter converter = new DataDictionaryIndicatorConverter( batchHandler,
 
679
                    importObjectService,
 
680
                    objectMappingGenerator.getDataDictionaryMapping( params.skipMapping() ),
 
681
                    objectMappingGenerator.getIndicatorMapping( params.skipMapping() ) );
 
682
                
 
683
                converter.read( reader, params );
 
684
                
 
685
                batchHandler.flush();
 
686
                
 
687
                log.info( "Imported DataDictionary Indicators" );
 
688
            }
 
689
            else if ( reader.isStartElement( DataSetConverter.COLLECTION_NAME ) )
 
690
            {
 
691
                setMessage( "importing_data_sets" );
 
692
                
 
693
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class );
 
694
                
 
695
                batchHandler.init();
 
696
                
 
697
                XMLConverter converter = new DataSetConverter( batchHandler, importObjectService, dataSetService,
 
698
                    objectMappingGenerator.getPeriodTypeMapping() );
 
699
                
 
700
                converter.read( reader, params );
 
701
                
 
702
                batchHandler.flush();
 
703
                
 
704
                log.info( "Imported DataSets" );
 
705
            }
 
706
            else if ( reader.isStartElement( DataSetMemberConverter.COLLECTION_NAME ) )
 
707
            {
 
708
                setMessage( "importing_data_set_members" );
 
709
                
 
710
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataSetMemberBatchHandler.class );
 
711
                
 
712
                batchHandler.init();
 
713
                
 
714
                XMLConverter converter = new DataSetMemberConverter( batchHandler, importObjectService,
 
715
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
716
                    objectMappingGenerator.getDataSetMapping( params.skipMapping() ) );
 
717
                
 
718
                converter.read( reader, params );
 
719
                
 
720
                batchHandler.flush();
 
721
                
 
722
                log.info( "Imported DataSet members" );
 
723
            }
 
724
            else if ( reader.isStartElement( OrganisationUnitConverter.COLLECTION_NAME ) )
 
725
            {
 
726
                setMessage( "importing_organisation_units" );
 
727
                
 
728
                BatchHandler sourceBatchHandler = batchHandlerFactory.createBatchHandler( SourceBatchHandler.class );
 
729
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitBatchHandler.class );
 
730
                
 
731
                sourceBatchHandler.init();
 
732
                batchHandler.init();
 
733
                
 
734
                XMLConverter converter = new OrganisationUnitConverter( batchHandler, sourceBatchHandler,
 
735
                    importObjectService, organisationUnitService );
 
736
                
 
737
                converter.read( reader, params );
 
738
                
 
739
                sourceBatchHandler.flush();
 
740
                batchHandler.flush();
 
741
                
 
742
                log.info( "Imported OrganisationUnits" );
 
743
            }
 
744
            else if ( reader.isStartElement( OrganisationUnitRelationshipConverter.COLLECTION_NAME ) )
 
745
            {
 
746
                setMessage( "importing_organisation_unit_relationships" );
 
747
                
 
748
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitBatchHandler.class );
 
749
                
 
750
                batchHandler.init();
 
751
                
 
752
                XMLConverter converter = new OrganisationUnitRelationshipConverter( batchHandler, 
 
753
                    importObjectService,
 
754
                    organisationUnitService,
 
755
                    objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
 
756
                
 
757
                converter.read( reader, params );
 
758
                
 
759
                batchHandler.flush();
 
760
                
 
761
                log.info( "Imported OrganisationUnit relationships" );
 
762
            }
 
763
            else if ( reader.isStartElement( OrganisationUnitGroupConverter.COLLECTION_NAME ) )
 
764
            {
 
765
                setMessage( "importing_organisation_unit_groups" );
 
766
                
 
767
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupBatchHandler.class );
 
768
                
 
769
                batchHandler.init();
 
770
                
 
771
                XMLConverter converter = new OrganisationUnitGroupConverter( batchHandler, importObjectService, organisationUnitGroupService );
 
772
                
 
773
                converter.read( reader, params );
 
774
                
 
775
                batchHandler.flush();
 
776
                
 
777
                log.info( "Imported OrganisationUnitGroups" );
 
778
            }
 
779
            else if ( reader.isStartElement( OrganisationUnitGroupMemberConverter.COLLECTION_NAME ) )
 
780
            {
 
781
                setMessage( "importing_organisation_unit_group_members" );
 
782
                
 
783
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupMemberBatchHandler.class );
 
784
                
 
785
                batchHandler.init();
 
786
                
 
787
                XMLConverter converter = new OrganisationUnitGroupMemberConverter( batchHandler, importObjectService,
 
788
                    objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ),
 
789
                    objectMappingGenerator.getOrganisationUnitGroupMapping( params.skipMapping() ) );
 
790
                
 
791
                converter.read( reader, params );
 
792
                
 
793
                batchHandler.flush();
 
794
                
 
795
                log.info( "Imported OrganisationUnitGroup members" );
 
796
            }
 
797
            else if ( reader.isStartElement( GroupSetConverter.COLLECTION_NAME ) )
 
798
            {
 
799
                setMessage( "importing_organisation_unit_group_sets" );
 
800
                
 
801
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( GroupSetBatchHandler.class );
 
802
                
 
803
                batchHandler.init();
 
804
                
 
805
                XMLConverter converter = new GroupSetConverter( batchHandler, importObjectService, organisationUnitGroupService );
 
806
                
 
807
                converter.read( reader, params );
 
808
                
 
809
                batchHandler.flush();
 
810
                
 
811
                log.info( "Imported OrganisationUnitGroupSets" );
 
812
            }
 
813
            else if ( reader.isStartElement( GroupSetMemberConverter.COLLECTION_NAME ) )
 
814
            {
 
815
                setMessage( "importing_organisation_unit_group_set_members" );
 
816
                
 
817
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( GroupSetMemberBatchHandler.class );
 
818
                
 
819
                batchHandler.init();
 
820
                
 
821
                XMLConverter converter = new GroupSetMemberConverter( batchHandler, importObjectService,
 
822
                    objectMappingGenerator.getOrganisationUnitGroupMapping( params.skipMapping() ),
 
823
                    objectMappingGenerator.getOrganisationUnitGroupSetMapping( params.skipMapping() ) );
 
824
                
 
825
                converter.read( reader, params );
 
826
                
 
827
                batchHandler.flush();
 
828
                
 
829
                log.info( "Imported OrganisationUnitGroupSet members" );
 
830
            }
 
831
            else if ( reader.isStartElement( OrganisationUnitLevelConverter.COLLECTION_NAME ) )
 
832
            {
 
833
                setMessage( "importing_organisation_unit_levels" );
 
834
                
 
835
                XMLConverter converter = new OrganisationUnitLevelConverter( organisationUnitService, importObjectService );
 
836
                
 
837
                converter.read( reader, params );
 
838
                
 
839
                log.info( "Imported OrganisationUnitLevels" );
 
840
            }
 
841
            else if ( reader.isStartElement( DataSetSourceAssociationConverter.COLLECTION_NAME ) )
 
842
            {
 
843
                setMessage( "importing_data_set_source_associations" );
 
844
                
 
845
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataSetSourceAssociationBatchHandler.class );
 
846
                
 
847
                batchHandler.init();
 
848
                
 
849
                XMLConverter converter = new DataSetSourceAssociationConverter( batchHandler, importObjectService,
 
850
                    objectMappingGenerator.getDataSetMapping( params.skipMapping() ),
 
851
                    objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
 
852
                
 
853
                converter.read( reader, params );
 
854
                
 
855
                batchHandler.flush();
 
856
                
 
857
                log.info( "Imported DataSet Source associations" );
 
858
            }
 
859
            else if ( reader.isStartElement( ValidationRuleConverter.COLLECTION_NAME ) )
 
860
            {
 
861
                setMessage( "importing_validation_rules" );
 
862
                
 
863
                XMLConverter converter = new ValidationRuleConverter( importObjectService, 
 
864
                    validationRuleService, 
 
865
                    expressionService,
 
866
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
867
                    objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
868
                
 
869
                converter.read( reader, params );
 
870
                
 
871
                log.info( "Imported ValidationRules" );
 
872
            }
 
873
            else if ( reader.isStartElement( PeriodConverter.COLLECTION_NAME ) )
 
874
            {
 
875
                setMessage( "importing_periods" );
 
876
                
 
877
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class );
 
878
                
 
879
                batchHandler.init();
 
880
                
 
881
                XMLConverter converter = new PeriodConverter( batchHandler, importObjectService, periodService,
 
882
                    objectMappingGenerator.getPeriodTypeMapping() );
 
883
                
 
884
                converter.read( reader, params );
 
885
                
 
886
                batchHandler.flush();
 
887
                
 
888
                log.info( "Imported Periods" );
 
889
            }
 
890
            else if ( reader.isStartElement( ReportTableConverter.COLLECTION_NAME ) )
 
891
            {
 
892
                setMessage( "importing_report_tables" );
 
893
                
 
894
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableBatchHandler.class );
 
895
                
 
896
                batchHandler.init();
 
897
                
 
898
                XMLConverter converter = new ReportTableConverter( batchHandler, reportTableStore, importObjectService );
 
899
                
 
900
                converter.read( reader, params );
 
901
                
 
902
                batchHandler.flush();
 
903
                
 
904
                log.info( "Imported ReportTables" );
 
905
            }
 
906
            else if ( reader.isStartElement( ReportTableDataElementConverter.COLLECTION_NAME ) )
 
907
            {
 
908
                setMessage( "importing_report_table_dataelements" );
 
909
                
 
910
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableDataElementBatchHandler.class );
 
911
                
 
912
                batchHandler.init();
 
913
                
 
914
                XMLConverter converter = new ReportTableDataElementConverter( batchHandler, importObjectService,
 
915
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
916
                    objectMappingGenerator.getDataElementMapping( params.skipMapping() ) );
 
917
                
 
918
                converter.read( reader, params );
 
919
                
 
920
                batchHandler.flush();
 
921
                
 
922
                log.info( "Imported ReportTable DataElements" );
 
923
            }
 
924
            else if ( reader.isStartElement( ReportTableCategoryOptionComboConverter.COLLECTION_NAME ) )
 
925
            {
 
926
                setMessage( "importing_report_table_category_option_combos" );
 
927
                
 
928
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableCategoryOptionComboBatchHandler.class );
 
929
                
 
930
                batchHandler.init();
 
931
                
 
932
                XMLConverter converter = new ReportTableCategoryOptionComboConverter( batchHandler, importObjectService,
 
933
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
934
                    objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
935
                
 
936
                converter.read( reader, params );
 
937
                
 
938
                batchHandler.flush();
 
939
                
 
940
                log.info( "Imported ReportTable CategoryOptionCombos" );
 
941
            }
 
942
            else if ( reader.isStartElement( ReportTableIndicatorConverter.COLLECTION_NAME ) )
 
943
            {
 
944
                setMessage( "importing_report_table_indicators" );
 
945
                
 
946
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableIndicatorBatchHandler.class );
 
947
                
 
948
                batchHandler.init();
 
949
                
 
950
                XMLConverter converter = new ReportTableIndicatorConverter( batchHandler, importObjectService,
 
951
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
952
                    objectMappingGenerator.getIndicatorMapping( params.skipMapping() ) );
 
953
                
 
954
                converter.read( reader, params );
 
955
                
 
956
                batchHandler.flush();
 
957
                
 
958
                log.info( "Imported ReportTable Indicators" );
 
959
            }
 
960
            else if ( reader.isStartElement( ReportTableDataSetConverter.COLLECTION_NAME ) )
 
961
            {
 
962
                setMessage( "importing_report_table_datasets" );
 
963
                
 
964
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableDataSetBatchHandler.class );
 
965
                
 
966
                batchHandler.init();
 
967
                
 
968
                XMLConverter converter = new ReportTableDataSetConverter( batchHandler, importObjectService,
 
969
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
970
                    objectMappingGenerator.getDataSetMapping( params.skipMapping() ) );
 
971
                
 
972
                converter.read( reader, params );
 
973
                
 
974
                batchHandler.flush();
 
975
                
 
976
                log.info( "Imported ReportTable DataSets" );
 
977
            }
 
978
            else if ( reader.isStartElement( ReportTablePeriodConverter.COLLECTION_NAME ) )
 
979
            {
 
980
                setMessage( "importing_report_table_periods" );
 
981
                
 
982
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTablePeriodBatchHandler.class );
 
983
                
 
984
                batchHandler.init();
 
985
                
 
986
                XMLConverter converter = new ReportTablePeriodConverter( batchHandler, importObjectService,
 
987
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
988
                    objectMappingGenerator.getPeriodMapping( params.skipMapping() ) );
 
989
                
 
990
                converter.read( reader, params );
 
991
                
 
992
                batchHandler.flush();
 
993
                
 
994
                log.info( "Imported ReportTable Periods" );
 
995
            }
 
996
            else if ( reader.isStartElement( ReportTableOrganisationUnitConverter.COLLECTION_NAME ) )
 
997
            {
 
998
                setMessage( "importing_report_table_organisation_units" );
 
999
                
 
1000
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( ReportTableOrganisationUnitBatchHandler.class );
 
1001
                
 
1002
                batchHandler.init();
 
1003
                
 
1004
                XMLConverter converter = new ReportTableOrganisationUnitConverter( batchHandler, importObjectService,
 
1005
                    objectMappingGenerator.getReportTableMapping( params.skipMapping() ),
 
1006
                    objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
 
1007
                
 
1008
                converter.read( reader, params );
 
1009
                
 
1010
                batchHandler.flush();
 
1011
                
 
1012
                log.info( "Imported ReportTable OrganisationUnits" );
 
1013
            }
 
1014
            else if ( reader.isStartElement( OlapUrlConverter.COLLECTION_NAME ) )
 
1015
            {
 
1016
                setMessage( "importing_olap_urls" );
 
1017
                
 
1018
                XMLConverter converter = new OlapUrlConverter( importObjectService, olapURLService );
 
1019
                
 
1020
                converter.read( reader, params );
 
1021
                
 
1022
                log.info( "Imported OlapURLs" );
 
1023
            }
 
1024
            else if ( reader.isStartElement( CompleteDataSetRegistrationConverter.COLLECTION_NAME ) && params.isDataValues() )
 
1025
            {
 
1026
                setMessage( "importing_complete_data_set_registrations" );
 
1027
                
 
1028
                BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( CompleteDataSetRegistrationBatchHandler.class );
 
1029
                
 
1030
                batchHandler.init();
 
1031
                
 
1032
                XMLConverter converter = new CompleteDataSetRegistrationConverter( batchHandler, importObjectService, params,
 
1033
                    objectMappingGenerator.getDataSetMapping( params.skipMapping() ),
 
1034
                    objectMappingGenerator.getPeriodMapping( params.skipMapping() ),
 
1035
                    objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ) );
 
1036
                
 
1037
                converter.read( reader, params );
 
1038
                
 
1039
                batchHandler.flush();
 
1040
                
 
1041
                log.info( "Imported CompleteDataSetRegistrations" );
 
1042
            }
 
1043
            else if ( reader.isStartElement( DataValueConverter.COLLECTION_NAME ) && params.isDataValues() )
 
1044
            {
 
1045
                if ( params.skipMapping() == false && lockingManager.currentImportContainsLockedData() )
 
1046
                {
 
1047
                    setMessage( "import_contains_data_for_locked_periods" );
 
1048
                    
 
1049
                    log.warn( "Import file contained DataValues for locked periods" );                    
 
1050
                }
 
1051
                else
 
1052
                {
 
1053
                    setMessage( "importing_data_values" );
 
1054
                    
 
1055
                    BatchHandler batchHandler = batchHandlerFactory.createBatchHandler( DataValueBatchHandler.class );
 
1056
                    
 
1057
                    BatchHandler importDataValueBatchHandler = batchHandlerFactory.createBatchHandler( ImportDataValueBatchHandler.class );
 
1058
                    
 
1059
                    batchHandler.init();
 
1060
                    
 
1061
                    importDataValueBatchHandler.init();
 
1062
                    
 
1063
                    XMLConverter converter = new DataValueConverter( batchHandler, 
 
1064
                        importDataValueBatchHandler,                    
 
1065
                        dataValueService,
 
1066
                        importObjectService,
 
1067
                        params,
 
1068
                        objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
 
1069
                        objectMappingGenerator.getPeriodMapping( params.skipMapping() ),
 
1070
                        objectMappingGenerator.getOrganisationUnitMapping( params.skipMapping() ),
 
1071
                        objectMappingGenerator.getCategoryOptionComboMapping( params.skipMapping() ) );
 
1072
                    
 
1073
                    converter.read( reader, params );
 
1074
                    
 
1075
                    batchHandler.flush();
 
1076
                    
 
1077
                    importDataValueBatchHandler.flush();
 
1078
                    
 
1079
                    log.info( "Imported DataValues" );
 
1080
                }
 
1081
            }
 
1082
        }
 
1083
        
 
1084
        setMessage( "import_process_done" );
 
1085
        
 
1086
        NameMappingUtil.clearMapping();
 
1087
                
 
1088
        StreamUtils.closeInputStream( zipIn );
 
1089
        
 
1090
        cacheManager.clearCache();
 
1091
    }
 
1092
}