dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19851
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8830: Don't get all orgunits if to select Use data from level(s) as All in Manual person aggregation fu...
------------------------------------------------------------
revno: 8830
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-11-02 11:25:31 +0700
message:
Don't get all orgunits if to select Use data from level(s) as All in Manual person aggregation function.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-10-26 09:02:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2012-11-02 04:25:31 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
@@ -96,6 +97,13 @@
this.dataValueService = dataValueService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -188,6 +196,8 @@
// Get selected orgunits
// ---------------------------------------------------------------------
+ Set<Integer> orgunitIds = new HashSet<Integer>();
+
OrganisationUnit selectedOrgunit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
if ( selectedOrgunit == null )
@@ -197,19 +207,18 @@
if ( facilityLB.equals( "selected" ) )
{
- orgunits.add( selectedOrgunit );
+ orgunitIds.add( selectedOrgunit.getId() );
}
else if ( facilityLB.equals( "childrenOnly" ) )
{
- orgunits.addAll( getChildOrgUnitTree( selectedOrgunit ) );
+ orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+ selectedOrgunit.getId() ) );
+ orgunitIds.remove( selectedOrgunit.getId() );
}
else
{
- List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( selectedOrgunit.getChildren() );
- Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE );
-
- orgunits.addAll( organisationUnits );
- orgunits.add( selectedOrgunit );
+ orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+ selectedOrgunit.getId() ) );
}
// ---------------------------------------------------------------------
@@ -227,15 +236,15 @@
CalendarPeriodType periodType = (CalendarPeriodType) selectedDataSet.getPeriodType();
- periods.addAll( periodType.generatePeriods( format.parseDate( startDate ),
- format.parseDate( endDate ) ) );
+ periods.addAll( periodType.generatePeriods( format.parseDate( startDate ), format.parseDate( endDate ) ) );
// ---------------------------------------------------------------------
// Aggregation
// ---------------------------------------------------------------------
- for ( OrganisationUnit orgUnit : orgunits )
+ for ( Integer orgUnitId : orgunitIds )
{
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
for ( CaseAggregationCondition condition : aggregationConditions )
{
DataElement dElement = condition.getAggregationDataElement();
@@ -244,7 +253,6 @@
for ( Period period : periods )
{
Integer resultValue = aggregationConditionService.parseConditition( condition, orgUnit, period );
-
DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
String key = orgUnit.getId() + "-" + format.formatPeriod( period );
@@ -258,6 +266,7 @@
null, optionCombo );
mapStatusValues.put( keyStatus, i18n.getString( ADD_STATUS ) );
+ orgunits.add( orgUnit );
}
else
{
@@ -266,9 +275,7 @@
mapStatusValues.put( keyStatus, i18n.getString( UPDATE_STATUS ) );
}
-
mapCaseAggCondition.put( dataValue, condition );
-
}
else if ( dataValue != null )
{
@@ -289,31 +296,12 @@
dataValues.add( dataValue );
mapDataValues.put( key, dataValues );
+ orgunits.add( orgUnit );
}
}
}
}
-
return SUCCESS;
}
-
- // -------------------------------------------------------------------------
- // Support methods
- // -------------------------------------------------------------------------
-
- private 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, IdentifiableObjectNameComparator.INSTANCE );
-
- for ( OrganisationUnit child : children )
- {
- orgUnitTree.addAll( getChildOrgUnitTree( child ) );
- }
- return orgUnitTree;
- }
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-11-01 15:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-11-02 04:25:31 +0000
@@ -283,6 +283,8 @@
<property name="aggregationConditionService"
ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-10-31 16:02:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-11-02 04:25:31 +0000
@@ -81,7 +81,8 @@
on_value=on
value=Value
status=Status
-no_value_added_or_update=No values added or updated
+no_aggregate_date_values_are_added_or_update_in_all_facilities=No aggregage data values are added or updated in all facilities
+no_aggregate_date_values_are_added_or_update_in_other_facilities=No aggregage data values are added or updated in other facilities
date_less_incident_date=This date is less then the incident date
deleted=Deleted
person_aggregation=Person Aggregation
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2012-11-02 04:25:31 +0000
@@ -1,73 +1,74 @@
<h4> $i18n.getString( "case_aggregation_result" )</h4>
-
-<div>
- <input type="button" value="$i18n.getString( 'back' )" onclick="backBtnOnClick();" style="width:10em">
- <input type='button' value="$i18n.getString( 'save_selected_values' )" onclick='saveAggregateDataValues( false )' >
- <input type='button' value="$i18n.getString( 'save_all_values' )" onclick='saveAggregateDataValues( true )' >
-</div>
-<p></p>
-
-#set( $index = 0 )
-#foreach( $orgunit in $orgunits)
- <h2>$orgunit.name</h2>
- #foreach( $period in $periods)
- #set( $index = $index + 1 )
- #set( $periodInfo = $orgunit.id + '-' + $index )
- #set( $periodButton = $periodInfo + "-button")
- #set( $periodDiv = $periodInfo + "-div")
- #set( $key = $orgunit.id + '-' + $format.formatPeriod($period) )
-
- <h4>$format.formatPeriod( $period )
- #if( $!mapDataValues.get( $key ) )
- <img id='$periodButton' src="../images/down.png" onclick="toggleResult('$periodInfo');" style="cursor: pointer;"></h4>
-
- #set( $dataValues = $mapDataValues.get( $key ) )
- <table class="formSection mainPageTable hidden" id='$periodDiv'>
- <col width="40">
- <col>
- <col>
- <col>
- <tbody>
- #set( $mark = false )
- #set($no = 1)
- <tr>
- <th>#</th>
- <th><input type='checkbox' onchange="toogleAllCheckBoxes( '$periodDiv', this.checked );"></th>
- <th>$i18n.getString('name')</th>
- <th>$i18n.getString('value')</th>
- <th>$i18n.getString('status')</th>
- <th>$i18n.getString('operator')</th>
- </tr>
- #foreach( $dataValue in $dataValues)
- #set( $statusKey = $key + '-' + $dataValue.dataElement.id )
- <tr #alternate( $mark )>
- <td>$no</td>
- <td>
- #set( $item=$dataValue.dataElement.id + '_' + $dataValue.optionCombo.id + '_' + $period.periodType.name + '_' + $format.formatDate($period.startDate) + '_' + $orgunit.id + '_' + $dataValue.value )
- <input type='checkbox' name='aggregateValues' value='$item'>
- </td>
- <td>$dataValue.dataElement.name</td>
- <td>$dataValue.value</td>
- <td>$!mapStatusValues.get( $statusKey )</td>
- <td>
- #if( $mapCaseAggCondition.get($dataValue).id )
- <a href='javascript:viewResultDetails($orgunit.id, "$period.periodType.name", "$format.formatDate($period.startDate)",$mapCaseAggCondition.get($dataValue).id)' title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
- #end
- </td>
+#if($orgunits.size()>0)
+ <div>
+ <input type="button" value="$i18n.getString( 'back' )" onclick="backBtnOnClick();" style="width:10em">
+ <input type='button' value="$i18n.getString( 'save_selected_values' )" onclick='saveAggregateDataValues( false )' >
+ <input type='button' value="$i18n.getString( 'save_all_values' )" onclick='saveAggregateDataValues( true )' >
+ </div>
+ <p></p>
+
+ #set( $index = 0 )
+ #foreach( $orgunit in $orgunits)
+ <h2>$orgunit.name</h2>
+ #foreach( $period in $periods)
+ #set( $index = $index + 1 )
+ #set( $periodInfo = $orgunit.id + '-' + $index )
+ #set( $periodButton = $periodInfo + "-button")
+ #set( $periodDiv = $periodInfo + "-div")
+ #set( $key = $orgunit.id + '-' + $format.formatPeriod($period) )
+
+ <h4>$format.formatPeriod( $period )
+ #if( $!mapDataValues.get( $key ) )
+ <img id='$periodButton' src="../images/down.png" onclick="toggleResult('$periodInfo');" style="cursor: pointer;"></h4>
+
+ #set( $dataValues = $mapDataValues.get( $key ) )
+ <table class="formSection mainPageTable hidden" id='$periodDiv'>
+ <col width="40">
+ <col>
+ <col>
+ <col>
+ <tbody>
+ #set( $mark = false )
+ #set($no = 1)
+ <tr>
+ <th>#</th>
+ <th><input type='checkbox' onchange="toogleAllCheckBoxes( '$periodDiv', this.checked );"></th>
+ <th>$i18n.getString('name')</th>
+ <th>$i18n.getString('value')</th>
+ <th>$i18n.getString('status')</th>
+ <th>$i18n.getString('operator')</th>
</tr>
- #set( $mark = !$mark )
- #set ($no = $no + 1)
- #end
- </tbody>
- </table>
- #else
- ($i18n.getString('no_value_added_or_update')) </h4>
+ #foreach( $dataValue in $dataValues)
+ #set( $statusKey = $key + '-' + $dataValue.dataElement.id )
+ <tr #alternate( $mark )>
+ <td>$no</td>
+ <td>
+ #set( $item=$dataValue.dataElement.id + '_' + $dataValue.optionCombo.id + '_' + $period.periodType.name + '_' + $format.formatDate($period.startDate) + '_' + $orgunit.id + '_' + $dataValue.value )
+ <input type='checkbox' name='aggregateValues' value='$item'>
+ </td>
+ <td>$dataValue.dataElement.name</td>
+ <td>$dataValue.value</td>
+ <td>$!mapStatusValues.get( $statusKey )</td>
+ <td>
+ #if( $mapCaseAggCondition.get($dataValue).id )
+ <a href='javascript:viewResultDetails($orgunit.id, "$period.periodType.name", "$format.formatDate($period.startDate)",$mapCaseAggCondition.get($dataValue).id)' title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
+ #end
+ </td>
+ </tr>
+ #set( $mark = !$mark )
+ #set ($no = $no + 1)
+ #end
+ </tbody>
+ </table>
+ #end
#end
#end
+
+ <h2>$i18n.getString('no_aggregate_date_values_are_added_or_update_in_other_facilities')</h2>
+ <div id='contentDetails'></div>
+#else
+ <h2>$i18n.getString('no_aggregate_date_values_are_added_or_update_in_all_facilities')</h2>
#end
-
-<div id='contentDetails'></div>
-
<script>
var i18n_aggregate_details = '$encoder.jsEscape( $i18n.getString( "aggregate_details" ) , "'")';
var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'")';