← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2088: Applied I18nFormat for parsing the given date instead of using default date format

 

------------------------------------------------------------
revno: 2088
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2010-11-17 13:42:38 +0700
message:
  Applied I18nFormat for parsing the given date instead of using default date format
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java
  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/DataBrowserTest.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18nFormat.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.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-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java	2010-09-08 05:46:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java	2010-11-17 06:42:38 +0000
@@ -51,7 +51,7 @@
      * @return DataBrowserTable the DataBrowserTable with structure for
      *         presentation
      */
-    DataBrowserTable getDataSetsInPeriod( String startDate, String endDate, PeriodType periodType );
+    DataBrowserTable getDataSetsInPeriod( String startDate, String endDate, PeriodType periodType, I18nFormat format );
 
     /**
      * Method that retrieves - all DataElementGroups with DataElement quantity -
@@ -63,7 +63,7 @@
      * @return DataBrowserTable the DataBrowserTable with structure for
      *         presentation
      */
-    DataBrowserTable getDataElementGroupsInPeriod( String startDate, String endDate, PeriodType periodType );
+    DataBrowserTable getDataElementGroupsInPeriod( String startDate, String endDate, PeriodType periodType, I18nFormat format );
 
     /**
      * Method that retrieves - all OrganisationUnitGroups with DataElement
@@ -75,7 +75,7 @@
      * @return DataBrowserTable the DataBrowserTable with structure for
      *         presentation
      */
-    DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String endDate, PeriodType periodType );
+    DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String endDate, PeriodType periodType, I18nFormat format );
 
     /**
      * Method that retrieves - all OrganisationUnits with DataElement quantity -
@@ -90,7 +90,7 @@
      *         presentation
      */
     DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String startDate, String endDate,
-        PeriodType periodType, Integer maxLevel );
+        PeriodType periodType, Integer maxLevel, I18nFormat format );
 
     /**
      * Method that retrieves - all the DataElements count - in a given period -
@@ -104,7 +104,7 @@
      *         presentation
      */
     DataBrowserTable getCountDataElementsForDataSetInPeriod( Integer dataSetId, String startDate, String endDate,
-        PeriodType periodType );
+        PeriodType periodType, I18nFormat format );
 
     /**
      * Method that retrieves - all the DataElements count - in a given period -
@@ -119,7 +119,7 @@
      *         presentation
      */
     DataBrowserTable getCountDataElementsForDataElementGroupInPeriod( Integer dataElementGroupId, String startDate,
-        String endDate, PeriodType periodType );
+        String endDate, PeriodType periodType, I18nFormat format );
 
     /**
      * Method retrieves - all the DataElementGroups count - in a given period -
@@ -134,7 +134,7 @@
      *         presentation
      */
     DataBrowserTable getCountDataElementGroupsForOrgUnitGroupInPeriod( Integer orgUnitGroupId, String startDate,
-        String endDate, PeriodType periodType );
+        String endDate, PeriodType periodType, I18nFormat format );
 
     /**
      * Method that retrieves - all the DataElements count - in a given period -
@@ -149,7 +149,7 @@
      *         presentation
      */
     DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer orgUnitId, String startDate, String endDate,
