← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2080: Increase unit test - DataBrowserServiceTest

 

------------------------------------------------------------
revno: 2080
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-09-08 12:46:03 +0700
message:
  Increase unit test - DataBrowserServiceTest
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserStore.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/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-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/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm


--
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-04-14 09:23:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserService.java	2010-09-08 05:46:03 +0000
@@ -85,10 +85,12 @@
      * @param startDate the start date
      * @param endDate the end date
      * @param periodType the period type
+     * @param maxLevel is the max level of the hierarchy
      * @return DataBrowserTable the DataBrowserTable with structure for
      *         presentation
      */
-    DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String startDate, String endDate, PeriodType periodType );
+    DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String startDate, String endDate,
+        PeriodType periodType, Integer maxLevel );
 
     /**
      * Method that retrieves - all the DataElements count - in a given period -

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserStore.java	2009-08-24 13:55:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserStore.java	2010-09-08 05:46:03 +0000
@@ -187,10 +187,11 @@
      * @param table the DataBrowserTable to insert column into
      * @param orgUnitParent the OrganisationUnit parent id
      * @param betweenPeriodIds list of Period ids
+     * @param maxLevel is the max level of the hierarchy
      * @return 0 if no results are found else number of rows inserted
      */
     Integer setCountOrgUnitsBetweenPeriods( DataBrowserTable table, Integer orgUnitParent,
-        List<Integer> betweenPeriodIds );
+        List<Integer> betweenPeriodIds, Integer maxLevel );
 
     /**
      * Sets DataElement count-Columns in DataBrowserTable for betweenPeriod List

=== 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-18 15:17:23 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java	2010-09-08 05:46:03 +0000
@@ -130,7 +130,7 @@
     }
 
     public DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String startDate, String endDate,
-        PeriodType periodType )
+        PeriodType periodType, Integer maxLevel )
     {
         if ( startDate == null || startDate.length() == 0 )
         {
@@ -146,7 +146,8 @@
 
         dataBrowserStore.setStructureForOrgUnitBetweenPeriods( table, orgUnitParent, betweenPeriodIds );
 
-        Integer numResults = dataBrowserStore.setCountOrgUnitsBetweenPeriods( table, orgUnitParent, betweenPeriodIds );
+        Integer numResults = dataBrowserStore.setCountOrgUnitsBetweenPeriods( table, orgUnitParent, betweenPeriodIds,
+            maxLevel );
 
         if ( numResults == 0 )
         {

=== 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-09-01 09:34:51 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java	2010-09-08 05:46:03 +0000
@@ -528,7 +528,7 @@
     }
 
     public Integer setCountOrgUnitsBetweenPeriods( DataBrowserTable table, Integer orgUnitParent,
-        List<Integer> betweenPeriodIds )
+        List<Integer> betweenPeriodIds, Integer maxLevel )
     {
         StatementHolder holder = statementManager.getHolder();
 
@@ -538,7 +538,9 @@
         dropView( "view_count_descentdants" );
 
         sqlsbDescentdants.append( "CREATE VIEW view_count_descentdants AS " );
-        setUpQueryForDrillDownDescendants( sqlsbDescentdants, orgUnitParent, betweenPeriodIds );
+        setUpQueryForDrillDownDescendants( sqlsbDescentdants, orgUnitParent, betweenPeriodIds, maxLevel );
+
+        table.incrementQueryCount();
 
         try
         {
@@ -667,13 +669,17 @@
     }
 
     private void setUpQueryForDrillDownDescendants( StringBuffer sb, Integer orgUnitSelected,
-        List<Integer> betweenPeriodIds )
+        List<Integer> betweenPeriodIds, Integer maxLevel )
     {
+        if ( maxLevel == null )
+        {
+            maxLevel = new Integer( organisationUnitService.getNumberOfOrganisationalLevels() );
+        }
+
         int i = 0;
         int loopSize = betweenPeriodIds.size();
         int curLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnitSelected );
-        int maxLevel = organisationUnitService.getNumberOfOrganisationalLevels();
-        int diffLevel = maxLevel - curLevel;
+        int diffLevel = maxLevel.intValue() - curLevel;
         String orgIndex = this.getTableIndexByDiffLevel( diffLevel );
 
         for ( Integer periodid : betweenPeriodIds )

=== 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-03 19:36:21 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java	2010-09-08 05:46:03 +0000
@@ -218,16 +218,15 @@
      * startDate, String endDate, PeriodType periodType );
      */
     @Test
-    @Ignore // Will be fixed by Hieu
     public void testGetOrgUnitsInPeriod()
     {
         // 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() );
+            periodA.getPeriodType(), 4 );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
-        assertEquals( "No. of queries", 2, table.getQueryCount() );
+        assertEquals( "No. of queries", 3, table.getQueryCount() );
         assertNotSame( "Querytime more than 0", 0, table.getQueryTime() );
 
         assertEquals( "Metacolumns", 3, table.getColumns().size() );
@@ -259,17 +258,16 @@
             .intValue() );
 
         // Retrieve children of unitG - zero children
-        table = dataBrowserService.getOrgUnitsInPeriod( unitG.getId(), null, null, periodA.getPeriodType() );
+        table = dataBrowserService.getOrgUnitsInPeriod( unitG.getId(), null, null, periodA.getPeriodType(), 4 );
 
         assertNotNull( "DataBrowserTable not supposed to be null", table );
-        assertEquals( "No. of queries", 2, table.getQueryCount() );
+        assertEquals( "No. of queries", 3, table.getQueryCount() );
         assertNotSame( "Querytime more than 0", 0, table.getQueryTime() );
 
         assertEquals( "Metacolumns", 2, table.getColumns().size() );
         assertEquals( "drilldown_organisation_unit", table.getColumns().get( 0 ).getName() );
+        assertEquals( "counts_of_aggregated_values", table.getColumns().get( 1 ).getName() );
         // Service layer adds "zero-column"
-        assertEquals( "counts_of_aggregated_values", table.getColumns().get( 1 ).getName() );
-
         assertEquals( "Metarows", 0, table.getRows().size() );
     }
 
@@ -515,6 +513,7 @@
      * format );
      */
     @Test
+    @Ignore
     public void testConvertDate()
     {
         // To do
@@ -525,6 +524,7 @@
      * String toDate, I18nFormat format );
      */
     @Test
+    @Ignore
     public void getFromToDateFormat()
     {
         // To do

=== 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-07 07:47:42 +0000
+++ 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
@@ -500,7 +500,7 @@
             else if ( selectedUnit != null )
             {
                 dataBrowserTable = dataBrowserService.getOrgUnitsInPeriod( selectedUnit.getId(), fromDate, toDate,
-                    periodType );
+                    periodType, null );
             }
             else
             {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm	2010-09-07 07:47:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm	2010-09-08 05:46:03 +0000
@@ -14,8 +14,7 @@
 
 </style>
 
-
-<h3>$i18n.getString( "search_results_for" ) $searchOption #if ($!parentName) - $!parentName #end</h3>
+<h3>$i18n.getString( "search_results_for" ) $searchOption #if ($parentName != "") - $parentName #end</h3>
 
     <span id="info">
     	$i18n.getString( "request_returned_in" ): ${requestTime} $i18n.getString( "ms" ).