← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2947: Merging changes from 2.0.6

 

------------------------------------------------------------
revno: 2947
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-03-01 15:09:28 +0530
message:
  Merging changes from 2.0.6
modified:
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/DashBoardHomePageAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/GetOrgUnitNameAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateSummaryDataStatusResultAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/GenerateGraphicalAnalyserDataElementsFormAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataElementAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ta/action/GenerateTabularAnalysisResultAction.java
  local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.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 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/DashBoardHomePageAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/DashBoardHomePageAction.java	2010-12-08 07:24:10 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/DashBoardHomePageAction.java	2011-03-01 09:39:28 +0000
@@ -115,7 +115,7 @@
     {
         statementManager.initialise();
         
-        clearCache();
+        //clearCache();
         
         resultString = "";
         //getIndicatorValues();

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/GetOrgUnitNameAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/GetOrgUnitNameAction.java	2011-01-13 09:39:35 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/action/GetOrgUnitNameAction.java	2011-03-01 09:39:28 +0000
@@ -22,12 +22,6 @@
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
-    private String selectedOrgUnitId;
-    
-    public void setSelectedOrgUnitId( String selectedOrgUnitId )
-    {
-        this.selectedOrgUnitId = selectedOrgUnitId;
-    }
     
     private Integer id;
 
@@ -48,12 +42,8 @@
 
     public String execute()
     {
-       
-        System.out.println( "orgUnit Id is "  + id );
         organisationUnit = organisationUnitService.getOrganisationUnit( id );
         
-        System.out.println( "orgUnit Id is "  + selectedOrgUnitId + " , orgNunit name is : " + organisationUnit.getName() );
-        
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateSummaryDataStatusResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateSummaryDataStatusResultAction.java	2010-12-23 07:23:23 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateSummaryDataStatusResultAction.java	2011-03-01 09:39:28 +0000
@@ -11,12 +11,10 @@
 import java.util.Set;
 import java.util.UUID;
 
-import org.hibernate.SessionFactory;
 import org.hisp.dhis.dataanalyser.util.DashBoardService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -45,14 +43,6 @@
         this.jdbcTemplate = jdbcTemplate;
     }
 
-    @SuppressWarnings( "unused" )
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
     private OrganisationUnitService organisationUnitService;
 
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -91,14 +81,6 @@
         this.dashBoardService = dashBoardService;
     }
 
-    @SuppressWarnings("unused")
-	private DisplayPropertyHandler displayPropertyHandler;
-
-    public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
-    {
-        this.displayPropertyHandler = displayPropertyHandler;
-    }
-
     // ---------------------------------------------------------------
     // Output Parameters
     // ---------------------------------------------------------------
@@ -124,20 +106,6 @@
         return orgUnitList;
     }
 
-    private List<DataSet> dataSetList;
-
-    public List<DataSet> getDataSetList()
-    {
-        return dataSetList;
-    }
-
-    private List<Integer> results;
-
-    public List<Integer> getResults()
-    {
-        return results;
-    }
-
     private Map<DataSet, Map<OrganisationUnit, List<Integer>>> dataStatusResult;
 
     public Map<DataSet, Map<OrganisationUnit, List<Integer>>> getDataStatusResult()
@@ -248,18 +216,13 @@
         this.orgUnitListCB = orgUnitListCB;
     }
 
-    private List<String> selectedDataSets;
+    private String selectedDataSets;
 
-    public void setSelectedDataSets( List<String> selectedDataSets )
+    public void setSelectedDataSets( String selectedDataSets )
     {
         this.selectedDataSets = selectedDataSets;
     }
 
-    public List<String> getSelectedDataSets()
-    {
-        return selectedDataSets;
-    }
-
     private int minOULevel;
 
     public int getMinOULevel()
@@ -267,13 +230,6 @@
         return minOULevel;
     }
 
-    private int number;
-
-    public int getNumber()
-    {
-        return number;
-    }
-
     private DataSet selDataSet;
 
     public DataSet getSelDataSet()
@@ -297,11 +253,12 @@
     int orgUnitCount;
 
     private String dataViewName;
+    
+    Set<Source> dso;
 
     // ---------------------------------------------------------------
     // Action Implementation
     // ---------------------------------------------------------------
-//    @SuppressWarnings( { "deprecation", "unchecked" } )
     public String execute()
         throws Exception
     {
@@ -311,41 +268,23 @@
         // Intialization
         periodNameList = new ArrayList<String>();
         ouMapSummaryStatusResult = new HashMap<OrganisationUnit, List<Integer>>();
-        results = new ArrayList<Integer>();
         maxOULevel = 1;
         minOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
 
-        //System.out.println( "BLABLA : " + immChildOption + " : " + dsId + " : " + ouId + " : " + sDateLB + " : " + eDateLB );
-        //System.out.println( "BLA : " + immChildOption + " : " + dsId + " : " + ouId + " : " + sDateLB + " : " + eDateLB );
-
         if ( immChildOption != null && immChildOption.equalsIgnoreCase( "yes" ) )
         {
             orgUnitListCB = new ArrayList<String>();
             orgUnitListCB.add( ouId );
             facilityLB = "immChildren";
-            selectedDataSets = new ArrayList<String>();
-            selectedDataSets.add( dsId );
+            selectedDataSets = dsId;
         }
 
         // DataSet Related Info
-        dataSetList = new ArrayList<DataSet>();
-
         deInfo = "-1";
-        if ( selectedDataSets == null )
-        {
-            System.out.println( "slectedDataSets is empty" );
-        }
-        else
-        {
-            //System.out.println( "slectedDataSets is not empty" );
-        }
-        for ( String ds : selectedDataSets )
-        {
-            DataSet dSet = dataSetService.getDataSet( Integer.parseInt( ds ) );
-            selDataSet = dSet;
-            for ( DataElement de : dSet.getDataElements() )
-                deInfo += "," + de.getId();
-        }
+        DataSet dSet = dataSetService.getDataSet( Integer.parseInt( selectedDataSets ) );
+        selDataSet = dSet;
+        for ( DataElement de : dSet.getDataElements() )
+            deInfo += "," + de.getId();
 
         // OrgUnit Related Info
         OrganisationUnit selectedOrgUnit = new OrganisationUnit();
@@ -353,26 +292,23 @@
         if ( facilityLB.equals( "children" ) )
         {
             selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
-            orgUnitList = getChildOrgUnitTree( selectedOrgUnit );
+            orgUnitList.addAll( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) );
+            //getChildOrgUnitTree( selectedOrgUnit );
         }
         else if ( facilityLB.equals( "immChildren" ) )
         {
-            @SuppressWarnings( "unused" )
-            int number;
             selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
-            number = selectedOrgUnit.getChildren().size();
-            orgUnitList = new ArrayList<OrganisationUnit>();
+            //number = selectedOrgUnit.getChildren().size();
             Iterator<String> orgUnitIterator = orgUnitListCB.iterator();
             while ( orgUnitIterator.hasNext() )
             {
                 OrganisationUnit o = organisationUnitService.getOrganisationUnit( Integer
                     .parseInt( (String) orgUnitIterator.next() ) );
+                orgUnitList.add( o );
                 List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( o.getChildren() );
                 Collections.sort( organisationUnits, new OrganisationUnitShortNameComparator() );
                 orgUnitList.addAll( organisationUnits );
-                orgUnitList.add( 0, o );
             }
-            //System.out.println( "Selected is immediate children" );
         }
         else
         {
@@ -445,14 +381,13 @@
         deInfo = getDEInfo( dataElements );
         Iterator<OrganisationUnit> orgUnitListIterator = orgUnitList.iterator();
         OrganisationUnit o;
-        Set<Source> dso = new HashSet<Source>();
+        dso = new HashSet<Source>();
         Iterator<Period> periodIterator;
         dso = selDataSet.getSources();
         String orgUnitId = "";
         
         while ( orgUnitListIterator.hasNext() )
         {
-            //System.out.println( "Getting into first orgunit loop" );
             o = (OrganisationUnit) orgUnitListIterator.next();
             orgUnitInfo = "" + o.getId();
 
@@ -472,7 +407,6 @@
             {
                 p = (Period) periodIterator.next();
                 periodInfo = "" + p.getId();
-                //System.out.println( "Getting into period loop" );
 
                 if ( dso == null )
                 {
@@ -483,8 +417,7 @@
                 else if ( !dso.contains( o ) )
                 {
                     List<OrganisationUnit> childOrgUnits = new ArrayList<OrganisationUnit>();
-                    childOrgUnits = filterChildOrgUnitsByDataSet( dataSetService.getDataSet( Integer
-                        .valueOf( selectedDataSets.get( 0 ) ) ), o );
+                    childOrgUnits = filterChildOrgUnitsByDataSet( selDataSet, o );
                     Iterator<OrganisationUnit> assignedChildrenIterator = childOrgUnits.iterator();
                     int dataStatusCount = 0;
 
@@ -515,7 +448,6 @@
                         {
                             try
                             {
-                                //System.out.println( "Result is : \t" + sqlResultSet.getLong( 1 ) );
                                 dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) (dataSetMemberCount1)) * 100.0;
                             }
                             catch ( Exception e )
@@ -538,7 +470,6 @@
                         }
                     }
                     dsSummaryResults.add( dataStatusCount );
-
                     continue;
                 }
 
@@ -586,18 +517,10 @@
                     dsSummaryResults.add( 0 );
                 }
             }
+            
             ouMapSummaryStatusResult.put( o, dsSummaryResults );
         }
 
-        Iterator<OrganisationUnit> orgUnitListIterator2 = orgUnitList.iterator();
-
-        while ( orgUnitListIterator2.hasNext() )
-        {
-            //OrganisationUnit oo = (OrganisationUnit) orgUnitListIterator2.next();
-            //System.out.println( "OrgUnit :\t" + oo.getShortName() + " \t and value : \t "
-            //    + ouMapSummaryStatusResult.get( oo ) );
-        }
-
         // For Level Names
         String ouLevelNames[] = new String[organisationUnitService.getNumberOfOrganisationalLevels() + 1];
         
@@ -639,6 +562,7 @@
         }// finally block end
 
         periodNameList = dashBoardService.getPeriodNamesByPeriodType( dataSetPeriodType, periodList );
+        
         return SUCCESS;
     }
 
@@ -667,15 +591,14 @@
 
         try
         {
-            @SuppressWarnings("unused")
-	    int sqlResult = jdbcTemplate.update( query );
+	    jdbcTemplate.update( query );
             System.out.println( "View " + dataViewName + " dropped Successfully (if exists) " );
 
-            query = "CREATE view " + dataViewName + " AS "
+            query = "CREATE VIEW " + dataViewName + " AS "
                 + " SELECT sourceid,dataelementid,periodid,value FROM datavalue " + " WHERE dataelementid in ("
                 + deInfo + ") AND " + " sourceid in (" + orgUnitInfo + ") AND " + " periodid in (" + periodInfo + ")";
 
-            sqlResult = jdbcTemplate.update( query );
+            jdbcTemplate.update( query );
 
             System.out.println( "View " + dataViewName + " created Successfully" );
         } // try block end
@@ -706,8 +629,7 @@
 
         try
         {
-            @SuppressWarnings("unused")
-			int sqlResult = jdbcTemplate.update( query );
+            jdbcTemplate.update( query );
             System.out.println( "View " + dataViewName + " dropped Successfully" );
         } // try block end
         catch ( Exception e )
@@ -789,12 +711,8 @@
     private List<OrganisationUnit> filterChildOrgUnitsByDataSet( DataSet selectedDataSet,
         OrganisationUnit selectedOrganisationUnit )
     {
-        List<OrganisationUnit> filteredOrganisationUnits = getChildOrgUnitTree( selectedOrganisationUnit );
-
-        @SuppressWarnings( "unused" )
-        List<OrganisationUnit> assignedOrganisationUnits = new ArrayList<OrganisationUnit>();
-        Set<Source> assignedSources = selectedDataSet.getSources();
-        filteredOrganisationUnits.retainAll( assignedSources );
+        List<OrganisationUnit> filteredOrganisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrganisationUnit.getId() ) );
+        filteredOrganisationUnits.retainAll( dso );
         return filteredOrganisationUnits;
     }
 

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/GenerateGraphicalAnalyserDataElementsFormAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/GenerateGraphicalAnalyserDataElementsFormAction.java	2010-12-08 07:24:10 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/GenerateGraphicalAnalyserDataElementsFormAction.java	2011-03-01 09:39:28 +0000
@@ -189,11 +189,9 @@
         return orgUnitGroups;
     }
 
-    
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
-    
 
     public String execute() throws Exception
     {
@@ -201,22 +199,19 @@
         /* DataElements and Groups */
         dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
         
-        System.out.println(" dataElements size before filter = "+ dataElements.size());
         // take only those dataElement which are VALUE_TYPE_INT and DOMAIN_TYPE_AGGREGATE
         Iterator<DataElement> alldeIterator = dataElements.iterator();
         while ( alldeIterator.hasNext() )
         {
             DataElement de1 = alldeIterator.next();
             if ( !de1.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) || !de1.getDomainType().equalsIgnoreCase( DataElement.DOMAIN_TYPE_AGGREGATE ) )
-           // if ( !de1.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) || !de1.getType().equalsIgnoreCase( DataElement.DOMAIN_TYPE_AGGREGATE ) )
             {
                 alldeIterator.remove();
             }
         }
-        System.out.println(" dataElements size after filter= " + dataElements.size());
-       // Collections.sort( dataElements, dataElementComparator );
-        
+
         dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
+        
         Collections.sort( dataElements, new DataElementNameComparator() );
         Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
         
@@ -224,18 +219,6 @@
         periodTypes = new ArrayList<PeriodType>( periodService.getAllPeriodTypes() );
         
         Iterator<PeriodType> ptIterator = periodTypes.iterator();
-       /*
-        while ( ptIterator.hasNext() )
-        {
-            String pTName = ptIterator.next().getName();
-            if ( pTName.equalsIgnoreCase( DailyPeriodType.NAME ) || pTName.equalsIgnoreCase( TwoYearlyPeriodType.NAME )
-                || pTName.equalsIgnoreCase( OnChangePeriodType.NAME )
-                || pTName.equalsIgnoreCase( WeeklyPeriodType.NAME ) || pTName.equalsIgnoreCase( FinancialAprilPeriodType.NAME) )
-            {
-                ptIterator.remove();
-            }
-        }
-        */
         while ( ptIterator.hasNext() )
         {
             String pTName = ptIterator.next().getName();
@@ -248,14 +231,15 @@
         
         dailyPeriodTypeName = DailyPeriodType.NAME;
         weeklyPeriodTypeName = WeeklyPeriodType.NAME;
+        monthlyPeriodTypeName = MonthlyPeriodType.NAME;
+        quarterlyPeriodTypeName = QuarterlyPeriodType.NAME;
+        sixMonthPeriodTypeName = SixMonthlyPeriodType.NAME;
+        yearlyPeriodTypeName = YearlyPeriodType.NAME;
+        
         monthlyPeriods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new MonthlyPeriodType() ) );
         periodNameList = new ArrayList<String>();
         Collections.sort( monthlyPeriods, new PeriodComparator() );
         simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
-        monthlyPeriodTypeName = MonthlyPeriodType.NAME;
-        quarterlyPeriodTypeName = QuarterlyPeriodType.NAME;
-        sixMonthPeriodTypeName = SixMonthlyPeriodType.NAME;
-        yearlyPeriodTypeName = YearlyPeriodType.NAME;
 
         yearlyPeriods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new YearlyPeriodType() ) );
         Iterator<Period> periodIterator = yearlyPeriods.iterator();
@@ -272,13 +256,8 @@
         
         Collections.sort( yearlyPeriods, new PeriodComparator() );
         simpleDateFormat = new SimpleDateFormat( "yyyy" );
