← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2302: Added sorting of pdf export

 

------------------------------------------------------------
revno: 2302
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-12-07 00:20:10 +0100
message:
  Added sorting of pdf export
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.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-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java	2010-12-06 23:20:10 +0000
@@ -27,10 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataelement.comparator.DataElementNameComparator;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.importexport.ExportParams;
@@ -69,8 +72,9 @@
 
         PDFUtils.printDataElementFrontPage( document, params.getDataElements(), i18n, format );
 
-        Collection<DataElement> elements = dataElementService.getDataElements( params.getDataElements() );
-
+        List<DataElement> elements = new ArrayList<DataElement>( dataElementService.getDataElements( params.getDataElements() ) );
+        Collections.sort( elements, new DataElementNameComparator() );
+        
         BaseFont bf = getTrueTypeFontByDimension( BaseFont.IDENTITY_H );
         Font TEXT = new Font( bf, 9, Font.NORMAL );
         Font ITALIC = new Font( bf, 9, Font.ITALIC );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java	2010-12-06 23:20:10 +0000
@@ -27,7 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.i18n.I18n;
@@ -36,6 +38,7 @@
 import org.hisp.dhis.importexport.PDFConverter;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.indicator.comparator.IndicatorNameComparator;
 import org.hisp.dhis.system.util.PDFUtils;
 
 import com.lowagie.text.Document;
@@ -73,7 +76,8 @@
 
         PDFUtils.printIndicatorFrontPage( document, params.getIndicators(), i18n, format );
 
-        Collection<Indicator> indicators = indicatorService.getIndicators( params.getIndicators() );
+        List<Indicator> indicators = new ArrayList<Indicator>( indicatorService.getIndicators( params.getIndicators() ) );
+        Collections.sort( indicators, new IndicatorNameComparator() );
 
         BaseFont bf = getTrueTypeFontByDimension( BaseFont.IDENTITY_H );
         Font TEXT = new Font( bf, 9, Font.NORMAL );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java	2010-12-06 23:20:10 +0000
@@ -27,7 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -35,6 +37,7 @@
 import org.hisp.dhis.importexport.PDFConverter;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
 import org.hisp.dhis.system.util.PDFUtils;
 
 import com.lowagie.text.Document;
@@ -70,7 +73,8 @@
 
         PDFUtils.printOrganisationUnitFrontPage( document, params.getOrganisationUnits(), i18n, format );
 
-        Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnits( params.getOrganisationUnits() );
+        List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnits( params.getOrganisationUnits() ) );
+        Collections.sort( units, new OrganisationUnitNameComparator() );
 
         BaseFont bf = getTrueTypeFontByDimension( BaseFont.IDENTITY_H );
         Font ITALIC = new Font( bf, 9, Font.ITALIC );
@@ -79,8 +83,7 @@
 
         for ( OrganisationUnit unit : units )
         {
-            addTableToDocument( document, printOrganisationUnit( unit, i18n, format, HEADER3, ITALIC, TEXT, true,
-                0.40f, 0.60f ) );
+            addTableToDocument( document, printOrganisationUnit( unit, i18n, format, HEADER3, ITALIC, TEXT, true, 0.40f, 0.60f ) );
         }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-10-19 10:12:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-12-06 23:20:10 +0000
@@ -140,7 +140,7 @@
 
             if ( type.equals( TYPE_DATAELEMENT ) )
             {
-                if ( (activeIds != null) && !activeIds.isEmpty() )
+                if ( ( activeIds != null) && !activeIds.isEmpty() )
                 {
                     params.setDataElements( activeIds );
                 }
@@ -155,7 +155,7 @@
             }
             else if ( type.equals( TYPE_INDICATOR ) )
             {
-                if ( (activeIds != null) && !activeIds.isEmpty() )
+                if ( ( activeIds != null) && !activeIds.isEmpty() )
                 {
                     params.setIndicators( activeIds );
                 }