← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5547: Chart, minor fix

 

------------------------------------------------------------
revno: 5547
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-22 16:07:07 +0100
message:
  Chart, minor fix
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/tallysheet/TallySheetServiceTest.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-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-12-22 13:59:37 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-12-22 15:07:07 +0000
@@ -27,11 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.chart.Chart.TYPE_AREA;
 import static org.hisp.dhis.chart.Chart.TYPE_BAR;
+import static org.hisp.dhis.chart.Chart.TYPE_COLUMN;
 import static org.hisp.dhis.chart.Chart.TYPE_LINE;
 import static org.hisp.dhis.chart.Chart.TYPE_PIE;
 import static org.hisp.dhis.chart.Chart.TYPE_STACKED_BAR;
-import static org.hisp.dhis.chart.Chart.*;
+import static org.hisp.dhis.chart.Chart.TYPE_STACKED_COLUMN;
 import static org.hisp.dhis.reporttable.ReportTable.getIdentifier;
 import static org.hisp.dhis.system.util.ConversionUtils.getArray;
 
@@ -743,13 +745,13 @@
         
         SimpleRegression regression = new SimpleRegression();
         
-        double count = 0;
-        
         for ( NameableObject series : chart.series() )
         {
+            double categoryIndex = 0;
+            
             for ( NameableObject category : chart.category() )
-            {
-                count++;
+            {   
+                categoryIndex++;
                 
                 String key = getIdentifier( Arrays.asList( series, category, chart.filter() ) );
                 
@@ -757,25 +759,22 @@
                 
                 regularDataSet.addValue( value, series.getShortName(), category.getShortName() );
                 
-                if ( chart.isRegression() && MathUtils.isEqual( value, MathUtils.ZERO ) )
+                if ( chart.isRegression() && !MathUtils.isEqual( value, MathUtils.ZERO ) )
                 {
-                    regression.addData( ++count, value );
+                    regression.addData( categoryIndex, value );
                 }
             }
-        }
-        
-        if ( chart.isRegression() ) // Period must be category
-        {
-            count = 0;
             
-            for ( NameableObject series : chart.series() )
+            if ( chart.isRegression() ) // Period must be category
             {
+                categoryIndex = 0;
+                
                 for ( NameableObject category : chart.category() )
                 {
-                    final double value = regression.predict( count++ );
+                    final double value = regression.predict( categoryIndex++ );
 
                     // Enough values must exist for regression
-
+                    
                     if ( !Double.isNaN( value ) )
                     {
                         regressionDataSet.addValue( value, TREND_PREFIX + series.getShortName(), category.getShortName() );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2011-12-21 14:03:20 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2011-12-22 15:07:07 +0000
@@ -27,14 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.common.GenericStore;
 import org.hisp.dhis.dashboard.DashboardContent;
 import org.hisp.dhis.dashboard.DashboardService;
 import org.hisp.dhis.user.User;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2011-12-10 23:03:56 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/document/impl/DefaultDocumentService.java	2011-12-22 15:07:07 +0000
@@ -27,13 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java	2011-12-19 19:45:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java	2011-12-22 15:07:07 +0000
@@ -27,10 +27,19 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.OutputStream;
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import net.sf.jasperreports.engine.JasperCompileManager;
 import net.sf.jasperreports.engine.JasperFillManager;
 import net.sf.jasperreports.engine.JasperPrint;
 import net.sf.jasperreports.engine.JasperReport;
+
 import org.amplecode.quick.StatementManager;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.common.Grid;
@@ -50,10 +59,6 @@
 import org.hisp.dhis.system.util.StreamUtils;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.OutputStream;
-import java.sql.Connection;
-import java.util.*;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-12-14 11:29:43 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-12-22 15:07:07 +0000
@@ -27,10 +27,34 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.reporttable.ReportTable.ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.PARAM_ORGANISATIONUNIT_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.PRETTY_COLUMNS;
+import static org.hisp.dhis.reporttable.ReportTable.REPORTING_MONTH_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.SPACE;
+import static org.hisp.dhis.reporttable.ReportTable.TOTAL_COLUMN_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.TOTAL_COLUMN_PRETTY_NAME;
+import static org.hisp.dhis.reporttable.ReportTable.columnEncode;
+import static org.hisp.dhis.reporttable.ReportTable.getColumnName;
+import static org.hisp.dhis.reporttable.ReportTable.getIdentifier;
+import static org.hisp.dhis.reporttable.ReportTable.getPrettyColumnName;
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.*;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.GridHeader;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.completeness.DataSetCompletenessService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
@@ -52,11 +76,6 @@
 import org.hisp.dhis.system.util.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
-
-import static org.hisp.dhis.reporttable.ReportTable.*;
-import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java	2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/document/DocumentServiceTest.java	2011-12-22 15:07:07 +0000
@@ -27,13 +27,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
 import java.util.Collection;
 
 import org.hisp.dhis.DhisSpringTest;
 import org.junit.Test;
 
-import static junit.framework.Assert.*;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java	2011-09-08 15:47:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java	2011-12-22 15:07:07 +0000
@@ -1,5 +1,8 @@
 package org.hisp.dhis.orgunitdistribution;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -9,8 +12,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.junit.Test;
 
-import static junit.framework.Assert.*;
-
 public class OrgUnitDistributionServiceTest
     extends DhisSpringTest
 {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java	2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java	2011-12-22 15:07:07 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -68,8 +70,6 @@
 import org.hisp.dhis.period.RelativePeriods;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 /**
  * @author Lars Helge Overland
  */

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/tallysheet/TallySheetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/tallysheet/TallySheetServiceTest.java	2010-12-25 16:43:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/tallysheet/TallySheetServiceTest.java	2011-12-22 15:07:07 +0000
@@ -36,9 +36,6 @@
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.tallysheet.TallySheet;
-import org.hisp.dhis.tallysheet.TallySheetPdfService;
-import org.hisp.dhis.tallysheet.TallySheetService;
 import org.junit.Test;
 
 /**