-        //System.out.println( monthlyPeriodTypeName );
-       // int year;
         for ( Period p1 : yearlyPeriods )
         {
-           // year = Integer.parseInt( simpleDateFormat.format( p1.getStartDate() ) ) + 1;
-           // periodNameList.add( simpleDateFormat.format( p1.getStartDate() ) + "-" + year );
-            
             periodNameList.add( simpleDateFormat.format( p1.getStartDate() ) );
         }
         

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataAction.java	2011-01-07 05:45:11 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataAction.java	2011-03-01 09:39:28 +0000
@@ -986,10 +986,8 @@
                                 String values = selectedOrgUnit.getId() + ":"+ dElement.getId() + ":"+ decoc1.getId() + ":" + p.getId();
                                 selectedValues.add(values);
 
-                                CaseAggregationCondition caseAggregationCondition = caseAggregationConditionService.getCaseAggregationCondition( dElement, decoc );
+                                CaseAggregationCondition caseAggregationCondition = caseAggregationConditionService.getCaseAggregationCondition( dElement, decoc1 );
 
-                                //CaseAggregationMapping caseAggMapping = caseAggregationMappingService.getCaseAggregationMappingByOptionCombo( dElement, decoc1 );
-                                
                                 if( caseAggregationCondition == null )
                                 {
                                     selectedStatus.add( "no" );

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataElementAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataElementAction.java	2011-01-11 08:04:51 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataElementAction.java	2011-03-01 09:39:28 +0000
@@ -28,7 +28,6 @@
 
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -47,6 +46,7 @@
 import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
 import org.hisp.dhis.dataanalyser.util.DataElementChartResult;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -86,8 +86,6 @@
     
     private final String OPTIONCOMBO = "optioncombo";
     
-   // private final String ORGUNITGROUP = "orgUnitSelectedRadio";
-    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -154,14 +152,7 @@
     {
         this.caseAggregationConditionService = caseAggregationConditionService;
     }
-/*    
-    private DashBoardService dashBoardService;
 
-    public void setDashBoardService( DashBoardService dashBoardService )
-    {
-        this.dashBoardService = dashBoardService;
-    }
-*/ 
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -169,17 +160,6 @@
         this.format = format;
     }
     
-    // -------------------------------------------------------------------------
-    // Comparator
-    // -------------------------------------------------------------------------
-/*
-    private Comparator<DataElement> dataElementComparator;
-
-    public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
-    {
-        this.dataElementComparator = dataElementComparator;
-    }
-*/    
     // --------------------------------------------------------------------------
     // Parameters
     // --------------------------------------------------------------------------
@@ -191,8 +171,6 @@
         return session;
     }
     
-    private List<DataElementCategoryOptionCombo> selectedOptionComboList;
-    
     private List<Object> selectedServiceList;
 
     public List<Object> getSelectedServiceList()
@@ -200,21 +178,11 @@
         return selectedServiceList;
     }
     
-    private List<OrganisationUnit> selOUList;
-    
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
-/*    
-    private List<String> selectedDataElements;
-    
-    public void setSelectedDataElements( List<String> selectedDataElements )
-    {
-        this.selectedDataElements = selectedDataElements;
-    }
-*/
-    private List<String> selectedDataElements;
-    
+
+    private List<String> selectedDataElements;
 
     public void setSelectedDataElements( List<String> selectedDataElements )
     {
@@ -233,22 +201,6 @@
         return deSelection;
     }
     
-/*
-    private List<String> ougGroupSetCB;
-    
-    public List<String> getOugGroupSetCB()
-    {
-        return ougGroupSetCB;
-    }
-
-    public void setOugGroupSetCB( List<String> ougGroupSetCB )
-    {
-        this.ougGroupSetCB = ougGroupSetCB;
-    }
-*/
-     
-
-
     private String ougGroupSetCB;
     
     public void setOugGroupSetCB( String ougGroupSetCB )
@@ -262,7 +214,6 @@
     }
    
     private List<String> orgUnitGroupList;
-    
 
     public List<String> getOrgUnitGroupList()
     {
@@ -338,12 +289,6 @@
         this.periodLB = periodLB;
     }
     
-    private  List<String> periodNames;
-    
-    private List<Date> selStartPeriodList;
-
-    private List<Date> selEndPeriodList;
-    
     private DataElementChartResult dataElementChartResult;
     
     public DataElementChartResult getDataElementChartResult()
@@ -351,38 +296,6 @@
         return dataElementChartResult;
     }
     
-    private OrganisationUnit selectedOrgUnit;
-    
-    private OrganisationUnitGroup selOrgUnitGroup;
-    
-    private List<OrganisationUnit> selOUGroupMemberList = new ArrayList<OrganisationUnit>();
-    //public List<OrganisationUnit> orgUnit;
-    
-//    public List<DataElementCategoryOptionCombo>  decoc ;
-
-/*    
-    String chartTitle ;
-
-    public String getChartTitle()
-    {
-        return chartTitle;
-    }
-
-    String xAxis_Title;
-
-    public String getXAxis_Title()
-    {
-        return xAxis_Title;
-    }
-
-    String yAxis_Title;
-
-    public String getYAxis_Title()
-    {
-        return yAxis_Title;
-    }
-*/    
-    
     List<String> yseriesList;
 
     public List<String> getYseriesList()
@@ -417,97 +330,70 @@
     {
         return listTool;
     }
-    
+
+    private List<OrganisationUnit> selOUList;
+    private List<DataElementCategoryOptionCombo> selectedOptionComboList;
+    private OrganisationUnit selectedOrgUnit;
+    private OrganisationUnitGroup selOrgUnitGroup;
+    private List<OrganisationUnit> selOUGroupMemberList = new ArrayList<OrganisationUnit>();
+    private  List<String> periodNames;
+    private List<Date> selStartPeriodList;
+    private List<Date> selEndPeriodList;
     private String drillDownPeriodStartDate;
     private String drillDownPeriodEndDate;
     private String drillDownPeriodNames;
-    
     private String aggChecked;
     
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
-    
-    @SuppressWarnings( "unchecked" )
     public String execute()  throws Exception
     {
         statementManager.initialise();
+
+        listTool = new ListTool();
         selectedOptionComboList = new ArrayList<DataElementCategoryOptionCombo>();
-        
-        listTool = new ListTool();
-        
-        aggChecked = "";
-        
-        if( aggDataCB != null )
-        {
-            aggChecked = "1";
-        }
-        else
-        {
-            aggChecked = "0";
-        }
         selOUList = new ArrayList<OrganisationUnit>();
-        System.out.println( "selected orgUnit  size : " + orgUnitListCB.size() );
-        
-        System.out.println( "selected Year  size : " + yearLB.size());
-        
-      //  System.out.println( "selected Period  size : " + periodLB.size());
-        
-        System.out.println( "selected dataelements : " + selectedDataElements);
-        
-        System.out.println( "selected dataelements size : " + selectedDataElements.size());
-        
-        // int flag = 0;
-        //  selOUList = new ArrayList<OrganisationUnit>();
         selStartPeriodList = new ArrayList<Date>();
         selEndPeriodList = new ArrayList<Date>();
-        
         yseriesList = new ArrayList<String>();
-        
-        selectedValues = new ArrayList<String>();//for DrillDown ( for NBIT)
+        selectedValues = new ArrayList<String>();
         selectedStatus = new ArrayList<String>();
-        
-        selectedDrillDownData = new ArrayList<String>();//drillDown for periodWise to OrgChildWise and OrgChildWise to periodWise
-        
-      //  DataElement dElement = new DataElement();
-        
-       // DataElementCategoryOptionCombo decoc1 = new DataElementCategoryOptionCombo();
-       // int countForServiceList = 0;
-        
-      //  ouChildCountMap = new HashMap<OrganisationUnit, Integer>();
-
-       // String monthOrder[] = { "04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02", "03" };
-       // int monthDays[] = { 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31 };
-
+        selectedDrillDownData = new ArrayList<String>();
+
+        aggChecked = "";
+        
+        if( aggDataCB != null )
+        {
+            aggChecked = "1";
+        }
+        else
+        {
+            aggChecked = "0";
+        }
+
+        //----------------------------------------------------------------------
+        // Period Info
+        //----------------------------------------------------------------------
         String monthOrder[] = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
         int monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-        
-        /* Period Info */
 
         String startD = "";
         String endD = "";
-        
         drillDownPeriodStartDate = "";
         drillDownPeriodEndDate = "";
         drillDownPeriodNames = "";
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
-
         periodNames = new ArrayList<String>();
         
-        // for weekly period
-        if ( periodTypeLB.equalsIgnoreCase( WeeklyPeriodType.NAME ) )
+        if( periodTypeLB.equalsIgnoreCase( WeeklyPeriodType.NAME ) )
         {
-           // System.out.println( " Inside  weekly" );
             int periodCount = 0;
-            for ( String periodStr : periodLB )
+            for( String periodStr : periodLB )
             {
-                String  startWeekDate = periodStr.split( "To" )[0] ; //for start week
-                String  endWeekDate = periodStr.split( "To" )[1] ; //for end week
-                
-                startD = startWeekDate.trim();
-                endD = endWeekDate.trim();
-                
-                // for DrillDown Period String
+                startD = periodStr.split( "To" )[0].trim();
+                endD = periodStr.split( "To" )[1].trim();
+                
                 if( periodCount == periodLB.size()-1 )
                 {
                     drillDownPeriodStartDate += startD;
@@ -523,10 +409,8 @@
                 
                 selStartPeriodList.add( format.parseDate( startD ) );
                 selEndPeriodList.add( format.parseDate( endD ) );
-                
                 periodNames.add( periodStr );
                 periodCount++;
-                //System.out.println( startD + " : " + endD );
             }
         }
         else
@@ -534,16 +418,12 @@
             int periodCount = 0;
             for ( String year : yearLB )
             {
-                //int selYear = Integer.parseInt( year.split( "-" )[0] );
                 int selYear = Integer.parseInt( year );
-                
                 if ( periodTypeLB.equalsIgnoreCase( YearlyPeriodType.NAME ) )
                 {
-                    
                     startD = "" + selYear + "-01-01";
                     endD = "" + selYear  + "-12-31";
                     
-                    // for DrillDown Period String
                     if( periodCount == yearLB.size()-1 )
                     {
                         drillDownPeriodStartDate += startD;
@@ -559,20 +439,12 @@
                     
                     selStartPeriodList.add( format.parseDate( startD ) );
                     selEndPeriodList.add( format.parseDate( endD ) );
-            
-                   // periodNames.add( "" + selYear + "-" + (selYear + 1) );
-                    
                     periodNames.add( "" + selYear );
-                   // System.out.println( "Start Date : " + startD + " , End Date : " + endD );
                     continue;
-                    
                 }
                
-               // int periodCount = 0;
-                for ( String periodStr : periodLB )
+                for( String periodStr : periodLB )
                 {
-                   // int period = Integer.parseInt( periodStr );
-            
                     if ( periodTypeLB.equalsIgnoreCase( MonthlyPeriodType.NAME ) )
                     {
                         int period = Integer.parseInt( periodStr );
@@ -581,28 +453,17 @@
                         startD = "" + selYear + "-" + monthOrder[period] + "-01";
                         endD = "" + selYear  + "-" + monthOrder[period] + "-" + monthDays[period];
                        
-                        //check for leapYear
                         if ( ((( selYear ) % 400 == 0 ) || ((( selYear) % 100 != 0 && ( selYear ) % 4 == 0))) && period == 1 )
                         {
                             endD = "" + selYear  + "-" + monthOrder[period] + "-" + ( monthDays[period] + 1 );
                         } 
                         
-                        // for DrillDown Period String
-                        /*if( periodCount == periodLB.size()-1 )
-                        {
-                            drillDownPeriodStartDate += startD;
-                            drillDownPeriodEndDate += endD;
-                        }
-                        else*/
-                      //  {
-                            drillDownPeriodStartDate += startD + ";";
-                            drillDownPeriodEndDate += endD + ";";
-                            drillDownPeriodNames += simpleDateFormat.format( format.parseDate( startD ) ) + ";";
-                       // }
+                        drillDownPeriodStartDate += startD + ";";
+                        drillDownPeriodEndDate += endD + ";";
+                        drillDownPeriodNames += simpleDateFormat.format( format.parseDate( startD ) ) + ";";
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
                         periodNames.add( simpleDateFormat.format( format.parseDate( startD ) ) );
-                       // System.out.println( "Start Date : " + startD + " , End Date : " + endD );
                     }
                     else if ( periodTypeLB.equalsIgnoreCase( QuarterlyPeriodType.NAME ) )
                     {
@@ -636,7 +497,6 @@
                             drillDownPeriodNames += selYear + "-Q4" + ";";
                         }
                         
-                        // for DrillDown Period String
                         if( periodCount == periodLB.size()-1 )
                         {
                             drillDownPeriodStartDate += startD;
@@ -650,7 +510,6 @@
                         
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
-                       // System.out.println( "Start Date : " + startD + " , End Date : " + endD );
                     }
                     else if ( periodTypeLB.equalsIgnoreCase( SixMonthlyPeriodType.NAME ) )
                     {
@@ -670,28 +529,15 @@
                             drillDownPeriodNames += selYear + "-HY2" + ";";
                         }
                        
-                        // for DrillDown Period String
-                        /*
-                        if( periodCount == periodLB.size()-1 )
-                        {
-                            drillDownPeriodStartDate += startD;
-                            drillDownPeriodEndDate += endD;
-                        }*/
-                        //else
-                       // {
-                            drillDownPeriodStartDate += startD + ";";
-                            drillDownPeriodEndDate += endD + ";";
-                        //}
-                        
+                        drillDownPeriodStartDate += startD + ";";
+                        drillDownPeriodEndDate += endD + ";";
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
                     }
-                    
                     else if ( periodTypeLB.equalsIgnoreCase( DailyPeriodType.NAME ) )
                     {
                        String  month = periodStr.split( "-" )[0] ;
                        String  date = periodStr.split( "-" )[1] ;
-                       
                        startD = selYear + "-" + periodStr;
                        endD = selYear + "-" + periodStr ;
                        
@@ -708,7 +554,6 @@
                             endD = selYear  + "-" + month + "-" + date;
                         }
                        
-                        // for DrillDown Period String
                         if( periodCount == periodLB.size()-1 )
                         {
                             drillDownPeriodStartDate += startD;
@@ -724,20 +569,16 @@
                         
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
-                        
                         periodNames.add( startD );
-                       // System.out.println( startD + " : " + endD );
                     }
-                    //System.out.println( startD + " : " + endD );
-                    //periodCount++; 
                 }
-               // periodCountYear++;
                 periodCount++;
             }
-      }    
+        }    
         
+        //----------------------------------------------------------------------
         // DataElement Information        
-        
+        //----------------------------------------------------------------------
         List<DataElement> dataElementList = new ArrayList<DataElement>();
         
         if ( deSelection == null )
@@ -745,107 +586,53 @@
             System.out.println( "deOptionValue is null" );
             return null;
         }
-        else
-        {
-            //System.out.println( "deOptionValue : " + deSelection );
-        }
-        
-        System.out.println("\n\n\n ===== \n deSelection: " + deSelection);
-        
-       
         
         if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
         { 
-           // System.out.println("\n\n\n ===== \n deSelection: OK ");
-            Iterator deIterator = selectedDataElements.iterator();
-            
-          //  dElement = (DataElement) deIterator.next();
-            
+            Iterator<String> deIterator = selectedDataElements.iterator();
             while ( deIterator.hasNext() )
             {
                 String serviceId = (String) deIterator.next();
                 String partsOfServiceId[] = serviceId.split( ":" );
                 int dataElementId = Integer.parseInt( partsOfServiceId[0] );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                // selectedServiceList.add( dataElement );
                 dataElementList.add( dataElement );
                 int optionComboId = Integer.parseInt( partsOfServiceId[1] );
                 DataElementCategoryOptionCombo decoc = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboId );
                 selectedOptionComboList.add( decoc );
-              //  chartTitle += dataElement.getName() + " : " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc ).getName() + ", ";
-              /*  
-                decoc1 = selectedOptionComboList.get( countForServiceList );
-                yseriesList.add( dElement.getName() + " : " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc1 ).getName() );
-                System.out.println( "Data Elenent name is  : " + dElement.getName() + " categoryOptionCombo is :  " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc1 ).getName() );
-            */
             }
         }
         else
         {
-            Iterator deIterator = selectedDataElements.iterator();
+            Iterator<String> deIterator = selectedDataElements.iterator();
             while ( deIterator.hasNext() )
             {
                 int serviceID = Integer.parseInt( (String) deIterator.next() );
                 DataElement dataElement = dataElementService.getDataElement( serviceID );
-                // selectedServiceList.add( dataElement );
                 dataElementList.add( dataElement );
-               // chartTitle += dataElement.getName() + ", ";
-             /*   yseriesList.add( dElement.getName() );
-                System.out.println( "Data Elenent name is  : " + dElement.getName() );*/
             }
-            
         }
        