-        PeriodType periodType );
+        PeriodType periodType, I18nFormat format );
 
     /**
      * This method converts a string from the date format "yyyy-MM-dd" to "MMMM

=== 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-09-08 05:46:03 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java	2010-11-17 06:42:38 +0000
@@ -81,67 +81,39 @@
     // DataBrowserService implementation
     // -------------------------------------------------------------------------
 
-    public DataBrowserTable getDataSetsInPeriod( String startDate, String endDate, PeriodType periodType )
+    public DataBrowserTable getDataSetsInPeriod( String startDate, String endDate, PeriodType periodType,
+        I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
-
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
         return dataBrowserStore.getDataSetsBetweenPeriods( betweenPeriodIds );
     }
 
-    public DataBrowserTable getDataElementGroupsInPeriod( String startDate, String endDate, PeriodType periodType )
+    public DataBrowserTable getDataElementGroupsInPeriod( String startDate, String endDate, PeriodType periodType,
+        I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
-
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
         return dataBrowserStore.getDataElementGroupsBetweenPeriods( betweenPeriodIds );
     }
 
-    public DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String endDate, PeriodType periodType )
+    public DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String endDate, PeriodType periodType,
+        I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
-
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
         return dataBrowserStore.getOrgUnitGroupsBetweenPeriods( betweenPeriodIds );
     }
 
     public DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String startDate, String endDate,
-        PeriodType periodType, Integer maxLevel )
+        PeriodType periodType, Integer maxLevel, I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
         DataBrowserTable table = new DataBrowserTable();
 
         dataBrowserStore.setStructureForOrgUnitBetweenPeriods( table, orgUnitParent, betweenPeriodIds );
@@ -158,18 +130,11 @@
     }
 
     public DataBrowserTable getCountDataElementsForDataSetInPeriod( Integer dataSetId, String startDate,
-        String endDate, PeriodType periodType )
+        String endDate, PeriodType periodType, I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
         DataBrowserTable table = new DataBrowserTable();
 
         dataBrowserStore.setDataElementStructureForDataSetBetweenPeriods( table, dataSetId, betweenPeriodIds );
@@ -180,18 +145,11 @@
     }
 
     public DataBrowserTable getCountDataElementsForDataElementGroupInPeriod( Integer dataElementGroupId,
-        String startDate, String endDate, PeriodType periodType )
+        String startDate, String endDate, PeriodType periodType, I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
         DataBrowserTable table = new DataBrowserTable();
 
         dataBrowserStore.setDataElementStructureForDataElementGroupBetweenPeriods( table, dataElementGroupId,
@@ -204,18 +162,10 @@
     }
 
     public DataBrowserTable getCountDataElementGroupsForOrgUnitGroupInPeriod( Integer orgUnitGroupId, String startDate,
-        String endDate, PeriodType periodType )
+        String endDate, PeriodType periodType, I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
-
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
         DataBrowserTable table = new DataBrowserTable();
 
@@ -229,20 +179,12 @@
     }
 
     public DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer orgUnitGroupId, String startDate,
-        String endDate, PeriodType periodType )
+        String endDate, PeriodType periodType, I18nFormat format )
     {
-        if ( startDate == null || startDate.length() == 0 )
-        {
-            startDate = STARTDATE;
-        }
-        if ( endDate == null || endDate.length() == 0 )
-        {
-            endDate = ENDDATE;
-        }
-
         DataBrowserTable table = new DataBrowserTable();
 
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
+            format );
 
         dataBrowserStore.setDataElementStructureForOrgUnitBetweenPeriods( table, orgUnitGroupId, betweenPeriodIds );
 
@@ -314,26 +256,27 @@
      * @param endDate
      * @param periodType
      * @return List<Integer>
-     */
+     */    
     private List<Integer> getAllPeriodIdsBetweenDatesOnPeriodType( String startDate, String endDate,
-        PeriodType periodType )
+        PeriodType periodType, I18nFormat i18nFormat )
     {
-        String formatString = Period.DEFAULT_DATE_FORMAT;
-        SimpleDateFormat sdf = new SimpleDateFormat( formatString );
+        if ( startDate == null || startDate.length() == 0 )
+        {
+            startDate = STARTDATE;
+        }
+        if ( endDate == null || endDate.length() == 0 )
+        {
+            endDate = ENDDATE;
+        }
+
         Date date1 = new Date();
         Date date2 = new Date();
 
-        try
-        {
-            date1 = sdf.parse( startDate );
-            date2 = sdf.parse( endDate );
-        }
-        catch ( ParseException e )
-        {
-            e.printStackTrace();
-        }
+        date1 = i18nFormat.parseDate( startDate );
+        date2 = i18nFormat.parseDate( endDate );
 
         Collection<Period> pp = periodService.getPeriodsBetweenDates( periodType, date1, date2 );
+
         Iterator<Period> it = pp.iterator();
         List<Integer> betweenPeriodIds = new ArrayList<Integer>();
 

=== 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-09-16 11:36:24 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java	2010-11-17 06:42:38 +0000
@@ -31,7 +31,6 @@
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNotSame;
 
-import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
@@ -74,7 +73,8 @@
     {
         // Get all DataSets from earliest to latest registered on daily basis
         // (this should be period A and B data values)
-        DataBrowserTable table = dataBrowserService.getDataSetsInPeriod( null, null, periodA.getPeriodType() );
+        DataBrowserTable table = dataBrowserService.getDataSetsInPeriod( null, null, periodA.getPeriodType(),
+            mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 1, table.getQueryCount() );
@@ -102,7 +102,8 @@
 
         // Get all DataSets from 2005-05-01 to 2005-05-31 registered on weekly
         // basis (this should be only period D data values)
-        table = dataBrowserService.getDataSetsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType() );
+        table = dataBrowserService
+            .getDataSetsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 1, table.getQueryCount() );
@@ -130,7 +131,8 @@
     {
         // Get all DataElementGroups from earliest to latest registered on daily
         // basis (this should be period A and B data values)
-        DataBrowserTable table = dataBrowserService.getDataElementGroupsInPeriod( null, null, periodA.getPeriodType() );
+        DataBrowserTable table = dataBrowserService.getDataElementGroupsInPeriod( null, null, periodA.getPeriodType(),
+            mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 1, table.getQueryCount() );
@@ -159,7 +161,8 @@
 
         // Get all DataElementGroups from 2005-05-01 to 2005-05-31 registered on
         // weekly basis (this should be only period D data values)
-        table = dataBrowserService.getDataElementGroupsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType() );
+        table = dataBrowserService.getDataElementGroupsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType(),
+            mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 1, table.getQueryCount() );
@@ -189,7 +192,8 @@
         // Get all OrganisationUnitGroups from earliest to latest registered on
         // daily
         // basis (this should be period A and B data values)
