dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25723
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12794: DataValueSetService, improved code
------------------------------------------------------------
revno: 12794
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-22 16:28:10 +0200
message:
DataValueSetService, improved code
modified:
dhis-2/dhis-services/dhis-service-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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2013-09-03 19:31:42 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2013-10-22 14:28:10 +0000
@@ -35,6 +35,7 @@
import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
import static org.hisp.dhis.system.util.ConversionUtils.wrap;
import static org.hisp.dhis.system.util.DateUtils.getDefaultDate;
+import static org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty.UUID;
import java.io.InputStream;
import java.io.OutputStream;
@@ -274,22 +275,7 @@
Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, dataElementIdScheme );
- Map<String, OrganisationUnit> orgUnitMap = new HashMap<String, OrganisationUnit>();
-
- if ( orgUnitIdScheme == IdentifiableProperty.UUID )
- {
- Collection<OrganisationUnit> allOrganisationUnits = organisationUnitService.getAllOrganisationUnits();
-
- for ( OrganisationUnit organisationUnit : allOrganisationUnits )
- {
- orgUnitMap.put( organisationUnit.getUuid(), organisationUnit );
- }
- }
- else
- {
- orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme );
- }
-
+ Map<String, OrganisationUnit> orgUnitMap = orgUnitIdScheme == UUID ? getUuidOrgUnitMap() : identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme );
Map<String, DataElementCategoryOptionCombo> categoryOptionComboMap = identifiableObjectManager.getIdMap( DataElementCategoryOptionCombo.class, IdentifiableProperty.UID );
Map<String, Period> periodMap = new HashMap<String, Period>();
@@ -519,7 +505,7 @@
return dataElements;
}
- public Set<OrganisationUnit> getOrgUnits( Set<String> orgUnits )
+ private Set<OrganisationUnit> getOrgUnits( Set<String> orgUnits )
{
Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
@@ -537,4 +523,18 @@
return organisationUnits;
}
+
+ private Map<String, OrganisationUnit> getUuidOrgUnitMap()
+ {
+ Map<String, OrganisationUnit> orgUnitMap = new HashMap<String, OrganisationUnit>();
+
+ Collection<OrganisationUnit> allOrganisationUnits = organisationUnitService.getAllOrganisationUnits();
+
+ for ( OrganisationUnit organisationUnit : allOrganisationUnits )
+ {
+ orgUnitMap.put( organisationUnit.getUuid(), organisationUnit );
+ }
+
+ return orgUnitMap;
+ }
}