-        //Collections.sort( dataElementList, dataElementComparator );
         selectedServiceList = new ArrayList<Object>( dataElementList );
         
-        // OrgUnit Information              
-        
+        //----------------------------------------------------------------------
+        // OrgUnit Information
+        //----------------------------------------------------------------------
         for ( String ouStr : orgUnitListCB )
         {
             OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( ouStr ) );
             selOUList.add( orgUnit );
         }
 
-        Calendar now = Calendar.getInstance();//for mili seconds
-        
-        // calling individual Function 
         if ( categoryLB.equalsIgnoreCase( PERIODWISE )&& ougGroupSetCB == null )
         {
-            System.out.println( "Inside PeriodWise Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
            
-            
             dataElementChartResult = generateChartDataPeriodWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUList.iterator().next() );
-           /* 
-            ActionContext ctx = ActionContext.getContext();
-            HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST );
-
-            session = req.getSession();
-            /*
-            #foreach( )
-                $dataElementChartResult.data[$count1][$count2]
-            #end
-            *//*
-            Integer i = dataElementChartResult.getCategories().length;
-            System.out.println( "\n Categories Length is " + i );
-            
-            Integer j = dataElementChartResult.getSeries().length;
-            System.out.println( "\n Series Length is " + j );
-            
-            session.setAttribute( "data1", dataElementChartResult.getData() );
-            session.setAttribute( "series1", dataElementChartResult.getSeries() );
-            session.setAttribute( "categories1", dataElementChartResult.getCategories() );
-            session.setAttribute( "chartTitle", dataElementChartResult.getChartTitle() );
-            session.setAttribute( "xAxisTitle", dataElementChartResult.getXAxis_Title() );
-            session.setAttribute( "yAxisTitle", dataElementChartResult.getYAxis_Title() );
-           */ 
-
         }
         else if ( categoryLB.equalsIgnoreCase( CHILDREN ) && ougGroupSetCB == null )
         {
-            System.out.println( "Inside Child Wise Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
             
             selectedOrgUnit = new OrganisationUnit();
             selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
@@ -853,120 +640,53 @@
             List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
             childOrgUnitList = new ArrayList<OrganisationUnit>( selectedOrgUnit.getChildren());
             
-            System.out.println( "length of childOrgUnitList :" + childOrgUnitList.size());
-            
             dataElementChartResult = generateChartDataWithChildrenWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,childOrgUnitList );
-           /*
-            for( String drillDown : selectedDrillDownData )
-            {
-                System.out.println( "drill Down value is :" + drillDown);
-                System.out.println( "---------");
-            }
-            */
-           // dataElementChartResult.getSeries()
         }
         else if ( categoryLB.equalsIgnoreCase( SELECTED ) && ougGroupSetCB == null )
         {
-            
-            System.out.println( "Inside Selected OrgUnit Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
             
             dataElementChartResult = generateChartDataSelectedOrgUnitWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUList );
-          
         }
-        
         else if ( categoryLB.equalsIgnoreCase( PERIODWISE ) && ougGroupSetCB != null )
         {
-            System.out.println( "Inside Period dWise With OrgGroup Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
           
-            //finding the common list of selected org unit and selected Group
-            
-            //  selOUList = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
-            
             selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
             List<OrganisationUnit> orgUnitChildList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) );
            
-            System.out.println( "oug Group Set is  = " + orgUnitGroupList );
-            
             selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupList.get( 0 ) ) );
-           // String selOrgGroupname = selOrgUnitGroup.getName();
             selOUGroupMemberList = new ArrayList<OrganisationUnit>( selOrgUnitGroup.getMembers() );
-            
-           // System.out.println( "Report Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() );
-           
-           // System.out.println( "Size of Group member is before retain : " + selOUGroupMemberList.size() );
-            
             selOUGroupMemberList.retainAll( orgUnitChildList );
             
-           // orgUnitChildList.retainAll( selOUGroupMemberList );
-           /* 
-            System.out.println( "Size of Group member is after retain : " + selOUGroupMemberList.size() );
-            
-            System.out.println( "Report Generation End Time is : \t" + new Date()+ "Mili seconds is : " + now.getTimeInMillis() );
-            
-            System.out.println( "OruUnit: " + selectedOrgUnit.getName() + "Group Name is : " + selOrgUnitGroup.getName() + "Size of Group member after retain is : " + selOUGroupMemberList.size() );
-            
-            System.out.println( "Inside PeriodWise With OrgGroup Chart Data" );
-            */
-          
-           // dataElementChartResult = generateChartDataOrgGroupPeriodWise(selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selectedOrgUnit,selOrgUnitGroup,selOUGroupMemberList);
             dataElementChartResult = generateChartDataOrgGroupPeriodWise(selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUGroupMemberList);
- 
         }
-        
         else if ( categoryLB.equalsIgnoreCase( CHILDREN ) && ougGroupSetCB != null )
         {
-            System.out.println( "Inside ChildWise With OrgGroup Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
             
             selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
             List<OrganisationUnit> orgUnitChildList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) );
             
             int groupCount = 0;
-           // System.out.println("\n\n ++++++++++++++++++++++ \n orgUnitGroup : " + orgUnitGroupList );
             for ( String orgUnitGroupId : orgUnitGroupList )
             {
                 OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
-               
                 List<OrganisationUnit> selectedOUGroupMemberList = new ArrayList<OrganisationUnit>( selOrgUnitGroup.getMembers() );
-                
                 selOUGroupMemberList.addAll( selectedOUGroupMemberList );
-
-               // System.out.println( "Total Size of " + groupCount + " : " + selOUGroupMemberList.size()  );
-
                 groupCount++;
-    
             }
             
-          //  System.out.println( "Total Size of " + selOUGroupMemberList.size()  );
-
-           // System.out.println( "Report Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() );
-            
-           // System.out.println( "Size of Group member is before retain : " + selOUGroupMemberList.size() + " ,Size of Child Member is :" + orgUnitChildList.size() );
-            
             selOUGroupMemberList.retainAll( orgUnitChildList );
             
-           // System.out.println( "Report Generation End Time is : \t" + new Date()+ "Mili seconds is : " + now.getTimeInMillis() );
-            
-           // System.out.println( "OruUnit: " + selectedOrgUnit.getName() + " Group Size is : " + orgUnitGroupList.size() + " ,Size of Group member after retain is : " + selOUGroupMemberList.size() );
-            // generateChartDataOrgGroupChildWise();
-            
-            // calling sane function in case of SelectedOrgUnit Chart Data
             dataElementChartResult = generateChartDataSelectedOrgUnitWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUGroupMemberList );
-            
-
         }
-        
         else if ( categoryLB.equalsIgnoreCase( SELECTED ) && ougGroupSetCB != null )
         {
-            System.out.println( "Inside Selected With OrgGroup Chart Data" );
-            System.out.println( "Chart Generation Start Time is : \t" + new Date() );
+            System.out.println( "Chart Generation Start Time is : " + new Date() );
             
             Map<OrganisationUnitGroup,List<OrganisationUnit>> orgUnitGroupMap = new HashMap<OrganisationUnitGroup,List<OrganisationUnit>>();
            
-            System.out.println( "Inside SelectedOrgUnit With OrgGroup Chart Data" );
-           
            selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
            List<OrganisationUnit> orgUnitChildList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) );
            
@@ -974,17 +694,11 @@
            {
                OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) );
                List<OrganisationUnit> selectedOUGroupMemberList = new ArrayList<OrganisationUnit>( selOrgUnitGroup.getMembers() );
-               
                selectedOUGroupMemberList.retainAll( orgUnitChildList );
-               
                orgUnitGroupMap.put( selOrgUnitGroup,  selectedOUGroupMemberList);
-               //selOUGroupMemberList.addAll( selectedOUGroupMemberList );
            }
-           
-          // System.out.println( "selOrgUnitGroup Size is : " + orgUnitGroupMap.keySet().size()  );
           
            dataElementChartResult = generateChartDataSelectedOrgUnitGroupWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,orgUnitGroupMap );
-
         }
        
         ActionContext ctx = ActionContext.getContext();
@@ -999,18 +713,15 @@
         session.setAttribute( "xAxisTitle", dataElementChartResult.getXAxis_Title() );
         session.setAttribute( "yAxisTitle", dataElementChartResult.getYAxis_Title() );
         
-        System.out.println( "Chart Generation End Time is : \t" + new Date() );
+        System.out.println( "Chart Generation End Time is : " + new Date() );
         statementManager.destroy();
+        
         return SUCCESS;
     }
-    // execute end
     
-    // Supporting Methods
     // -------------------------------------------------------------------------
     // Methods for getting Chart Data only Period Wise start
     // -------------------------------------------------------------------------
-    
-   
     public DataElementChartResult generateChartDataPeriodWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,List<String> periodNames,List<DataElement> dataElementList,List<DataElementCategoryOptionCombo> decocList,OrganisationUnit orgUnit ) throws Exception
     {
        DataElementChartResult dataElementChartResult;
@@ -1021,39 +732,18 @@
        String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
        String xAxis_Title = "Time Line";
        String yAxis_Title = "Value";
-    
-      // System.out.println("\n\n +++ \n decoc : " + decocList);
        
        int serviceCount = 0;     
      
-     
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
-          /*
-           if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) && dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
-           {
-               System.out.println( " inside value type : - INT and Number Type : - INT"  );
-               System.out.println( " DataElementName : "+ dataElement.getName() );
-           }
-           if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) && !dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
-           {
-               System.out.println( " inside value type : - INT and Number Type : - other than INT"  );
-               System.out.println( " DataElementName : "+ dataElement.getName() );
-           }
-           */
-           // if( dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
-          // {
-             // System.out.println( " DataElement VALUE_TYPE_INT  is : " + DataElement.VALUE_TYPE_INT );
-          // }
-           //else
-          // {
-              // System.out.println( " DataElementName : "+ dataElement.getName() +" , DataElement Value Type  is : " + dataElement.getType() + ", DataElement Number Type  is : " + dataElement.getNumberType() );
-          // }
-          
+
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+           
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
                    
@@ -1061,8 +751,6 @@
                
                CaseAggregationCondition caseAggregationCondition = caseAggregationConditionService.getCaseAggregationCondition( dataElement, decoc );
 
-               //CaseAggregationMapping caseAggMapping = caseAggregationMappingService.getCaseAggregationMappingByOptionCombo( dElement, decoc1 );
-               
                if( caseAggregationCondition == null )
                {
                    selectedStatus.add( "no" );
@@ -1072,7 +760,6 @@
                    selectedStatus.add( "yes" );
                }
 
-               //System.out.println( "selectedStatus  : " + selectedStatus );
                yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
            else
@@ -1091,7 +778,6 @@
                    selectedStatus.add( "yes" );
                }
                
-               //System.out.println( "selectedStatus  : " + selectedStatus );
                yseriesList.add( dataElement.getName() );
            }
            
@@ -1100,7 +786,6 @@
            {
                Date endDate = selEndPeriodList.get( periodCount );
                String drillDownPeriodName = periodNames.get( periodCount );
-               //format.formatDate( date )
                String tempStartDate = format.formatDate( startDate );
                String tempEndDate   = format.formatDate( endDate );
                
@@ -1111,41 +796,33 @@
                selectedValues.add( values );
                
                String drillDownData = orgUnit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + drillDownPeriodName + ":" + deSelection + ":" + aggChecked;
-               //String drillDownData = orgUnit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
-               //selectedDrillDownData
                selectedDrillDownData.add( drillDownData );
-             //  System.out.println( "selectedValues Size  : " + selectedValues.size() );
                
                Double aggDataValue = 0.0;
-               if( aggDataCB != null )
-               {
-                   aggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit );
-                   //System.out.println( "start Date is   : " + startDate + " , End date is : " + endDate );
-                   //System.out.println( "Agg data value before is  : " + aggDataValue );
-                   if(aggDataValue == null ) aggDataValue = 0.0;
-                   //System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
-               }
-               else
-               {
-                 //  PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                  // Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
-                   Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                   for( Period period : periods )
-                   {
-                       DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc );
-                      
-                      // String values = orgUnit.getId() + ":"+ dataElement.getId() + ":"+ decoc.getId() + ":" + period.getId();
-                      // selectedValues.add(values);
-                       
-                      // System.out.println( "selectedValues  : " + selectedValues );
-                       
-                       try
-                       {
-                           aggDataValue += Double.parseDouble( dataValue.getValue() );
-                       }
-                       catch( Exception e )
-                       {
-                           
+
+               Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+               while ( optionComboIterator.hasNext() )
+               {
+                   DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
+                   if( aggDataCB != null )
+                   {
+                       Double temp = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgUnit );
+                       if( temp != null ) aggDataValue += temp;
+                   }
+                   else
+                   {
+                       Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
+                       for( Period period : periods )
+                       {
+                           DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc1 );
+                           try
+                           {
+                               aggDataValue += Double.parseDouble( dataValue.getValue() );
+                           }
+                           catch( Exception e )
+                           {
+                           }
                        }
                    }
                }
@@ -1169,17 +846,12 @@
            serviceCount++;          
        }
        
-       
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
+
        return dataElementChartResult;
     }
     
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data only Period Wise end
-    // -------------------------------------------------------------------------
-    
-    
-    // -------------------------------------------------------------------------
     // Methods for getting Chart Data With Children Wise start
     // -------------------------------------------------------------------------
         
@@ -1192,21 +864,19 @@
        Double[][] data = new Double[dataElementList.size()][childOrgUnitList.size()];
        String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName();
        
-      // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
        String xAxis_Title = "Facilities";
        String yAxis_Title = "Value";
     
-      // System.out.println("\n\n +++ \n decoc : " + decocList);
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
-          
+
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
                    
@@ -1235,44 +905,33 @@
                for( Date startDate : selStartPeriodList )
                {
                    Date endDate = selEndPeriodList.get( periodCount );
-                  // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                   //Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
                    Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                   
-                   //String drillDownData = orgChild.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
-                   
-                   //System.out.println( drillDownData );
-                   //selectedDrillDownData.add( drillDownData );
-                   
-                  // for( Period period : periods )
-                   //{
+
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
                        if( aggDataCB != null )
                        {
-                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgChild );
-                          // System.out.println( "Agg data value before is  : " + aggDataValue );
-                          
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgChild );
                            if(tempAggDataValue != null ) aggDataValue += tempAggDataValue;
-                          // System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
                        }
                        else
                        {
                            for( Period period : periods )
                            {
-                               DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc );
-                               
+                               DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc1 );
                                try
                                {
                                    aggDataValue += Double.parseDouble( dataValue.getValue() );
                                }
                                catch( Exception e )
                                {
-                                   
                                }
                            }
-                           
-                          
                        }
-                   //}
+                   }
                    periodCount++;
                }
  
@@ -1298,15 +957,10 @@
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
        return dataElementChartResult;
     }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Children Wise end
-    // -------------------------------------------------------------------------
-    
     
     // -------------------------------------------------------------------------
     // Methods for getting Chart Data With Selected Wise start
     // -------------------------------------------------------------------------