-        DataBrowserTable table = dataBrowserService.getOrgUnitGroupsInPeriod( null, null, periodA.getPeriodType() );
+        DataBrowserTable table = dataBrowserService.getOrgUnitGroupsInPeriod( null, null, periodA.getPeriodType(),
+            mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 1, table.getQueryCount() );
@@ -227,7 +231,7 @@
         // Get all children of unit B from 2005-03-01 to 2005-04-30 registered
         // on daily basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getOrgUnitsInPeriod( unitB.getId(), "2005-03-01", "2005-04-30",
-            periodA.getPeriodType(), 4 );
+            periodA.getPeriodType(), 4, mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 3, table.getQueryCount() );
@@ -262,7 +266,8 @@
             .intValue() );
 
         // Retrieve children of unitG - zero children
-        table = dataBrowserService.getOrgUnitsInPeriod( unitG.getId(), null, null, periodA.getPeriodType(), 4 );
+        table = dataBrowserService.getOrgUnitsInPeriod( unitG.getId(), null, null, periodA.getPeriodType(), 4,
+            mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 3, table.getQueryCount() );
@@ -285,7 +290,7 @@
         // Get count for dataSetA from 2005-03-01 to 2005-04-30 registered on
         // daily basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getCountDataElementsForDataSetInPeriod( dataSetA.getId(),
-            "2005-03-01", "2005-04-30", periodA.getPeriodType() );
+            "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -308,7 +313,7 @@
         // Get count for dataSetC from 2005-05-01 to 2005-05-31 registered on
         // weekly basis (this should be only period D data values)
         table = dataBrowserService.getCountDataElementsForDataSetInPeriod( dataSetC.getId(), "2005-05-01",
-            "2005-05-31", periodD.getPeriodType() );
+            "2005-05-31", periodD.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -343,7 +348,7 @@
         // Get count for dataElementGroupA from 2005-03-01 to 2005-04-30
         // registered on daily basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getCountDataElementsForDataElementGroupInPeriod( dataElementGroupA
-            .getId(), "2005-03-01", "2005-04-30", periodA.getPeriodType() );
+            .getId(), "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -366,7 +371,7 @@
         // Get count for dataElementGroupC from 2005-05-01 to 2005-05-31
         // registered on weekly basis (this should be only period D data values)
         table = dataBrowserService.getCountDataElementsForDataElementGroupInPeriod( dataElementGroupC.getId(),
-            "2005-05-01", "2005-05-31", periodD.getPeriodType() );
+            "2005-05-01", "2005-05-31", periodD.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -402,7 +407,7 @@
         // daily
         // basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getCountDataElementGroupsForOrgUnitGroupInPeriod( unitGroupA
-            .getId(), "2005-03-01", "2005-04-30", periodA.getPeriodType() );
+            .getId(), "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -450,7 +455,7 @@
         // Get count for unitB from 2005-03-01 to 2005-04-30 registered on daily
         // basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getCountDataElementsForOrgUnitInPeriod( unitB.getId(),
-            "2005-03-01", "2005-04-30", periodA.getPeriodType() );
+            "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -469,7 +474,7 @@
         // Get count for unitF from 2005-03-01 to 2005-04-30 registered on daily
         // basis (this should be period A and B data values)
         table = dataBrowserService.getCountDataElementsForOrgUnitInPeriod( unitF.getId(), "2005-03-01", "2005-04-30",
-            periodA.getPeriodType() );
+            periodA.getPeriodType(), mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 2, table.getQueryCount() );
@@ -520,13 +525,12 @@
     @Ignore
     public void testConvertDate()
     {
-        I18nFormat format = new I18nFormat();
         PeriodType monthlyPeriodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
 
         // Get all children of unit B from 2005-03-01 to 2005-04-30 registered
         // on monthly basis (this should be period A and B data values)
         DataBrowserTable table = dataBrowserService.getOrgUnitsInPeriod( unitB.getId(), "2005-03-01", "2005-04-30",
-            periodA.getPeriodType(), 4 );
+            periodA.getPeriodType(), 4, mockFormat );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
         assertEquals( "No. of queries", 3, table.getQueryCount() );
