=== 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 2010-12-29 16:17:28 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataAction.java 2011-01-07 05:45:11 +0000 @@ -46,7 +46,6 @@ import org.hisp.dhis.aggregation.AggregationService; import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.caseaggregation.CaseAggregationConditionService; -import org.hisp.dhis.dataanalyser.util.DashBoardService; import org.hisp.dhis.dataanalyser.util.SurveyData; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; === 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 2010-12-23 07:23:23 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateChartDataElementAction.java 2011-01-07 05:45:11 +0000 @@ -41,6 +41,7 @@ import org.amplecode.quick.StatementManager; import org.apache.struts2.ServletActionContext; +import org.apache.velocity.tools.generic.ListTool; import org.hisp.dhis.aggregation.AggregationService; import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.caseaggregation.CaseAggregationConditionService; @@ -227,6 +228,11 @@ this.deSelection = deSelection; } + public String getDeSelection() + { + return deSelection; + } + /* private List ougGroupSetCB; @@ -241,6 +247,8 @@ } */ + + private String ougGroupSetCB; public void setOugGroupSetCB( String ougGroupSetCB ) @@ -273,6 +281,11 @@ this.aggDataCB = aggDataCB; } + public String getAggDataCB() + { + return aggDataCB; + } + private List orgUnitListCB; public void setOrgUnitListCB( List orgUnitListCB ) @@ -390,21 +403,49 @@ { return selectedStatus; } + + private List selectedDrillDownData; + + public List getSelectedDrillDownData() + { + return selectedDrillDownData; + } + + ListTool listTool; - + public ListTool getListTool() + { + return listTool; + } + + private String drillDownPeriodStartDate; + private String drillDownPeriodEndDate; + private String drillDownPeriodNames; + + private String aggChecked; + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- - - - @SuppressWarnings( "unchecked" ) public String execute() throws Exception { statementManager.initialise(); selectedOptionComboList = new ArrayList(); + listTool = new ListTool(); + + aggChecked = ""; + + if( aggDataCB != null ) + { + aggChecked = "1"; + } + else + { + aggChecked = "0"; + } selOUList = new ArrayList(); System.out.println( "selected orgUnit size : " + orgUnitListCB.size() ); @@ -423,8 +464,11 @@ yseriesList = new ArrayList(); - selectedValues = new ArrayList();//for DrillDown + selectedValues = new ArrayList();//for DrillDown ( for NBIT) selectedStatus = new ArrayList(); + + selectedDrillDownData = new ArrayList();//drillDown for periodWise + // DataElement dElement = new DataElement(); // DataElementCategoryOptionCombo decoc1 = new DataElementCategoryOptionCombo(); @@ -442,7 +486,10 @@ String startD = ""; String endD = ""; - + + drillDownPeriodStartDate = ""; + drillDownPeriodEndDate = ""; + drillDownPeriodNames = ""; SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" ); periodNames = new ArrayList(); @@ -451,6 +498,7 @@ if ( periodTypeLB.equalsIgnoreCase( WeeklyPeriodType.NAME ) ) { // System.out.println( " Inside weekly" ); + int periodCount = 0; for ( String periodStr : periodLB ) { String startWeekDate = periodStr.split( "To" )[0] ; //for start week @@ -459,25 +507,56 @@ startD = startWeekDate.trim(); endD = endWeekDate.trim(); + // for DrillDown Period String + if( periodCount == periodLB.size()-1 ) + { + drillDownPeriodStartDate += startD; + drillDownPeriodEndDate += endD; + drillDownPeriodNames += periodStr; + } + else + { + drillDownPeriodStartDate += startD + ";"; + drillDownPeriodEndDate += endD + ";"; + drillDownPeriodNames += periodStr + ";"; + } + selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); periodNames.add( periodStr ); + periodCount++; //System.out.println( startD + " : " + endD ); } } else { + 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; + drillDownPeriodEndDate += endD; + drillDownPeriodNames += selYear; + } + else + { + drillDownPeriodStartDate += startD + ";"; + drillDownPeriodEndDate += endD + ";"; + drillDownPeriodNames += selYear + ";"; + } + selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); @@ -489,6 +568,7 @@ } + // int periodCount = 0; for ( String periodStr : periodLB ) { // int period = Integer.parseInt( periodStr ); @@ -506,6 +586,19 @@ { 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 ) ) + ";"; + // } selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); periodNames.add( simpleDateFormat.format( format.parseDate( startD ) ) ); @@ -519,25 +612,42 @@ startD = "" + selYear + "-01-01"; endD = "" + selYear + "-03-31"; periodNames.add( selYear + "-Q1" ); + drillDownPeriodNames += selYear + "-Q1" + ";"; } else if ( period == 1 ) { startD = "" + selYear + "-04-01"; endD = "" + selYear + "-06-30"; periodNames.add( selYear + "-Q2" ); + drillDownPeriodNames += selYear + "-Q2" + ";"; } else if ( period == 2 ) { startD = "" + selYear + "-07-01"; endD = "" + selYear + "-09-30"; periodNames.add( selYear + "-Q3" ); + drillDownPeriodNames += selYear + "-Q3" + ";"; } else { startD = "" + selYear + "-10-01"; endD = "" + selYear + "-12-31"; periodNames.add( (selYear) + "-Q4" ); - } + drillDownPeriodNames += selYear + "-Q4" + ";"; + } + + // for DrillDown Period String + if( periodCount == periodLB.size()-1 ) + { + drillDownPeriodStartDate += startD; + drillDownPeriodEndDate += endD; + } + else + { + drillDownPeriodStartDate += startD + ";"; + drillDownPeriodEndDate += endD + ";"; + } + selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); // System.out.println( "Start Date : " + startD + " , End Date : " + endD ); @@ -550,13 +660,29 @@ startD = "" + selYear + "-01-01"; endD = "" + selYear + "-06-30"; periodNames.add( selYear + "-HY1" ); + drillDownPeriodNames += selYear + "-HY1" + ";"; } else { startD = "" + selYear + "-07-01"; endD = "" + selYear + "-12-31"; periodNames.add( selYear + "-HY2" ); + drillDownPeriodNames += selYear + "-HY2" + ";"; } + + // for DrillDown Period String + /* + if( periodCount == periodLB.size()-1 ) + { + drillDownPeriodStartDate += startD; + drillDownPeriodEndDate += endD; + }*/ + //else + // { + drillDownPeriodStartDate += startD + ";"; + drillDownPeriodEndDate += endD + ";"; + //} + selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); } @@ -582,15 +708,31 @@ endD = selYear + "-" + month + "-" + date; } + // for DrillDown Period String + if( periodCount == periodLB.size()-1 ) + { + drillDownPeriodStartDate += startD; + drillDownPeriodEndDate += endD; + drillDownPeriodNames += startD; + } + else + { + drillDownPeriodStartDate += startD + ";"; + drillDownPeriodEndDate += endD + ";"; + drillDownPeriodNames += startD + ";"; + } + selStartPeriodList.add( format.parseDate( startD ) ); selEndPeriodList.add( format.parseDate( endD ) ); periodNames.add( startD ); // System.out.println( startD + " : " + endD ); } - System.out.println( startD + " : " + endD ); + //System.out.println( startD + " : " + endD ); + //periodCount++; } - + // periodCountYear++; + periodCount++; } } @@ -711,9 +853,17 @@ List childOrgUnitList = new ArrayList(); childOrgUnitList = new ArrayList( 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 ) { @@ -949,6 +1099,7 @@ for( Date startDate : selStartPeriodList ) { Date endDate = selEndPeriodList.get( periodCount ); + String drillDownPeriodName = periodNames.get( periodCount ); //format.formatDate( date ) String tempStartDate = format.formatDate( startDate ); String tempEndDate = format.formatDate( endDate ); @@ -957,14 +1108,19 @@ PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); String values = orgUnit.getId() + ":"+ dataElement.getId() + ":"+ decoc.getId() + ":" + periodType + ":" + tempStartDate + ":" + tempEndDate; - selectedValues.add(values); + 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( "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 ); @@ -972,8 +1128,8 @@ else { // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); - Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); - + // Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection periods = periodService.getPeriodsBetweenDates( startDate, endDate ); for( Period period : periods ) { DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); @@ -1070,20 +1226,29 @@ { categories[childCount] = orgChild.getName(); + String drillDownData = orgChild.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":" + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggChecked; + selectedDrillDownData.add( drillDownData ); + Double aggDataValue = 0.0; int periodCount = 0; for( Date startDate : selStartPeriodList ) { Date endDate = selEndPeriodList.get( periodCount ); - PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); - Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); - - for( Period period : periods ) - { + // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + //Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection 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 ) + //{ if( aggDataCB != null ) { - Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgChild ); + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgChild ); // System.out.println( "Agg data value before is : " + aggDataValue ); if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; @@ -1091,18 +1256,23 @@ } else { - DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc ); + for( Period period : periods ) + { + DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + } - try - { - aggDataValue += Double.parseDouble( dataValue.getValue() ); - } - catch( Exception e ) - { - - } + } - } + //} periodCount++; } @@ -1180,20 +1350,24 @@ { categories[orgUnitCount] = orgunit.getName(); + String drillDownData = orgunit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ decoc.getId() + ":" + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggChecked; + selectedDrillDownData.add( drillDownData ); + Double aggDataValue = 0.0; - + int periodCount = 0; for( Date startDate : selStartPeriodList ) { Date endDate = selEndPeriodList.get( periodCount ); - PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); - Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + // PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + //Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection periods = periodService.getPeriodsBetweenDates( startDate, endDate ); - for( Period period : periods ) - { + //for( Period period : periods ) + //{ if( aggDataCB != null ) { - Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgunit ); + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgunit ); //System.out.println( "Agg data value before is : " + aggDataValue ); if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; @@ -1201,18 +1375,22 @@ } else { - DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, decoc ); - - try - { - aggDataValue += Double.parseDouble( dataValue.getValue() ); - } - catch( Exception e ) - { + + for( Period period : periods ) + { + DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, decoc ); + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } } } - } + // } periodCount++; } @@ -1254,7 +1432,7 @@ String[] series = new String[dataElementList.size()]; String[] categories = new String[selStartPeriodList.size()]; Double[][] data = new Double[dataElementList.size()][selStartPeriodList.size()]; - String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "(" + selOrgUnitGroup.getName() + ")"; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "( Group- " + selOrgUnitGroup.getName() + " )"; String xAxis_Title = "Time Line"; String yAxis_Title = "Value"; @@ -1282,19 +1460,31 @@ yseriesList.add( dataElement.getName() ); } - Double aggDataValue = 0.0; + int periodCount = 0; for( Date startDate : selStartPeriodList ) { Date endDate = selEndPeriodList.get( periodCount ); categories[periodCount] = periodNames.get( periodCount ); - - PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); - Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); - - for( Period period : periods ) - { + 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 periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + Collection 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 ) @@ -1302,29 +1492,33 @@ if( aggDataCB != null ) { - Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgUnit ); + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit ); // System.out.println( "Agg data value before is : " + aggDataValue ); - if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; + if(tempAggDataValue != null ) aggDataValue = tempAggDataValue; // System.out.println( "Agg data value after zero assign is : " + aggDataValue ); } - else - { - DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); - - try - { - aggDataValue += Double.parseDouble( dataValue.getValue() ); - } - catch( Exception e ) - { - - } - } - orgGroupCount++; + else + { + for( Period period : periods ) + { + DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + } + + } + orgGroupCount++; } - } + // } data[serviceCount][periodCount] = aggDataValue; @@ -1392,66 +1586,77 @@ yseriesList.add( dataElement.getName() ); } + + int orgGroupCount = 0; + // int orgGroupCount1 = 0; + // Double aggDataValue = 0.0; - int orgGroupCount = 0; - // int orgGroupCount1 = 0; - // Double aggDataValue = 0.0; - - for( OrganisationUnitGroup orgUnitGroup : orgUnitGroupMap.keySet() ) - { - // Double aggDataValue = 0.0; - Double aggDataValue = 0.0; - - categories[orgGroupCount] = orgUnitGroup.getName(); - - if( serviceCount == 0 ) - { - chartTitle += orgUnitGroup.getName() + ","; - } - Collection orgUnitGroupMembers = orgUnitGroupMap.get( orgUnitGroup ); - if( orgUnitGroupMembers == null || orgUnitGroupMembers.size() == 0 ) - { - data[serviceCount][orgGroupCount] = aggDataValue; - orgGroupCount++; - continue; - } - for( OrganisationUnit orgUnit : orgUnitGroupMembers ) - { + 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() + ","; + } + Collection orgUnitGroupMembers = orgUnitGroupMap.get( orgUnitGroup ); + + if( orgUnitGroupMembers == null || orgUnitGroupMembers.size() == 0 ) + { + data[serviceCount][orgGroupCount] = aggDataValue; + orgGroupCount++; + continue; + } + for( OrganisationUnit orgUnit : orgUnitGroupMembers ) + { + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + + //PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + //Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection 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 ); - int periodCount = 0; - for( Date startDate : selStartPeriodList ) - { - Date endDate = selEndPeriodList.get( periodCount ); - - PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); - Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); - - for( Period period : periods ) - { - if( aggDataCB != null ) - { - Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), 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 - { - DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); - - try - { - aggDataValue += Double.parseDouble( dataValue.getValue() ); - } - catch( Exception e ) - { - - } - } - } - periodCount++; - } + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + } + } + // } + periodCount++; + } } data[serviceCount][orgGroupCount] = aggDataValue; === added 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 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java 2011-01-07 05:45:11 +0000 @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.dataanalyser.ga.action.charts; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.amplecode.quick.StatementManager; +import org.apache.struts2.ServletActionContext; +import org.apache.velocity.tools.generic.ListTool; +import org.hisp.dhis.dataanalyser.util.DashBoardService; +import org.hisp.dhis.dataanalyser.util.DataElementChartResult; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitService; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; + +/** + * @author Mithilesh Kumar Thakur + * + * @version GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction.java Jan 3, 2011 11:04:22 AM + */ +public class GenerateDrillDownOrgUnitToPeriodChartDataElementResultAction implements Action +{ + private final String PERIODWISE = "period"; + + //private final String CHILDREN = "children"; + + //private final String OPTIONCOMBO = "optioncombo"; + //private final String SELECTED = "random"; + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private StatementManager statementManager; + + public void setStatementManager( StatementManager statementManager ) + { + this.statementManager = statementManager; + } + + private DashBoardService dashBoardService; + + public void setDashBoardService( DashBoardService dashBoardService ) + { + this.dashBoardService = dashBoardService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private DataElementCategoryService dataElementCategoryService; + + public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService ) + { + this.dataElementCategoryService = dataElementCategoryService; + } + + private OrganisationUnitService organisationUnitService; + + public OrganisationUnitService getOrganisationUnitService() + { + return organisationUnitService; + } + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + // ------------------------------------------------------------------------- + // Input/output + // ------------------------------------------------------------------------- + + private String categoryLB; + + public void setCategoryLB( String categoryLB ) + { + this.categoryLB = categoryLB; + } + + public String getCategoryLB() + { + return categoryLB; + } + + /* + private String ougGroupSetCB; + + + public void setOugGroupSetCB( String ougGroupSetCB ) + { + this.ougGroupSetCB = ougGroupSetCB; + } + */ + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + private String selDrillDownData; + + public void setSelDrillDownData( String selDrillDownData ) + { + this.selDrillDownData = selDrillDownData; + } + + public String[] values; + + ListTool listTool; + + public ListTool getListTool() + { + return listTool; + } + + private DataElementChartResult dataElementChartResult; + + public DataElementChartResult getDataElementChartResult() + { + return dataElementChartResult; + } + + private List selectedOptionComboList; + + private OrganisationUnit selectedOrgUnit; + + private OrganisationUnitGroup selectedOrgUnitGroup; + + private DataElement dataElement; + + //private DataElementCategoryOptionCombo categoryCombo; + + private HttpSession session; + + public HttpSession getSession() + { + return session; + } + + private List selStartPeriodList; + + private List selEndPeriodList; + + private String selectedButton; + + public String getSelectedButton() + { + return selectedButton; + } + + public void setSelectedButton( String selectedButton ) + { + 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; + + private List periodNames; + + private List selectedDrillDownData; + + public List getSelectedDrillDownData() + { + 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();//drillDown for periodWise + + selectedOptionComboList = new ArrayList(); + + 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 ); + + int dataElementid = Integer.parseInt( values[2] ); + int optionComboid = Integer.parseInt( values[3] ); + + dataElement = dataElementService.getDataElement( dataElementid ); + //categoryCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboid ); + DataElementCategoryOptionCombo categoryCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboid ); + + List dataElementList = new ArrayList(); + dataElementList.add( dataElement ); + + selectedOptionComboList.add( categoryCombo ); + + String periodTypeLB = values[4]; + + selStartPeriodList = new ArrayList(); + selEndPeriodList = new ArrayList(); + periodNames = new ArrayList(); + + //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 )) ) + { + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + String tempStartDate = format.formatDate( startDate ); + String tempEndDate = format.formatDate( endDate ); + String drillDownData = selectedOrgUnit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":" + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB; + selectedDrillDownData.add( drillDownData ); + periodCount++; + } + //System.out.println( "hhhiiiiiiiiiiiiii-------------hhhhhhhhhh" ); + + } + + if( orgUnitGroup != 0 && ( categoryLB.equalsIgnoreCase( PERIODWISE )) ) + { + int periodCount = 0; + for( Date startdate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + String tempStartDate = format.formatDate( startdate ); + String tempEndDate = format.formatDate( endDate ); + String drillDownData = selectedOrgUnit.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":" + periodTypeLB + ":" + tempStartDate + ":" + tempEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB; + selectedDrillDownData.add( drillDownData ); + periodCount++; + } + } + + + 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.generateChartDataWithGroupToPeriodWise( selStartPeriodList, selEndPeriodList, periodNames ,periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, selectedOrgUnitGroup ,aggDataCB ); + } + else + { + dataElementChartResult = dashBoardService.generateChartDataWithPeriodWise( selStartPeriodList, selEndPeriodList,periodNames, periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, aggDataCB ); + } + + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + + session = req.getSession(); + + 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() ); + + System.out.println( "Chart Generation End Time is drillDown : \t" + new Date() ); + + statementManager.destroy(); + return SUCCESS; + } + + +} + + === added 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 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ga/action/charts/GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java 2011-01-07 05:45:11 +0000 @@ -0,0 +1,394 @@ +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.dataanalyser.ga.action.charts; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.amplecode.quick.StatementManager; +import org.apache.struts2.ServletActionContext; +import org.apache.velocity.tools.generic.ListTool; +import org.hisp.dhis.dataanalyser.util.DashBoardService; +import org.hisp.dhis.dataanalyser.util.DataElementChartResult; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitService; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; + +/** + * @author Mithilesh Kumar Thakur + * + * @version GenerateDrillDownPeriodToOrgChildChartDataElementResultAction.java Dec 30, 2010 1:07:30 PM + */ +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 + // ------------------------------------------------------------------------- + + private StatementManager statementManager; + + public void setStatementManager( StatementManager statementManager ) + { + this.statementManager = statementManager; + } + + private DashBoardService dashBoardService; + + public void setDashBoardService( DashBoardService dashBoardService ) + { + this.dashBoardService = dashBoardService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private DataElementCategoryService dataElementCategoryService; + + public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService ) + { + this.dataElementCategoryService = dataElementCategoryService; + } + + private OrganisationUnitService organisationUnitService; + + public OrganisationUnitService getOrganisationUnitService() + { + return organisationUnitService; + } + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + // ------------------------------------------------------------------------- + // Input/output + // ------------------------------------------------------------------------- + + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + private String selDrillDownData; + + public void setSelDrillDownData( String selDrillDownData ) + { + this.selDrillDownData = selDrillDownData; + } + + public String[] values; + + ListTool listTool; + + public ListTool getListTool() + { + return listTool; + } + + private DataElementChartResult dataElementChartResult; + + public DataElementChartResult getDataElementChartResult() + { + return dataElementChartResult; + } + + private List selectedOptionComboList; + + private OrganisationUnit selectedOrgUnit; + + private OrganisationUnitGroup selectedOrgUnitGroup; + + private DataElement dataElement; + + //private DataElementCategoryOptionCombo categoryCombo; + + private HttpSession session; + + public HttpSession getSession() + { + return session; + } + + private List selStartPeriodList; + + private List selEndPeriodList; + + private String selectedButton; + + public String getSelectedButton() + { + return selectedButton; + } + + public void setSelectedButton( String selectedButton ) + { + this.selectedButton = selectedButton; + } + + public String[] startDateArray; + public String[] endDateArray; + public String[] priodNameArray; + + private List periodNames; + + private String categoryLB; + + public void setCategoryLB( String categoryLB ) + { + this.categoryLB = categoryLB; + } + + public String getCategoryLB() + { + return categoryLB; + } + private List selectedDrillDownData; + + public List 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();//drillDown for periodWise + + selectedOptionComboList = new ArrayList(); + + 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 ); + + int dataElementid = Integer.parseInt( values[2] ); + int optionComboid = Integer.parseInt( values[3] ); + + dataElement = dataElementService.getDataElement( dataElementid ); + //categoryCombo = dataElementCategoryOptionComboService.getDataElementCategoryOptionCombo( optionComboid ); + DataElementCategoryOptionCombo categoryCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboid ); + + List dataElementList = new ArrayList(); + dataElementList.add( dataElement ); + + selectedOptionComboList.add( categoryCombo ); + + String periodTypeLB = values[4]; + // String startD = values[5]; + //String endD = values[6]; + + selStartPeriodList = new ArrayList(); + selEndPeriodList = new ArrayList(); + periodNames = new ArrayList(); + + 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 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() ); + + if( orgUnitGroup == 0 && ( categoryLB.equalsIgnoreCase( CHILDREN ) || ( categoryLB.equalsIgnoreCase( SELECTED )) )) + { + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( selectedOrgUnit.getChildren()); + + for( OrganisationUnit orgChild : childOrgUnitList ) + { + String drillDownData = orgChild.getId() + ":" + "0" + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":" + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB; + selectedDrillDownData.add( drillDownData ); + } + } + + if ( orgUnitGroup != 0 && ( categoryLB.equalsIgnoreCase( CHILDREN ) || ( categoryLB.equalsIgnoreCase( SELECTED )) )) + { + // List childOrgUnitList = new ArrayList(); + //childOrgUnitList = new ArrayList( selectedOrgUnit.getChildren()); + + List selectedOUGroupMemberList = new ArrayList( selectedOrgUnitGroup.getMembers() ); + + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + selectedOUGroupMemberList.retainAll( childOrgUnitList ); + + for( OrganisationUnit orgChild : selectedOUGroupMemberList ) + { + String drillDownData = orgChild.getId() + ":" + selectedOrgUnitGroup.getId() + ":" + dataElement.getId() + ":"+ categoryCombo.getId() + ":" + periodTypeLB + ":" + drillDownPeriodStartDate + ":" + drillDownPeriodEndDate + ":" + drillDownPeriodNames + ":" + deSelection + ":" + aggDataCB; + 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.generateChartDataWithGroupMemberWise( selStartPeriodList, selEndPeriodList, periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, selectedOrgUnitGroup ,aggDataCB ); + } + else + { + dataElementChartResult = dashBoardService.generateChartDataWithChildrenWise( selStartPeriodList, selEndPeriodList, periodTypeLB, dataElementList, deSelection, selectedOptionComboList, selectedOrgUnit, aggDataCB ); + } + + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + + session = req.getSession(); + + 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() ); + + System.out.println( "Chart Generation End Time is drillDown : \t" + new Date() ); + + statementManager.destroy(); + return SUCCESS; + } + + +} === 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 2010-12-29 16:17:28 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/util/DashBoardService.java 2011-01-07 05:45:11 +0000 @@ -37,8 +37,16 @@ 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.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; @@ -46,6 +54,8 @@ public class DashBoardService { + private final String OPTIONCOMBO = "optioncombo"; + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -63,7 +73,34 @@ { this.reportservice = reportservice; } - + + private AggregationService aggregationService; + + public void setAggregationService( AggregationService aggregationService ) + { + this.aggregationService = aggregationService; + } + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } + + private DataElementCategoryService dataElementCategoryService; + + public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService ) + { + this.dataElementCategoryService = dataElementCategoryService; + } + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + /* private DBConnection dbConnection; @@ -726,4 +763,509 @@ return aggregatedValue; } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data With Children Wise start ( this method is called when view by -> periodWise and group not selected ) + // ------------------------------------------------------------------------- + + + public DataElementChartResult generateChartDataWithChildrenWise( List selStartPeriodList,List selEndPeriodList,String periodTypeLB ,List dataElementList, String deSelection, List decocList, OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception + { + System.out.println( "inside Dashboard Service generateChartDataWithChildrenWise " ); + + DataElementChartResult dataElementChartResult; + + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( 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; + + 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; + for( OrganisationUnit orgChild : childOrgUnitList ) + { + categories[childCount] = orgChild.getName(); + + Double aggDataValue = 0.0; + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + //Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection 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 ); + + 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 ); + + 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 ); + + 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++; + } + + data[serviceCount][childCount] = aggDataValue; + + if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + if ( dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + data[serviceCount][childCount] = Math.round( data[serviceCount][childCount] * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 ); + } + else + { + data[serviceCount][childCount] = Math.round( data[serviceCount][childCount] * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + } + } + childCount++; + } + + serviceCount++; + } + + 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 ) + // ------------------------------------------------------------------------- + + + public DataElementChartResult generateChartDataWithGroupMemberWise( List selStartPeriodList,List selEndPeriodList,String periodTypeLB ,List dataElementList, String deSelection, List decocList, OrganisationUnit selectedOrgUnit , OrganisationUnitGroup selectedOrgUnitGroup , String aggDataCB ) throws Exception + { + System.out.println( "inside Dashboard Service generateChartDataWithGroupMemberWise " ); + + DataElementChartResult dataElementChartResult; + + //OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( selectedOrgUnitGroup ); + + List selectedOUGroupMemberList = new ArrayList( selectedOrgUnitGroup.getMembers() ); + + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + 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; + + 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; + for( OrganisationUnit orgUnit : selectedOUGroupMemberList ) + { + categories[GroupMemberCount] = orgUnit.getName(); + + Double aggDataValue = 0.0; + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + //PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + //Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection 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 ); + + 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 ); + + 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 ); + + 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++; + } + + data[serviceCount][GroupMemberCount] = aggDataValue; + + if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + if ( dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + data[serviceCount][GroupMemberCount] = Math.round( data[serviceCount][GroupMemberCount] * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 ); + } + else + { + data[serviceCount][GroupMemberCount] = Math.round( data[serviceCount][GroupMemberCount] * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + } + } + GroupMemberCount++; + } + + serviceCount++; + } + + 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 generateChartDataWithPeriodWise( List selStartPeriodList,List selEndPeriodList,List periodNames,String periodTypeLB ,List dataElementList, String deSelection, List decocList, OrganisationUnit selectedOrgUnit , String aggDataCB ) throws Exception + { + DataElementChartResult dataElementChartResult; + + System.out.println( "inside Dashboard Service generate Chart Data With Period Wise " ); + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[selStartPeriodList.size()]; + Double[][] data = new Double[dataElementList.size()][selStartPeriodList.size()]; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.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 ( 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; + for( Date startDate : selStartPeriodList ) + { + 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 periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + Collection 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 ); + } + } + + data[serviceCount][periodCount] = aggDataValue; + + if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + if ( dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 ); + } + else + { + data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + } + } + periodCount++; + } + + 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 OrgGroup Period Wise start + // ------------------------------------------------------------------------- + + public DataElementChartResult generateChartDataWithGroupToPeriodWise( List selStartPeriodList,List selEndPeriodList,List periodNames,String periodTypeLB ,List dataElementList, String deSelection, List decocList, OrganisationUnit selectedOrgUnit , OrganisationUnitGroup selectedOrgUnitGroup , String aggDataCB ) throws Exception + { + DataElementChartResult dataElementChartResult; + + List selectedOUGroupMemberList = new ArrayList( selectedOrgUnitGroup.getMembers() ); + + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + selectedOUGroupMemberList.retainAll( childOrgUnitList ); + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[selStartPeriodList.size()]; + Double[][] data = new Double[dataElementList.size()][selStartPeriodList.size()]; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "(" + selectedOrgUnitGroup.getName() + ")"; + String xAxis_Title = "Time Line"; + String yAxis_Title = "Value"; + + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + 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 ) + { + Date endDate = selEndPeriodList.get( periodCount ); + categories[periodCount] = periodNames.get( periodCount ); + Double aggDataValue = 0.0; + Collection periods = periodService.getPeriodsBetweenDates( startDate, endDate ); + + int orgGroupCount = 0; + + 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 ) + { + + } + } + + } + orgGroupCount++; + } + + data[serviceCount][periodCount] = aggDataValue; + + if( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + if ( dataElement.getNumberType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) ) + { + data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 ); + } + else + { + data[serviceCount][periodCount] = Math.round( data[serviceCount][periodCount] * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 ); + } + } + periodCount++; + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + + return dataElementChartResult; + + } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data OrgGroup Period Wise end + // ------------------------------------------------------------------------- + } // class end === modified file 'local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml 2010-12-29 16:17:28 +0000 +++ local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml 2011-01-07 05:45:11 +0000 @@ -83,6 +83,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1070,6 +1100,14 @@ + + + + + + + + === modified file 'local/in/dhis-web-dashboard/src/main/resources/struts.xml' --- local/in/dhis-web-dashboard/src/main/resources/struts.xml 2010-12-29 07:47:36 +0000 +++ local/in/dhis-web-dashboard/src/main/resources/struts.xml 2011-01-07 05:45:11 +0000 @@ -67,6 +67,29 @@ 1024 + + + /popup.vm + /dhis-web-dashboard/graphicalAnalysisDataElementResult.vm + ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/ga.js,javascript/hashtable.js,javascript/gadataelement.js + css/StylesForTags.css + + + + + /popup.vm + /dhis-web-dashboard/graphicalAnalysisDataElementResult.vm + ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/ga.js,javascript/hashtable.js,javascript/gadataelement.js + css/StylesForTags.css + + + + + + + + + === modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/graphicalAnalysisDataElementResult.vm' --- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/graphicalAnalysisDataElementResult.vm 2010-12-07 05:07:09 +0000 +++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/graphicalAnalysisDataElementResult.vm 2011-01-07 05:45:11 +0000 @@ -6,6 +6,152 @@ evt.target.href = "drillDownResult.action?selectedValues="+selVal; } + function drillDownPeriodToOrgChildResult(evt, selDrillDownData ) + { + + //var aggDataCB = '$aggDataCB'; + var deSelection = '$deSelection'; + var selectedButton = '$selectedButton'; + + var viewBy = 'children'; + + //alert( deSelection + ":" + selectedButton ); + + //alert( selDrillDownData ); + + var arugDetails = selDrillDownData.split(":"); + var orgUnitId = arugDetails[0]; + var orgUnitGroupId = arugDetails[1]; + var dataElementId = arugDetails[2]; + var categoryCombo = arugDetails[3]; + var periodTypeName = arugDetails[4]; + var startDate = arugDetails[5]; + + var periodLB = startDate.split("-"); + var year = periodLB[0]; + var month = periodLB[1] + + var endDate = arugDetails[6]; + + var aggDataCB = arugDetails[9]; + //alert( aggDataCB ); + + //alert( orgUnitId + "," + dataElementId + "," + categoryCombo + "," + periodTypeName + "," + startDate + "," + endDate + "," + year + "," + month ); + + evt.target.href = "generatedrillDownPeriodToOrgChildChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton + "&categoryLB=" + viewBy + "&aggDataCB=" + aggDataCB; + + //evt.target.href = "generatedrillDownPeriodToChildChartDataElement.action?orgUnitListCB="+orgUnitId+"&periodTypeLB="+periodTypeName+"&selStartPeriodList="+startDate+"&selectedDataElements="+ dataElementId + "&categoryLB=children"; + } + + function drillDownOrgUnitToPeriodResult(evt, selDrillDownData ) + { + + //var aggDataCB = '$aggDataCB'; + var deSelection = '$deSelection'; + var selectedButton = '$selectedButton'; + + var viewBy = 'period'; + + //alert( viewBy ); + var orgGroupChecked = '$ougGroupSetCB'; + // alert( viewBy + ":" + orgGroupChecked ); + + //alert( deSelection + ":" + selectedButton ); + + //alert( selDrillDownData ); + var arugDetails = selDrillDownData.split(":"); + var orgUnitId = arugDetails[0]; + var orgUnitGroupId = arugDetails[1]; + var dataElementId = arugDetails[2]; + var categoryCombo = arugDetails[3]; + var periodTypeName = arugDetails[4]; + var startDate = arugDetails[5]; + var endDate = arugDetails[6]; + + var periodLB = startDate.split(";"); + var year = periodLB[0]; + var month = periodLB[1] + + var periodName = arugDetails[7]; + + var aggDataCB = arugDetails[9]; + //alert( aggDataCB ); + //alert( orgUnitId + "," + orgUnitGroupId + "," + dataElementId + "," + categoryCombo + "," + periodTypeName + "," + startDate + "," + endDate + "," + periodName ); + + // var radioButton = document.getElementById("riRadio").value; + + // var radioButton = document.getElementById("riRadio"); + + // var ouRadioVal = $( "input[name='riRadio']:checked" ).val(); + + // alert( ouRadioVal ); + //if( ouRadioVal == "periodWiseDrillDown" ) + //{ + evt.target.href = "generatedrillDownOurUnitToPeriodChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton + "&categoryLB=" + viewBy + "&aggDataCB=" + aggDataCB; + //} + //else + //{ + //evt.target.href = "generatedrillDownPeriodToOrgChildChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton; + //} + //var periodName = arugDetails[7]; + // alert( orgUnitId + "," + orgUnitGroupId + "," + dataElementId + "," + categoryCombo + "," + periodTypeName + "," + startDate + "," + endDate + "," + periodName ); + //evt.target.href = "generatedrillDownOurUnitToPeriodChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton; + } + + function drillDownOrgUnitGroupToPeriodResult(evt, selDrillDownData ) + { + + // var aggDataCB = '$aggDataCB'; + var deSelection = '$deSelection'; + var selectedButton = '$selectedButton'; + + var viewBy = '$categoryLB'; + var viewBy = 'period'; + var orgGroupChecked = '$ougGroupSetCB'; + //alert( viewBy + ":" + orgGroupChecked ); + + // alert( deSelection + ":" + selectedButton ); + + // alert( selDrillDownData ); + var arugDetails = selDrillDownData.split(":"); + var orgUnitId = arugDetails[0]; + var orgUnitGroupId = arugDetails[1]; + var dataElementId = arugDetails[2]; + var categoryCombo = arugDetails[3]; + var periodTypeName = arugDetails[4]; + var startDate = arugDetails[5]; + var endDate = arugDetails[6]; + + var periodLB = startDate.split(";"); + var year = periodLB[0]; + var month = periodLB[1] + + var periodName = arugDetails[7]; + + var aggDataCB = arugDetails[9]; + //alert( aggDataCB ); + alert( orgUnitId + "," + orgUnitGroupId + "," + dataElementId + "," + categoryCombo + "," + periodTypeName + "," + startDate + "," + endDate + "," + periodName ); + + //var ouRadioVal = $( "input[name='riRadio']:checked" ).val(); + + //alert( ouRadioVal ); + //if( ouRadioVal == "periodWiseDrillDown" ) + //{ + evt.target.href = "generatedrillDownOurUnitToPeriodChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton + "&categoryLB=" + viewBy + "&aggDataCB=" + aggDataCB; + //} + //else + //{ + // evt.target.href = "generatedrillDownPeriodToOrgChildChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton; + // } + + + + //var periodName = arugDetails[7]; + //alert( orgUnitId + "," + orgUnitGroupId + "," + dataElementId + "," + categoryCombo + "," + periodTypeName + "," + startDate + "," + endDate + "," + periodName ); + //evt.target.href = "generatedrillDownOurUnitToPeriodChartDataElement.action?selDrillDownData="+selDrillDownData + "&selectedButton=" + selectedButton + "&categoryLB=" + viewBy; + } + + // Chart Display Option change start function chartTypeOptionChange(evt) @@ -120,9 +266,17 @@
- #else - + + #set($count1 = 0) - #set( $count3 = 0 ) + #set( $count3 = 0 ) + #set( $count4 = 0 ) #foreach($onedataList in $dataElementChartResult.data) - + + #foreach($data in $onedataList)
- #if($selectedButton.equals("ViewSummary")) - + + + #if($selectedButton.equals("ViewSummary")) + Export To WorkBook   
Export To Excel   
$yseriesList.get($count1)$listTool.get( $dataElementChartResult.series, $count1 )