dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06502
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2072: Fixed the Unicode encoding in exporting pdf
------------------------------------------------------------
revno: 2072
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-07-04 02:36:21 +0700
message:
Fixed the Unicode encoding in exporting pdf
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportPDFAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties
--
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-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java 2010-07-03 19:36:21 +0000
@@ -84,9 +84,13 @@
public DataBrowserTable getDataSetsInPeriod( String startDate, String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
@@ -96,9 +100,13 @@
public DataBrowserTable getDataElementGroupsInPeriod( String startDate, String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
@@ -108,9 +116,13 @@
public DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
@@ -121,9 +133,13 @@
PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
DataBrowserTable table = new DataBrowserTable();
@@ -144,9 +160,13 @@
String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
DataBrowserTable table = new DataBrowserTable();
@@ -162,9 +182,13 @@
String startDate, String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
DataBrowserTable table = new DataBrowserTable();
@@ -182,9 +206,13 @@
String endDate, PeriodType periodType )
{
if ( startDate == null || startDate.length() == 0 )
+ {
startDate = STARTDATE;
+ }
if ( endDate == null || endDate.length() == 0 )
+ {
endDate = ENDDATE;
+ }
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
@@ -198,7 +226,7 @@
return table;
}
-
+
public DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer orgUnitGroupId, String startDate,
String endDate, PeriodType periodType )
{
@@ -212,14 +240,14 @@
}
DataBrowserTable table = new DataBrowserTable();
-
+
List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
dataBrowserStore.setDataElementStructureForOrgUnitBetweenPeriods( table, orgUnitGroupId, betweenPeriodIds );
int numRows = dataBrowserStore.setCountDataElementsForOrgUnitBetweenPeriods( table, orgUnitGroupId,
betweenPeriodIds );
-
+
if ( numRows == 0 )
{
table.addZeroColumn();
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java 2010-07-03 19:36:21 +0000
@@ -98,8 +98,7 @@
try
{
StringBuffer sqlsb = new StringBuffer();
- sqlsb
- .append( "(SELECT d.dataelementgroupid AS ID, d.name AS DataElementGroup, COUNT(*) AS counts_of_aggregated_values " );
+ sqlsb.append( "(SELECT d.dataelementgroupid AS ID, d.name AS DataElementGroup, COUNT(*) AS counts_of_aggregated_values " );
sqlsb.append( "FROM datavalue dv " );
sqlsb.append( "JOIN dataelementgroupmembers degm ON (dv.dataelementid = degm.dataelementid)" );
sqlsb.append( "JOIN dataelementgroup d ON (d.dataelementgroupid = degm.dataelementgroupid) " );
@@ -145,8 +144,7 @@
{
StringBuffer sqlsb = new StringBuffer();
- sqlsb
- .append( "(SELECT oug.orgunitgroupid, oug.name AS OrgUnitGroup, COUNT(*) AS counts_of_aggregated_values " );
+ sqlsb.append( "(SELECT oug.orgunitgroupid, oug.name AS OrgUnitGroup, COUNT(*) AS counts_of_aggregated_values " );
sqlsb.append( "FROM orgunitgroup oug " );
sqlsb.append( "JOIN orgunitgroupmembers ougm ON oug.orgunitgroupid = ougm.orgunitgroupid " );
sqlsb.append( "JOIN organisationunit ou ON ougm.organisationunitid = ou.organisationunitid " );
@@ -394,18 +392,14 @@
{
i++;
- sqlsb
- .append( "(SELECT de.dataelementid, de.name AS DataElement, Count(dv.value) AS counts_of_aggregated_values, p.periodid AS PeriodId, p.startDate AS ColumnHeader " );
+ sqlsb.append( "(SELECT de.dataelementid, de.name AS DataElement, Count(dv.value) AS counts_of_aggregated_values, p.periodid AS PeriodId, p.startDate AS ColumnHeader " );
sqlsb.append( "FROM dataelement de JOIN datavalue dv ON (de.dataelementid = dv.dataelementid) " );
sqlsb.append( "JOIN datasetmembers dsm ON (de.dataelementid = dsm.dataelementid) " );
sqlsb.append( "JOIN period p ON (dv.periodid = p.periodid) " );
sqlsb.append( "WHERE dsm.datasetid = '" + dataSetId + "' AND dv.periodid = '" + periodId + "' " );
sqlsb.append( "GROUP BY de.dataelementid, de.name, p.periodid, p.startDate)" );
- if ( i == betweenPeriodIds.size() )
- sqlsb.append( "ORDER BY PeriodId " );
- else
- sqlsb.append( " UNION " );
+ sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY PeriodId " : "\n UNION \n" );
}
try
@@ -452,10 +446,7 @@
sqlsb.append( "AND dv.periodid = '" + periodid + "' " );
sqlsb.append( "GROUP BY de.dataelementid, de.name, p.periodid, p.startDate) " );
- if ( i == betweenPeriodIds.size() )
- sqlsb.append( "ORDER BY PeriodId " );
- else
- sqlsb.append( " UNION " );
+ sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY PeriodId " : "\n UNION \n" );
}
try
@@ -504,7 +495,7 @@
sqlsb.append( "WHERE p.periodid = '" + periodid + "' AND ougm.orgunitgroupid = '" + orgUnitGroupId + "' " );
sqlsb.append( "GROUP BY deg.dataelementgroupid,deg.name,p.periodid,p.startdate) " );
- sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY PeriodId " : "\n UNION \n" );
+ sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY PeriodId " : "\n UNION \n" );
}
try
@@ -539,14 +530,14 @@
StringBuffer sqlsbDescentdants = new StringBuffer();
dropView( "view_count_descentdants" );
-
+
sqlsbDescentdants.append( "CREATE VIEW view_count_descentdants AS " );
setUpQueryForDrillDownDescendants( sqlsbDescentdants, orgUnitParent, betweenPeriodIds );
- TimeUtils.start();
-
try
{
+ TimeUtils.start();
+
holder.getStatement().executeUpdate( sqlsbDescentdants.toString() );
setUpQueryForDrillDownViewTable( sqlsbDescentdants );
@@ -554,11 +545,12 @@
ResultSet resultSet = getScrollableResult( sqlsbDescentdants.toString(), holder );
table.addQueryTime( TimeUtils.getMillis() );
-
+
table.incrementQueryCount();
numResults = table.addColumnToAllRows( resultSet );
-
+
+ TimeUtils.stop();
}
catch ( SQLException e )
{
@@ -569,8 +561,6 @@
holder.close();
}
- TimeUtils.stop();
-
return numResults;
}
@@ -597,10 +587,7 @@
sqlsb.append( "AND dv.periodid = '" + periodId + "' " );
sqlsb.append( "GROUP BY de.dataelementid, de.name, p.periodid, p.startDate)" );
- if ( i == betweenPeriodIds.size() )
- sqlsb.append( "ORDER BY PeriodId " );
- else
- sqlsb.append( " UNION " );
+ sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY PeriodId " : "\n UNION \n" );
}
try
@@ -687,7 +674,7 @@
i++;
/**
- * The current organisation unit
+ * The current organization unit
*/
sb.append( "SELECT DISTINCT o.organisationunitid AS parentid, o.name AS OrganisationUnit, COUNT(value) as countdv_descendants, p.periodid AS PeriodId, p.startDate AS ColumnHeader " );
sb.append( "FROM OrganisationUnit o " );
@@ -699,9 +686,9 @@
sb.append( "UNION " );
/**
- * All descendant levels of selected organisation unit
+ * All descendant levels of selected organization unit
*/
- sb.append( "SELECT DISTINCT ou" + orgIndex + ".organisationunitid AS parentid, ou" + orgIndex + ".name AS OrganisationUnit, COUNT(value) as countdv_descendants, p.periodid AS PeriodId, p.startDate AS ColumnHeader " );
+ sb.append( "SELECT DISTINCT ou" + orgIndex + ".organisationunitid AS parentid, ou" + orgIndex + ".name AS OrganisationUnit, COUNT(value) as countdv_descendants, p.periodid AS PeriodId, p.startDate AS ColumnHeader " );
sb.append( "FROM DataValue dv " );
sb.append( "JOIN OrganisationUnit ou ON ( ou.organisationunitid = dv.sourceid ) " );
this.setUpQueryForJOINTable( sb, diffLevel );
@@ -712,11 +699,9 @@
sb.append( this.setUpQueryGetDescendants( curLevel, maxLevel, orgUnitSelected ) );
sb.append( " ) " );
sb.append( "GROUP BY ou" + orgIndex + ".organisationunitid, OrganisationUnit, p.periodid, p.startDate " );
-
- if ( i < loopSize )
- {
- sb.append( "UNION " );
- }
+
+ sb.append( i < loopSize ? "UNION " : "" );
+
}
}
@@ -740,9 +725,10 @@
{
sb.delete( 0, sb.capacity() );
- sb.append( "SELECT parentid, OrganisationUnit, sum(countdv_descendants) AS counts_of_aggregated_values, periodid, columnheader " );
+ sb
+ .append( "SELECT parentid, organisationunit, sum(countdv_descendants) AS counts_of_aggregated_values, periodid, columnheader " );
sb.append( "FROM view_count_descentdants " );
- sb.append( "GROUP BY parentid, OrganisationUnit, periodid, columnheader " );
+ sb.append( "GROUP BY parentid, organisationunit, periodid, columnheader " );
sb.append( "ORDER BY periodid; " );
}
@@ -767,10 +753,10 @@
return (index == 0) ? "" : index + "";
}
- public void dropView( String view )
+ private void dropView( String view )
{
final StatementHolder holder = statementManager.getHolder();
-
+
try
{
holder.getStatement().executeUpdate( "DROP VIEW IF EXISTS " + view );
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java 2010-07-03 19:36:21 +0000
@@ -231,7 +231,7 @@
assertNotSame( "Querytime more than 0", 0, table.getQueryTime() );
assertEquals( "Metacolumns", 3, table.getColumns().size() );
- assertEquals( "OrganisationUnit", table.getColumns().get( 0 ).getName() );
+ assertEquals( "drilldown_organisation_unit", table.getColumns().get( 0 ).getName() );
assertEquals( "Period column header", "2005-03-01", table.getColumns().get( 1 ).getName() );
assertEquals( "Period column header", "2005-04-01", table.getColumns().get( 2 ).getName() );
@@ -266,7 +266,7 @@
assertNotSame( "Querytime more than 0", 0, table.getQueryTime() );
assertEquals( "Metacolumns", 2, table.getColumns().size() );
- assertEquals( "OrganisationUnit", table.getColumns().get( 0 ).getName() );
+ assertEquals( "drilldown_organisation_unit", table.getColumns().get( 0 ).getName() );
// Service layer adds "zero-column"
assertEquals( "counts_of_aggregated_values", table.getColumns().get( 1 ).getName() );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2010-06-03 08:32:23 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2010-07-03 19:36:21 +0000
@@ -324,6 +324,17 @@
}
/**
+ * Creates a cell with text 5 font.
+ *
+ * @param text The text to include in the cell.
+ * @return A PdfCell.
+ */
+ public static PdfPCell getText5Cell( String text, Font font )
+ {
+ return getCell( text, 1, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a cell with text 6 font.
*
* @param text The text to include in the cell.
@@ -335,6 +346,17 @@
}
/**
+ * Creates a cell with text 5 font.
+ *
+ * @param text The text to include in the cell.
+ * @return A PdfCell.
+ */
+ public static PdfPCell getText6Cell( String text, Font font )
+ {
+ return getCell( text, 1, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a cell with text 7 font.
*
* @param text The text to include in the cell.
@@ -346,6 +368,18 @@
}
/**
+ * Creates a cell with text 5 font.
+ *
+ * @param text The text to include in the cell.
+ * @return A PdfCell.
+ */
+
+ public static PdfPCell getText7Cell( String text, Font font )
+ {
+ return getCell( text, 1, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a cell with italic text font.
*
* @param text The text to include in the cell.
@@ -457,6 +491,19 @@
}
/**
+ * Creates a cell with header 5 font.
+ *
+ * @param text The text to include in the cell.
+ * @param colspan The column span of the cell.
+ * @param font The customize font of the cell.
+ * @return A PdfCell.
+ */
+ public static PdfPCell getHeader5Cell( String text, int colspan, Font font )
+ {
+ return getCell( text, colspan, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a cell with header 6 font.
*
* @param text The text to include in the cell.
@@ -469,6 +516,19 @@
}
/**
+ * Creates a cell with header 6 font.
+ *
+ * @param text The text to include in the cell.
+ * @param colspan The column span of the cell.
+ * @param font The customize font of the cell.
+ * @return A PdfCell.
+ */
+ public static PdfPCell getHeader6Cell( String text, int colspan, Font font )
+ {
+ return getCell( text, colspan, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a cell with header 7 font.
*
* @param text The text to include in the cell.
@@ -481,6 +541,19 @@
}
/**
+ * Creates a cell with header 7 font.
+ *
+ * @param text The text to include in the cell.
+ * @param colspan The column span of the cell.
+ * @param font The customize font of the cell.
+ * @return A PdfCell.
+ */
+ public static PdfPCell getHeader7Cell( String text, int colspan, Font font )
+ {
+ return getCell( text, colspan, font, ALIGN_LEFT );
+ }
+
+ /**
* Creates a BaseFont with the given dimension
*
* @param dimension whether horizontal or vertical
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportPDFAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportPDFAction.java 2009-09-03 09:02:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/ExportPDFAction.java 2010-07-03 19:36:21 +0000
@@ -48,6 +48,7 @@
import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.databrowser.DataBrowserTable;
import org.hisp.dhis.databrowser.MetaValue;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.PDFUtils;
import org.hisp.dhis.util.SessionUtils;
@@ -59,6 +60,7 @@
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.opensymphony.xwork2.Action;
@@ -69,12 +71,27 @@
*/
public class ExportPDFAction
implements Action
-{
- private static final String KEY_DATABROWSERTITLENAME = "dataBrowserTitleName";
- private static final String KEY_DATABROWSERFROMDATE = "dataBrowserFromDate";
- private static final String KEY_DATABROWSERTODATE = "dataBrowserToDate";
+{
+ private static final String KEY_DATABROWSERTITLENAME = "dataBrowserTitleName";
+
+ private static final String KEY_DATABROWSERFROMDATE = "dataBrowserFromDate";
+
+ private static final String KEY_DATABROWSERTODATE = "dataBrowserToDate";
+
private static final String KEY_DATABROWSERPERIODTYPE = "dataBrowserPeriodType";
- private static final String KEY_DATABROWSERTABLE = "dataBrowserTableResults";
+
+ private static final String KEY_DATABROWSERTABLE = "dataBrowserTableResults";
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
// -------------------------------------------------------------------------
// Input / output
@@ -127,16 +144,16 @@
{
return this.fileName;
}
-
+
private int fontSize;
-
+
public void setFontSize( int fontSize )
{
this.fontSize = fontSize;
}
-
+
private String pageLayout;
-
+
public void setPageLayout( String pageLayout )
{
this.pageLayout = pageLayout;
@@ -176,7 +193,7 @@
// Set initial inputStream for Velocity
inputStream = new ByteArrayInputStream( baos.toByteArray() );
-
+
// There is a problem with IText regarding setting of landscape. The
// problem is that the first page is always Portrait
// as newPage() does not create a new page when the page is empty.
@@ -184,9 +201,18 @@
// Document document = new Document(PageSize.A4.rotate());
// The openDocument in PDFUtils has been extended to support passing
// of the PageSize parameter;
-
+
Document document;
-
+ BaseFont bf = PDFUtils.getTrueTypeFontByDimension( BaseFont.IDENTITY_H );
+ Font titleFont = new Font( bf, 16, Font.HELVETICA );
+ Font periodFont = new Font( bf, 8, Font.HELVETICA );
+ Font header5Font = new Font( bf, 8, Font.BOLD );
+ Font header6Font = new Font( bf, 6, Font.BOLD );
+ Font header7Font = new Font( bf, 4, Font.BOLD );
+ Font text5Font = new Font( bf, 8, Font.NORMAL );
+ Font text6Font = new Font( bf, 6, Font.NORMAL );
+ Font text7Font = new Font( bf, 4, Font.NORMAL );
+
// Set document page size (layout)
if ( pageLayout.equals( "Landscape" ) )
{
@@ -196,56 +222,58 @@
{
document = openDocument( baos, PageSize.A4 );
}
- else // Default is landscape
+ else
+ // Default is landscape
{
document = openDocument( baos, PageSize.A4.rotate() );
}
-
+
// Heading information
- Paragraph titleParagraph = new Paragraph( "Export results for " + dataBrowserTitleName, FontFactory
- .getFont( FontFactory.HELVETICA, 16, Font.NORMAL, Color.BLACK ) );
+ Paragraph titleParagraph = new Paragraph( i18n.getString( "export_results_for" ) + " "
+ + dataBrowserTitleName, titleFont );
String fromDate = dataBrowserFromDate;
if ( dataBrowserFromDate.length() == 0 )
{
- fromDate = "earliest";
+ fromDate = i18n.getString( "earliest" );
}
String toDate = dataBrowserToDate;
if ( dataBrowserToDate.length() == 0 )
{
- toDate = "latest";
+ toDate = i18n.getString( "latest" );
}
-
- Paragraph periodParagraph = new Paragraph( "From date: " + fromDate + " To date: " + toDate
- + " Period type: " + dataBrowserPeriodType, FontFactory.getFont( FontFactory.HELVETICA, 8,
- Font.NORMAL, Color.BLACK ) );
+
+ Paragraph periodParagraph = new Paragraph( i18n.getString( "from_date" ) + ": " + fromDate + " "
+ + i18n.getString( "to_date" ) + ": " + toDate + ", " + i18n.getString( "period_type" ) + ": "
+ + dataBrowserPeriodType, periodFont );
// DataBrowser table
PdfPTable table = new PdfPTable( dataBrowserTable.getColumns().size() );
table.setWidthPercentage( 100f );
table.setKeepTogether( false );
-
+
// Header row
for ( MetaValue col : dataBrowserTable.getColumns() )
{
// Convert to new date format
- String colName = DateUtils.convertDate( col.getName() );
+ String colName = i18n.getString( DateUtils.convertDate( col.getName() ) );
PdfPCell cell;
// Set font size for header cell
- if (fontSize == 4)
- {
- cell = new PdfPCell( getHeader7Cell( colName, 1 ) );
- }
- else if (fontSize == 6)
- {
- cell = new PdfPCell( getHeader6Cell( colName, 1 ) );
- }
- else // Default is 8
- {
- cell = new PdfPCell( getHeader5Cell( colName, 1 ) );
+ if ( fontSize == 4 )
+ {
+ cell = new PdfPCell( getHeader7Cell( colName, 1, header7Font ) );
+ }
+ else if ( fontSize == 6 )
+ {
+ cell = new PdfPCell( getHeader6Cell( colName, 1, header6Font ) );
+ }
+ else
+ // Default is 8
+ {
+ cell = new PdfPCell( getHeader5Cell( colName, 1, header5Font ) );
}
cell.setMinimumHeight( fontSize );
@@ -255,8 +283,9 @@
}
// Data rows
+ int i = 0;
Iterator<MetaValue> rowIt = dataBrowserTable.getRows().iterator();
- int i = 0;
+
for ( List<Integer> col : dataBrowserTable.getCounts() )
{
i = i + 1;
@@ -275,20 +304,21 @@
PdfPCell cell;
// Set font size for text cell
- if (fontSize == 4)
- {
- cell = new PdfPCell( getText7Cell( rowMeta.getName() ) );
- }
- else if (fontSize == 6)
- {
- cell = new PdfPCell( getText6Cell( rowMeta.getName() ) );
- }
- else // Default is 8
- {
- cell = new PdfPCell( getText5Cell( rowMeta.getName() ) );
- }
+ if ( fontSize == 4 )
+ {
+ cell = new PdfPCell( getText7Cell( rowMeta.getName(), text7Font ) );
+ }
+ else if ( fontSize == 6 )
+ {
+ cell = new PdfPCell( getText6Cell( rowMeta.getName(), text6Font ) );
+ }
+ else
+ // Default is 8
+ {
+ cell = new PdfPCell( getText5Cell( rowMeta.getName(), text5Font ) );
+ }
+
cell.setMinimumHeight( fontSize );
-
cell.setBorder( Rectangle.BOX );
cell.setBackgroundColor( color );
table.addCell( cell );
@@ -297,7 +327,7 @@
{
Phrase phrase = new Phrase( new Integer( rowItem ).toString(), FontFactory.getFont(
FontFactory.HELVETICA, fontSize, Font.NORMAL, Color.BLACK ) );
-
+
// Color zero values as bold red
if ( rowItem == 0 )
{
@@ -310,34 +340,35 @@
cell.setBackgroundColor( color );
table.addCell( cell );
}
-
+
// Set first row as header row. This will be repeated for each
// new page.
table.setHeaderRows( 1 );
}
-
+
// Add heading information
document.add( titleParagraph );
document.add( periodParagraph );
- document.add( new Paragraph(" ") ); // Paragraph break
-
+ document.add( new Paragraph( " " ) ); // Paragraph break
+
// Adjust column widths so that first column is a bit wider than the
// rest.
int numColumns = dataBrowserTable.getColumns().size();
float[] widths = new float[numColumns];
widths[0] = 2;
+
for ( i = 1; i < numColumns; i++ )
{
widths[i] = 1;
}
table.setWidths( widths );
-
+
// Add DataBrowser table
addTableToDocument( document, table );
PDFUtils.closeDocument( document );
-
- // Set final inputStream for Velocity
+
+ // Set final inputStream for Velocity
inputStream = new ByteArrayInputStream( baos.toByteArray() );
}
catch ( Exception ex )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java 2010-07-03 19:36:21 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -138,6 +139,17 @@
}
// -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
// Input / output
// -------------------------------------------------------------------------
@@ -525,7 +537,8 @@
*/
private void setExportPDFVariables()
{
- SessionUtils.setSessionVar( KEY_DATABROWSERTITLENAME, searchOption + " - " + getParentName() );
+ SessionUtils.setSessionVar( KEY_DATABROWSERTITLENAME, i18n.getString( searchOption )
+ + ((searchOption.equals( "OrganisationUnit" ) == true) ? " - " + getParentName() : "") );
SessionUtils.setSessionVar( KEY_DATABROWSERFROMDATE, fromDate );
SessionUtils.setSessionVar( KEY_DATABROWSERTODATE, toDate );
SessionUtils.setSessionVar( KEY_DATABROWSERPERIODTYPE, periodTypeId );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2010-07-03 19:36:21 +0000
@@ -187,7 +187,8 @@
prune_organisation_unit_confirmation = Are you sure you want to prune?
pruning = Pruning
pruning_done = Pruning done
-choose_period_type = Please choose period type
+browser = Browser
+drilldown_choose_period_type = Please choose period type
drilldown_formdate_invalid = Please enter a valid From date
drilldown_enddate_invalid = Please enter a valid End date
drilldown_fromdate_is_later_than_todate = Fromdate is later than todate
@@ -199,5 +200,14 @@
drilldown_orgunit_group = Organisation Unit Group
browse_data_at_this_level = Browser data at this level only
browse_data_at_descendant_levels = Browser data at descendant levels
-view_data_at_this_level = View data at this level
-view_data_at_descendant_levels = View data at descendant levels
\ No newline at end of file
+view_data_at_descendant_levels = View data
+view_data_at_this_level = View data at this level only
+click_on_this_orgunit = Click on this organisation unit
+counts_of_aggregated_values = Registered Values Count
+export_results_for = Export results for
+earliest = earliest
+latest = latest
+DataSet = Data Set
+DataElementGroup = Data Set Group
+OrganisationUnit = Organisation Unit
+OrganisationUnitGroup = Organisation Unit Group
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties 2010-07-02 09:29:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties 2010-07-03 19:36:21 +0000
@@ -81,7 +81,7 @@
query_took = Truy v\u1ea5n m\u1ea5t
number_of_queries_executed = S\u1ed1 l\u01b0\u1ee3ng c\u00e1c truy v\u1ea5n th\u1ef1c thi
no_data_found = Kh\u00f4ng t\u00ecm th\u1ea5y d\u1eef li\u1ec7u
-browse = Tr\u00ecnh duy\u1ec7t
+browse = Duy\u1ec7t d\u1eef li\u1ec7u
back = Quay v\u1ec1
select_period_type = Ch\u1ecdn ki\u1ec3u d\u1eef li\u1ec7u
data_integrity = To\u00e0n v\u1eb9n d\u1eef li\u1ec7u
@@ -213,4 +213,12 @@
browse_data_at_this_level = Duy\u1ec7t d\u1eef li\u1ec7u \u1edf c\u1ea5p \u0111\u1ed9 n\u00e0y
browse_data_at_descendant_levels = Duy\u1ec7t d\u1eef li\u1ec7u \u1edf c\u00e1c c\u1ea5p \u0111\u1ed9 h\u1eadu du\u1ec7
view_data_at_this_level = Xem d\u1eef li\u1ec7u th\u1ef1c c\u1ee7a \u0111\u01a1n v\u1ecb n\u00e0y
-view_data_at_descendant_levels = Xem d\u1eef li\u1ec7u chi\u1ec1u s\u00e2u c\u1ee7a c\u00e1c \u0111\u01a1n v\u1ecb con
\ No newline at end of file
+view_data_at_descendant_levels = Xem d\u1eef li\u1ec7u chi\u1ec1u s\u00e2u c\u1ee7a c\u00e1c \u0111\u01a1n v\u1ecb con
+counts_of_aggregated_values = \u0110\u1ebfm c\u00e1c d\u1eef li\u1ec7u nh\u1eadp
+export_results_for = K\u1ebft xu\u1ea5t cho
+earliest = s\u1edbm nh\u1ea5t
+latest = m\u1edbi nh\u1ea5t
+DataSet = T\u1eadp d\u1eef li\u1ec7u
+DataElementGroup = Nh\u00f3m ph\u1ea7n t\u1eed d\u1eef li\u1ec7u
+OrganisationUnit = \u0110\u01a1n v\u1ecb
+OrganisationUnitGroup = Nh\u00f3m \u0111\u01a1n v\u1ecb
\ No newline at end of file