dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07991
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2374: Data Completeness Report - Improved and comestic code
------------------------------------------------------------
revno: 2374
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-10-15 15:07:52 +0700
message:
Data Completeness Report - Improved and comestic code
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessPDFAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java 2010-07-25 09:58:51 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java 2010-10-15 08:07:52 +0000
@@ -37,6 +37,8 @@
import org.hisp.dhis.completeness.comparator.DataSetCompletenessResultComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.util.SessionUtils;
@@ -50,13 +52,14 @@
implements Action
{
private static final String KEY_DATA_COMPLETENESS = "dataSetCompletenessResults";
+
private static final String KEY_DATA_COMPLETENESS_DATASET = "dataSetCompletenessDataSet";
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
- private ServiceProvider<DataSetCompletenessService> serviceProvider;
+ private ServiceProvider<DataSetCompletenessService> serviceProvider;
public void setServiceProvider( ServiceProvider<DataSetCompletenessService> serviceProvider )
{
@@ -69,7 +72,7 @@
{
this.dataSetService = dataSetService;
}
-
+
private PeriodService periodService;
public void setPeriodService( PeriodService periodService )
@@ -77,6 +80,13 @@
this.periodService = periodService;
}
+ private SelectionTreeManager selectionTreeManager;
+
+ public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+ {
+ this.selectionTreeManager = selectionTreeManager;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -87,21 +97,14 @@
{
this.periodId = periodId;
}
-
+
private Integer dataSetId;
public void setDataSetId( Integer dataSetId )
{
this.dataSetId = dataSetId;
}
-
- private Integer organisationUnitId;
- public void setOrganisationUnitId( Integer organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
-
private String criteria;
public void setCriteria( String criteria )
@@ -129,24 +132,25 @@
{
SessionUtils.removeSessionVar( KEY_DATA_COMPLETENESS );
SessionUtils.removeSessionVar( KEY_DATA_COMPLETENESS_DATASET );
-
+
Integer _periodId = periodService.getPeriodByExternalId( periodId ).getId();
-
- if ( periodId != null && organisationUnitId != null && criteria != null )
+ OrganisationUnit selectedUnit = selectionTreeManager.getSelectedOrganisationUnit();
+
+ if ( periodId != null && selectedUnit != null && criteria != null )
{
DataSetCompletenessService completenessService = serviceProvider.provide( criteria );
-
+
if ( dataSetId != null )
{
// -------------------------------------------------------------
// Display completeness by DataSets
// -------------------------------------------------------------
- results = new ArrayList<DataSetCompletenessResult>( completenessService.
- getDataSetCompleteness( _periodId, organisationUnitId, dataSetId ) );
-
+ results = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness(
+ _periodId, selectedUnit.getId(), dataSetId ) );
+
DataSet dataSet = dataSetService.getDataSet( dataSetId );
-
+
SessionUtils.setSessionVar( KEY_DATA_COMPLETENESS_DATASET, dataSet );
}
else
@@ -155,15 +159,15 @@
// Display completeness by child OrganisationUnits for a DataSet
// -------------------------------------------------------------
- results = new ArrayList<DataSetCompletenessResult>( completenessService.
- getDataSetCompleteness( _periodId, organisationUnitId ) );
+ results = new ArrayList<DataSetCompletenessResult>( completenessService.getDataSetCompleteness(
+ _periodId, selectedUnit.getId() ) );
}
-
+
Collections.sort( results, new DataSetCompletenessResultComparator() );
-
+
SessionUtils.setSessionVar( KEY_DATA_COMPLETENESS, results );
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessPDFAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessPDFAction.java 2010-09-15 04:42:49 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessPDFAction.java 2010-10-15 08:07:52 +0000
@@ -71,6 +71,10 @@
this.selectionTreeManager = selectionTreeManager;
}
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
private I18n i18n;
public void setI18n( I18n i18n )
@@ -83,7 +87,7 @@
// -------------------------------------------------------------------------
private OrganisationUnit selectedUnit;
-
+
private InputStream inputStream;
public InputStream getInputStream()
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-08-31 14:34:31 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-10-15 08:07:52 +0000
@@ -445,6 +445,8 @@
ref="org.hisp.dhis.dataset.DataSetService"/>
<property name="periodService"
ref="org.hisp.dhis.period.PeriodService"/>
+ <property name="selectionTreeManager"
+ ref="org.hisp.dhis.oust.manager.SelectionTreeManager"/>
</bean>
<bean id="org.hisp.dhis.reporting.completeness.action.GetDataCompletenessPDFAction"
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js 2010-09-04 13:07:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js 2010-10-15 08:07:52 +0000
@@ -1,52 +1,41 @@
-var selectedOrganisationUnitId = null;
-
-function setSelectedOrganisationUnitId( ids )
+function getPeriods( periodTypeList, availableList, selectedList, timespan )
{
- if ( ids != null && ids.length == 1 )
- {
- selectedOrganisationUnitId = ids[0];
- }
-
- displayCompleteness();
+ getAvailablePeriods( periodTypeList, availableList, selectedList, timespan );
+ displayCompleteness();
}
-selectionTreeSelection.setListenerFunction( setSelectedOrganisationUnitId );
-
function displayCompleteness()
{
var criteria = $( "input[name='criteria']:checked" ).val();
- var dataSetList = document.getElementById( "dataSetId" );
+ var dataSetList = byId( "dataSetId" );
var dataSetId = dataSetList.options[ dataSetList.selectedIndex ].value;
- var periodList = document.getElementById( "periodId" );
+ var periodList = byId( "periodId" );
var periodId = null;
- if ( periodList.disabled == false )
+ if ( !periodList.disabled && (periodList.options.length > 0) )
{
periodId = periodList.options[ periodList.selectedIndex ].value;
}
- if ( periodId != null && selectedOrganisationUnitId != null )
+ if ( periodId != null )
{
clearTable( "resultTable" );
-
showLoader();
- var request = new Request();
- var url = null;
+ var request = new Request();
+ var url = "getDataCompleteness.action"
+ + "?periodId=" + periodId
+ + "&criteria=" + criteria;
request.setResponseTypeXML( "dataSetCompletenessResult" );
-
+
if ( dataSetId == "ALL" )
{
// -----------------------------------------------------------------
// Display completeness by DataSets
// -----------------------------------------------------------------
- url = "getDataCompleteness.action?periodId=" + periodId +
- "&organisationUnitId=" + selectedOrganisationUnitId +
- "&criteria=" + criteria;
-
request.setCallbackSuccess( displayCompletenessByDataSetReceived );
}
else
@@ -55,21 +44,17 @@
// Display completeness by child OrganisationUnits for a DataSet
// -----------------------------------------------------------------
- url = "getDataCompleteness.action?periodId=" + periodId +
- "&organisationUnitId=" + selectedOrganisationUnitId +
- "&dataSetId=" + dataSetId +
- "&criteria=" + criteria;
+ url += "&dataSetId=" + dataSetId;
request.setCallbackSuccess( displayCompletenessByOrganisationUnitReceived );
- }
-
+ }
request.send( url );
}
}
function clearTable( tableId )
{
- var table = document.getElementById( tableId );
+ var table = byId( tableId );
while ( table.rows.length > 0 )
{
@@ -95,7 +80,7 @@
{
hideLoader();
- var table = document.getElementById( "resultTable" );
+ var table = byId( "resultTable" );
// -------------------------------------------------------------------------
// Adding header
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2010-09-15 04:01:07 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2010-10-15 08:07:52 +0000
@@ -1,35 +1,37 @@
+<script type="text/javascript">
+
+ jQuery(document).ready( function(){
+ // Override the listener after tree loaded succesfully
+ selectionTreeSelection.setListenerFunction( displayCompleteness );
+ });
+
+</script>
<h3>$i18n.getString( "data_completeness_report" )</h3>
<table>
- <col width="330">
- <col width="5">
- <col width="330">
+ <col width="330"/>
+ <col width="5"/>
+ <col width="330"/>
<tr>
- <td>
- <div id="selectionTree" style="width:325px; height:220px"></div>
-
- <script type="text/javascript">
- selectionTreeSelection.setMultipleSelectionAllowed( false );
- selectionTree.clearSelectedOrganisationUnits();
- selectionTree.buildSelectionTree();
- </script>
+ <td>
+ #organisationUnitSelectionTree( true, false, false )
</td>
<td></td>
<td valign="bottom">
<input type="button" value="$i18n.getString( 'configuration' )" style="width:150px"
- onclick="window.location.href='displayConfigureDataCompletenessForm.action'"/><br>
+ onclick="window.location.href='displayConfigureDataCompletenessForm.action'"/><br/>
<input type="button" value="$i18n.getString( 'generate_pdf' )" style="width:150px"
onclick="window.location.href='getDataCompletenessPDF.action'"/><input
type="button" value="$i18n.getString( 'generate_workbook' )" style="width:150px"
- onclick="window.location.href='getDataCompletenessWorkbook.action'"/><br><br>
+ onclick="window.location.href='getDataCompletenessWorkbook.action'"/><br/><br/>
<input type="radio" name="criteria" id="registrationRadio" value="registration" checked="checked" onclick="displayCompleteness()"/>
- <label for="registrationRadio">$i18n.getString( 'based_on_registration' )</label><br>
+ <label for="registrationRadio">$i18n.getString( 'based_on_registration' )</label><br/>
<input type="radio" name="criteria" id="compulsoryRadio" value="compulsory" onclick="displayCompleteness()"/>
- <label for="compulsoryRadio">$i18n.getString( 'based_on_compulsory' )</label><br>
+ <label for="compulsoryRadio">$i18n.getString( 'based_on_compulsory' )</label><br/>
<input type="radio" name="criteria" id="ratioRadio" value="ratio" onclick="displayCompleteness()"/>
- <label for="ratioRadio">$i18n.getString( 'based_on_ratio' )</label><br><br>
+ <label for="ratioRadio">$i18n.getString( 'based_on_ratio' )</label><br/><br/>
<!-- DataSet -->
@@ -38,18 +40,18 @@
#foreach( $dataSet in $dataSets )
<option value="$dataSet.id">$dataSet.name</option>
#end
- </select><br><br>
+ </select><br/><br/>
<!-- PeriodType -->
- <input type="button" style="width:50px" value="$i18n.getString( 'prev' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '-1' )"/>
- <input type="button" style="width:50px" value="$i18n.getString( 'next' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '1' )"/>
- <select id="periodType" name="periodType" style="min-width:222px" onchange="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '0' )">
+ <input type="button" style="width:50px" value="$i18n.getString( 'prev' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '-1' )"/>
+ <input type="button" style="width:50px" value="$i18n.getString( 'next' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '1' )"/>
+ <select id="periodType" name="periodType" style="min-width:222px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
<option value="">[ $i18n.getString( "select_period_type_all" ) ]</option>
#foreach ( $type in $periodTypes )
<option value="$type.name">$type.name</option>
#end
- </select><br><br>
+ </select><br/><br/>
<!-- Period -->