-        
     public DataElementChartResult generateChartDataSelectedOrgUnitWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,List<String> periodNames,List<DataElement> dataElementList,List<DataElementCategoryOptionCombo> decocList,List<OrganisationUnit> selOUList ) throws Exception
     {
        DataElementChartResult dataElementChartResult;
@@ -1315,25 +969,20 @@
        String[] categories = new String[selOUList.size()];
        Double[][] data = new Double[dataElementList.size()][selOUList.size()];
        String chartTitle = "OrganisationUnit : -----" ;
-       
-      // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
        String xAxis_Title = "Facilities";
        String yAxis_Title = "Value";
     
-      // System.out.println("\n\n +++ \n decoc : " + decocList);
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
-          
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+           
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
                yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
@@ -1341,7 +990,6 @@
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
                yseriesList.add( dataElement.getName() );
            }
            
@@ -1349,7 +997,6 @@
            for( OrganisationUnit orgunit : selOUList )
            {             
                categories[orgUnitCount] = orgunit.getName();
-               
                String drillDownData = orgunit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggChecked;
                selectedDrillDownData.add( drillDownData );
                
@@ -1359,38 +1006,33 @@
                for( Date startDate : selStartPeriodList )
                {
                    Date endDate = selEndPeriodList.get( periodCount );
-                  // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                   //Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
                    Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                   
-                   //for( Period period : periods )
-                   //{
+
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
                        if( aggDataCB != null )
                        {
-                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgunit );
-                           //System.out.println( "Agg data value before is  : " + aggDataValue );
-                          
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgunit );
                            if(tempAggDataValue != null ) aggDataValue += tempAggDataValue;
-                          // System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
                        }
                        else
                        {
-                          
                            for( Period period : periods )
                            {
-                               DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, decoc );
-                               
+                               DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, decoc1 );
                                try
                                {
                                    aggDataValue += Double.parseDouble( dataValue.getValue() );
                                }
                                catch( Exception e )
                                {
-                                   
                                }
                            }
                        }
-                  // }
+                   }
                    periodCount++;
                }
  
@@ -1408,18 +1050,14 @@
                   }
                }
                orgUnitCount++;
-             
            }
-           
            serviceCount++;          
        }
     
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
+
        return dataElementChartResult;
     }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Selected Wise end 
-    // -------------------------------------------------------------------------
         
     // -------------------------------------------------------------------------
     // Methods for getting Chart Data OrgGroup Period Wise start
@@ -1436,19 +1074,17 @@
        String xAxis_Title = "Time Line";
        String yAxis_Title = "Value";
        
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
           
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
                yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
@@ -1456,69 +1092,54 @@
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
                yseriesList.add( dataElement.getName() );
            }
-               
-               
               
-               int periodCount = 0;
-               for( Date startDate : selStartPeriodList )
+           int periodCount = 0;
+           for( Date startDate : selStartPeriodList )
+           {
+               Date endDate = selEndPeriodList.get( periodCount );
+               categories[periodCount] = periodNames.get( periodCount );
+               Double aggDataValue = 0.0;
+               
+               String tempStartDate = format.formatDate( startDate );
+               String tempEndDate   = format.formatDate( endDate );
+               String drillDownPeriodName = periodNames.get( periodCount );
+               
+               Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
+               String drillDownData = selectedOrgUnit.getId() + ":"+ selOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + drillDownPeriodName + ":" + deSelection + ":" + aggChecked;
+               selectedDrillDownData.add( drillDownData );
+             
+               int orgGroupCount = 0;
+               for( OrganisationUnit orgUnit : selOUGroupMemberList )
                {
-                   Date endDate = selEndPeriodList.get( periodCount );
-                   categories[periodCount] = periodNames.get( periodCount );
-                   Double aggDataValue = 0.0;
-                   
-                 //format.formatDate( date )
-                   String tempStartDate = format.formatDate( startDate );
-                   String tempEndDate   = format.formatDate( endDate );
-                   String drillDownPeriodName = periodNames.get( periodCount );
-                   
-                  // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                  // Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
-                   
-                   Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                  // String drillDownData = selectedOrgUnit.getId() + ":"+ selOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
-                   String drillDownData = selectedOrgUnit.getId() + ":"+ selOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + drillDownPeriodName + ":" + deSelection + ":" + aggChecked;
-                   //selectedDrillDownData
-                   selectedDrillDownData.add( drillDownData );
-                 
-                  // for( Period period : periods )
-                   //{
-                       int orgGroupCount = 0;
-                       
-                       for( OrganisationUnit orgUnit : selOUGroupMemberList )
-                       {
-                           
-                           if( aggDataCB != null )
-                           {
-                               Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit );
-                              // System.out.println( "Agg data value before is  : " + aggDataValue );
-                              
-                               if(tempAggDataValue != null ) aggDataValue = tempAggDataValue;
-                              // System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
-                           }
-                           else
-                           {
-                               for( Period period : periods )
-                               {
-                                   DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc );
-                                   
-                                   try
-                                   {
-                                       aggDataValue += Double.parseDouble( dataValue.getValue() );
-                                   }
-                                   catch( Exception e )
-                                   {
-                                       
-                                   }
-                               }
-                              
-                           }
-                              orgGroupCount++;
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
+                       if( aggDataCB != null )
+                       {
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgUnit );
+                           if(tempAggDataValue != null ) aggDataValue += tempAggDataValue;
+                       }
+                       else
+                       {
+                           for( Period period : periods )
+                           {
+                               DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc1 );
+                               try
+                               {
+                                   aggDataValue += Double.parseDouble( dataValue.getValue() );
+                               }
+                               catch( Exception e )
+                               {
+                               }
+                           }
+                       }
                    }
-                   
-              // }
+                   orgGroupCount++;
+               }
    
                data[serviceCount][periodCount] = aggDataValue;
                
@@ -1544,9 +1165,6 @@
       return dataElementChartResult;
     
    }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data OrgGroup Period Wise end 
-    // -------------------------------------------------------------------------
     
     // -------------------------------------------------------------------------
     // Methods for getting Chart Data OrgGroup Selected orgUnit Wise start
@@ -1563,19 +1181,17 @@
        String xAxis_Title = "Organisation Unit Group";
        String yAxis_Title = "Value";
        
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
           
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
                yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
@@ -1583,29 +1199,18 @@
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
                yseriesList.add( dataElement.getName() );
            }
    
-               int orgGroupCount = 0;
-              // int orgGroupCount1 = 0;
-          // Double aggDataValue = 0.0;
-           
+           int orgGroupCount = 0;
            for( OrganisationUnitGroup orgUnitGroup : orgUnitGroupMap.keySet() )
            {
-              // Double aggDataValue = 0.0;
                Double aggDataValue = 0.0;
                
                categories[orgGroupCount] = orgUnitGroup.getName();
-               
                String drillDownData = selectedOrgUnit.getId() + ":" + orgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggChecked;
                selectedDrillDownData.add( drillDownData );
                
-               //String drillDownData = selectedOrgUnit.getId() + ":"+ selOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ decoc.getId() + ":"  + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + deSelection + ":" + aggDataCB;
-               //selectedDrillDownData
-               //selectedDrillDownData.add( drillDownData );
-               
-               
                if( serviceCount == 0 )
                {
                    chartTitle += orgUnitGroup.getName() + ",";
@@ -1625,37 +1230,36 @@
                    {
                        Date endDate = selEndPeriodList.get( periodCount );
                      
-                       //PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                       //Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
                        Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );                               
-                          //for( Period period : periods )
-                         // {
-                       if( aggDataCB != null )
-                       {
-                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit );
-                         //  System.out.println( "Agg data value before is  : " + aggDataValue );
-                          
-                           if(tempAggDataValue != null ) aggDataValue += tempAggDataValue;
-                          // System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
-                       }
-                       else
-                       {
-                           for( Period period : periods )
-                           {    
-                               DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc );
-                               
-                               try
-                               {
-                                   aggDataValue += Double.parseDouble( dataValue.getValue() );
-                               }
-                               catch( Exception e )
-                               {
+
+                       Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                       while ( optionComboIterator.hasNext() )
+                       {
+                           DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
+                           if( aggDataCB != null )
+                           {
+                               Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgUnit );
+                               if(tempAggDataValue != null ) aggDataValue += tempAggDataValue;
+                           }
+                           else
+                           {
+                               for( Period period : periods )
+                               {    
+                                   DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc1 );
                                    
+                                   try
+                                   {
+                                       aggDataValue += Double.parseDouble( dataValue.getValue() );
+                                   }
+                                   catch( Exception e )
+                                   {
+                                       
+                                   }
                                }
                            }
                        }
-                         // }
-                     periodCount++;  
+                       periodCount++;  
                    }  
                }
                data[serviceCount][orgGroupCount] = aggDataValue;
@@ -1683,8 +1287,5 @@
       return dataElementChartResult;
     
    }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data OrgGroup Selected orgUnit Wise end
-    // -------------------------------------------------------------------------        
 
 }

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java	2011-01-11 08:04:51 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java	2011-03-01 09:39:28 +0000
@@ -60,10 +60,6 @@
 {
     private final String PERIODWISE = "period";
 
-    //private final String CHILDREN = "children";
-
-    //private final String OPTIONCOMBO = "optioncombo";
-    //private final String SELECTED = "random";
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -131,15 +127,6 @@
         return categoryLB;
     }
 
-    /* 
-    private String ougGroupSetCB;
-    
-    
-    public void setOugGroupSetCB( String ougGroupSetCB )
-    {
-        this.ougGroupSetCB = ougGroupSetCB;
-    }
-    */
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -178,8 +165,6 @@
 
     private DataElement dataElement;
 
-    //private DataElementCategoryOptionCombo categoryCombo;
-    
     private HttpSession session;
 
     public HttpSession getSession()
@@ -202,19 +187,7 @@
     {
         this.selectedButton = selectedButton;
     }
-   /*
-    private String aggDataCB;
-    
-    public void setAggDataCB( String aggDataCB )
-    {
-        this.aggDataCB = aggDataCB;
-    }
-    
-    public String getAggDataCB()
-    {
-        return aggDataCB;
-    }
-    */
+
     public String[] startDateArray;
     public String[] endDateArray;
     public String[] priodNameArray;
@@ -228,21 +201,15 @@
         return selectedDrillDownData;
     }
     
-    //private String drillDownPeriodStartDate;
-    //private String drillDownPeriodEndDate;
-    //private String drillDownPeriodNames;
-    
     // -------------------------------------------------------------------------
     // Action implements
     // -------------------------------------------------------------------------
     
     public String execute()throws Exception
     {
-        System.out.println( "Inside Generate DrillDown OrgUnit To Period Chart DataElement Result Action " );
-        
         statementManager.initialise();
         
-        selectedDrillDownData = new ArrayList<String>();//drillDown for periodWise
+        selectedDrillDownData = new ArrayList<String>();
         
         selectedOptionComboList = new ArrayList<DataElementCategoryOptionCombo>();
         
@@ -252,11 +219,10 @@
         
         int orgunit =Integer.parseInt( values[0] );
         int orgUnitGroup = Integer.parseInt( values[1]);
-        //System.out.println( " Group Id is " + orgUnitGroup );
+
         if ( orgUnitGroup != 0 )
         {
             selectedOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroup );
-            //System.out.println( " Group Name is " + selectedOrgUnitGroup.getName() );
         }
         
         selectedOrgUnit = organisationUnitService.getOrganisationUnit( orgunit );
@@ -265,7 +231,6 @@
         int optionComboid = Integer.parseInt( values[3] );
         
         dataElement = dataElementService.getDataElement( dataElementid );
-        //categoryCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboid );
         DataElementCategoryOptionCombo categoryCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboid );
         
         List<DataElement> dataElementList = new ArrayList<DataElement>();
@@ -279,48 +244,31 @@
         selEndPeriodList = new ArrayList<Date>();
         periodNames = new ArrayList<String>();
         
-        //drillDownPeriodStartDate = values[5];
-        //drillDownPeriodEndDate = values[6];
-        //drillDownPeriodNames = values[7];
-        
         startDateArray = values[5].split( ";" );
-        //String startDateArray[] = startDateString.split(";");  
-        
         for ( int i = 0 ; i < startDateArray.length ; i++ )
         {
             String startD = startDateArray[i];
             selStartPeriodList.add( format.parseDate( startD ) );
-            //System.out.println( "Start date " + startD );
         }
         
-        //String endDateString = values[6];
         endDateArray = values[6].split( ";" );
-        
         for ( int i = 0 ; i < endDateArray.length ; i++ )
         {
             String startD = endDateArray[i];
             selEndPeriodList.add( format.parseDate( startD ) );
-            //System.out.println( "End date " + startD );
         }
-       // selStartPeriodList.add( format.parseDate( startD ) );
-        //selEndPeriodList.add( format.parseDate( endD ) );
         
         priodNameArray = values[7].split( ";" );
-        
         for ( int i = 0 ; i < priodNameArray.length ; i++ )
         {
             String startD = priodNameArray[i];
             periodNames.add( startD );
         }
         
-        
         String deSelection = values[8];
         String aggDataCB = values[9];
         
-        //String drillDownData = orgUnit.getId() + ":"+ dataElement.getId() + ":"+ decoc.getId() + ":"  + periodType + ":" + tempStartDate + ":" + tempEndDate + ":" + deSelection + ":" + aggDataCB;
-        
         System.out.println( selStartPeriodList + ":" + selEndPeriodList + ":" + periodTypeLB + ":" +  dataElementList+ ":" + deSelection + ":" + selectedOptionComboList +  ":" + selectedOrgUnit + ":" + aggDataCB );
-       // System.out.println( selStartPeriodList.size() + ":" + selEndPeriodList.size() );
         System.out.println( "Chart Generation Start Time is for drillDown: \t" + new Date() );
         
         if( orgUnitGroup == 0 && ( categoryLB.equalsIgnoreCase( PERIODWISE )) ) 
@@ -336,8 +284,6 @@
                 selectedDrillDownData.add( drillDownData );
                 periodCount++;
             }
-            //System.out.println( "hhhiiiiiiiiiiiiii-------------hhhhhhhhhh" );
-            
         }
           
         if( orgUnitGroup != 0 && ( categoryLB.equalsIgnoreCase( PERIODWISE )) ) 
@@ -357,9 +303,7 @@
         
         
         if( orgUnitGroup != 0 )
-        //if( orgUnitGroup != 0 && categoryLB.equalsIgnoreCase( SELECTED ) )
         {
-            //System.out.println( "Inside the method when orgUnit view by selected and group checked" );
             dataElementChartResult = dashBoardService.generateDataElementChartDataWithGroupToPeriodWise( selStartPeriodList, selEndPeriodList, periodNames ,periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, selectedOrgUnitGroup ,aggDataCB );
         }
         else

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java	2011-01-11 08:04:51 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java	2011-03-01 09:39:28 +0000
@@ -59,13 +59,10 @@
 public class GenerateDrillDownPeriodToOrgChildChartDataElementResultAction implements Action
 {
 
-   // private final String PERIODWISE = "period";
-
     private final String CHILDREN = "children";
 
     private final String SELECTED = "random";
     
-    //private final String OPTIONCOMBO = "optioncombo";
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -117,17 +114,16 @@
         this.organisationUnitGroupService = organisationUnitGroupService;
     }
 
-    // -------------------------------------------------------------------------
-    // Input/output
-    // -------------------------------------------------------------------------
-    
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
     {
         this.format = format;
     }
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
     
     private String selDrillDownData;
     
@@ -136,8 +132,44 @@
         this.selDrillDownData = selDrillDownData;
     }
 