@@ -534,6 +538,6 @@
 
         assertEquals( "Metacolumns", 3, table.getColumns().size() );
         assertEquals( "drilldown_organisation_unit", dataBrowserService.convertDate( monthlyPeriodType, table
-            .getColumns().get( 0 ).getName(), format ) );
+            .getColumns().get( 0 ).getName(), mockFormat ) );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java	2010-06-08 19:47:40 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java	2010-11-17 06:42:38 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.mock.MockI18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -106,10 +107,14 @@
     
     protected OrganisationUnitGroup unitGroupA;
     protected OrganisationUnitGroup unitGroupB;
+    
+    protected MockI18nFormat mockFormat; 
 
     public void setUpDataBrowserTest()
         throws Exception
     {
+        mockFormat = new MockI18nFormat();
+        
         categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );
 
         dataSetService = (DataSetService) getBean( DataSetService.ID );

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18nFormat.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18nFormat.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18nFormat.java	2010-11-17 06:42:38 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.period.Period.DEFAULT_DATE_FORMAT;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Random;
 
@@ -53,4 +57,21 @@
         Random random = new Random();
         return "Date" + random.nextInt( 1000 );
     }
+    
+    @Override
+    public Date parseDate( String dateString )
+    {
+        try
+        {
+            final SimpleDateFormat format = new SimpleDateFormat();
+
+            format.applyPattern( DEFAULT_DATE_FORMAT );
+
+            return dateString != null ? format.parse( dateString ) : null;
+        }
+        catch ( ParseException ex )
+        {
+            throw new RuntimeException( "Failed to parse medium date", 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-09-08 05:46:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java	2010-11-17 06:42:38 +0000
@@ -440,13 +440,13 @@
                 Integer parentInt = Integer.parseInt( parent );
 
                 dataBrowserTable = dataBrowserService.getCountDataElementsForDataSetInPeriod( parentInt, fromDate,
-                    toDate, periodType );
+                    toDate, periodType, format );
 
             }
             else
             {
                 // Get all DataSets
-                dataBrowserTable = dataBrowserService.getDataSetsInPeriod( fromDate, toDate, periodType );
+                dataBrowserTable = dataBrowserService.getDataSetsInPeriod( fromDate, toDate, periodType, format );
             }
         }
         else if ( searchOption.equals( "OrganisationUnitGroup" ) )
@@ -456,11 +456,11 @@
                 // Show DataElementGroups
                 Integer parentInt = Integer.parseInt( parent );
                 dataBrowserTable = dataBrowserService.getCountDataElementGroupsForOrgUnitGroupInPeriod( parentInt,
-                    fromDate, toDate, periodType );
+                    fromDate, toDate, periodType, format );
             }
             else
             {
-                dataBrowserTable = dataBrowserService.getOrgUnitGroupsInPeriod( fromDate, toDate, periodType );
+                dataBrowserTable = dataBrowserService.getOrgUnitGroupsInPeriod( fromDate, toDate, periodType, format );
             }
         }
         else if ( searchOption.equals( "DataElementGroup" ) )
@@ -472,11 +472,12 @@
                 Integer parentInt = Integer.parseInt( parent );
 
                 dataBrowserTable = dataBrowserService.getCountDataElementsForDataElementGroupInPeriod( parentInt,
-                    fromDate, toDate, periodType );
+                    fromDate, toDate, periodType, format );
             }
             else
             {
-                dataBrowserTable = dataBrowserService.getDataElementGroupsInPeriod( fromDate, toDate, periodType );
+                dataBrowserTable = dataBrowserService.getDataElementGroupsInPeriod( fromDate, toDate, periodType,
+                    format );
             }
         }
         else if ( searchOption.equals( "OrganisationUnit" ) )
@@ -495,12 +496,12 @@
 
                 // Show DataElement values only for specified organization unit
                 dataBrowserTable = dataBrowserService.getCountDataElementsForOrgUnitInPeriod( parentInt, fromDate,
-                    toDate, periodType );
+                    toDate, periodType, format );
             }
             else if ( selectedUnit != null )
             {
                 dataBrowserTable = dataBrowserService.getOrgUnitsInPeriod( selectedUnit.getId(), fromDate, toDate,
-                    periodType, null );
+                    periodType, null, format );
             }
             else
             {