dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12590
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3910: Add New Functionality - Data Entry Status Mart in Data Analyser
------------------------------------------------------------
revno: 3910
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-15 11:31:50 +0530
message:
Add New Functionality - Data Entry Status Mart in Data Analyser
added:
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/DataEntryStatusSaveAction.java
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction_Test.java
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/GenerateDataEntryStatusResultAction.java
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/ValidateDataEntryStatusAction.java
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataEntryStatusResult.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartSave.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult_Test.vm
modified:
local/in/dhis-web-dashboard/pom.xml
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction.java
local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateGroupWiseDataStatusResultAction.java
local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-dashboard/src/main/resources/org/hisp/dhis/dataanalyser/i18n_module.properties
local/in/dhis-web-dashboard/src/main/resources/struts.xml
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusFront.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartFront.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/groupWiseDataStatusResult.vm
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/dataStatusMart.js
local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/ds.js
--
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/pom.xml'
--- local/in/dhis-web-dashboard/pom.xml 2011-04-27 16:07:05 +0000
+++ local/in/dhis-web-dashboard/pom.xml 2011-06-15 06:01:50 +0000
@@ -88,7 +88,11 @@
<artifactId>dhis-in-service-reports</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-in-service-dataentrystatus</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Other -->
<!--
<dependency>
=== added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/DataEntryStatusSaveAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/DataEntryStatusSaveAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/DataEntryStatusSaveAction.java 2011-06-15 06:01:50 +0000
@@ -0,0 +1,289 @@
+package org.hisp.dhis.dataanalyser.ds.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataentrystatus.DataEntryStatus;
+import org.hisp.dhis.dataentrystatus.DataEntryStatusService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+
+import com.opensymphony.xwork2.Action;
+
+public class DataEntryStatusSaveAction implements Action
+{
+ Collection<Period> periods = new ArrayList<Period>();
+
+ Collection<DataSet> dataSets = new ArrayList<DataSet>();
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SelectionTreeManager selectionTreeManager;
+
+ public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+ {
+ this.selectionTreeManager = selectionTreeManager;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private DataEntryStatusService dataEntryStatusService;
+
+ public void setDataEntryStatusService( DataEntryStatusService dataEntryStatusService )
+ {
+ this.dataEntryStatusService = dataEntryStatusService;
+ }
+
+ private JdbcTemplate jdbcTemplate;
+
+ public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+ {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+
+ private Collection<Integer> selectedPeriods = new ArrayList<Integer>();
+
+ public void setSelectedPeriods( Collection<Integer> selectedPeriods )
+ {
+ this.selectedPeriods = selectedPeriods;
+ }
+
+ private Collection<Integer> selectedDataSets = new ArrayList<Integer>();
+
+ public void setSelectedDataSets( Collection<Integer> selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+
+ private String includeZeros;
+
+ public void setIncludeZeros( String includeZeros )
+ {
+ this.includeZeros = includeZeros;
+ }
+
+ public String getIncludeZeros()
+ {
+ return includeZeros;
+ }
+
+ private int dataSetMemberCount;
+
+ private String deInfo;
+
+ private String orgUnitInfo;
+
+ private String periodInfo;
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+ public String execute()
+ {
+ System.out.println( "Data Entry Status Mart Start Time : " + new Date() );
+ String currentUserName = currentUserService.getCurrentUsername();
+
+ for ( Integer periodId : selectedPeriods )
+ {
+ periods.add( periodService.getPeriod( periodId.intValue() ) );
+ }
+
+ for ( Integer dataSetId : selectedDataSets )
+ {
+ dataSets.add( dataSetService.getDataSet( dataSetId.intValue() ) );
+ }
+
+ Collection<OrganisationUnit> selectedOrganisationUnits = selectionTreeManager.getSelectedOrganisationUnits();
+
+ String includeZero = "";
+ if ( includeZeros == null )
+ {
+ includeZero = "N";
+ }
+ else
+ {
+ includeZero = "Y";
+ }
+ String query2 = "";
+ Double dataStatusPercentatge = 0.0;
+
+ for ( DataSet dataSet : dataSets )
+ {
+ Set<OrganisationUnit> dataSetOrganisationUnits = dataSet.getSources();
+ Set<OrganisationUnit> selOrgUnitSource = new HashSet<OrganisationUnit>();
+
+ selOrgUnitSource.addAll( selectedOrganisationUnits );
+ selOrgUnitSource.retainAll( dataSetOrganisationUnits );
+
+ dataSetMemberCount = 0;
+ for ( DataElement de : dataSet.getDataElements() )
+ {
+ deInfo += "," + de.getId();
+ dataSetMemberCount += de.getCategoryCombo().getOptionCombos().size();
+ }
+
+ Iterator<OrganisationUnit> orgUnitListIterator = selOrgUnitSource.iterator();
+ while ( orgUnitListIterator.hasNext() )
+ {
+ OrganisationUnit orgUnit = orgUnitListIterator.next();
+
+ orgUnitInfo = "" + orgUnit.getId();
+
+ Period p;
+ Iterator<Period> periodIterator = periods.iterator();
+ while ( periodIterator.hasNext() )
+ {
+ p = (Period) periodIterator.next();
+ periodInfo = "" + p.getId();
+
+ if ( includeZeros == null )
+ {
+ query2 = "SELECT COUNT(*) FROM datavalue WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ") and value <> 0";
+ }
+ else
+ {
+ query2 = "SELECT COUNT(*) FROM datavalue WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ")";
+ }
+
+ SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query2 );
+ if ( sqlResultSet.next() )
+ {
+ try
+ {
+ dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount) * 100.0;
+ }
+ catch ( Exception e )
+ {
+ dataStatusPercentatge = 0.0;
+ }
+ }
+ dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+
+ DataEntryStatus dataEntryStatus = dataEntryStatusService.getDataEntryStatusValue( dataSet, orgUnit, p , includeZero );
+
+ if ( dataEntryStatus != null )
+ {
+ if ( includeZeros == null )
+ {
+ //includeZero = "N";
+ dataEntryStatus.setDataset( dataSet );
+ dataEntryStatus.setOrganisationunit( orgUnit );
+ dataEntryStatus.setPeriod( p );
+ dataEntryStatus.setValue( dataStatusPercentatge.toString() );
+ dataEntryStatus.setTimestamp( new Date() );
+ dataEntryStatus.setStoredBy( currentUserName );
+ dataEntryStatus.setIncludeZero( includeZero );
+ dataEntryStatusService.updateDataEntryStatus( dataEntryStatus );
+ }
+ else
+ {
+ // includeZero = "Y";
+ dataEntryStatus.setDataset( dataSet );
+ dataEntryStatus.setOrganisationunit( orgUnit );
+ dataEntryStatus.setPeriod( p );
+ dataEntryStatus.setValue( dataStatusPercentatge.toString() );
+ dataEntryStatus.setTimestamp( new Date() );
+ dataEntryStatus.setStoredBy( currentUserName );
+ dataEntryStatus.setIncludeZero( includeZero );
+ dataEntryStatusService.updateDataEntryStatus( dataEntryStatus );
+ }
+ }
+ else
+ {
+ if ( includeZeros == null )
+ {
+ //includeZero = "N";
+ dataEntryStatus = new DataEntryStatus();
+ dataEntryStatus.setDataset( dataSet );
+ dataEntryStatus.setOrganisationunit( orgUnit );
+ dataEntryStatus.setPeriod( p );
+ dataEntryStatus.setValue( dataStatusPercentatge.toString() );
+ dataEntryStatus.setTimestamp( new Date() );
+ dataEntryStatus.setStoredBy( currentUserName );
+ dataEntryStatus.setIncludeZero( includeZero );
+ dataEntryStatusService.addDataEntryStatus( dataEntryStatus );
+ }
+ else
+ {
+ //includeZero = "Y";
+ dataEntryStatus = new DataEntryStatus();
+ dataEntryStatus.setDataset( dataSet );
+ dataEntryStatus.setOrganisationunit( orgUnit );
+ dataEntryStatus.setPeriod( p );
+ dataEntryStatus.setValue( dataStatusPercentatge.toString() );
+ dataEntryStatus.setTimestamp( new Date() );
+ dataEntryStatus.setStoredBy( currentUserName );
+ dataEntryStatus.setIncludeZero( includeZero );
+ dataEntryStatusService.addDataEntryStatus( dataEntryStatus );
+ }
+ }
+ }
+ }
+
+
+ }
+ System.out.println( "Data Entry Status Mart End Time : " + new Date() );
+ message = i18n.getString( "information_successfully_saved" );
+ return SUCCESS;
+ }
+}
=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction.java 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction.java 2011-06-15 06:01:50 +0000
@@ -4,6 +4,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -104,6 +105,17 @@
this.orgUnitComparator = orgUnitComparator;
}
+/*
+ private DataEntryStatusService dataEntryStatusService;
+
+ public void setDataEntryStatusService( DataEntryStatusService dataEntryStatusService )
+ {
+ this.dataEntryStatusService = dataEntryStatusService;
+ }
+*/
+
+
+
// ---------------------------------------------------------------
// Output Parameters
// ---------------------------------------------------------------
@@ -228,6 +240,11 @@
}
private String immChildOption;
+
+ public String getImmChildOption()
+ {
+ return immChildOption;
+ }
public void setImmChildOption( String immChildOption )
{
@@ -335,6 +352,7 @@
{
return dataElementCount;
}
+
// ---------------------------------------------------------------
// Action Implementation
@@ -343,6 +361,8 @@
public String execute()
throws Exception
{
+
+ System.out.println( "Data Entry Status Start Time : " + new Date() );
orgUnitCount = 0;
dataViewName = "";
@@ -352,9 +372,12 @@
results = new ArrayList<Integer>();
maxOULevel = 1;
minOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
-
+
+
+ System.out.println( "immChildOption : " + immChildOption + ", Ou Id is : " + ouId + ", DS id is : " + dsId );
if ( immChildOption != null && immChildOption.equalsIgnoreCase( "yes" ) )
{
+ System.out.println( "Inside Drill Down" );
orgUnitListCB = new ArrayList<String>();
orgUnitListCB.add( ouId );
@@ -482,7 +505,7 @@
dataSetMemberCount1 += de1.getCategoryCombo().getOptionCombos().size();
}
- // System.out.println( "DataSet Member Count :" + dataSetMemberCount1 );
+
deInfo = getDEInfo( dataElements );
@@ -525,62 +548,75 @@
p = (Period) periodIterator.next();
periodInfo = "" + p.getId();
dataElementCount = 0;
- if ( dso == null )
- {
- dsResults.add( -1 );
- deCounts.add( -1 );
- continue;
- }
- else if ( !dso.contains( o ) )
- {
- System.out.println( "Dataset : " + selDataSet.getName() + " not assign to " + o.getName() );
- /*
- * if( childOrgUnits == null || childOrgUnits.size() <= 0 )
- * { dsResults.add( -2 ); continue; }
- *
- * else
- */
- // {
- /*
- * orgUnitInfo = "-1"; orgUnitCount = 0; getOrgUnitInfo( o,
- * dso );
- *
- * if ( includeZeros == null ) { query =
- * "SELECT COUNT(*) FROM " + dataViewName +
- * " WHERE dataelementid IN (" + deInfo +
- * ") AND sourceid IN (" + orgUnitInfo +
- * ") AND periodid IN (" + periodInfo + ") and value <> 0";
- *
- * } else { query = "SELECT COUNT(*) FROM " + dataViewName +
- * " WHERE dataelementid IN (" + deInfo +
- * ") AND sourceid IN (" + orgUnitInfo +
- * ") AND periodid IN (" + periodInfo + ")"; }
- *
- * System.out.println("Used Query is :::::::" + query );
- * SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet(
- * query );
- *
- * if ( sqlResultSet.next() ) { try { //System.out.println(
- * "Result is : \t" + sqlResultSet.getLong( 1 ) );
- * dataStatusPercentatge = ((double) sqlResultSet.getInt( 1
- * ) / (double) (dataSetMemberCount1 orgUnitCount)) 100.0;
- *
- * } catch ( Exception e ) { dataStatusPercentatge = 0.0; }
- * } else dataStatusPercentatge = 0.0;
- *
- * if ( dataStatusPercentatge > 100.0 )
- * dataStatusPercentatge = 100;
- *
- * dataStatusPercentatge = Math.round( dataStatusPercentatge
- * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
- */
- // dsResults.add( (int) dataStatusPercentatge );
- dsResults.add( -1 );
- // dataElementCount = sqlResultSet.getInt( 1 );
- deCounts.add( -1 );
- continue;
- // }
- }
+
+
+
+ if ( dso == null )
+ {
+ dsResults.add( -1 );
+ deCounts.add( -1 );
+ continue;
+ }
+ else if ( !dso.contains( o ) )
+ {
+ System.out.println("Dataset : " + selDataSet.getName() + " not assign to " + o.getName() );
+ /*
+ if( childOrgUnits == null || childOrgUnits.size() <= 0 )
+ {
+ dsResults.add( -2 );
+ continue;
+ }
+
+ else*/
+ //{
+ /*orgUnitInfo = "-1";
+ orgUnitCount = 0;
+ getOrgUnitInfo( o, dso );
+
+ if ( includeZeros == null )
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo
+ + ") and value <> 0";
+
+ }
+ else
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ")";
+ }
+
+ System.out.println("Used Query is :::::::" + query );
+ SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
+
+ if ( sqlResultSet.next() )
+ {
+ try
+ {
+ //System.out.println( "Result is : \t" + sqlResultSet.getLong( 1 ) );
+ dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) (dataSetMemberCount1 * orgUnitCount)) * 100.0;
+
+ }
+ catch ( Exception e )
+ {
+ dataStatusPercentatge = 0.0;
+ }
+ }
+ else
+ dataStatusPercentatge = 0.0;
+
+ if ( dataStatusPercentatge > 100.0 )
+ dataStatusPercentatge = 100;
+
+ dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+ */
+ //dsResults.add( (int) dataStatusPercentatge );
+ dsResults.add( -1 );
+ //dataElementCount = sqlResultSet.getInt( 1 );
+ deCounts.add( -1 );
+ continue;
+ //}
+ }
orgUnitInfo = "" + o.getId();
@@ -603,6 +639,7 @@
{
dataElementCount = sqlResultSet.getInt( 1 );
dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount1) * 100.0;
+
}
catch ( Exception e )
{
@@ -616,18 +653,21 @@
dataElementCount = -1;
}
+
if ( dataStatusPercentatge > 100.0 )
dataStatusPercentatge = 100;
- dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
-
+ dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+
dsResults.add( (int) dataStatusPercentatge );
deCounts.add( dataElementCount );
- }
-
+ //String dataEntryStatusValue = dataEntryStatusService.getValue( selDataSet.getId(), o.getId(), p.getId() );
+ }
+
ouMapDataStatusResult.put( o, dsResults );
ouMapDataElementCount.put( o, deCounts );
- }
+ }
+
// For Level Names
String ouLevelNames[] = new String[organisationUnitService.getNumberOfOrganisationalLevels() + 1];
@@ -671,7 +711,7 @@
// System.out.println("OrgUnit Size is :" + ouMapDataStatusResult.size()
// );
-
+ System.out.println( "Data Entry Status End Time : " + new Date() );
return SUCCESS;
}
=== added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction_Test.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction_Test.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateDataStatusResultAction_Test.java 2011-06-15 06:01:50 +0000
@@ -0,0 +1,921 @@
+package org.hisp.dhis.dataanalyser.ds.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.hibernate.SessionFactory;
+import org.hisp.dhis.common.ServiceProvider;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
+import org.hisp.dhis.completeness.DataSetCompletenessService;
+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;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitShortNameComparator;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import com.opensymphony.xwork2.Action;
+
+public class GenerateDataStatusResultAction_Test
+implements Action
+{
+ // ---------------------------------------------------------------
+ // Dependencies
+ // ---------------------------------------------------------------
+
+ private JdbcTemplate jdbcTemplate;
+
+ public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+ {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+
+ @SuppressWarnings( "unused" )
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ public OrganisationUnitService getOrganisationUnitService()
+ {
+ return organisationUnitService;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ public DataSetService getDataSetService()
+ {
+ return dataSetService;
+ }
+
+ private DashBoardService dashBoardService;
+
+ public void setDashBoardService( DashBoardService dashBoardService )
+ {
+ this.dashBoardService = dashBoardService;
+ }
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
+ @SuppressWarnings("unused")
+ private Comparator<OrganisationUnit> orgUnitComparator;
+
+ public void setOrgUnitComparator( Comparator<OrganisationUnit> orgUnitComparator )
+ {
+ this.orgUnitComparator = orgUnitComparator;
+ }
+
+ private ServiceProvider<DataSetCompletenessService> serviceProvider;
+
+ public void setServiceProvider( ServiceProvider<DataSetCompletenessService> serviceProvider )
+ {
+ this.serviceProvider = serviceProvider;
+ }
+
+ // ---------------------------------------------------------------
+ // Output Parameters
+ // ---------------------------------------------------------------
+
+ private Map<OrganisationUnit, List<DataSetCompletenessResult>> ouMapDataStatusResult;
+
+ public Map<OrganisationUnit, List<DataSetCompletenessResult>> getOuMapDataStatusResult()
+ {
+ return ouMapDataStatusResult;
+ }
+
+ private Map<OrganisationUnit, List<Integer>> ouMapDataElementCount;
+
+ public Map<OrganisationUnit, List<Integer>> getOuMapDataElementCount()
+ {
+ return ouMapDataElementCount;
+ }
+
+ private Collection<Period> periodList;
+
+ public Collection<Period> getPeriodList()
+ {
+ return periodList;
+ }
+
+ private List<OrganisationUnit> orgUnitList;
+
+ public List<OrganisationUnit> getOrgUnitList()
+ {
+ 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()
+ {
+ return dataStatusResult;
+ }
+
+
+
+ private Map<DataSet, Collection<Period>> dataSetPeriods;
+
+ public Map<DataSet, Collection<Period>> getDataSetPeriods()
+ {
+ return dataSetPeriods;
+ }
+
+ List<Period> selectedPeriodList;
+
+ public List<Period> getSelectedPeriodList()
+ {
+ return selectedPeriodList;
+ }
+
+ List<String> levelNames;
+
+ public List<String> getLevelNames()
+ {
+ return levelNames;
+ }
+
+ private int maxOULevel;
+
+ public int getMaxOULevel()
+ {
+ return maxOULevel;
+ }
+
+ // ---------------------------------------------------------------
+ // Input Parameters
+ // ---------------------------------------------------------------
+
+ private String dsId;
+
+ public void setDsId( String dsId )
+ {
+ this.dsId = dsId;
+ }
+
+ private String includeZeros;
+
+ public void setIncludeZeros( String includeZeros )
+ {
+ this.includeZeros = includeZeros;
+ }
+
+ public String getIncludeZeros()
+ {
+ return includeZeros;
+ }
+
+ private String selectedButton;
+
+ public void setselectedButton( String selectedButton )
+ {
+ this.selectedButton = selectedButton;
+ }
+
+ public String getSelectedButton()
+ {
+ return selectedButton;
+ }
+
+ private String ouId;
+
+ public void setOuId( String ouId )
+ {
+ this.ouId = ouId;
+ }
+
+ private String immChildOption;
+
+ public void setImmChildOption( String immChildOption )
+ {
+ this.immChildOption = immChildOption;
+ }
+
+ private int sDateLB;
+
+ public void setSDateLB( int dateLB )
+ {
+ sDateLB = dateLB;
+ }
+
+ public int getSDateLB()
+ {
+ return sDateLB;
+ }
+
+ private int eDateLB;
+
+ public void setEDateLB( int dateLB )
+ {
+ eDateLB = dateLB;
+ }
+
+ public int getEDateLB()
+ {
+ return eDateLB;
+ }
+
+ private String facilityLB;
+
+ public void setFacilityLB( String facilityLB )
+ {
+ this.facilityLB = facilityLB;
+ }
+
+ private List<String> orgUnitListCB;
+
+ public void setOrgUnitListCB( List<String> orgUnitListCB )
+ {
+ this.orgUnitListCB = orgUnitListCB;
+ }
+
+ private List<String> selectedDataSets;
+
+ public void setSelectedDataSets( List<String> selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+
+ public List<String> getSelectedDataSets()
+ {
+ return selectedDataSets;
+ }
+
+ private int minOULevel;
+
+ public int getMinOULevel()
+ {
+ return minOULevel;
+ }
+
+ private int number;
+
+ public int getNumber()
+ {
+ return number;
+ }
+
+ private DataSet selDataSet;
+
+ public DataSet getSelDataSet()
+ {
+ return selDataSet;
+ }
+
+ private List<String> periodNameList;
+
+ public List<String> getPeriodNameList()
+ {
+ return periodNameList;
+ }
+
+ String orgUnitInfo;
+
+ String periodInfo;
+
+ String deInfo;
+
+ int orgUnitCount;
+
+ //private String dataViewName;
+
+ private int dataSetMemberCount1;
+
+ public int getDataSetMemberCount1()
+ {
+ return dataSetMemberCount1;
+ }
+
+
+ private Integer dataElementCount;
+
+ public Integer getDataElementCount()
+ {
+ return dataElementCount;
+ }
+
+ // ---------------------------------------------------------------
+ // Action Implementation
+ // ---------------------------------------------------------------
+ // @SuppressWarnings( { "deprecation", "unchecked" } )
+ public String execute()
+ throws Exception
+ {
+ System.out.println("Inside Normal DtaaStatus Reult Action");
+ orgUnitCount = 0;
+ //dataViewName = "";
+
+ ouMapDataElementCount = new HashMap<OrganisationUnit,List<Integer>>();//Map for DataElement count
+
+
+ // Intialization
+ periodNameList = new ArrayList<String>();
+ ouMapDataStatusResult = new HashMap<OrganisationUnit, List<DataSetCompletenessResult>>();
+ results = new ArrayList<Integer>();
+ maxOULevel = 1;
+ minOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
+
+ if ( immChildOption != null && immChildOption.equalsIgnoreCase( "yes" ) )
+ {
+ orgUnitListCB = new ArrayList<String>();
+ orgUnitListCB.add( ouId );
+
+ facilityLB = "immChildren";
+
+ selectedDataSets = new ArrayList<String>();
+ selectedDataSets.add( 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();
+ }
+
+ // OrgUnit Related Info
+ OrganisationUnit selectedOrgUnit = new OrganisationUnit();
+ orgUnitList = new ArrayList<OrganisationUnit>();
+ if ( facilityLB.equals( "children" ) )
+ {
+ selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
+ orgUnitList = 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>();
+
+ 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 );
+ }
+ }
+ else
+ {
+ Iterator<String> orgUnitIterator = orgUnitListCB.iterator();
+ OrganisationUnit o;
+ while ( orgUnitIterator.hasNext() )
+ {
+ o = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitIterator.next() ) );
+ orgUnitList.add( o );
+ Collections.sort( orgUnitList, new OrganisationUnitShortNameComparator() );
+ displayPropertyHandler.handle( orgUnitList );
+ }
+ }
+
+ //Set<OrganisationUnit> dSetSource = selDataSet.getSources();
+
+ /*
+ List<OrganisationUnit> dSetSource = new ArrayList<OrganisationUnit>( selDataSet.getSources());
+ orgUnitInfo = "-1";
+ Iterator<OrganisationUnit> ouIt = orgUnitList.iterator();
+ while ( ouIt.hasNext() )
+ {
+ OrganisationUnit ou = ouIt.next();
+
+ orgUnitCount = 0;
+ if ( !dSetSource.contains( ou ) )
+ {
+ getDataSetAssignedOrgUnitCount( ou, dSetSource );
+
+ if ( orgUnitCount > 0 )
+ {
+ orgUnitInfo += "," + ou.getId();
+ getOrgUnitInfo( ou );
+ }
+ else
+ {
+ ouIt.remove();
+ }
+ }
+ else
+ {
+ orgUnitInfo += "," + ou.getId();
+ }
+ }
+ */
+ // Period Related Info
+ Period startPeriod = periodService.getPeriod( sDateLB );
+ Period endPeriod = periodService.getPeriod( eDateLB );
+
+ PeriodType dataSetPeriodType = selDataSet.getPeriodType();
+ periodList = new ArrayList<Period>(periodService.getPeriodsBetweenDates( dataSetPeriodType,
+ startPeriod.getStartDate(), endPeriod.getEndDate() ));
+
+ /*
+ periodInfo = "-1";
+ for ( Period p : periodList )
+ periodInfo += "," + p.getId();
+
+ dataViewName = createDataView( orgUnitInfo, deInfo, periodInfo );
+
+ String query = "";
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (?) AND sourceid IN (?) AND periodid IN (?)";
+
+ Collection<DataElement> dataElements = new ArrayList<DataElement>();
+ dataElements = selDataSet.getDataElements();
+
+ dataSetMemberCount1 = 0;
+ for ( DataElement de1 : dataElements )
+ {
+ dataSetMemberCount1 += de1.getCategoryCombo().getOptionCombos().size();
+ }
+
+ //System.out.println( "DataSet Member Count :" + dataSetMemberCount1 );
+
+ deInfo = getDEInfo( dataElements );
+ */
+ Iterator<OrganisationUnit> orgUnitListIterator = orgUnitList.iterator();
+ OrganisationUnit o;
+ //Set<OrganisationUnit> dso = new HashSet<OrganisationUnit>();
+
+ //List<OrganisationUnit> dso = new ArrayList<OrganisationUnit>( selDataSet.getSources());
+
+
+ Iterator<Period> periodIterator;
+ //dso = selDataSet.getSources();
+
+
+ List<DataSetCompletenessResult> dsResults = new ArrayList<DataSetCompletenessResult>();
+ String criteria = "ratio";
+
+ DataSetCompletenessService completenessService = serviceProvider.provide( criteria );
+
+ while ( orgUnitListIterator.hasNext() )
+ {
+ o = orgUnitListIterator.next();
+ orgUnitInfo = "" + o.getId();
+
+ if ( maxOULevel < organisationUnitService.getLevelOfOrganisationUnit( o ) )
+ maxOULevel = organisationUnitService.getLevelOfOrganisationUnit( o );
+
+ if ( minOULevel > organisationUnitService.getLevelOfOrganisationUnit( o ) )
+ minOULevel = organisationUnitService.getLevelOfOrganisationUnit( o );
+/*
+ List<OrganisationUnit> childOrgUnits = new ArrayList<OrganisationUnit>();
+
+ if ( !dso.contains( o ) )
+ {
+ childOrgUnits = filterChildOrgUnitsByDataSet( o, dso );
+ }
+ System.out.println( "Size of Child OrgUnit: " + childOrgUnits.size() );
+*/
+ periodIterator = periodList.iterator();
+
+ Period p;
+
+ // double dataStatusPercentatge;
+
+ //List<DataSetCompletenessResult> dsResults = new ArrayList<DataSetCompletenessResult>();
+ // String criteria = "ratio";
+
+ //DataSetCompletenessService completenessService = serviceProvider.provide( criteria );
+
+ //List<Integer> dsResults = new ArrayList<Integer>();
+ // List<Integer> deCounts = new ArrayList<Integer>();
+ while ( periodIterator.hasNext() )
+ {
+ //System.out.println("Inside period Iterator Loop");
+ p = (Period) periodIterator.next();
+ //periodInfo = "" + p.getId();
+ //dataElementCount = 0;
+
+ /*
+ if ( dso == null )
+ {
+ //dsResults.add( null );
+ //deCounts.add( null );
+ continue;
+ }*/
+
+ //else if ( !dso.contains( o ) )
+ //{
+ System.out.println( "Dataset : " + selDataSet.getName() + " ---:---:--- " + o.getName() );
+ /*
+ if( childOrgUnits == null || childOrgUnits.size() <= 0 )
+ {
+ dsResults.add( -2 );
+ continue;
+ }
+
+ else*/
+ //{
+ /*orgUnitInfo = "-1";
+ orgUnitCount = 0;
+ getOrgUnitInfo( o, dso );
+
+ if ( includeZeros == null )
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo
+ + ") and value <> 0";
+
+ }
+ else
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ")";
+ }
+
+ System.out.println("Used Query is :::::::" + query );
+ SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
+
+ if ( sqlResultSet.next() )
+ {
+ try
+ {
+ //System.out.println( "Result is : \t" + sqlResultSet.getLong( 1 ) );
+ dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) (dataSetMemberCount1 * orgUnitCount)) * 100.0;
+
+ }
+ catch ( Exception e )
+ {
+ dataStatusPercentatge = 0.0;
+ }
+ }
+ else
+ dataStatusPercentatge = 0.0;
+
+ if ( dataStatusPercentatge > 100.0 )
+ dataStatusPercentatge = 100;
+
+ dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+ */
+ //dsResults.add( (int) dataStatusPercentatge );
+ //dsResults.add( null );
+ //dataElementCount = sqlResultSet.getInt( 1 );
+ //deCounts.add( -1 );
+ // continue;
+ //}
+ // }
+
+ //orgUnitInfo = "" + o.getId();
+
+ if ( includeZeros == null )
+ {
+ //System.out.println( "Inside Not includeZeros " );
+
+ dsResults = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness( p.getId(), o.getId(), selDataSet.getId() ) );
+ }
+ else
+ {
+ // System.out.println( "Inside includeZeros " );
+ dsResults = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness( p.getId(), o.getId(), selDataSet.getId() ) );
+ }
+ /*
+
+ if ( includeZeros == null )
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ") and value <> 0";
+ }
+ else
+ {
+ query = "SELECT COUNT(*) FROM " + dataViewName + " WHERE dataelementid IN (" + deInfo
+ + ") AND sourceid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ")";
+ }
+
+ SqlRowSet sqlResultSet = jdbcTemplate.queryForRowSet( query );
+
+ if ( sqlResultSet.next() )
+ {
+ try
+ {
+ dataElementCount = sqlResultSet.getInt( 1 );
+ dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) dataSetMemberCount1) * 100.0;
+ }
+ catch ( Exception e )
+ {
+ dataElementCount = -1;
+ dataStatusPercentatge = 0.0;
+ }
+ }
+ else
+ {
+ dataStatusPercentatge = 0.0;
+ dataElementCount = -1;
+ }
+
+ if ( dataStatusPercentatge > 100.0 )
+ dataStatusPercentatge = 100;
+
+ dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+ */
+ //dsResults.add( (int) dataStatusPercentatge );
+
+ //deCounts.add( dataElementCount );
+
+ }
+ System.out.println( "Size of dsResults is : " + dsResults.size() );
+ ouMapDataStatusResult.put( o, dsResults );
+ //ouMapDataElementCount.put( o, deCounts );
+ }
+
+ System.out.println( "Size of ouMapDataStatusResult is : " + ouMapDataStatusResult.size() );
+
+ for ( OrganisationUnit org : ouMapDataStatusResult.keySet() )
+ {
+ System.out.println( "Inside ouMapDataStatusResult " );
+ List<DataSetCompletenessResult> tempDsResultList = ouMapDataStatusResult.get( org );
+ //System.out.println( "Size of DataSetCompletenessResult is " + tempDsResultList.size() );
+
+ //if( tempDsResultList != null && tempDsResultList.size() > 0 )
+ //{
+
+ for( DataSetCompletenessResult result : tempDsResultList )
+ {
+ //System.out.println( "Inside DataSetCompletenessResult " );
+ System.out.println( "Org Unit Name : " + org.getName() + " , percentage is : " + result.getPercentage() + ", DataElementCount is : " + result.getRegistrations() );
+ }
+
+ //}
+
+ }
+
+ // For Level Names
+ String ouLevelNames[] = new String[organisationUnitService.getNumberOfOrganisationalLevels() + 1];
+ for ( int i = 0; i < ouLevelNames.length; i++ )
+ {
+ ouLevelNames[i] = "Level" + i;
+ }
+
+ List<OrganisationUnitLevel> ouLevels = new ArrayList<OrganisationUnitLevel>( organisationUnitService.getFilledOrganisationUnitLevels() );
+ for ( OrganisationUnitLevel ouL : ouLevels )
+ {
+ ouLevelNames[ouL.getLevel()] = ouL.getName();
+ }
+
+ levelNames = new ArrayList<String>();
+ int count1 = minOULevel;
+ while ( count1 <= maxOULevel )
+ {
+ levelNames.add( ouLevelNames[count1] );
+ count1++;
+ }
+/*
+ try
+ {
+
+ }
+ finally
+ {
+ try
+ {
+ deleteDataView( dataViewName );
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "Exception while closing DB Connections : " + e.getMessage() );
+ }*/
+ // }// finally block end
+
+ periodNameList = dashBoardService.getPeriodNamesByPeriodType( dataSetPeriodType, periodList );
+
+ //System.out.println("OrgUnit Size is :" + ouMapDataStatusResult.size() );
+
+ return SUCCESS;
+ }
+
+ public void getDataSetAssignedOrgUnitCount( OrganisationUnit organisationUnit, List<OrganisationUnit> dso )
+ {
+ Collection<OrganisationUnit> children = organisationUnit.getChildren();
+
+ Iterator<OrganisationUnit> childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = childIterator.next();
+ if ( dso.contains( child ) )
+ {
+ orgUnitCount++;
+ }
+ getDataSetAssignedOrgUnitCount( child, dso );
+ }
+ }
+
+ public String createDataView( String orgUnitInfo, String deInfo, String periodInfo )
+ {
+ String dataViewName = "_ds_" + UUID.randomUUID().toString();
+ dataViewName = dataViewName.replaceAll( "-", "" );
+
+ String query = "DROP VIEW IF EXISTS " + dataViewName;
+
+ try
+ {
+ @SuppressWarnings("unused")
+ int sqlResult = jdbcTemplate.update( query );
+
+ System.out.println( "View " + dataViewName + " dropped Successfully (if exists) " );
+
+ 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 );
+
+ System.out.println( "View " + dataViewName + " created Successfully" );
+ } // try block end
+ catch ( Exception e )
+ {
+ System.out.println( "SQL Exception : " + e.getMessage() );
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "SQL Exception : " + e.getMessage() );
+ return null;
+ }
+ }// finally block end
+
+ return dataViewName;
+ }
+
+ public void deleteDataView( String dataViewName )
+ {
+ String query = "DROP VIEW IF EXISTS " + dataViewName;
+
+ try
+ {
+ @SuppressWarnings("unused")
+ int sqlResult = jdbcTemplate.update( query );
+ System.out.println( "View " + dataViewName + " dropped Successfully" );
+ } // try block end
+ catch ( Exception e )
+ {
+ System.out.println( "SQL Exception : " + e.getMessage() );
+ }
+ finally
+ {
+ try
+ {
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "SQL Exception : " + e.getMessage() );
+ }
+ }// finally block end
+ }
+
+ // Returns the OrgUnitTree for which Root is the orgUnit
+ @SuppressWarnings( "unchecked" )
+ public List<OrganisationUnit> getChildOrgUnitTree( OrganisationUnit orgUnit )
+ {
+ List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>();
+ orgUnitTree.add( orgUnit );
+
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
+ Collections.sort( children, new OrganisationUnitNameComparator() );
+
+ Iterator childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = (OrganisationUnit) childIterator.next();
+ orgUnitTree.addAll( getChildOrgUnitTree( child ) );
+ }
+ return orgUnitTree;
+ }// getChildOrgUnitTree end
+
+ /*
+ private void getOrgUnitInfo( OrganisationUnit organisationUnit )
+ {
+ Collection<OrganisationUnit> children = organisationUnit.getChildren();
+
+ Iterator<OrganisationUnit> childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = childIterator.next();
+ orgUnitInfo += "," + child.getId();
+ getOrgUnitInfo( child );
+ }
+ }*/
+/*
+ private void getOrgUnitInfo( OrganisationUnit organisationUnit, List<OrganisationUnit> dso )
+ {
+ Collection<OrganisationUnit> children = organisationUnit.getChildren();
+
+ Iterator<OrganisationUnit> childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = childIterator.next();
+ if ( dso.contains( child ) )
+ {
+ orgUnitInfo += "," + child.getId();
+ orgUnitCount++;
+ }
+ getOrgUnitInfo( child, dso );
+ }
+ }
+*/
+ /*
+ private String getDEInfo( Collection<DataElement> dataElements )
+ {
+ StringBuffer deInfo = new StringBuffer( "-1" );
+
+ for ( DataElement de : dataElements )
+ {
+ deInfo.append( "," ).append( de.getId() );
+ }
+ return deInfo.toString();
+ }
+ */
+/*
+ private List<OrganisationUnit> filterChildOrgUnitsByDataSet( OrganisationUnit selectedOrganisationUnit, List<OrganisationUnit> dso )
+ {
+ List<OrganisationUnit> filteredOrganisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( selectedOrganisationUnit.getId() ) );
+ filteredOrganisationUnits.retainAll( dso );
+ return filteredOrganisationUnits;
+ }
+*/
+
+
+
+
+
+}// class end
=== modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateGroupWiseDataStatusResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateGroupWiseDataStatusResultAction.java 2011-04-27 17:15:13 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/ds/action/GenerateGroupWiseDataStatusResultAction.java 2011-06-15 06:01:50 +0000
@@ -199,7 +199,8 @@
{
return maxOULevel;
}
-
+
+
// ---------------------------------------------------------------
// Input Parameters
// ---------------------------------------------------------------
@@ -228,6 +229,11 @@
private String immChildOption;
+ public String getImmChildOption()
+ {
+ return immChildOption;
+ }
+
public void setImmChildOption( String immChildOption )
{
this.immChildOption = immChildOption;
@@ -339,13 +345,34 @@
{
return dsSize;
}
-
+/*
private List<Integer> dataElementCount;
public List<Integer> getDataElementCount()
{
return dataElementCount;
}
+*/
+ private Integer dataElementCount;
+
+ public Integer getDataElementCount()
+ {
+ return dataElementCount;
+ }
+
+ private Map<DataElementGroup, Map<OrganisationUnit, List<Integer>>> ouGroupMapDeMapCount;
+
+ public Map<DataElementGroup, Map<OrganisationUnit, List<Integer>>> getOuGroupMapDeMapCount()
+ {
+ return ouGroupMapDeMapCount;
+ }
+
+ private Map<OrganisationUnit, List<Integer>> ouMapDataElementCount;
+
+ public Map<OrganisationUnit, List<Integer>> getOuMapDataElementCount()
+ {
+ return ouMapDataElementCount;
+ }
// ---------------------------------------------------------------
// Action Implementation
@@ -365,7 +392,9 @@
deMapGroupCount = new HashMap<DataElementGroup, Integer>(); // dataelement Group Count
results = new ArrayList<Integer>();
- dataElementCount = new ArrayList<Integer>();
+
+ ouGroupMapDeMapCount = new HashMap<DataElementGroup,Map<OrganisationUnit, List<Integer>>>();
+ //dataElementCount = new ArrayList<Integer>();
maxOULevel = 1;
minOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
@@ -537,7 +566,7 @@
OrganisationUnit o;
Set<OrganisationUnit> dso = new HashSet<OrganisationUnit>();
Iterator<Period> periodIterator;
-
+ ouMapDataElementCount = new HashMap<OrganisationUnit,List<Integer>>();//Map for DataElement count
while ( orgUnitListIterator.hasNext() )
{
o = orgUnitListIterator.next();
@@ -556,21 +585,24 @@
// @SuppressWarnings("unused")
// Collection dataValueResult;
double dataStatusPercentatge;
- int tempDataElementCount = 0;
-
+ //int tempDataElementCount = 0;
+ List<Integer> deCounts = new ArrayList<Integer>();
while ( periodIterator.hasNext() )
{
p = (Period) periodIterator.next();
periodInfo = "" + p.getId();
-
+ dataElementCount = 0;
+
if ( dso == null )
{
results.add( -1 );
- dataElementCount.add( -1 );
+ //dataElementCount.add( -1 );
+ deCounts.add( -1 );
continue;
}
else if ( !dso.contains( o ) )
{
+ /*
orgUnitInfo = "-1";
orgUnitCount = 0;
getOrgUnitInfo( o, dso );
@@ -610,9 +642,11 @@
tempDataElementCount = sqlResultSet.getInt( 1 );
dataElementCount.add( tempDataElementCount );
-
- results.add( (int) dataStatusPercentatge );
- dataElementCount.add( -1 );
+ */
+ //results.add( (int) dataStatusPercentatge );
+ //dataElementCount.add( -1 );
+ results.add( -1 );
+ deCounts.add( -1 );
continue;
}
@@ -635,27 +669,37 @@
{
try
{
+ dataElementCount = sqlResultSet.getInt( 1 );
dataStatusPercentatge = ((double) sqlResultSet.getInt( 1 ) / (double) deGroupMemberCount1) * 100.0;
}
catch ( Exception e )
{
dataStatusPercentatge = 0.0;
+ dataElementCount = -1;
}
}
else
+ {
dataStatusPercentatge = 0.0;
+ dataElementCount = -1;
+
+ }
+
if ( dataStatusPercentatge > 100.0 )
dataStatusPercentatge = 100;
dataStatusPercentatge = Math.round( dataStatusPercentatge * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
- tempDataElementCount = sqlResultSet.getInt( 1 );
- dataElementCount.add( tempDataElementCount );
+ //tempDataElementCount = sqlResultSet.getInt( 1 );
+ // dataElementCount.add( tempDataElementCount );
+ deCounts.add( dataElementCount );
results.add( (int) dataStatusPercentatge );
}
+ ouMapDataElementCount.put( o, deCounts );
}
+ ouGroupMapDeMapCount.put( deg, ouMapDataElementCount );
}
// For Level Names
@@ -818,7 +862,7 @@
getOrgUnitInfo( child );
}
}
-
+/*
private void getOrgUnitInfo( OrganisationUnit organisationUnit, Set<OrganisationUnit> dso )
{
Collection<OrganisationUnit> children = organisationUnit.getChildren();
@@ -836,7 +880,7 @@
getOrgUnitInfo( child, dso );
}
}
-
+*/
private String getDEInfo( Collection<DataElement> dataElements )
{
StringBuffer deInfo = new StringBuffer( "-1" );
=== added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/GenerateDataEntryStatusResultAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/GenerateDataEntryStatusResultAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/GenerateDataEntryStatusResultAction.java 2011-06-15 06:01:50 +0000
@@ -0,0 +1,523 @@
+package org.hisp.dhis.dataanalyser.dsMart.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitShortNameComparator;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+
+import com.opensymphony.xwork2.Action;
+
+public class GenerateDataEntryStatusResultAction implements Action
+{
+ // ---------------------------------------------------------------
+ // Dependencies
+ // ---------------------------------------------------------------
+
+ private JdbcTemplate jdbcTemplate;
+
+ public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+ {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+
+ @SuppressWarnings( "unused" )
+ private SessionFactory sessionFactory;
+
+ public void setSessionFactory( SessionFactory sessionFactory )
+ {
+ this.sessionFactory = sessionFactory;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ public OrganisationUnitService getOrganisationUnitService()
+ {
+ return organisationUnitService;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ private DashBoardService dashBoardService;
+
+ public void setDashBoardService( DashBoardService dashBoardService )
+ {
+ this.dashBoardService = dashBoardService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
+ // ---------------------------------------------------------------
+ // Input/Output Parameters
+ // ---------------------------------------------------------------
+
+/*
+ private Map<OrganisationUnit, List<Integer>> ouMapDataEntryStatusResult;
+
+ public Map<OrganisationUnit, List<Integer>> getOuMapDataEntryStatusResult()
+ {
+ return ouMapDataEntryStatusResult;
+ }
+*/
+ private Map<String , Integer> ouMapDataEntryStatusResult;
+
+ public Map<String, Integer> getOuMapDataEntryStatusResult()
+ {
+ return ouMapDataEntryStatusResult;
+ }
+
+ private Map<String , Integer> ouMapDataElementCount;
+
+ public Map<String, Integer> getOuMapDataElementCount()
+ {
+ return ouMapDataElementCount;
+ }
+
+ /*
+ private Map<OrganisationUnit, List<Integer>> ouMapDataElementCount;
+
+ public Map<OrganisationUnit, List<Integer>> getOuMapDataElementCount()
+ {
+ return ouMapDataElementCount;
+ }
+*/
+ private List<Integer> results;
+
+ public List<Integer> getResults()
+ {
+ return results;
+ }
+
+ private String includeZeros;
+
+ public void setIncludeZeros( String includeZeros )
+ {
+ this.includeZeros = includeZeros;
+ }
+
+ public String getIncludeZeros()
+ {
+ return includeZeros;
+ }
+
+ private int sDateLB;
+
+ public void setSDateLB( int dateLB )
+ {
+ sDateLB = dateLB;
+ }
+
+ public int getSDateLB()
+ {
+ return sDateLB;
+ }
+
+ private int eDateLB;
+
+ public void setEDateLB( int dateLB )
+ {
+ eDateLB = dateLB;
+ }
+
+ public int getEDateLB()
+ {
+ return eDateLB;
+ }
+
+ private DataSet selDataSet;
+
+ public DataSet getSelDataSet()
+ {
+ return selDataSet;
+ }
+
+ private Collection<Period> periodList;
+
+ public Collection<Period> getPeriodList()
+ {
+ return periodList;
+ }
+
+ private List<String> periodNameList;
+
+ public List<String> getPeriodNameList()
+ {
+ return periodNameList;
+ }
+/*
+ private String selectedDataSets;
+
+ public void setSelectedDataSets( String selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+*/
+ private List<String> selectedDataSets;
+
+ public void setSelectedDataSets( List<String> selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+
+ public List<String> getSelectedDataSets()
+ {
+ return selectedDataSets;
+ }
+
+ private String dataSetName;
+
+ public String getDataSetName()
+ {
+ return dataSetName;
+ }
+
+ private List<OrganisationUnit> orgUnitList;
+
+ public List<OrganisationUnit> getOrgUnitList()
+ {
+ return orgUnitList;
+ }
+
+ private String facilityLB;
+
+ public void setFacilityLB( String facilityLB )
+ {
+ this.facilityLB = facilityLB;
+ }
+
+ private List<String> orgUnitListCB;
+
+ public void setOrgUnitListCB( List<String> orgUnitListCB )
+ {
+ this.orgUnitListCB = orgUnitListCB;
+ }
+
+ private int maxOULevel;
+
+ public int getMaxOULevel()
+ {
+ return maxOULevel;
+ }
+
+ private int minOULevel;
+
+ public int getMinOULevel()
+ {
+ return minOULevel;
+ }
+
+ String orgUnitInfo;
+ String periodInfo;
+
+ List<String> levelNames;
+
+ public List<String> getLevelNames()
+ {
+ return levelNames;
+ }
+
+ private int totalDataElementCount;
+
+ public int getTotalDataElementCount()
+ {
+ return totalDataElementCount;
+ }
+
+ private List<OrganisationUnit> dataSetSources;
+
+ public List<OrganisationUnit> getDataSetSources()
+ {
+ return dataSetSources;
+ }
+
+ private String immChildOption;
+
+ public void setImmChildOption( String immChildOption )
+ {
+ this.immChildOption = immChildOption;
+ }
+
+ private String ouId;
+
+ public void setOuId( String ouId )
+ {
+ this.ouId = ouId;
+ }
+ private String dsId;
+
+ public void setDsId( String dsId )
+ {
+ this.dsId = dsId;
+ }
+
+ private String selectedButton;
+
+ public void setselectedButton( String selectedButton )
+ {
+ this.selectedButton = selectedButton;
+ }
+
+ public String getSelectedButton()
+ {
+ return selectedButton;
+ }
+
+ // ---------------------------------------------------------------
+ // Action Implementation
+ // ---------------------------------------------------------------
+ public String execute() throws Exception
+ {
+ System.out.println( "Data Entry Status Start Time : " + new Date() );
+ periodNameList = new ArrayList<String>();
+ maxOULevel = 1;
+ minOULevel = organisationUnitService.getNumberOfOrganisationalLevels();
+
+ dataSetSources = new ArrayList<OrganisationUnit>();
+
+ ouMapDataElementCount = new HashMap<String, Integer>();// Map for DataElement count
+
+ ouMapDataEntryStatusResult = new HashMap<String, Integer>();// Map for Results
+ results = new ArrayList<Integer>();//for Results
+
+ System.out.println( "immChildOption : " + immChildOption + ", Ou Id is : " + ouId + ", DS id is : " + dsId );
+
+ if ( immChildOption != null && immChildOption.equalsIgnoreCase( "yes" ) )
+ {
+ System.out.println( "Inside Drill Down" );
+ orgUnitListCB = new ArrayList<String>();
+ orgUnitListCB.add( ouId );
+
+ facilityLB = "immChildren";
+
+ selectedDataSets = new ArrayList<String>();
+ selectedDataSets.add( dsId );
+
+ }
+
+ // DataSet Related Info
+ for ( String ds : selectedDataSets )
+ {
+ DataSet dSet = dataSetService.getDataSet( Integer.parseInt( ds ) );
+ selDataSet = dSet;
+ dataSetName = selDataSet.getName();
+ }
+
+
+ Collection<DataElement> dataElements = new ArrayList<DataElement>();
+ dataElements = selDataSet.getDataElements();
+ totalDataElementCount = 0;
+ for ( DataElement de1 : dataElements )
+ {
+ totalDataElementCount += de1.getCategoryCombo().getOptionCombos().size();
+ }
+
+ dataSetSources = new ArrayList<OrganisationUnit>( selDataSet.getSources() );
+
+ // Period Related Info
+ Period startPeriod = periodService.getPeriod( sDateLB );
+ Period endPeriod = periodService.getPeriod( eDateLB );
+
+ PeriodType dataSetPeriodType = selDataSet.getPeriodType();
+ periodList = new ArrayList<Period>( periodService.getPeriodsBetweenDates( dataSetPeriodType, startPeriod.getStartDate(), endPeriod.getEndDate() ) );
+
+ periodNameList = dashBoardService.getPeriodNamesByPeriodType( dataSetPeriodType, periodList );
+
+ Iterator<Period> periodIterator = periodList.iterator();
+ Period p;
+ periodInfo = "-1";
+ while ( periodIterator.hasNext() )
+ {
+ p = (Period) periodIterator.next();
+ periodInfo += "," + p.getId();
+ }
+
+ // OrgUnit Related Info
+ OrganisationUnit selectedOrgUnit = new OrganisationUnit();
+ orgUnitList = new ArrayList<OrganisationUnit>();
+ if ( facilityLB.equals( "children" ) )
+ {
+ selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) );
+ orgUnitList = 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>();
+
+ 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 );
+ }
+ }
+ else
+ {
+ Iterator<String> orgUnitIterator = orgUnitListCB.iterator();
+ OrganisationUnit o;
+ while ( orgUnitIterator.hasNext() )
+ {
+ o = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitIterator.next() ) );
+ orgUnitList.add( o );
+ Collections.sort( orgUnitList, new OrganisationUnitShortNameComparator() );
+ displayPropertyHandler.handle( orgUnitList );
+ }
+ }
+
+ Iterator<OrganisationUnit> orgUnitListIterator = orgUnitList.iterator();
+ OrganisationUnit o;
+ orgUnitInfo = "-1";
+ while ( orgUnitListIterator.hasNext() )
+ {
+ o = orgUnitListIterator.next();
+ orgUnitInfo += "," + o.getId();
+
+ if ( maxOULevel < organisationUnitService.getLevelOfOrganisationUnit( o ) )
+ maxOULevel = organisationUnitService.getLevelOfOrganisationUnit( o );
+
+ if ( minOULevel > organisationUnitService.getLevelOfOrganisationUnit( o ) )
+ minOULevel = organisationUnitService.getLevelOfOrganisationUnit( o );
+ }
+
+ // For Level Names
+ String ouLevelNames[] = new String[organisationUnitService.getNumberOfOrganisationalLevels() + 1];
+ for ( int i = 0; i < ouLevelNames.length; i++ )
+ {
+ ouLevelNames[i] = "Level" + i;
+ }
+
+ List<OrganisationUnitLevel> ouLevels = new ArrayList<OrganisationUnitLevel>( organisationUnitService
+ .getFilledOrganisationUnitLevels() );
+ for ( OrganisationUnitLevel ouL : ouLevels )
+ {
+ ouLevelNames[ouL.getLevel()] = ouL.getName();
+ }
+
+ levelNames = new ArrayList<String>();
+ int count1 = minOULevel;
+ while ( count1 <= maxOULevel )
+ {
+ levelNames.add( ouLevelNames[count1] );
+ count1++;
+ }
+
+ String query ="";
+ if ( includeZeros == null )
+ {
+ query = "SELECT organisationunitid, periodid, value FROM dataentrystatus WHERE datasetid = " + selDataSet.getId() + " AND organisationunitid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ") and includezero ='N' ";
+ }
+ else
+ {
+ query = "SELECT organisationunitid, periodid, value FROM dataentrystatus WHERE datasetid = " + selDataSet.getId() + " AND organisationunitid IN (" + orgUnitInfo + ") AND periodid IN (" + periodInfo + ") and includezero ='Y' ";
+ }
+
+ SqlRowSet rs = jdbcTemplate.queryForRowSet( query );
+ //System.out.println( "Query is : " + query );
+
+ double value ;
+ while ( rs.next() )
+ {
+ Integer orgUnitId = rs.getInt( 1 );
+ Integer periodId = rs.getInt( 2 );
+ //Integer value = rs.getInt( 3 );
+ String tempValue = rs.getString( 3 );
+ //Integer value = Integer.parseInt( tempValue );
+ //Double value = rs.getDouble( 1 );
+
+ // double value = ((double) rs.getInt( 3 ));
+
+ try
+ {
+ value = Double.parseDouble( tempValue );
+
+ }
+ catch ( Exception e )
+ {
+ value = 0.0;
+ }
+
+ String orgIdPeriodId = orgUnitId + ":" + periodId;
+ double dataElementCount = ( value * (double) totalDataElementCount ) / 100;
+ //Integer dataElementCount = Math.round( tempDataElementCount * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+
+ value = Math.round( value * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+ dataElementCount = Math.round( dataElementCount * Math.pow( 10, 0 ) ) / Math.pow( 10, 0 );
+
+ ouMapDataEntryStatusResult.put( orgIdPeriodId, (int)value );
+ ouMapDataElementCount.put( orgIdPeriodId, (int)dataElementCount );
+ }
+ System.out.println( "Size of ouMap DataEntry Status Result Map is : " + ouMapDataEntryStatusResult.size() + ", Size of ouMap DataElement Count Map is : " + ouMapDataElementCount.size() );
+ System.out.println( "Data Entry Status End Time : " + new Date() );
+ return SUCCESS;
+ }
+
+ // Returns the OrgUnitTree for which Root is the orgUnit
+ @SuppressWarnings( "unchecked" )
+ public List<OrganisationUnit> getChildOrgUnitTree( OrganisationUnit orgUnit )
+ {
+ List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>();
+ orgUnitTree.add( orgUnit );
+
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
+ Collections.sort( children, new OrganisationUnitNameComparator() );
+
+ Iterator childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = (OrganisationUnit) childIterator.next();
+ orgUnitTree.addAll( getChildOrgUnitTree( child ) );
+ }
+ return orgUnitTree;
+ }// getChildOrgUnitTree end
+}
=== added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/ValidateDataEntryStatusAction.java'
--- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/ValidateDataEntryStatusAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dataanalyser/dsMart/action/ValidateDataEntryStatusAction.java 2011-06-15 06:01:50 +0000
@@ -0,0 +1,99 @@
+package org.hisp.dhis.dataanalyser.dsMart.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+
+import com.opensymphony.xwork2.Action;
+
+public class ValidateDataEntryStatusAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SelectionTreeManager selectionTreeManager;
+
+ public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+ {
+ this.selectionTreeManager = selectionTreeManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Collection<Integer> selectedPeriods = new ArrayList<Integer>();
+
+ public void setSelectedPeriods( Collection<Integer> selectedPeriods )
+ {
+ this.selectedPeriods = selectedPeriods;
+ }
+
+ private Collection<Integer> selectedDataSets = new ArrayList<Integer>();
+
+ public void setSelectedDataSets( Collection<Integer> selectedDataSets )
+ {
+ this.selectedDataSets = selectedDataSets;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ if ( selectedPeriods == null || selectedPeriods.size() == 0 )
+ {
+ message = i18n.getString( "period_not_selected" );
+
+ return INPUT;
+ }
+
+ if ( selectedDataSets == null || selectedDataSets.size() == 0 )
+ {
+ message = i18n.getString( "dataset_not_selected" );
+
+ return INPUT;
+ }
+
+ Collection<OrganisationUnit> selectedUnits = new HashSet<OrganisationUnit>();
+ selectedUnits = selectionTreeManager.getSelectedOrganisationUnits();
+
+ if ( selectedUnits == null || selectedUnits.size() == 0 )
+ {
+ message = i18n.getString( "organisation_not_selected" );
+
+ return INPUT;
+ }
+
+ return SUCCESS;
+ }
+}
=== 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 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml 2011-06-15 06:01:50 +0000
@@ -611,6 +611,7 @@
</property>
<property name="sessionFactory" ref="sessionFactory"/>
<property name="jdbcTemplate" ref="jdbcTemplate"/>
+<!-- <property name="serviceProvider" ref="dataCompletenessServiceProvider"/>-->
</bean>
<!-- Null report for DataEntry Status -->
@@ -672,7 +673,10 @@
<ref bean="org.hisp.dhis.period.PeriodService"/>
</property>
</bean>
-
+
+
+
+
@@ -1335,4 +1339,56 @@
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
+ <!-- Data Entry Status -->
+
+ <bean id="org.hisp.dhis.dataanalyser.ds.action.DataEntryStatusSaveAction"
+ class="org.hisp.dhis.dataanalyser.ds.action.DataEntryStatusSaveAction"
+ scope="prototype">
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService"/>
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService"/>
+ </property>
+ <property name="dataSetService">
+ <ref bean="org.hisp.dhis.dataset.DataSetService"/>
+ </property>
+ <property name="dataEntryStatusService">
+ <ref bean="org.hisp.dhis.dataentrystatus.DataEntryStatusService"/>
+ </property>
+ <property name="selectionTreeManager">
+ <ref bean="org.hisp.dhis.oust.manager.SelectionTreeManager"></ref>
+ </property>
+ <property name="jdbcTemplate" ref="jdbcTemplate"/>
+ </bean>
+ <!-- Data Entry Status Validation -->
+ <bean id="org.hisp.dhis.dataanalyser.dsMart.action.ValidateDataEntryStatusAction"
+ class="org.hisp.dhis.dataanalyser.dsMart.action.ValidateDataEntryStatusAction"
+ scope="prototype">
+ <property name="selectionTreeManager">
+ <ref bean="org.hisp.dhis.oust.manager.SelectionTreeManager"></ref>
+ </property>
+ </bean>
+
+ <!-- Data Entry Status -->
+
+ <bean id="org.hisp.dhis.dataanalyser.dsMart.action.GenerateDataEntryStatusResultAction"
+ class="org.hisp.dhis.dataanalyser.dsMart.action.GenerateDataEntryStatusResultAction"
+ scope="prototype">
+ <property name="dashBoardService">
+ <ref bean="org.hisp.dhis.dataanalyser.util.DashBoardService"/>
+ </property>
+ <property name="dataSetService">
+ <ref bean="org.hisp.dhis.dataset.DataSetService"/>
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService"/>
+ </property>
+ <property name="organisationUnitService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </property>
+ <property name="sessionFactory" ref="sessionFactory"/>
+ <property name="jdbcTemplate" ref="jdbcTemplate"/>
+ </bean>
+
</beans>
\ No newline at end of file
=== modified file 'local/in/dhis-web-dashboard/src/main/resources/org/hisp/dhis/dataanalyser/i18n_module.properties'
--- local/in/dhis-web-dashboard/src/main/resources/org/hisp/dhis/dataanalyser/i18n_module.properties 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/resources/org/hisp/dhis/dataanalyser/i18n_module.properties 2011-06-15 06:01:50 +0000
@@ -145,6 +145,12 @@
selected_periods = Selected Periods
available_datasets = Available Datasets
selected_datasets = Selected Datasets
-
+data_status_mart = Data Status Mart
+select_period_type = Select Period Type
+information_successfully_saved = Information Successfully Saved
+back = Back
+organisation_not_selected = There is no organization unit selected
+period_not_selected = Select Available Period
+dataset_not_selected = Select Available data sets
=== modified file 'local/in/dhis-web-dashboard/src/main/resources/struts.xml'
--- local/in/dhis-web-dashboard/src/main/resources/struts.xml 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/resources/struts.xml 2011-06-15 06:01:50 +0000
@@ -904,8 +904,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-dashboard/dataStatusMartFront.vm</param>
<param name="menu">/dhis-web-dashboard/menu.vm</param>
- <param name="javascripts">../dhis-web-commons/oust/oust.js,
- javascript/dataStatusMart.js</param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/dataStatusMart.js</param>
</action>
<action name="getPeriodsDSMart"
@@ -923,6 +922,30 @@
</action>
+ <action name="calculateDataStatus"
+ class="org.hisp.dhis.dataanalyser.ds.action.DataEntryStatusSaveAction">
+ <interceptor-ref name="organisationUnitTreeStack"/>
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-dashboard/dataStatusMartSave.vm</param>
+ <param name="menu">/dhis-web-dashboard/menu.vm</param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/dataStatusMart.js</param>
+ </action>
+ <!-- Data Entry Status Validation -->
+ <action name="validateDataEntryStatus"
+ class="org.hisp.dhis.dataanalyser.dsMart.action.ValidateDataEntryStatusAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <!-- Data Entry Status Validation -->
+ <action name="dataEntryStatusResult"
+ class="org.hisp.dhis.dataanalyser.dsMart.action.GenerateDataEntryStatusResultAction">
+ <result name="success" type="velocity">/popup.vm</result>
+ <param name="page">/dhis-web-dashboard/dataEntryStatusResult.vm</param>
+ <param name="javascripts">javascript/ds.js,javascript/hashtable.js</param>
+ <param name="stylesheets">css/StylesForTags.css</param>
+ </action>
</package>
</struts>
\ No newline at end of file
=== added file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataEntryStatusResult.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataEntryStatusResult.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataEntryStatusResult.vm 2011-06-15 06:01:50 +0000
@@ -0,0 +1,159 @@
+<html>
+ <head>
+ <title>DataStatus Result</title>
+ <link type="text/css" rel="stylesheet" media="screen" href="css/StylesForTags.css">
+ </link>
+ <script>
+ var startDate = "$sDateLB";
+ var endDate = "$eDateLB";
+ var dsType = "$selectedButton";
+ var includeZeros = "$includeZeros";
+
+ function getImmChildInfo( evt, dsId, selOrgUnit )
+ {
+ //alert("Data Entry Status : " + dsId + ":" + selOrgUnit + ":" + includeZeros );
+ immChildOption = "yes";
+ if( document.getElementById('includeZeros').checked )
+ {
+ //alert("inside include zero : " + immChildOption );
+ // var urlForImmChild = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType+"&includeZeros="+includeZeros;
+ //alert( urlForImmChild );
+ evt.target.href = "dataEntryStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType+"&includeZeros="+includeZeros;
+ }
+ else
+ {
+ alert("inside include zero null");
+ evt.target.href = "dataEntryStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType;
+ }
+ }
+ function exportDataStatusResultToWorkBook()
+ {
+ document.getElementById('htmlCode').value = document.getElementById('formResult').innerHTML;
+ return true;
+ }
+
+ function getNullReportInfo( dsId, periodId, selOrgUnit )
+ {
+ var url = "nullReportResult.action?dsId="+dsId+"&periodId="+periodId+"&ouId="+selOrgUnit;
+ $('#contentDataRecord').dialog('destroy').remove();
+ $('<div id="contentDataRecord">' ).load(url).dialog({
+ title: 'Null Report',
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 600
+ });
+ }
+
+ </script>
+ </head>
+ <body>
+
+ #if( "$!ouMapDataEntryStatusResult" == "" || $ouMapDataEntryStatusResult.isEmpty() || $ouMapDataEntryStatusResult.size() == 0 )
+ <div align="center" class="NormalB">Data Entry Status Mart is not Generated for the Selected Options</div>
+ #else
+ <form id="form1" name="form1" action="exportDataStatusToExcel.action" method="post" onsubmit="return exportDataStatusResultToWorkBook()" target="_newtab">
+ <input type="hidden" name="htmlCode" id="htmlCode" />
+
+ <div align="right" class="NormalB">
+ <input type="checkbox" name="includeZeros" id="includeZeros" #if($includeZeros) checked #end /> Include Zero<br />
+ <input type="submit" name="ExportToWorkBook" value="Export To WorkBook" style="width: 160; height: 25; font-family:Arial; font-weight:bold; color:#000000">
+ </div>
+
+ <div id="formResult">
+ <div align="center" class="NormalB">Data Entry Status</div>
+ <div align="right">
+ <table width="30%">
+ <tr class="TableDataCellStyles" >
+ <td bgcolor="#a0c0a0"> </td>
+ <td align="left"> Completed (75+) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#a0a0ff"> </td>
+ <td align="left"> Partially Completed (41 - 75) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#905090"> </td>
+ <td align="left"> Not Completed (1 - 40) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#ff0000"> </td>
+ <td align="left"> Not Entered ( 0 ) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="blue"> </td>
+ <td align="left"> Not Assigned</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="white"> </td>
+ <td align="left"> Data Not Mart</td>
+ </tr>
+ </table>
+ </div>
+
+ <br><br>
+ <div align="left" class="NormalB">DataSet : $dataSetName ( $totalDataElementCount )</div>
+ <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
+ <tr class="TableHeadingCellStyles" align="center">
+ #foreach($levelName in $levelNames)
+ <th>$!levelName</th>
+ #end
+
+ #foreach($periodname in $periodNameList)
+ <th>$periodname</th>
+ #end
+ </tr>
+
+ #foreach( $chiildorgUnit in $orgUnitList )
+ #set( $count1 = $minOULevel )
+ #set( $curOrgUnitLevel = $organisationUnitService.getLevelOfOrganisationUnit( $chiildorgUnit ) )
+ <tr class="TableHeadingCellStyles">
+ #foreach( $levelName in $levelNames )
+ #if( $count1 == $curOrgUnitLevel )
+ <td><a href="#" onclick="javascript:getImmChildInfo(event, '$selDataSet.id', '$chiildorgUnit.id')" target="_blank">$chiildorgUnit.name</a></td>
+ #else
+ <td> </td>
+ #end
+ #set($count1 = $count1 + 1)
+ #end
+
+ ##set( $dsresultList = $ouMapDataStatusResult.get( $chiildorgUnit ) )
+ ##set( $dataElementCounts = $ouMapDataElementCount.get( $chiildorgUnit ) )
+ ##set( $periodCounts = $periodList )
+
+ #set( $count2 = 0 )
+ #foreach( $period in $periodList )
+ #set( $result = -1 )
+ #set( $result = $ouMapDataEntryStatusResult.get( "$chiildorgUnit.id:$period.id" ) )
+ #set( $deCount = $ouMapDataElementCount.get( "$chiildorgUnit.id:$period.id" ) )
+
+ ##set( $result = $dsresultList.get( $count2 ) )
+ ##set( $deCount = $dataElementCounts.get( $count2 ) )
+
+ ##set( $deCount = $dataElementCounts.get( $count2 ) )
+ ##set( $periodCount = $periodCounts.get( $count2 ) )
+ #if( !$dataSetSources.contains( $chiildorgUnit ) )
+ <td bgcolor="blue"> </td>
+ #elseif( $result < 0 )
+ <td bgcolor="white"> </td>
+ #elseif( $result == 0 )
+ <td align="center" bgcolor="#ff0000"><font color="#ffffff"><a href="javascript:getNullReportInfo('$selDataSet.id','$period.id','$chiildorgUnit.id')">$result% ( $deCount ) </a></font></td>
+ #elseif( $result > 75 )
+ <td align="center" bgcolor="#a0c0a0"><font color="#ffffff"><a href="javascript:getNullReportInfo('$selDataSet.id','$period.id','$chiildorgUnit.id')">$result% ( $deCount ) </a></font></td>
+ #elseif( $result > 40 && $result <= 75 )
+ <td align="center" bgcolor="#a0a0ff"><font color="#ffffff"><a href="javascript:getNullReportInfo('$selDataSet.id','$period.id','$chiildorgUnit.id')">$result% ( $deCount ) </a></font></td>
+ #else
+ <td align="center" bgcolor="#905090"><font color="#ffffff"><a href="javascript:getNullReportInfo('$selDataSet.id','$period.id','$chiildorgUnit.id')">$result% ( $deCount ) </a></font></td>
+ #end
+ #set( $count2 = $count2 + 1 )
+ #end
+ </tr>
+ #end
+ </table>
+ </div>
+ </form>
+ #end
+ </body>
+</html>
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusFront.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusFront.vm 2011-04-15 11:35:33 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusFront.vm 2011-06-15 06:01:50 +0000
@@ -52,11 +52,11 @@
<select id="eDateLB" name="eDateLB" style="width:300px"></select>
</td>
<td class="NormalB">
- <input type="checkbox" name="includeZeros" id="includeZeros" checked> Include Zero
+ <input type="checkbox" name="includeZeros" id="includeZeros" checked> Include Zero <input type="checkbox" name="usingDataEntryStatus" id="usingDataEntryStatus" > Data Entry Status
<br/><br/>
- <input type="button" name="ViewStatus" value="View DataStatus" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('DataStatus')"/><br/><br/>
- <input type="button" name="ViewGroupWise" value="View By Data Element Group" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('GroupWiseStatus')"/><br/><br/>
- <input type="button" name="ViewSummary" value="View DataSummary" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('SummaryStatus')"/><br/><br/>
+ <input type="button" name="ViewStatus" value="View DataStatus - Data Set" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('DataStatus')"/><br/><br/>
+ <input type="button" name="ViewGroupWise" value="View DataStatus - Data Element Group" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('GroupWiseStatus')"/><br/><br/>
+ <input type="button" name="ViewSummary" value="View DataSummary - Data Set" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('SummaryStatus')"/><br/><br/>
<input type="button" name="LastUpdatedStatus" value="User Details" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('LastUpdatedStatus')"/><br/><br/>
<input type="button" name="ValidationStatus" value="Validation Status" style="width:250px;height:30px;font-family: Arial; font-weight: bold; color: rgb(0, 0, 0);" onclick="textvalue('ValidationStatus')"/>
</td>
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartFront.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartFront.vm 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartFront.vm 2011-06-15 06:01:50 +0000
@@ -1,4 +1,4 @@
-<h3>$i18n.getString( "data_locking_form" ) #openHelp( "dataLocking" )</h3>
+<h3>$i18n.getString( "data_status_mart" )</h3>
<form id="dataStatusMartForm" name="dataStatusMartForm" action="calculateDataStatus.action" method="POST">
<input type="hidden" id="selectForDataStatusMart" name="selectForDataStatusMart"/>
@@ -6,7 +6,7 @@
<tr>
<td valign="top">
<table valign="top">
- <tr><th>$i18n.getString( "period_type" )</th></tr>
+ <tr><th>$i18n.getString( "period_type" )</th><td></td><td><input type="checkbox" name="includeZeros" id="includeZeros" checked> Include Zero</td></tr>
<tr>
<td>
<select id="periodTypeId" name="periodTypeId" style="min-width:325px" onchange="getPeriods()">
@@ -61,12 +61,12 @@
</table>
<table>
<tr>
- <td>#organisationUnitSelectionTree( true, true, false )</td>
+ <td>#organisationUnitSelectionTree( false, true, false )</td>
</tr>
<tr></tr>
<tr>
<td>
- <input type="submit" id="lock" name="lock" value="$i18n.getString( 'calculate' )" style="width:10em" disabled="true" />
+ <input type="submit" id="calculate" name="calculate" value="$i18n.getString( 'calculate' )" style="width:10em" disabled="true" />
###if( $auth.hasAccess( "dhis-web-maintenance-dataadmin", "collectiveDataLockingForUnlocking") )
##<input type="submit" id="unlock" name="unlock" onclick="setClickedButtonElementValue( false )" value="$i18n.getString( 'unlock' )" style="width:10em" disabled="true"/>
## #end
=== added file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartSave.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartSave.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusMartSave.vm 2011-06-15 06:01:50 +0000
@@ -0,0 +1,7 @@
+<h3>$i18n.getString( "data_status_mart" )</h3>
+
+<div align="left"><h3>$message</h3></div>
+
+<p>
+ <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='dataStatusMartForm.action'" style="width:100px" />
+</p>
\ No newline at end of file
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult.vm 2011-05-24 08:25:51 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult.vm 2011-06-15 06:01:50 +0000
@@ -8,16 +8,22 @@
var startDate = "$sDateLB";
var endDate = "$eDateLB";
var dsType = "$selectedButton";
+ var includeZeros = "$includeZeros";
function getImmChildInfo( evt, dsId, selOrgUnit )
{
+ //alert("DataStatus : " + dsId + ":" + selOrgUnit );
immChildOption = "yes";
if( document.getElementById('includeZeros').checked )
{
+ //alert("inside include zero : " + immChildOption );
+ //var urlForImmChild = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType+"&includeZeros="+includeZeros;
+ //alert( urlForImmChild );
evt.target.href = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType+"&includeZeros="+includeZeros;
}
else
{
+ alert("inside include zero null");
evt.target.href = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType;
}
}
=== added file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult_Test.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult_Test.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/dataStatusResult_Test.vm 2011-06-15 06:01:50 +0000
@@ -0,0 +1,140 @@
+
+<html>
+ <head>
+ <title>DataStatus Result</title>
+ <link type="text/css" rel="stylesheet" media="screen" href="css/StylesForTags.css">
+ </link>
+ <script>
+ var startDate = "$sDateLB";
+ var endDate = "$eDateLB";
+ var dsType = "$selectedButton";
+
+ function getImmChildInfo( evt, dsId, selOrgUnit )
+ {
+ immChildOption = "yes";
+ if( document.getElementById('includeZeros').checked )
+ {
+ evt.target.href = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType+"&includeZeros="+includeZeros;
+ }
+ else
+ {
+ evt.target.href = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit+"&selectedButton="+dsType;
+ }
+ }
+ function exportDataStatusResultToWorkBook()
+ {
+ document.getElementById('htmlCode').value = document.getElementById('formResult').innerHTML;
+ return true;
+ }
+
+ function getNullReportInfo( dsId, periodId, selOrgUnit )
+ {
+ var url = "nullReportResult.action?dsId="+dsId+"&periodId="+periodId+"&ouId="+selOrgUnit;
+ $('#contentDataRecord').dialog('destroy').remove();
+ $('<div id="contentDataRecord">' ).load(url).dialog({
+ title: 'Null Report',
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 600
+ });
+ }
+
+ </script>
+ </head>
+ <body>
+
+ #if( "$!ouMapDataStatusResult" == "" || $ouMapDataStatusResult.isEmpty() || $ouMapDataStatusResult.size() == 0 )
+ <div align="center" class="NormalB">Selected OrgUnit and its Children are Not assigned to $selDataSet.name</div>
+ #else
+ <form id="form1" name="form1" action="exportDataStatusToExcel.action" method="post" onsubmit="return exportDataStatusResultToWorkBook()" target="_newtab">
+ <input type="hidden" name="htmlCode" id="htmlCode" />
+
+ <div align="right" class="NormalB">
+ <input type="checkbox" name="includeZeros" id="includeZeros" #if($includeZeros) checked #end /> Include Zero<br />
+ <input type="submit" name="ExportToWorkBook" value="Export To WorkBook" style="width: 160; height: 25; font-family:Arial; font-weight:bold; color:#000000">
+ </div>
+
+ <div id="formResult">
+ <div align="center" class="NormalB">Data Entry Status</div>
+ <div align="right">
+ <table width="30%">
+ <tr class="TableDataCellStyles" >
+ <td bgcolor="#a0c0a0"> </td>
+ <td align="left"> Completed (75+) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#a0a0ff"> </td>
+ <td align="left"> Partially Completed (41 - 75) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#905090"> </td>
+ <td align="left"> Not Completed (1 - 40) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="#ff0000"> </td>
+ <td align="left"> Not Entered ( 0 ) %</td>
+ </tr>
+ <tr class="TableDataCellStyles">
+ <td bgcolor="white"> </td>
+ <td align="left"> Not Assigned</td>
+ </tr>
+ </table>
+ </div>
+
+ <br><br>
+ <div align="left" class="NormalB">DataSet : $selDataSet.name ( $dataSetMemberCount1 )</div>
+ <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
+ <tr class="TableHeadingCellStyles" align="center">
+ #foreach($levelName in $levelNames)
+ <th>$!levelName</th>
+ #end
+
+ #foreach($periodname in $periodNameList)
+ <th>$periodname</th>
+ #end
+ </tr>
+
+ #foreach( $chiildorgUnit in $orgUnitList )
+ #set( $count1 = $minOULevel )
+ #set( $curOrgUnitLevel = $organisationUnitService.getLevelOfOrganisationUnit( $chiildorgUnit ) )
+ <tr class="TableHeadingCellStyles">
+ #foreach( $levelName in $levelNames )
+ #if( $count1 == $curOrgUnitLevel )
+ <td><a href="#" onclick="javascript:getImmChildInfo(event, '$selDataSet.id', '$chiildorgUnit.id')" target="_blank">$chiildorgUnit.name</a></td>
+ #else
+ <td> </td>
+ #end
+ #set($count1 = $count1 + 1)
+ #end
+
+ #set( $dsresultList = $ouMapDataStatusResult.get( $chiildorgUnit ) )
+ ##set( $dataElementCounts = $ouMapDataElementCount.get( $chiildorgUnit ) )
+ ##set( $periodCounts = $periodList )
+ #set( $count2 = 0 )
+ #foreach( $result in $dsresultList )
+ ##set( $deCount = $dataElementCounts.get( $count2 ) )
+ ##set( $periodCount = $periodCounts.get( $count2 ) )
+ #if( !$result )
+ <td bgcolor="white"> </td>
+ #elseif( $result.percentage == 0 )
+ <td align="center" bgcolor="#ff0000"><font color="#ffffff">$result.percentage% ( $result.registrations ) </font></td>
+ #elseif( $result.percentage > 75 )
+ <td align="center" bgcolor="#a0c0a0"><font color="#ffffff">$result.percentage% ( $result.registrations )</font></td>
+ #elseif( $result.percentage > 40 && $result.percentage <= 75 )
+ <td align="center" bgcolor="#a0a0ff"><font color="#ffffff">$result.percentage% ( $result.registrations ) </font></td>
+ #else
+ <td align="center" bgcolor="#905090"><font color="#ffffff">$result.percentage% ( $result.registrations ) </font></td>
+ #end
+ #set( $count2 = $count2 + 1 )
+ #end
+ </tr>
+ #end
+ </table>
+ </div>
+ </form>
+ #end
+ </body>
+</html>
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/groupWiseDataStatusResult.vm'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/groupWiseDataStatusResult.vm 2011-04-15 11:35:33 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/groupWiseDataStatusResult.vm 2011-06-15 06:01:50 +0000
@@ -69,6 +69,7 @@
#foreach($dataElementGroup in $dataElementGroups)
<br><br>
#set( $deGroupCount = $deMapGroupCount.get($dataElementGroup) )
+ #set( $ouMapDeCount = $ouGroupMapDeMapCount.get($dataElementGroup) )
<div align="left" class="NormalB">Data Element Group : $dataElementGroup.name ( $!deGroupCount )</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr class="TableHeadingCellStyles" align="center">
@@ -93,21 +94,25 @@
#set($count1 = $count1 + 1)
#end
#set($periods = $dataSetPeriods.get($selDataSet))
+ #set( $dataElementCounts = $ouMapDeCount.get( $chiildorgUnit ) )
+ #set($count3 = 0)
#foreach($period in $periods)
#set($result = $results.get($count2))
- #set($dataElement = $dataElementCount.get($count2))
+ ##set($dataElement = $dataElementCount.get($count2))
+ #set( $deCount = $dataElementCounts.get( $count3 ) )
#if($result < 0)
<td bgcolor="white"> </td>
#elseif($result == 0)
- <td align="center" bgcolor="#ff0000"><font color="#ffffff">$result% #if( $dataElement != -1 ) ( $dataElement ) #end</font></td>
+ <td align="center" bgcolor="#ff0000"><font color="#ffffff">$result% #if( $deCount != -1 ) ( $deCount ) #end</font></td>
#elseif($result > 75)
- <td align="center" bgcolor="#a0c0a0"><font color="#ffffff">$result% #if( $dataElement != -1 ) ( $dataElement ) #end</font></td>
+ <td align="center" bgcolor="#a0c0a0"><font color="#ffffff">$result% #if( $deCount != -1 ) ( $deCount ) #end</font></td>
#elseif($result > 40 && $result <= 75 )
- <td align="center" bgcolor="#a0a0ff"><font color="#ffffff">$result% #if( $dataElement != -1 ) ( $dataElement ) #end</font></td>
+ <td align="center" bgcolor="#a0a0ff"><font color="#ffffff">$result% #if( $deCount != -1 ) ( $deCount ) #end</font></td>
#else
- <td align="center" bgcolor="#905090"><font color="#ffffff">$result% #if( $dataElement != -1 ) ( $dataElement ) #end</font></td>
+ <td align="center" bgcolor="#905090"><font color="#ffffff">$result% #if( $deCount != -1 ) ( $deCount ) #end</font></td>
#end
+ #set($count3 = $count3 + 1)
#set($count2 = $count2 + 1)
#end
</tr>
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/dataStatusMart.js'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/dataStatusMart.js 2011-06-07 05:58:08 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/dataStatusMart.js 2011-06-15 06:01:50 +0000
@@ -1,3 +1,43 @@
+
+// J query validation
+jQuery(document).ready(function()
+{
+ validation2('dataStatusMartForm', function( form )
+ {
+ validateDataEntryStatusForm(form);
+ },
+ {
+ 'beforeValidateHandler' : function() {
+ $("#selectedPeriods option").each(function() { $(this).attr("selected", "true"); });
+ $("#selectedDataSets option").each(function() { $(this).attr("selected", "true"); });
+ },
+ 'rules' : getValidationRules("dataLocking")
+ });
+});
+
+// for Validation of form
+function validateDataEntryStatusForm( form )
+{
+ var url = "validateDataEntryStatus.action?";
+ url += getParamString( "selectedPeriods", "selectedPeriods" );
+ url += "&" + getParamString( "selectedDataSets", "selectedDataSets" );
+
+ $.postJSON( url, {}, function( json )
+ {
+ if ( json.response == "input" )
+ {
+ setHeaderDelayMessage( json.message );
+ }
+ else if ( json.response == "success" )
+ {
+ selectAllById( "selectedPeriods" );
+ selectAllById( "selectedDataSets" );
+ form.submit();
+ }
+ });
+}
+
+
function getPeriods()
{
var periodTypeList = byId("periodTypeId");
@@ -24,7 +64,7 @@
});
}
- enable("lock");
+ enable("calculate");
enable("unlock");
enable("availablePeriods");
=== modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/ds.js'
--- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/ds.js 2011-05-24 08:25:51 +0000
+++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/ds.js 2011-06-15 06:01:50 +0000
@@ -9,7 +9,7 @@
document.ChartGenerationForm.orgUnitListCB.options[i] = null;
}
}// remOUFunction end
-
+/*
function getImmChildInfo(evt, dsId, selOrgUnit)
{
@@ -19,7 +19,7 @@
evt.target.href = "dataStatusResult.action?immChildOption="+immChildOption+"&dsId="+dsId+"&sDateLB="+startDate+"&eDateLB="+endDate+"&ouId="+selOrgUnit;
}
-
+*/
function getImmChildInfo1(evt, dsId, selOrgUnit)
{
@@ -142,8 +142,19 @@
else
{
- document.ChartGenerationForm.action = "dataStatusResult.action";
- document.ChartGenerationForm.submit();
+ var dataEntryStatus = document.getElementById("usingDataEntryStatus").checked;
+ //alert( dataEntryStatus );
+ if ( dataEntryStatus == true )
+ {
+ document.ChartGenerationForm.action = "dataEntryStatusResult.action";
+ document.ChartGenerationForm.submit();
+ }
+ else
+ {
+ document.ChartGenerationForm.action = "dataStatusResult.action";
+ document.ChartGenerationForm.submit();
+ }
+
}
}