-    public String[] values;
-    
+    private String selectedButton;
+    
+    public String getSelectedButton()
+    {
+        return selectedButton;
+    }
+
+    public void setSelectedButton( String selectedButton )
+    {
+        this.selectedButton = selectedButton;
+    }
+
+    private String categoryLB;
+
+    public void setCategoryLB( String categoryLB )
+    {
+        this.categoryLB = categoryLB;
+    }
+
+    public String getCategoryLB()
+    {
+        return categoryLB;
+    }
+
+    private List<String> selectedDrillDownData;
+    
+    public List<String> getSelectedDrillDownData()
+    {
+        return selectedDrillDownData;
+    }
+
+    private HttpSession session;
+
+    public HttpSession getSession()
+    {
+        return session;
+    }
+
     ListTool listTool;
 
     public ListTool getListTool()
@@ -153,106 +185,42 @@
     }
     
     private List<DataElementCategoryOptionCombo> selectedOptionComboList;
-    
     private OrganisationUnit selectedOrgUnit;
-    
     private OrganisationUnitGroup selectedOrgUnitGroup;
-
     private DataElement dataElement;
-
-    //private DataElementCategoryOptionCombo categoryCombo;
-    
-    private HttpSession session;
-
-    public HttpSession getSession()
-    {
-        return session;
-    }
-    
     private List<Date> selStartPeriodList;
-
     private List<Date> selEndPeriodList;
-    
-    private String selectedButton;
-    
-    public String getSelectedButton()
-    {
-        return selectedButton;
-    }
-
-    public void setSelectedButton( String selectedButton )
-    {
-        this.selectedButton = selectedButton;
-    }
-    
+    public String[] values;
     public String[] startDateArray;
     public String[] endDateArray;
     public String[] priodNameArray;
-    
     private  List<String> periodNames;
-    
-    private String categoryLB;
-
-    public void setCategoryLB( String categoryLB )
-    {
-        this.categoryLB = categoryLB;
-    }
-
-    public String getCategoryLB()
-    {
-        return categoryLB;
-    }
-    private List<String> selectedDrillDownData;
-    
-    public List<String> getSelectedDrillDownData()
-    {
-        return selectedDrillDownData;
-    }
-    
     private String drillDownPeriodStartDate;
     private String drillDownPeriodEndDate;
     private String drillDownPeriodNames;
     
-    /*
-    private String aggDataCB;
-    
-    public void setAggDataCB( String aggDataCB )
-    {
-        this.aggDataCB = aggDataCB;
-    }
-    
-    public String getAggDataCB()
-    {
-        return aggDataCB;
-    }
-    */
-    
     // -------------------------------------------------------------------------
     // Action implements
     // -------------------------------------------------------------------------
     
     public String execute()throws Exception
     {
-        
         statementManager.initialise();
         
-        selectedDrillDownData = new ArrayList<String>();//drillDown for periodWise
+        selectedDrillDownData = new ArrayList<String>();
         
         selectedOptionComboList = new ArrayList<DataElementCategoryOptionCombo>();
         
         listTool = new ListTool();
         
-        
-        
         values = selDrillDownData.split( ":" );
         
         int orgunit =Integer.parseInt( values[0] );
         int orgUnitGroup = Integer.parseInt( values[1]);
-        //System.out.println( " Group Id is " + orgUnitGroup );
+
         if ( orgUnitGroup != 0 )
         {
             selectedOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitGroup );
-            //System.out.println( " Group Name is " + selectedOrgUnitGroup.getName() );
         }
         
         selectedOrgUnit = organisationUnitService.getOrganisationUnit( orgunit );
@@ -261,7 +229,6 @@
         int optionComboid = Integer.parseInt( values[3] );
         
         dataElement = dataElementService.getDataElement( dataElementid );
-        //categoryCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboid );
         DataElementCategoryOptionCombo categoryCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboid );
         
         List<DataElement> dataElementList = new ArrayList<DataElement>();
@@ -270,8 +237,6 @@
         selectedOptionComboList.add( categoryCombo );
         
         String periodTypeLB = values[4];
-       // String startD = values[5];
-        //String endD = values[6];
         
         selStartPeriodList = new ArrayList<Date>();
         selEndPeriodList = new ArrayList<Date>();
@@ -281,45 +246,30 @@
         drillDownPeriodEndDate = values[6];
         drillDownPeriodNames = values[7];
         
-        
-        
         startDateArray = values[5].split( ";" );
-        //String startDateArray[] = startDateString.split(";");  
-        
         for ( int i = 0 ; i < startDateArray.length ; i++ )
         {
             String startD = startDateArray[i];
             selStartPeriodList.add( format.parseDate( startD ) );
-           // System.out.println( "Start date " + startD );
         }
         
-        //String endDateString = values[6];
         endDateArray = values[6].split( ";" );
-        
         for ( int i = 0 ; i < endDateArray.length ; i++ )
         {
             String startD = endDateArray[i];
             selEndPeriodList.add( format.parseDate( startD ) );
-           // System.out.println( "End date " + startD );
         }
-       // selStartPeriodList.add( format.parseDate( startD ) );
-        //selEndPeriodList.add( format.parseDate( endD ) );
         
         priodNameArray = values[7].split( ";" );
-        
         for ( int i = 0 ; i < priodNameArray.length ; i++ )
         {
             String periodName = priodNameArray[i];
             periodNames.add( periodName );
         }
-       // selStartPeriodList.add( format.parseDate( startD ) );
-        //selEndPeriodList.add( format.parseDate( endD ) );
         
         String deSelection = values[8];
         String aggDataCB = values[9];
         
-        //String drillDownData = orgUnit.getId() + ":"+ dataElement.getId() + ":"+ decoc.getId() + ":"  + periodType + ":" + tempStartDate + ":" + tempEndDate + ":" + deSelection + ":" + aggDataCB;
-        
         System.out.println( selStartPeriodList + ":" + selEndPeriodList + ":" +periodTypeLB + ":" +  dataElementList+ ":" + deSelection + ":" + selectedOptionComboList +  ":" + selectedOrgUnit + ":" + aggDataCB );
         System.out.println( "Chart Generation Start Time is for drillDown: \t" + new Date() );
         
@@ -331,17 +281,14 @@
            for( OrganisationUnit orgChild : childOrgUnitList )
            {
                String drillDownData = orgChild.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
+               System.out.println(drillDownData);
                selectedDrillDownData.add( drillDownData );
            }
         }
        
         if ( orgUnitGroup != 0 && ( categoryLB.equalsIgnoreCase( CHILDREN ) || ( categoryLB.equalsIgnoreCase( SELECTED )) )) 
         {
-           // List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
-            //childOrgUnitList = new ArrayList<OrganisationUnit>( selectedOrgUnit.getChildren());
-            
             List<OrganisationUnit> selectedOUGroupMemberList = new ArrayList<OrganisationUnit>( selectedOrgUnitGroup.getMembers() );
-            
             List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
             childOrgUnitList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) );
            
@@ -350,19 +297,11 @@
            for( OrganisationUnit orgChild : selectedOUGroupMemberList )
            {
                 String drillDownData = orgChild.getId() + ":" + selectedOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
+                System.out.println(drillDownData);
                 selectedDrillDownData.add( drillDownData );
            }
-            
         }
-/*
-        if ( orgUnitGroup != 0 &&  categoryLB.equals( SELECTED ) )
-           {
-               String drillDownData = selectedOrgUnit.getId() + ":" + selectedOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":"  + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB;
-               selectedDrillDownData.add( drillDownData );
-            
-           }
-            
-*/       
+
         if ( orgUnitGroup != 0 )
         {
             dataElementChartResult = dashBoardService.generateDataElementChartDataWithGroupMemberWise( selStartPeriodList, selEndPeriodList, periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, selectedOrgUnitGroup ,aggDataCB );
@@ -389,6 +328,5 @@
         statementManager.destroy();
         return SUCCESS;
     }
-
     
 }

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ta/action/GenerateTabularAnalysisResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ta/action/GenerateTabularAnalysisResultAction.java	2010-12-29 16:17:28 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ta/action/GenerateTabularAnalysisResultAction.java	2011-03-01 09:39:28 +0000
@@ -214,11 +214,6 @@
         this.deSelection = deSelection;
     }
 
-    /*
-     * private String ouSelCB;
-     * 
-     * public void setOuSelCB( String ouSelCB ) { this.ouSelCB = ouSelCB; }
-     */
     private List<String> orgUnitListCB;
 
     public void setOrgUnitListCB( List<String> orgUnitListCB )
@@ -283,22 +278,12 @@
         /* Initialization */
         statementManager.initialise();
 
-        /* Service Info */
-        /*
-         * Indicator selIndicator = new Indicator(); DataElement selDataElement
-         * = new DataElement(); DataElementCategoryOptionCombo selDecoc = new
-         * DataElementCategoryOptionCombo();
-         */
-        // int flag = 0;
         selOUList = new ArrayList<OrganisationUnit>();
         selStartPeriodList = new ArrayList<Date>();
         selEndPeriodList = new ArrayList<Date>();
 
         ouChildCountMap = new HashMap<OrganisationUnit, Integer>();
 
-      //  String monthOrder[] = { "04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02", "03" };
-       // int monthDays[] = { 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31 };
-
         String monthOrder[] = {  "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
         int monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
         
@@ -309,7 +294,6 @@
         String endD = "";
 
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
-       // SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat( "yyyy-MM-dd" );
        
         periodNames = new ArrayList<String>();
         // for weekly period
@@ -338,31 +322,16 @@
             System.out.println( " Inside other than weekly" );
             for ( String year : yearLB )
             {
-                //int selYear = Integer.parseInt( year.split( "-" )[0] );
-                
                 int selYear = Integer.parseInt( year );
         
                 if ( periodTypeLB.equalsIgnoreCase( YearlyPeriodType.NAME ) )
                 {
-        
-                   // startD = "" + selYear + "-04-01";
-                   // endD = "" + (selYear + 1) + "-03-31";
-                    
-                    
                     startD = "" + selYear + "-01-01";
                     endD = "" + selYear  + "-12-31";
                     
-                   // System.out.println( " Start Peroid  : " + format.parseDate( startD ) + " , End Peroid : " + format.parseDate( endD ) );
-                    
                     selStartPeriodList.add( format.parseDate( startD ) );
                     selEndPeriodList.add( format.parseDate( endD ) );
                     
-                   // System.out.println( "Size of Start Peroid List : " + selStartPeriodList.size() + " , Size of End Peroid List : " + selEndPeriodList.size() );
-                    
-                    //System.out.println( " Start Peroid List : " + selStartPeriodList + " , End Peroid List : " + selEndPeriodList );
-                    
-                   // periodNames.add( "" + selYear + "-" + (selYear + 1) );
-                    
                     periodNames.add( "" + selYear );
         
                     continue;
@@ -370,8 +339,6 @@
         
                 for ( String periodStr : periodLB )
                 {
-                   // int period = Integer.parseInt( periodStr );
-        
                     if ( periodTypeLB.equalsIgnoreCase( MonthlyPeriodType.NAME ) )
                     {
                         int period = Integer.parseInt( periodStr );
@@ -388,10 +355,7 @@
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
                         
-                       // System.out.println( "Size of Start Date List : " + selStartPeriodList.size() + " , Size of End Date List : " + selEndPeriodList.size() );
-                        
                         periodNames.add( simpleDateFormat.format( format.parseDate( startD ) ) );
-                        
                     }
                     else if ( periodTypeLB.equalsIgnoreCase( QuarterlyPeriodType.NAME ) )
                     {
@@ -422,7 +386,6 @@
                         }
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
-                        //System.out.println( "Start Date : " + startD + " , End Date : " + endD );
                     }
                     else if ( periodTypeLB.equalsIgnoreCase( SixMonthlyPeriodType.NAME ) )
                     {
@@ -442,7 +405,6 @@
                        
                         selStartPeriodList.add( format.parseDate( startD ) );
                         selEndPeriodList.add( format.parseDate( endD ) );
-                        //System.out.println( "Start Date : " + startD + " , End Date : " + endD );
                     }
                     else if ( periodTypeLB.equalsIgnoreCase( DailyPeriodType.NAME ) )
                     {
@@ -452,22 +414,18 @@
                        startD = selYear + "-" + periodStr;
                        endD = selYear + "-" + periodStr ;
                        
-                       if ( selYear  % 4 != 0 && month.trim().equalsIgnoreCase( "02" )  && date.trim().equalsIgnoreCase( "29" ) )
-                       {
-                            startD = selYear + "-" + month + "-" + date;
-                            endD = selYear + "-" + month + "-" + date;
-                            continue;
-                       }
-                       if ( (( selYear % 400 == 0) || (( selYear % 100 != 0 && selYear % 4 == 0))) && month.trim().equalsIgnoreCase( "02" )  && date.trim().equalsIgnoreCase( "29" ) ); 
-                       {
-                            startD = selYear + "-" + month + "-" + date;
-                            endD = selYear  + "-" + month + "-" + date;
-                       }
+                       if( selYear  % 4 != 0 && month.trim().equalsIgnoreCase( "02" )  && date.trim().equalsIgnoreCase( "29" ) )
+                       {
+                           continue;
+                       }
+
+                       startD = selYear + "-" + month + "-" + date;
+                       endD = selYear  + "-" + month + "-" + date;
+                       
                        selStartPeriodList.add( format.parseDate( startD ) );
                        selEndPeriodList.add( format.parseDate( endD ) );
-                        
+                       System.out.println( startD + " *** " + endD );
                        periodNames.add( startD );
-                       // System.out.println( startD + " : " + endD );
                     }
                 }
             }
@@ -872,40 +830,35 @@
         sheet0.addCell( new Label( headerCol, headerRow, "Sl.No.", getCellFormat1() ) );
 
         selOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
-        List<OrganisationUnit> orgUnitList1 = new ArrayList<OrganisationUnit>( organisationUnitService
+        List<OrganisationUnit> selOUList = new ArrayList<OrganisationUnit>( organisationUnitService
             .getOrganisationUnitWithChildren( selOrgUnit.getId() ) );
-        System.out.println( "ordunitlevelcb = " + orgUnitLevelCB );
         OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( orgUnitLevelCB );
-        selOUList = new ArrayList<OrganisationUnit>( selOrgUnitGroup.getMembers() );
+        List<OrganisationUnit> orgUnitList1 = new ArrayList<OrganisationUnit>( selOrgUnitGroup.getMembers() );
 
         selOUList.retainAll( orgUnitList1 );
-        // List<OrganisationUnit> ouList = new
-        // ArrayList<OrganisationUnit>(selOUList);
-        // int minLevel = organisationUnitService.getLevelOfOrganisationUnit(
-        // selOrgUnit );
-        // int maxLevel = organisationUnitService.getLevelOfOrganisationUnit(
-        // ouList.get( 0 ) );
 
-        Collections.sort( selOUList, new OrganisationUnitNameComparator() );
+        //Collections.sort( selOUList, new OrganisationUnitNameComparator() );
         // displayPropertyHandler.handle( selOUList );
 
         int minOULevel = 1;
+        int maxOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
+        
+        
         /*
-         * int maxOuLevel = 1; if( selOUList != null && selOUList.size() > 0 ) {
-         * if(orgUnitLevelCB != null ) { maxOuLevel =
-         * organisationUnitService.getLevelOfOrganisationUnit( selOUList.get( 0
-         * ) ); }
-         * 
-         * }
-         */
         if ( orgUnitLevelCB != null )
+        {
             minOULevel = organisationUnitService.getLevelOfOrganisationUnit( selOrgUnit );
-
+        }
+        */
+        
         int c1 = headerCol + 1;
 
-        sheet0.mergeCells( c1, headerRow, c1, headerRow + 1 );
-        sheet0.addCell( new Label( c1, headerRow, "Facility", getCellFormat1() ) );
-        c1++;
+        for( int i = minOULevel; i <= maxOULevel; i++ )
+        {
+            sheet0.mergeCells( c1, headerRow, c1, headerRow + 1 );
+            sheet0.addCell( new Label( c1, headerRow, "Level- "+i, getCellFormat1() ) );
+            c1++;
+        }
 
         /* Calculation Part */
         int rowCount = 1;
@@ -919,8 +872,19 @@
 
             // sheet0.mergeCells( colCount, headerRow+1+rowCount, colCount,
             // headerRow+1+rowCount+ouChildCountMap.get( ou ));
-            sheet0.addCell( new Label( 1, rowCount + 1, ou.getName(), getCellFormat2() ) );
-
+            sheet0.addCell( new Label( colCount, rowCount + 1, ou.getName(), getCellFormat2() ) );
+            
+            OrganisationUnit orgUnit = new OrganisationUnit();
+            orgUnit = ou;
+            int count1=1;
+            while( orgUnit.getParent() != null )
+            {
+                orgUnit = orgUnit.getParent();
+                sheet0.addCell( new Label( colCount-count1, rowCount + 1, orgUnit.getName(), getCellFormat2() ) );
+                count1++;
+            }
+            
+            
             /*
              * 
              * OrganisationUnit parentOu = ou; for(int i =
@@ -1227,23 +1191,17 @@
     }
 
     // -------------------------------------------------------------------------
-    // Methods for getting OrgUnit Lebel wise List in Excel Sheet
+    // Method for getting OrgUnit Level wise List in Excel Sheet
     // -------------------------------------------------------------------------
-
     public void generateOrgUnitLevel()
         throws Exception
     {
         int startRow = 0;
-        // int startCol = 0;
         int headerRow = 0;
         int headerCol = 0;
 
-        System.out.println( "inside the generateOrgUnitLevel" );
-
-        String raFolderName = configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER )
-            .getValue();
-        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
-            + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
+        String raFolderName = configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER ).getValue();
+        String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "output" + File.separator + UUID.randomUUID().toString() + ".xls";
         WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ) );
         WritableSheet sheet0 = outputReportWorkbook.createSheet( "TabularAnalysis", 0 );
 
@@ -1251,9 +1209,7 @@
         sheet0.addCell( new Label( headerCol, headerRow, "Sl.No.", getCellFormat1() ) );
 
         selOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
-
-        selOUList = getChildOrgUnitTree( selOrgUnit );
-        System.out.println( "selected OugUnit : " + selOUList.get( 0 ).getName() );
+        selOUList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selOrgUnit.getId() ) );
 
         Iterator<OrganisationUnit> ouIterator = selOUList.iterator();
         while ( ouIterator.hasNext() )
@@ -1273,10 +1229,7 @@
         }
         maxOuLevel = orgUnitLevelCB;
 
-        System.out.println( "minOULevel : " + minOULevel + ", maxOuLevel : " + maxOuLevel );
-
         int c1 = headerCol + 1;
-
         for ( int i = minOULevel; i <= maxOuLevel; i++ )
         {
             sheet0.mergeCells( c1, headerRow, c1, headerRow + 1 );
@@ -1297,22 +1250,8 @@
         {
             sheet0.addCell( new Number( headerCol, headerRow + 1 + rowCount, rowCount, getCellFormat2() ) );
             colCount = 1 + organisationUnitService.getLevelOfOrganisationUnit( ou ) - minOULevel;
-            // System.out.println(colCount + " : " + minOULevel + " : " +
-            // organisationUnitService.getLevelOfOrganisationUnit( ou ));
-
-            // sheet0.mergeCells( colCount, headerRow+1+rowCount, colCount,
-            // headerRow+1+rowCount+ouChildCountMap.get( ou ));
             sheet0.addCell( new Label( colCount, headerRow + 1 + rowCount, ou.getName(), getCellFormat2() ) );
 
-            /*
-             * OrganisationUnit parentOu = ou; for(int i =
-             * maxOuLevel-minOULevel+1; i >= minOULevel-1; i-- ) { if( i ==
-             * colCount ) { sheet0.addCell( new Label( colCount-1,
-             * headerRow+1+rowCount, ou.getName(), getCellFormat2() ) ); } else
-             * { parentOu = parentOu.getParent(); sheet0.addCell( new Label( i,
-             * headerRow+rowCount, parentOu.getName(), getCellFormat2() ) ); } }
-             */
-
             colCount = c1;
             for ( String service : selectedServices )
             {
@@ -1331,7 +1270,6 @@
                         {
                             sheet0.mergeCells( colCount, startRow, colCount, startRow + 1 );
                         }
-
                         sheet0.addCell( new Label( colCount, startRow, selIndicator.getName(), getCellFormat1() ) );
                     }
                 }
@@ -1342,22 +1280,18 @@
 
                     if ( deSelection.equalsIgnoreCase( "optioncombo" ) )
                     {
-                        selDecoc = dataElementCategoryService.getDataElementCategoryOptionCombo( Integer
-                            .parseInt( partsOfService[2] ) );
+                        selDecoc = dataElementCategoryService.getDataElementCategoryOptionCombo( Integer.parseInt( partsOfService[2] ) );
                         if ( rowCount == 1 )
                         {
                             if ( aggPeriodCB == null )
                             {
-                                sheet0.mergeCells( colCount, startRow, colCount + selStartPeriodList.size() - 1,
-                                    startRow );
+                                sheet0.mergeCells( colCount, startRow, colCount + selStartPeriodList.size() - 1, startRow );
                             }
                             else
                             {
                                 sheet0.mergeCells( colCount, startRow, colCount, startRow + 1 );
                             }
-
-                            sheet0.addCell( new Label( colCount, startRow, selDataElement.getName() + "-"
-                                + selDecoc.getName(), getCellFormat1() ) );
+                            sheet0.addCell( new Label( colCount, startRow, selDataElement.getName() + "-" + selDecoc.getName(), getCellFormat1() ) );
                         }
                     }
                     else
@@ -1366,16 +1300,13 @@
                         {
                             if ( aggPeriodCB == null )
                             {
-                                sheet0.mergeCells( colCount, startRow, colCount + selStartPeriodList.size() - 1,
-                                    startRow );
+                                sheet0.mergeCells( colCount, startRow, colCount + selStartPeriodList.size() - 1, startRow );
                             }
                             else
                             {
                                 sheet0.mergeCells( colCount, startRow, colCount, startRow + 1 );
                             }
-
-                            sheet0
-                                .addCell( new Label( colCount, startRow, selDataElement.getName(), getCellFormat1() ) );
+                            sheet0.addCell( new Label( colCount, startRow, selDataElement.getName(), getCellFormat1() ) );
                         }
                     }
                 }
