dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18165
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7549: local vn - Improved the speed of generating Org-listing report.
------------------------------------------------------------
revno: 7549
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-10 11:54:06 +0700
message:
local vn - Improved the speed of generating Org-listing report.
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-05-04 09:50:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-07-10 04:54:06 +0000
@@ -59,6 +59,8 @@
{
private static final String PREFIX_FORMULA_SUM = "SUM(";
+ private static Map<Integer, List<OrganisationUnit>> childrenGroupMap = new HashMap<Integer, List<OrganisationUnit>>();
+
// -------------------------------------------------------------------------
// Dependency
// -------------------------------------------------------------------------
@@ -78,31 +80,88 @@
ExportReportOrganizationGroupListing exportReportInstance = (ExportReportOrganizationGroupListing) exportReport;
- Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels = new HashMap<OrganisationUnitGroup, OrganisationUnitLevel>(
- exportReportInstance.getOrganisationUnitLevels() );
+ Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUnitGroupAtLevels = exportReportInstance
+ .getOrganisationUnitLevels();
+
+ prepareChildrenGroupMap( exportReportInstance, organisationUnit, orgUnitGroupAtLevels );
this.installReadTemplateFile( exportReportInstance, period, organisationUnit );
+ Collection<ExportItem> exportReportItems = null;
+
for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) )
{
Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 );
- Collection<ExportItem> exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo );
+ exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo );
- generateOutPutFile( exportReportInstance, orgUniGroupAtLevels, exportReportItems, organisationUnit, sheet );
+ generateOutPutFile( exportReportInstance, exportReportItems, sheet );
}
+
+ /**
+ * Garbage
+ */
+ exportReportItems = null;
+ orgUnitGroupAtLevels = null;
+ childrenGroupMap = null;
}
// -------------------------------------------------------------------------
// Supportive method
// -------------------------------------------------------------------------
+ private void prepareChildrenGroupMap( ExportReportOrganizationGroupListing exportReport,
+ OrganisationUnit organisationUnit, Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUnitGroupAtLevels )
+ {
+ OrganisationUnitLevel organisationUnitLevel = null;
+ Collection<OrganisationUnit> membersOfGroup = null;
+ Collection<OrganisationUnit> organisationUnitsAtLevel = null;
+ Collection<OrganisationUnit> childrens = organisationUnit.getChildren();
+
+ for ( OrganisationUnitGroup organisationUnitGroup : exportReport.getOrganisationUnitGroups() )
+ {
+ List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
+
+ membersOfGroup = organisationUnitGroup.getMembers();
+
+ if ( membersOfGroup != null && !membersOfGroup.isEmpty() )
+ {
+ organisationUnits.addAll( membersOfGroup );
+ }
+
+ organisationUnitLevel = orgUnitGroupAtLevels.get( organisationUnitGroup );
+
+ if ( organisationUnitLevel != null )
+ {
+ organisationUnitsAtLevel = organisationUnitService.getOrganisationUnitsAtLevel( organisationUnitLevel
+ .getLevel(), organisationUnit );
+
+ organisationUnits.retainAll( organisationUnitsAtLevel );
+ }
+ else
+ {
+ organisationUnits.retainAll( childrens );
+ }
+
+ Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() );
+
+ childrenGroupMap.put( organisationUnitGroup.getId(), organisationUnits );
+ }
+
+ /**
+ * Garbage
+ */
+ childrens = null;
+ membersOfGroup = null;
+ organisationUnitLevel = null;
+ organisationUnitsAtLevel = null;
+ }
+
private void generateOutPutFile( ExportReportOrganizationGroupListing exportReport,
- Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels,
- Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
+ Collection<ExportItem> exportReportItems, Sheet sheet )
{
- List<OrganisationUnit> childrens = new ArrayList<OrganisationUnit>( organisationUnit.getChildren() );
-
+ List<OrganisationUnit> organisationUnits = null;
+
for ( ExportItem reportItem : exportReportItems )
{
int run = 0;
@@ -115,28 +174,10 @@
for ( OrganisationUnitGroup organisationUnitGroup : exportReport.getOrganisationUnitGroups() )
{
- List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitGroup
- .getMembers() );
-
- OrganisationUnitLevel organisationUnitLevel = orgUniGroupAtLevels.get( organisationUnitGroup );
-
- if ( organisationUnitLevel != null )
- {
- List<OrganisationUnit> organisationUnitsAtLevel = new ArrayList<OrganisationUnit>(
- organisationUnitService.getOrganisationUnitsAtLevel( organisationUnitLevel.getLevel(),
- organisationUnit ) );
-
- organisationUnits.retainAll( organisationUnitsAtLevel );
- }
- else
- {
- organisationUnits.retainAll( childrens );
- }
-
- Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() );
-
int beginChapter = rowBegin;
+ organisationUnits = childrenGroupMap.get( organisationUnitGroup.getId() );
+
if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION )
&& (!organisationUnits.isEmpty()) )
{
@@ -232,5 +273,7 @@
ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula );
}
}
+
+ organisationUnits = null;
}
}