dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17361
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6873: Improved performance of datavalueset import
------------------------------------------------------------
revno: 6873
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-05-07 16:29:01 +0200
message:
Improved performance of datavalueset import
modified:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.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-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-15 20:48:08 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-05-07 14:29:01 +0000
@@ -41,6 +41,7 @@
import java.io.Reader;
import java.io.Writer;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -222,6 +223,7 @@
Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, dataElementIdScheme );
Map<String, OrganisationUnit> orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme );
Map<String, DataElementCategoryOptionCombo> categoryOptionComboMap = identifiableObjectManager.getIdMap( DataElementCategoryOptionCombo.class, IdentifiableProperty.UID );
+ Map<String, Period> periodMap = new HashMap<String, Period>();
DataSet dataSet = dataValueSet.getDataSet() != null ? identifiableObjectManager.getObject( DataSet.class, IdentifiableProperty.UID, dataValueSet.getDataSet() ) : null;
Date completeDate = getDefaultDate( dataValueSet.getCompleteDate() );
@@ -284,14 +286,24 @@
{
categoryOptionCombo = fallbackCategoryOptionCombo;
}
-
+
if ( dataValue.getValue() == null && dataValue.getComment() == null )
{
continue;
}
+ if ( periodMap.containsKey( dataValue.getPeriod() ) )
+ {
+ period = periodMap.get( dataValue.getPeriod() );
+ }
+ else
+ {
+ period = periodService.reloadPeriod( period );
+ periodMap.put( dataValue.getPeriod(), period );
+ }
+
internalValue.setDataElement( dataElement );
- internalValue.setPeriod( periodService.reloadPeriod( period ) );
+ internalValue.setPeriod( period );
internalValue.setSource( orgUnit );
internalValue.setOptionCombo( categoryOptionCombo );
internalValue.setValue( dataValue.getValue() );