@@ -1403,6 +1334,7 @@
                         if ( tempAggVal == null )
                             tempAggVal = 0.0;
                         pwnumAggValue = tempAggVal;
+                        
                         tempAggVal = aggregationService.getAggregatedDenominatorValue( selIndicator, sDate, eDate, ou );
                         if ( tempAggVal == null )
                             tempAggVal = 0.0;
@@ -1415,7 +1347,6 @@
 
                         pwdAggIndValue = Math.round( pwdAggIndValue * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 );
                         tempStr = "" + pwdAggIndValue;
-
                     }
                     else if ( flag == 2 )
                     {
@@ -1423,8 +1354,7 @@
                         {
                             if ( selDataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
                             {
-                                tempAggVal = aggregationService.getAggregatedDataValue( selDataElement, selDecoc,
-                                    sDate, eDate, ou );
+                                tempAggVal = aggregationService.getAggregatedDataValue( selDataElement, selDecoc, sDate, eDate, ou );
                                 if ( tempAggVal == null )
                                     tempAggVal = 0.0;
                                 pwdvAggValue = tempAggVal;
@@ -1437,10 +1367,9 @@
                                 Period tempPeriod = periodService.getPeriod( sDate, eDate, periodType );
                                 if ( tempPeriod != null )
                                 {
-                                    DataValue dataValue = dataValueService.getDataValue( ou, selDataElement,
-                                        tempPeriod, selDecoc );
+                                    DataValue dataValue = dataValueService.getDataValue( ou, selDataElement, tempPeriod, selDecoc );
 
-                                    if ( dataValue != null )
+                                    if ( dataValue != null && dataValue.getValue() != null )
                                     {
                                         tempStr = dataValue.getValue();
                                     }

=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java	2011-01-11 08:04:51 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java	2011-03-01 09:39:28 +0000
@@ -34,11 +34,13 @@
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
 
 import org.hisp.dhis.aggregation.AggregationService;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.datavalue.DataValue;
@@ -126,22 +128,6 @@
     }
 
     /*
-     * public List<Period> getMonthlyPeriods(Date start, Date end) { PeriodType
-     * monthlyPeriodType = getPeriodTypeObject("monthly"); Calendar cal =
-     * Calendar.getInstance(); cal.setTime(start); Calendar cal1 =
-     * Calendar.getInstance(); cal1.setTime(end); boolean januaryIsFirst =
-     * false; if (cal.get(Calendar.MONTH) == Calendar.JANUARY) { januaryIsFirst
-     * = true; } List<Period> periods = new ArrayList<Period>(); while
-     * (cal.get(Calendar.MONTH) != cal1.get(Calendar.MONTH)) { Period period =
-     * getPeriodByMonth(cal.get(Calendar.MONTH), cal .get(Calendar.YEAR),
-     * monthlyPeriodType); if (period != null) { periods.add(period); }
-     * cal.roll(Calendar.MONTH, true); if (!januaryIsFirst &&
-     * cal.get(Calendar.MONTH) == 0) { cal.roll(Calendar.YEAR, true); } }
-     * periods.add(getPeriodByMonth(cal1.get(Calendar.MONTH), cal1
-     * .get(Calendar.YEAR), monthlyPeriodType)); return periods; }
-     */
-
-    /*
      * Returns the Period Object of the given date For ex:- if the month is 3,
      * year is 2006 and periodType Object of type Monthly then it returns the
      * corresponding Period Object
@@ -178,332 +164,8 @@
         return newPeriod;
     }
 
-    /*
-    public String getRootDataPath()
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st = null;
-
-        ResultSet rs1 = null;
-
-        String rootDataPath = null;
-
-        String query = "";
-
-        try
-        {
-            st = con.createStatement();
-
-            query = "SELECT mvalue FROM maintenancein WHERE mkey LIKE '" + MaintenanceIN.KEY_ROOTDATAPATH + "'";
-            rs1 = st.executeQuery( query );
-
-            if ( rs1.next() )
-            {
-                rootDataPath = rs1.getString( 1 );
-            }
-        }
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-            return null;
-        }
-        finally
-        {
-            try
-            {
-                if ( st != null )
-                    st.close();
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-                return null;
-            }
-        }// finally block end
-
-        return rootDataPath;
-    }
-
-    public String getMYSqlPath()
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st = null;
-
-        ResultSet rs1 = null;
-
-        String mysqlPath = null;
-
-        String query = "";
-
-        try
-        {
-            st = con.createStatement();
-
-            query = "SELECT mvalue FROM maintenancein WHERE mkey LIKE '" + MaintenanceIN.KEY_MYSQLPATH + "'";
-            rs1 = st.executeQuery( query );
-
-            if ( rs1.next() )
-            {
-                mysqlPath = rs1.getString( 1 );
-            }
-
-        }
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-            return null;
-        }
-        finally
-        {
-            try
-            {
-                if ( st != null )
-                    st.close();
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-                return null;
-            }
-        }// finally block end
-
-        return mysqlPath;
-
-    }
-
-    public void setUserdefinedConfigurations( String dbPath, String dataPath )
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st = null;
-        Statement st1 = null;
-        Statement st2 = null;
-
-        Statement st3 = null;
-        Statement st4 = null;
-
-        ResultSet rs1 = null;
-        ResultSet rs2 = null;
-
-        String mysqlKey = null;
-        String mysqlPath = null;
-
-        String rootDataKey = null;
-        String rootDataPath = null;
-
-        String query = "";
-
-        try
-        {
-            st = con.createStatement();
-            st1 = con.createStatement();
-
-            query = "CREATE TABLE IF NOT EXISTS maintenancein ( mkey varchar(100) NOT NULL, mvalue varchar(400) default NULL, PRIMARY KEY  (mkey)  ) ENGINE=InnoDB DEFAULT CHARSET=utf8";
-            st.executeUpdate( query );
-            System.out.println( "Table Created (if not exists) " );
-
-            // MYSQL PATH
-            query = "SELECT mkey, mvalue FROM maintenancein WHERE mkey LIKE '" + MaintenanceIN.KEY_MYSQLPATH + "'";
-            rs1 = st1.executeQuery( query );
-
-            if ( rs1.next() )
-            {
-                mysqlKey = rs1.getString( 1 );
-                mysqlPath = rs1.getString( 2 );
-            }
-
-            if ( mysqlKey == null )
-            {
-                mysqlKey = MaintenanceIN.KEY_MYSQLPATH;
-                mysqlPath = dbPath;
-
-                st2 = con.createStatement();
-                query = "INSERT INTO maintenancein VALUES ('" + mysqlKey + "','" + mysqlPath + "')";
-
-                st2.executeUpdate( query );
-                System.out.println( " MySQL UserDefined Path added" );
-            }
-            else
-            {
-                mysqlPath = dbPath;
-
-                st2 = con.createStatement();
-                query = "UPDATE maintenancein SET mvalue = '" + mysqlPath + "' WHERE mkey LIKE '"
-                    + MaintenanceIN.KEY_MYSQLPATH + "'";
-
-                st2.executeUpdate( query );
-                System.out.println( " MySQL UserDefined Path updated" );
-            }
-
-            // DATA PATH
-            st3 = con.createStatement();
-
-            query = "SELECT mkey, mvalue FROM maintenancein WHERE mkey LIKE '" + MaintenanceIN.KEY_ROOTDATAPATH + "'";
-            rs2 = st3.executeQuery( query );
-
-            if ( rs2.next() )
-            {
-                rootDataKey = rs2.getString( 1 );
-                rootDataPath = rs2.getString( 2 );
-            }
-
-            if ( rootDataKey == null )
-            {
-                rootDataKey = MaintenanceIN.KEY_ROOTDATAPATH;
-                rootDataPath = dataPath;
-
-                st4 = con.createStatement();
-                query = "INSERT INTO maintenancein VALUES ('" + rootDataKey + "','" + rootDataPath + "')";
-
-                st4.executeUpdate( query );
-                System.out.println( " RootData UserDefined Path added" );
-            }
-            else
-            {
-                rootDataPath = dataPath;
-
-                st4 = con.createStatement();
-                query = "UPDATE maintenancein SET mvalue = '" + rootDataPath + "' WHERE mkey LIKE '"
-                    + MaintenanceIN.KEY_ROOTDATAPATH + "'";
-
-                st4.executeUpdate( query );
-                System.out.println( " RootData UserDefined Path updated" );
-            }
-        }
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-        }
-        finally
-        {
-            try
-            {
-                if ( st != null )
-                    st.close();
-                if ( st1 != null )
-                    st1.close();
-                if ( st2 != null )
-                    st2.close();
-
-                if ( st3 != null )
-                    st3.close();
-                if ( st4 != null )
-                    st4.close();
-
-                if ( rs1 != null )
-                    rs1.close();
-                if ( rs2 != null )
-                    rs2.close();
-
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-            }
-        }// finally block end
-    }
-
-    public String setMYSqlDefaultPath( String path )
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st = null;
-        Statement st1 = null;
-        Statement st2 = null;
-
-        ResultSet rs1 = null;
-
-        String mysqlKey = null;
-        String mysqlPath = null;
-
-        String query = "";
-
-        try
-        {
-            st = con.createStatement();
-            st1 = con.createStatement();
-
-            query = "CREATE TABLE IF NOT EXISTS maintenancein ( mkey varchar(100) NOT NULL, mvalue varchar(400) default NULL, PRIMARY KEY  (mkey)  ) ENGINE=InnoDB DEFAULT CHARSET=utf8";
-            st.executeUpdate( query );
-            System.out.println( "Table Created (if not exists) " );
-
-            query = "SELECT mkey, mvalue FROM maintenancein WHERE mkey LIKE '" + MaintenanceIN.KEY_MYSQLPATH + "'";
-            rs1 = st1.executeQuery( query );
-
-            if ( rs1.next() )
-            {
-                mysqlKey = rs1.getString( 1 );
-                mysqlPath = rs1.getString( 2 );
-            }
-
-            if ( mysqlKey == null )
-            {
-                mysqlKey = MaintenanceIN.KEY_MYSQLPATH;
-                mysqlPath = path;
-
-                st2 = con.createStatement();
-                query = "INSERT INTO maintenancein VALUES ('" + mysqlKey + "','" + mysqlPath + "')";
-
-                st2.executeUpdate( query );
-                System.out.println( " MySQL Default Path added" );
-            }
-            else if ( mysqlPath == null || mysqlPath.trim().equals( "" ) )
-            {
-                mysqlPath = path;
-
-                st2 = con.createStatement();
-                query = "UPDATE maintenancein SET mvalue = '" + mysqlPath + "' WHERE mkey LIKE '"
-                    + MaintenanceIN.KEY_MYSQLPATH + "'";
-
-                st2.executeUpdate( query );
-                System.out.println( " MySQL Default Path updated" );
-            }
-        }
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-            return null;
-        }
-        finally
-        {
-            try
-            {
-                if ( st != null )
-                    st.close();
-                if ( st1 != null )
-                    st1.close();
-                if ( st2 != null )
-                    st2.close();
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-                return null;
-            }
-        }// finally block end
-
-        return mysqlPath;
-    }
-*/
     public String createDataTable( String orgUnitInfo, String deInfo, String periodInfo, Connection con )
     {
-        // Connection con = (new DBConnection()).openConnection();
-        // Connection con = dbConnection.openConnection();
-
         Statement st1 = null;
         Statement st2 = null;
 
@@ -555,100 +217,6 @@
         return dataTableName;
     }
 
-    /*
-    public String createDataTableForComments( String orgUnitInfo, String deInfo, String periodInfo )
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st1 = null;
-        Statement st2 = null;
-
-        String dataTableName = "data" + UUID.randomUUID().toString();
-        dataTableName = dataTableName.replaceAll( "-", "" );
-
-        String query = "DROP TABLE IF EXISTS " + dataTableName;
-
-        try
-        {
-            st1 = con.createStatement();
-            st2 = con.createStatement();
-
-            st1.executeUpdate( query );
-
-            System.out.println( "TABLE NAME : " + dataTableName );
-            System.out.println( "Table dropped Successfully (if exists) " );
-
-            query = "CREATE table " + dataTableName + " AS "
-                + " SELECT sourceid,dataelementid,periodid,value,comment FROM datavalue " + " WHERE dataelementid in ("
-                + deInfo + ") AND " + " sourceid in (" + orgUnitInfo + ") AND " + " periodid in (" + periodInfo
-                + ") AND " + " commnet IS NOT NULL";
-
-            st2.executeUpdate( query );
-
-            System.out.println( "Table created Successfully" );
-        } // try block end
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-            return null;
-        }
-        finally
-        {
-            try
-            {
-                if ( st1 != null )
-                    st1.close();
-                if ( st2 != null )
-                    st2.close();
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-                return null;
-            }
-        }// finally block end
-
-        return dataTableName;
-    }
-
-    public void deleteDataTable( String dataTableName )
-    {
-        // Connection con = (new DBConnection()).openConnection();
-        Connection con = dbConnection.openConnection();
-
-        Statement st1 = null;
-
-        String query = "DROP TABLE IF EXISTS " + dataTableName;
-
-        try
-        {
-            st1 = con.createStatement();
-            st1.executeUpdate( query );
-            System.out.println( "Table " + dataTableName + " dropped Successfully" );
-        } // try block end
-        catch ( Exception e )
-        {
-            System.out.println( "SQL Exception : " + e.getMessage() );
-        }
-        finally
-        {
-            try
-            {
-                if ( st1 != null )
-                    st1.close();
-                if ( con != null )
-                    con.close();
-            }
-            catch ( Exception e )
-            {
-                System.out.println( "SQL Exception : " + e.getMessage() );
-            }
-        }// finally block end
-    }
-*/
     public List<String> getPeriodNamesByPeriodType( PeriodType periodType, Collection<Period> periods )
     {
         SimpleDateFormat simpleDateFormat1;
@@ -693,7 +261,6 @@
             for ( Period p1 : periods )
             {
                 String tempPeriodName = simpleDateFormat1.format( p1.getStartDate() );
-                //String tempPeriodName = ""+p1.getStartDate();   
                 periodNameList.add( tempPeriodName );
             }
         }
@@ -713,7 +280,6 @@
     
     public double getIndividualIndicatorValue( Indicator indicator, OrganisationUnit orgunit, Date startDate, Date endDate ) 
     {
-
         String numeratorExp = indicator.getNumerator();
         String denominatorExp = indicator.getDenominator();
         int indicatorFactor = indicator.getIndicatorType().getFactor();
@@ -744,7 +310,6 @@
         double aggregatedValue;
         try
         {
-            //aggregatedValue = ( numeratorValue / denominatorValue ) * indicatorFactor;
             if( denominatorValue == 0 )
             {
                 aggregatedValue = 0.0;
@@ -764,10 +329,9 @@
     }
 
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Children Wise start ( this method is called when view by -> periodWise and group not selected )
+    // Methods for getting Chart Data With Children Wise start 
+    // ( this method is called when view by -> periodWise and group not selected )
     // -------------------------------------------------------------------------
-        
- 
     public DataElementChartResult generateDataElementChartDataWithChildrenWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,String  periodTypeLB ,List<DataElement> dataElementList, String deSelection, List<DataElementCategoryOptionCombo> decocList, OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception
     {
        System.out.println( "inside Dashboard Service generateChartDataWithChildrenWise " );
@@ -777,39 +341,32 @@
        List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
        childOrgUnitList = new ArrayList<OrganisationUnit>( selectedOrgUnit.getChildren());
        
-       
        String[] series = new String[dataElementList.size()];
        String[] categories = new String[childOrgUnitList.size()];
        Double[][] data = new Double[dataElementList.size()][childOrgUnitList.size()];
        String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName();
        
-      // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
        String xAxis_Title = "Facilities";
        String yAxis_Title = "Value";
     
-      // System.out.println("\n\n +++ \n decoc : " + decocList);
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
-          
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
-               //yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
            else
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
-               //yseriesList.add( dataElement.getName() );
            }
            
            int childCount = 0;
@@ -824,48 +381,37 @@
                {
                    Date endDate = selEndPeriodList.get( periodCount );
                    PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                   //Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
                    Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
                    
                    System.out.println( periods.size() + ":" + periodType + ":" + startDate + ":" +  endDate );
                    
-                  // for( Period period : periods )
-                  // {
-                      // System.out.println( dataElement + ":" + decoc + ":" +period.getStartDate() + ":" +  period.getEndDate()+ ":" + orgChild + ":" + aggDataCB );
-                       
-                      // if( aggDataCB != null )
-                       int aggChecked = Integer.parseInt( aggDataCB );
-                   
+                   int aggChecked = Integer.parseInt( aggDataCB );
+
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
                        if( aggChecked == 1 )
                        {
-                           //System.out.println( "inside aggDataCB check  : " );
-                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgChild );
-                           //System.out.println( dataElement + ":" + decoc + ":" +period.getStartDate() + ":" +  period.getEndDate()+ ":" + orgChild );
-                          
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgChild );
                            if( tempAggDataValue != null ) aggDataValue += tempAggDataValue;
-                           //System.out.println( "Agg data value after zero assign is aggDataCB check  : " + aggDataValue );
                        }
                        else
                        {
                            for( Period period : periods )
                            {
-                               //System.out.println( "inside aggDataCB not check  : " );
-                               DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc );
-                               
+                               DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc1 );                               
                                try
                                {
                                    aggDataValue += Double.parseDouble( dataValue.getValue() );
                                }
                                catch( Exception e )
-                               {
-                                   
+                               {                                   
                                }
-                               
                            }
-                         
-                           //System.out.println( "Agg data value after zero assign is when aggDataCB not check  : " + aggDataValue );
                        }
-                  // }
+                   }
                    periodCount++;
                }
  
@@ -891,25 +437,19 @@
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
        return dataElementChartResult;
     }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Children Wise end
-    // -------------------------------------------------------------------------
-        
-    
-    
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With groupMember Wise start ( this method is called when view by -> periodWise and group  selected )
-    // -------------------------------------------------------------------------
-        
- 
+    
+    
+    // -------------------------------------------------------------------------
+    // Methods for getting Chart Data With groupMember Wise start 
+    // ( this method is called when view by -> periodWise and group  selected )
+    // -------------------------------------------------------------------------
+    
     public DataElementChartResult generateDataElementChartDataWithGroupMemberWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,String  periodTypeLB ,List<DataElement> dataElementList, String deSelection, List<DataElementCategoryOptionCombo> decocList, OrganisationUnit selectedOrgUnit , OrganisationUnitGroup selectedOrgUnitGroup , String aggDataCB ) throws Exception
     {
         System.out.println( "inside Dashboard Service generateChartDataWithGroupMemberWise " );
         
         DataElementChartResult dataElementChartResult;
         
-        //OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup(  selectedOrgUnitGroup  );
-        
         List<OrganisationUnit> selectedOUGroupMemberList = new ArrayList<OrganisationUnit>( selectedOrgUnitGroup.getMembers() );
        
         List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
@@ -917,40 +457,31 @@
        
         selectedOUGroupMemberList.retainAll( childOrgUnitList );
         
-       
         String[] series = new String[dataElementList.size()];
         String[] categories = new String[selectedOUGroupMemberList.size()];
         Double[][] data = new Double[dataElementList.size()][selectedOUGroupMemberList.size()];
-        //String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName();
         String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "(" + selectedOrgUnitGroup.getName() +  ")";
        
-      // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
         String xAxis_Title = "Facilities";
         String yAxis_Title = "Value";
     
-        //System.out.println("size of children : " +childOrgUnitList.size() + ", Size og GroupMember : " + selectedOUGroupMemberList.size()+ ", size of CommomGroupMember : " + selectedOUGroupMemberList.size());
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
           
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
-               //yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
            else
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
-               //yseriesList.add( dataElement.getName() );
            }
            
            int GroupMemberCount = 0;
