=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java 2010-10-26 08:26:41 +0000 @@ -38,6 +38,7 @@ */ public class I18n { + String ID = I18n.class.getName(); private ResourceBundle globalResourceBundle; private ResourceBundle specificResourceBundle; === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java 2010-10-21 14:24:15 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java 2010-10-26 08:26:41 +0000 @@ -48,11 +48,11 @@ String writeReportTableData( OutputStream outputStream, int id, I18nFormat format ); - void writeAllDataElements( OutputStream outputStream ); - - void writeAllIndicators( OutputStream outputStream ); - - void writeAllOrganisationUnits( OutputStream outputStream ); + void writeAllDataElements( OutputStream outputStream, I18n i18n ); + + void writeAllIndicators( OutputStream outputStream, I18n i18n ); + + void writeAllOrganisationUnits( OutputStream outputStream, I18n i18n ); void writeDataSetCompletenessResult( Collection results, OutputStream out, I18n i18n, OrganisationUnit unit, DataSet dataSet ); === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java 2010-10-21 14:24:15 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java 2010-10-26 08:26:41 +0000 @@ -178,7 +178,7 @@ return data.getName(); } - public void writeAllDataElements( OutputStream outputStream ) + public void writeAllDataElements( OutputStream outputStream, I18n i18n ) { try { @@ -194,25 +194,25 @@ rowNumber++; - sheet.addCell( new Label( 0, rowNumber, "Alternative name", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "alternative_name" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, element.getAlternativeName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Short name", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "short_name" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, element.getShortName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Code", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "code" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, element.getCode(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Description", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "description" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, element.getDescription(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Active", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "active" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, getBoolean().get( element.isActive() ), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Type", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "type" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, getType().get( element.getType() ), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Aggregation operator", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "aggregation_operator" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, getAggregationOperator().get( element.getAggregationOperator() ), FORMAT_TEXT ) ); @@ -229,7 +229,7 @@ } } - public void writeAllIndicators( OutputStream outputStream ) + public void writeAllIndicators( OutputStream outputStream, I18n i18n ) { try { @@ -245,28 +245,28 @@ rowNumber++; - sheet.addCell( new Label( 0, rowNumber, "Alternative name", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "alternative_name" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getAlternativeName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Short name", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "short_name" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getShortName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Code", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "code" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getCode(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Description", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "description" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getDescription(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Annualized", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "annualized" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, getBoolean().get( indicator.getAnnualized() ), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Indicator type", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "indicator_type" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getIndicatorType().getName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Numerator description", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "numerator_description" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getNumeratorDescription(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Denominator description", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "denominator_description" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, indicator.getDenominatorDescription(), FORMAT_TEXT ) ); rowNumber++; @@ -282,7 +282,7 @@ } } - public void writeAllOrganisationUnits( OutputStream outputStream ) + public void writeAllOrganisationUnits( OutputStream outputStream, I18n i18n ) { try { @@ -298,19 +298,19 @@ rowNumber++; - sheet.addCell( new Label( 0, rowNumber, "Short name", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "short_name" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, unit.getShortName(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Code", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "code" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, unit.getCode(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Active", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "active" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, getBoolean().get( unit.isActive() ), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Comment", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "comment" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, unit.getComment(), FORMAT_TEXT ) ); - sheet.addCell( new Label( 0, rowNumber, "Geo code", FORMAT_LABEL ) ); + sheet.addCell( new Label( 0, rowNumber, i18n.getString( "geo_code" ), FORMAT_LABEL ) ); sheet.addCell( new Label( 1, rowNumber++, unit.getGeoCode(), FORMAT_TEXT ) ); rowNumber++; === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java 2010-10-25 12:38:03 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java 2010-10-26 08:26:41 +0000 @@ -32,7 +32,7 @@ import java.io.ByteArrayOutputStream; import java.io.OutputStream; -import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.DhisTest; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; @@ -48,7 +48,7 @@ * @author Hieu */ public class PdfServiceTest - extends DhisSpringTest + extends DhisTest { private PdfService pdfService; @@ -73,7 +73,7 @@ @Override public void setUpTest() { - i18n = new MockI18n(); + i18n = new MockI18n(); format = new MockI18nFormat(); @@ -100,6 +100,12 @@ organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'B' ) ); organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'C' ) ); } + + @Override + public boolean emptyDatabaseAfterTest() + { + return true; + } // ------------------------------------------------------------------------- // Tests === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/workbook/WorkbookServiceTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/workbook/WorkbookServiceTest.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/workbook/WorkbookServiceTest.java 2010-10-26 08:26:41 +0000 @@ -27,17 +27,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayOutputStream; import java.io.OutputStream; import org.hisp.dhis.DhisTest; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.indicator.IndicatorType; +import org.hisp.dhis.mock.MockI18n; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.system.util.StreamUtils; -import org.junit.Ignore; import org.junit.Test; /** @@ -48,13 +50,15 @@ extends DhisTest { private WorkbookService workbookService; - + private DataElementService dataElementService; - + private IndicatorService indicatorService; - + private OrganisationUnitService organisationUnitService; - + + private I18n i18n; + // ------------------------------------------------------------------------- // Fixture // ------------------------------------------------------------------------- @@ -62,67 +66,77 @@ @Override public void setUpTest() { + i18n = new MockI18n(); workbookService = (WorkbookService) getBean( WorkbookService.ID ); - + dataElementService = (DataElementService) getBean( DataElementService.ID ); - + indicatorService = (IndicatorService) getBean( IndicatorService.ID ); - + organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID ); - + dataElementService.addDataElement( createDataElement( 'A' ) ); dataElementService.addDataElement( createDataElement( 'B' ) ); dataElementService.addDataElement( createDataElement( 'C' ) ); - + IndicatorType indicatorType = createIndicatorType( 'A' ); indicatorService.addIndicatorType( indicatorType ); - + indicatorService.addIndicator( createIndicator( 'A', indicatorType ) ); indicatorService.addIndicator( createIndicator( 'B', indicatorType ) ); indicatorService.addIndicator( createIndicator( 'C', indicatorType ) ); - + organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'A' ) ); organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'B' ) ); - organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'C' ) ); + organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'C' ) ); + } + + @Override + public boolean emptyDatabaseAfterTest() + { + return true; } // ------------------------------------------------------------------------- // Tests // ------------------------------------------------------------------------- - - @Ignore + @Test public void testWriteAllDataElements() throws Exception - { - OutputStream outputStream = new BufferedOutputStream( new FileOutputStream( "dataElementsTest.xls" ) ); - - workbookService.writeAllDataElements( outputStream ); - + { + OutputStream outputStream = new ByteArrayOutputStream(); + + workbookService.writeAllDataElements( outputStream, i18n ); + + assertNotNull( outputStream ); + StreamUtils.closeOutputStream( outputStream ); } - @Ignore @Test public void testWriteAllIndicators() throws Exception - { - OutputStream outputStream = new BufferedOutputStream( new FileOutputStream( "indicatorsTest.xls" ) ); - - workbookService.writeAllIndicators( outputStream ); - + { + OutputStream outputStream = new ByteArrayOutputStream(); + + workbookService.writeAllIndicators( outputStream, i18n ); + + assertNotNull( outputStream ); + StreamUtils.closeOutputStream( outputStream ); } - @Ignore @Test public void testWriteAllOrganisationUnits() throws Exception { - OutputStream outputStream = new BufferedOutputStream( new FileOutputStream( "organisationUnitsTest.xls" ) ); - - workbookService.writeAllOrganisationUnits( outputStream ); - + OutputStream outputStream = new ByteArrayOutputStream(); + + workbookService.writeAllOrganisationUnits( outputStream, i18n ); + + assertNotNull( outputStream ); + StreamUtils.closeOutputStream( outputStream ); } } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2010-10-25 12:38:03 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2010-10-26 08:26:41 +0000 @@ -39,7 +39,7 @@ cannot_clear_selected_orgunits = Kh\u00f4ng th\u1ec3 x\u00f3a c\u00e1c \u0111\u01a1n v\u1ecb \u0111\u01b0\u1ee3c ch\u1ecdn tr\u01b0\u1edbc \u0111\u00f3 error_occurred = L\u1ed7i trong qu\u00e1 tr\u00ecnh duy\u1ec7t d\u1eef li\u1ec7u. select_organisationunit = Vui l\u00f2ng ch\u1ecdn m\u1ed9t \u0111\u01a1n v\u1ecb trong c\u00e2y \u0111\u01a1n v\u1ecb. - +geo_code = Geo Code #-- Modules -------------------------------------------------------------------# dhis-web-maintenance-datadictionary = Ph\u1ea7n t\u1eed d\u1eef li\u1ec7u & Ch\u1ec9 s\u1ed1 @@ -384,4 +384,4 @@ numerator_formula = C\u00f4ng th\u1ee9c t\u1eed s\u1ed1 denominator_formula = C\u00f4ng th\u1ee9c m\u1eabu s\u1ed1 numerator_aggregation_operator = Ki\u1ec3u s\u1ed1 li\u1ec7u t\u1ed5ng h\u1ee3p cho t\u1eed s\u1ed1 -denominator_aggregation_operator = Ki\u1ec3u s\u1ed1 li\u1ec7u t\u1ed5ng h\u1ee3p cho m\u1eabu s\u1ed1 \ No newline at end of file +denominator_aggregation_operator = Ki\u1ec3u s\u1ed1 li\u1ec7u t\u1ed5ng h\u1ee3p cho m\u1eabu s\u1ed1