@@ -964,48 +495,35 @@
                for( Date startDate : selStartPeriodList )
                {
                    Date endDate = selEndPeriodList.get( periodCount );
-                   //PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                   //Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
                    Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                   
-                   //System.out.println( periods.size() + ":" + periodType + ":" + startDate + ":" +  endDate );
-                   
-                  // for( Period period : periods )
-                  // {
-                      // System.out.println( dataElement + ":" + decoc + ":" +period.getStartDate() + ":" +  period.getEndDate()+ ":" + orgChild + ":" + aggDataCB );
                        
-                       int aggChecked = Integer.parseInt( aggDataCB );
-                   
+                   int aggChecked = Integer.parseInt( aggDataCB );
+
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
                        if( aggChecked == 1 )
                        {
-                           //System.out.println( "inside aggDataCB check  : " );
-                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit );
-                           //System.out.println( dataElement + ":" + decoc + ":" +period.getStartDate() + ":" +  period.getEndDate()+ ":" + orgChild );
-                          
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgUnit );
                            if( tempAggDataValue != null ) aggDataValue += tempAggDataValue;
-                           //System.out.println( "Agg data value after zero assign is aggDataCB check  : " + aggDataValue );
                        }
                        else
                        {
                            for( Period period : periods )
                            {
-                               //System.out.println( "inside aggDataCB not check  : " );
-                               DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc );
-                               
+                               DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc1 );
                                try
                                {
                                    aggDataValue += Double.parseDouble( dataValue.getValue() );
                                }
                                catch( Exception e )
                                {
-                                   
                                }
-                               
                            }
-                         
-                           //System.out.println( "Agg data value after zero assign is when aggDataCB not check  : " + aggDataValue );
                        }
-                  // }
+                   }
                    periodCount++;
                }
  
@@ -1029,17 +547,14 @@
        }
     
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
+
        return dataElementChartResult;
     }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With groupMember Wise end
-    // -------------------------------------------------------------------------
     
     // -------------------------------------------------------------------------
     // Methods for getting Chart Data only Period Wise start ( this method is called when view by ->Selected + children and  Group not selected,and view by -> children and group selected )
     // -------------------------------------------------------------------------
     
-    
     public DataElementChartResult generateDataElementChartDataWithPeriodWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,List<String> periodNames,String  periodTypeLB ,List<DataElement> dataElementList, String deSelection, List<DataElementCategoryOptionCombo> decocList, OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception
     {
        DataElementChartResult dataElementChartResult;
@@ -1053,27 +568,23 @@
        String xAxis_Title = "Time Line";
        String yAxis_Title = "Value";
     
-      // System.out.println("\n\n +++ \n decoc : " + decocList);
-       
        int serviceCount = 0;     
      
-     
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
-               //yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
            else
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               //System.out.println( "selectedStatus  : " + selectedStatus );
-               //yseriesList.add( dataElement.getName() );
            }
            
            int periodCount = 0;
@@ -1082,50 +593,36 @@
                Date endDate = selEndPeriodList.get( periodCount );
                
                categories[periodCount] = periodNames.get( periodCount );
-               //PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
                
                Double aggDataValue = 0.0;
                int aggChecked = Integer.parseInt( aggDataCB );
                
-               if( aggChecked == 1 )
-               {
-                   //System.out.println( "inside aggDataCB check  : " );
-                   aggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, selectedOrgUnit );
-                   //System.out.println( "start Date is   : " + startDate + " , End date is : " + endDate );
-                   //System.out.println( "Agg data value before is  : " + aggDataValue );
-                   if(aggDataValue == null ) aggDataValue = 0.0;
-                   //System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
-                   //System.out.println( "Agg data value after zero assign is aggDataCB check  : " + aggDataValue );
-               }
-               else
-               {
-                   //System.out.println( "inside aggDataCB not check  : " );
-                 //  PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB );
-                  // Collection<Period> periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate );
-                   Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
-                   
-                  // System.out.println( periods.size() + ":"  + startDate + ":" +  endDate );
-                   for( Period period : periods )
-                   {
-                       DataValue dataValue = dataValueService.getDataValue( selectedOrgUnit, dataElement, period, decoc );
-                      
-                      // String values = orgUnit.getId() + ":"+ dataElement.getId() + ":"+ decoc.getId() + ":" + period.getId();
-                      // selectedValues.add(values);
-                       
-                      // System.out.println( "selectedValues  : " + selectedValues );
-                       
-                       try
-                       {
-                           aggDataValue += Double.parseDouble( dataValue.getValue() );
-                       }
-                       catch( Exception e )
-                       {
-                           
-                       }
-                      // System.out.println( "Agg data value after zero assign is when aggDataCB not check  : " + aggDataValue );
-                   }
-               }
-               
+               Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+               while ( optionComboIterator.hasNext() )
+               {
+                   DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
+                   if( aggChecked == 1 )
+                   {
+                       Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, selectedOrgUnit );
+                       if( tempAggDataValue != null ) aggDataValue += tempAggDataValue;
+                   }
+                   else
+                   {
+                       Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
+                       for( Period period : periods )
+                       {
+                           DataValue dataValue = dataValueService.getDataValue( selectedOrgUnit, dataElement, period, decoc1 );
+                           try
+                           {
+                               aggDataValue += Double.parseDouble( dataValue.getValue() );
+                           }
+                           catch( Exception e )
+                           {
+                           }
+                       }
+                   }
+               }
                data[serviceCount][periodCount] = aggDataValue;
                
                if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
@@ -1146,15 +643,11 @@
        }
        
        dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title );
+
        return dataElementChartResult;
     }
     
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data only Period Wise end
-    // -------------------------------------------------------------------------
-    
-    
-    // -------------------------------------------------------------------------
     // Methods for getting Chart Data OrgGroup Period Wise start
     // -------------------------------------------------------------------------
        
@@ -1176,29 +669,25 @@
        String xAxis_Title = "Time Line";
        String yAxis_Title = "Value";
        
-       
        int serviceCount = 0;     
      
        for( DataElement dataElement : dataElementList )
        {
            DataElementCategoryOptionCombo decoc;
-          
+           DataElementCategoryCombo dataElementCategoryCombo = dataElement.getCategoryCombo();
+           List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( dataElementCategoryCombo.getOptionCombos() );
+
            if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) )
-           
-          // if( dataElement.isMultiDimensional() )               
            {
                decoc = decocList.get( serviceCount );
-                   
                series[serviceCount] = dataElement.getName() + " : " + decoc.getName();
-               //yseriesList.add( dataElement.getName() + " : " + decoc.getName() );
            }
            else
            {
                decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
                series[serviceCount] = dataElement.getName();
-               
-               //yseriesList.add( dataElement.getName() );
            }
+
            int periodCount = 0;
            for( Date startDate : selStartPeriodList )
            {
@@ -1212,33 +701,34 @@
                for( OrganisationUnit orgUnit : selectedOUGroupMemberList )
                {
                    int aggChecked = Integer.parseInt( aggDataCB );
-                   if( aggChecked == 1 )
-                   {
-                       Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit );
-                      // System.out.println( "Agg data value before is  : " + aggDataValue );
-                      
-                       if(tempAggDataValue != null ) aggDataValue = tempAggDataValue;
-                      // System.out.println( "Agg data value after zero assign is  : " + aggDataValue );
-                   }
-                   else
-                   {
-                       for( Period period : periods )
-                       {
-                           DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc );
-                           
-                           try
-                           {
-                               aggDataValue += Double.parseDouble( dataValue.getValue() );
-                           }
-                           catch( Exception e )
-                           {
-                               
-                           }
-                       }
-                      
+
+                   Iterator<DataElementCategoryOptionCombo> optionComboIterator = optionCombos.iterator();
+                   while ( optionComboIterator.hasNext() )
+                   {
+                       DataElementCategoryOptionCombo decoc1 = (DataElementCategoryOptionCombo) optionComboIterator.next();
+
+                       if( aggChecked == 1 )
+                       {
+                           Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc1, startDate, endDate, orgUnit );
+                           if(tempAggDataValue != null ) aggDataValue = tempAggDataValue;
+                       }
+                       else
+                       {
+                           for( Period period : periods )
+                           {
+                               DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc1 );
+                               try
+                               {
+                                   aggDataValue += Double.parseDouble( dataValue.getValue() );
+                               }
+                               catch( Exception e )
+                               {
+                               }
+                           }
+                       }
                    }
                    orgGroupCount++;
-           }
+               }
    
            data[serviceCount][periodCount] = aggDataValue;
                
@@ -1266,19 +756,10 @@
    }
    
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data OrgGroup Period Wise end 
-    // -------------------------------------------------------------------------
-    
-    
-    // --------------------------------------------------------
-    // for Indicators DrillDown Supportive method   ndicator Wise
-    //---------------------------------------------------------
-   
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Children Wise start ( this method is called when view by -> periodWise and group not selected ) --ndicator Wise
+    // Methods for getting Chart Data With Children Wise start 
+    // ( this method is called when view by -> periodWise and group not selected ) -Indicator Wise
     // -------------------------------------------------------------------------
         
-    
     public IndicatorChartResult generateIndicatorChartDataWithChildrenWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList, String  periodTypeLB, List<Indicator> indicatorList, OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception
     {
         System.out.println( "inside Dashboard Service generate Chart Data With Children Wise " );
@@ -1305,15 +786,10 @@
         for ( Indicator indicator : indicatorList )
         {
             series[serviceCount] = indicator.getName();
-            //yseriesList.add( indicator );
-
-            //numeratorDEList.add( indicator.getNumeratorDescription() );
-           // denominatorDEList.add( indicator.getDenominatorDescription() );
 
             int childCount = 0;
             for ( OrganisationUnit orgChild : childOrgUnitList )
             {
-
                 categories[childCount] = orgChild.getName();
 
                 Double aggIndicatorValue = 0.0;
@@ -1323,9 +799,6 @@
                 for ( Date startDate : selStartPeriodList )
                 {
                     Date endDate = selEndPeriodList.get( periodCount );
-
-                   // if ( aggDataCB != null )
-                   // {
                     int aggChecked = Integer.parseInt( aggDataCB );
                         
                     if( aggChecked == 1 )
@@ -1336,14 +809,11 @@
                         if ( tempAggIndicatorNumValue != null )
                         {
                             aggIndicatorNumValue += tempAggIndicatorNumValue;
-
                         }
                         if ( tempAggIndicatorDenumValue != null )
                         {
                             aggIndicatorDenumValue += tempAggIndicatorDenumValue;
-
                         }
-
                     }
                     else
                     {
@@ -1378,9 +848,6 @@
                 }
                 try
                 {
-                    // aggIndicatorValue = ( aggIndicatorNumValue /
-                    // aggIndicatorDenumValue )*
-                    // indicator.getIndicatorType().getFactor();
                     if ( aggIndicatorDenumValue == 0 )
                     {
                         aggIndicatorValue = 0.0;
@@ -1394,6 +861,7 @@
                 {
                     aggIndicatorValue = 0.0;
                 }
+
                 // rounding indicator value ,Numenetor,denumenetor
                 data[serviceCount][childCount] = aggIndicatorValue;
                 data[serviceCount][childCount] = Math.round( data[serviceCount][childCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
@@ -1403,7 +871,6 @@
                 
                 denumDataArray[serviceCount][childCount] = aggIndicatorDenumValue;
                 denumDataArray[serviceCount][childCount] = Math.round( denumDataArray[serviceCount][childCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
-                // data[serviceCount][childCount] = aggDataValue;
                 childCount++;
             }
 
@@ -1415,13 +882,8 @@
     }
 
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With Children Wise start ( this method is called when view by -> periodWise and group not selected ) End --ndicator Wise
-    // -------------------------------------------------------------------------
-        
-    // -------------------------------------------------------------------------
     // Methods for getting Chart Data With groupMember Wise start ( this method is called when view by -> periodWise and group  selected ) --- indicator Wise
     // -------------------------------------------------------------------------
-        
  
     public IndicatorChartResult generateIndicatorChartDataWithGroupMemberWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,String  periodTypeLB ,List<Indicator> indicatorList, OrganisationUnit selectedOrgUnit , OrganisationUnitGroup selectedOrgUnitGroup , String aggDataCB ) throws Exception
     {
@@ -1429,8 +891,6 @@
         
         IndicatorChartResult indicatorChartResult;
         
-        //OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup(  selectedOrgUnitGroup  );
-        
         List<OrganisationUnit> selectedOUGroupMemberList = new ArrayList<OrganisationUnit>( selectedOrgUnitGroup.getMembers() );
        
         List<OrganisationUnit> childOrgUnitList = new ArrayList<OrganisationUnit>();
@@ -1438,21 +898,16 @@
        
         selectedOUGroupMemberList.retainAll( childOrgUnitList );
         
-       
         String[] series = new String[indicatorList.size()];
         String[] categories = new String[selectedOUGroupMemberList.size()];
 
         Double[][] numDataArray = new Double[indicatorList.size()][selectedOUGroupMemberList.size()];
         Double[][] denumDataArray = new Double[indicatorList.size()][selectedOUGroupMemberList.size()];
         Double[][] data = new Double[indicatorList.size()][selectedOUGroupMemberList.size()];
-        //String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName();
         String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "( Group - " + selectedOrgUnitGroup.getName() +  ")";
-       
-      // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName();
         String xAxis_Title = "Facilities";
         String yAxis_Title = "Value";
     
-        //System.out.println("size of children : " +childOrgUnitList.size() + ", Size og GroupMember : " + selectedOUGroupMemberList.size()+ ", size of CommomGroupMember : " + selectedOUGroupMemberList.size());
        
         int serviceCount = 0;
 
@@ -1463,13 +918,12 @@
             int childCount = 0;
             for ( OrganisationUnit orgChild : selectedOUGroupMemberList )
             {
-
                 categories[childCount] = orgChild.getName();
-
                 Double aggIndicatorValue = 0.0;
                 Double aggIndicatorNumValue = 0.0;
                 Double aggIndicatorDenumValue = 0.0;
                 int periodCount = 0;
+
                 for ( Date startDate : selStartPeriodList )
                 {
                     Date endDate = selEndPeriodList.get( periodCount );
@@ -1487,14 +941,11 @@
                         if ( tempAggIndicatorNumValue != null )
                         {
                             aggIndicatorNumValue += tempAggIndicatorNumValue;
-
                         }
                         if ( tempAggIndicatorDenumValue != null )
                         {
                             aggIndicatorDenumValue += tempAggIndicatorDenumValue;
-
                         }
-
                     }
                     else
                     {
@@ -1524,16 +975,12 @@
                             tempAggIndicatorDenumValue = 0.0;
                         }
                         aggIndicatorDenumValue += tempAggIndicatorDenumValue;
-
                     }
 
                     periodCount++;
                 }
                 try
                 {
-                    // aggIndicatorValue = ( aggIndicatorNumValue /
-                    // aggIndicatorDenumValue )*
-                    // indicator.getIndicatorType().getFactor();
                     if ( aggIndicatorDenumValue == 0 )
                     {
                         aggIndicatorValue = 0.0;
@@ -1548,6 +995,7 @@
                 {
                     aggIndicatorValue = 0.0;
                 }
+
                 // rounding indicator value ,Numenetor,denumenetor
                 data[serviceCount][childCount] = aggIndicatorValue;
                 data[serviceCount][childCount] = Math.round( data[serviceCount][childCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
@@ -1557,7 +1005,6 @@
                 
                 denumDataArray[serviceCount][childCount] = aggIndicatorDenumValue;
                 denumDataArray[serviceCount][childCount] = Math.round( denumDataArray[serviceCount][childCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
-                // data[serviceCount][childCount] = aggDataValue;
                 childCount++;
             }
 
@@ -1567,16 +1014,13 @@
         indicatorChartResult = new IndicatorChartResult( series, categories, data, numDataArray, denumDataArray,chartTitle, xAxis_Title, yAxis_Title );
         return indicatorChartResult;
     }
-    // -------------------------------------------------------------------------
-    // Methods for getting Chart Data With groupMember Wise start ( this method is called when view by -> periodWise and group  selected ) --- indicator Wise
-    // ------ end
-    
+
     // -------------------------------------------------------------------------
     // for Indicator
-    // Methods for getting Chart Data only Period Wise start ( this method is called when view by ->Selected + children and  Group not selected,and view by -> children and group selected )
+    // Methods for getting Chart Data only Period Wise start 
+    // ( this method is called when view by ->Selected + children and  Group not selected,and view by -> children and group selected )
     // -------------------------------------------------------------------------
     
-    
     public IndicatorChartResult generateIndicatorChartDataWithPeriodWise( List<Date> selStartPeriodList,List<Date> selEndPeriodList,List<String> periodNames,String  periodTypeLB ,List<Indicator> indicatorList,  OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception
     {
        System.out.println( "inside Dashboard Service generate Chart Data With Period Wise " );
@@ -1590,9 +1034,6 @@
        Double[][] numDataArray = new Double[indicatorList.size()][selStartPeriodList.size()];
        Double[][] denumDataArray = new Double[indicatorList.size()][selStartPeriodList.size()];
 
-       // Map<Integer, List<Double>> numData = new HashMap<Integer, List<Double>>();
-       // Map<Integer, List<Double>> denumData = new HashMap<Integer, List<Double>>();
-
        String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName();
        String xAxis_Title = "Time Line";
        String yAxis_Title = "Value";
@@ -1602,14 +1043,10 @@
        {
            series[serviceCount] = indicator.getName();
 
-           // List<Double> numeratorValueList = new ArrayList<Double>();
-           // List<Double> denumeratorValueList = new ArrayList<Double>();
-
            int periodCount = 0;
            for ( Date startDate : selStartPeriodList )
            {
                Date endDate = selEndPeriodList.get( periodCount );
-              // String drillDownPeriodName = periodNames.get( periodCount );
 
                categories[periodCount] = periodNames.get( periodCount );
 
@@ -1627,17 +1064,11 @@
                    aggIndicatorDenumValue = aggregationService.getAggregatedDenominatorValue( indicator, startDate, endDate, selectedOrgUnit );
 
                    if ( aggIndicatorValue == null ) aggIndicatorValue = 0.0;
-
                }
                else
                {
                    aggIndicatorValue = getIndividualIndicatorValue( indicator, selectedOrgUnit, startDate, endDate );
-
-                  // System.out.println( " \nIndicator Numerator value  : " + indicator.getNumerator()
-                     //  + ", Start Date :- " + startDate + ", End Date :- " + endDate + ", Org Unit :- " + orgUnit );
-
                    String tempStr = reportservice.getIndividualResultDataValue( indicator.getNumerator(), startDate, endDate, selectedOrgUnit, "" );
-                  // System.out.println( " \nIndicatorNumerator valu is " + tempStr );
 
                    try
                    {
@@ -1658,8 +1089,8 @@
                    {
                        aggIndicatorDenumValue = 0.0;
                    }
+               }
 
-               }
                // rounding indicator value ,Numenetor,denumenetor
                data[serviceCount][periodCount] = aggIndicatorValue;
                data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
@@ -1669,28 +1100,19 @@
                
                denumDataArray[serviceCount][periodCount] = aggIndicatorDenumValue;
                denumDataArray[serviceCount][periodCount] = Math.round( denumDataArray[serviceCount][periodCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
-               // numeratorValueList.add( aggIndicatorNumValue );
-               // denumeratorValueList.add( aggIndicatorDenumValue );
 
                periodCount++;
            }
 
-           // numData.put( serviceCount, numeratorValueList );
-           // denumData.put( serviceCount, denumeratorValueList );
-
            serviceCount++;
        }
 
        indicatorChartResult = new IndicatorChartResult( series, categories, data, numDataArray, denumDataArray,chartTitle, xAxis_Title, yAxis_Title );
+
        return indicatorChartResult;
-
     }
     
     // -------------------------------------------------------------------------
-    // Methods for getting Chart Data only Period Wise end
-    // -------------------------------------------------------------------------
-    
-    // -------------------------------------------------------------------------
     // Methods for getting Chart Data OrgGroup Period Wise start - IndicatorWise
     // -------------------------------------------------------------------------
     
@@ -1747,12 +1169,10 @@
                         if ( tempAggIndicatorNumValue != null )
                         {
                             aggIndicatorNumValue += tempAggIndicatorNumValue;
-
                         }
                         if ( tempAggIndicatorDenumValue != null )
                         {
                             aggIndicatorDenumValue += tempAggIndicatorDenumValue;
-
                         }
                     }
                     else
@@ -1772,10 +1192,6 @@
 
                         Double tempAggIndicatorDenumValue = 0.0;
 
-                        // tempStr =
-                        // reportService.getIndividualResultIndicatorValue(
-                        // indicator.getDenominator(), startDate, endDate,
-                        // orgUnit );
                         tempStr = reportservice.getIndividualResultDataValue( indicator.getDenominator(), startDate, endDate, orgUnit, "" );
                         try
                         {
@@ -1793,9 +1209,6 @@
 
                 try
                 {
-                    // aggIndicatorValue = ( aggIndicatorNumValue /
-                    // aggIndicatorDenumValue )*
-                    // indicator.getIndicatorType().getFactor();
                     if ( aggIndicatorDenumValue == 0 )
                     {
                         aggIndicatorValue = 0.0;
@@ -1810,6 +1223,7 @@
                 {
                     aggIndicatorValue = 0.0;
                 }
+
                 // rounding indicator value ,Numenetor,denumenetor
                 data[serviceCount][periodCount] = aggIndicatorValue;
                 data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 1 ) )/ Math.pow( 10, 1 );
@@ -1827,10 +1241,8 @@
         }
 
         indicatorChartResult = new IndicatorChartResult( series, categories, data, numDataArray, denumDataArray, chartTitle, xAxis_Title, yAxis_Title );
+
         return indicatorChartResult;
-
     }
     
-    
-    
 } // class end