dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09547
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2560: Impl function for including current users organisation unit in charts.
------------------------------------------------------------
revno: 2560
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-13 16:44:09 +0100
message:
Impl function for including current users organisation unit in charts.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2010-08-28 10:44:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-01-13 15:44:09 +0000
@@ -81,6 +81,8 @@
private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
private RelativePeriods relatives;
+
+ private Boolean userOrganisationUnit;
// -------------------------------------------------------------------------
// Transient properties
@@ -92,6 +94,10 @@
private List<Period> allPeriods = new ArrayList<Period>();
+ private OrganisationUnit organisationUnit;
+
+ private List<OrganisationUnit> allOrganisationUnits = new ArrayList<OrganisationUnit>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -108,7 +114,9 @@
public void init()
{
allPeriods.addAll( periods );
- allPeriods.addAll( relativePeriods );
+ allPeriods.addAll( relativePeriods );
+ allOrganisationUnits.addAll( organisationUnits );
+ allOrganisationUnits.add( organisationUnit );
}
// -------------------------------------------------------------------------
@@ -198,6 +206,11 @@
{
return isSize( SIZE_TALL ) ? 800 : 500;
}
+
+ public boolean isUserOrganisationUnit()
+ {
+ return userOrganisationUnit != null && userOrganisationUnit;
+ }
// -------------------------------------------------------------------------
// Importable object
@@ -357,6 +370,16 @@
this.relatives = relatives;
}
+ public Boolean getUserOrganisationUnit()
+ {
+ return userOrganisationUnit;
+ }
+
+ public void setUserOrganisationUnit( Boolean userOrganisationUnit )
+ {
+ this.userOrganisationUnit = userOrganisationUnit;
+ }
+
public List<Period> getRelativePeriods()
{
return relativePeriods;
@@ -376,4 +399,24 @@
{
this.allPeriods = allPeriods;
}
+
+ public OrganisationUnit getOrganisationUnit()
+ {
+ return organisationUnit;
+ }
+
+ public void setOrganisationUnit( OrganisationUnit organisationUnit )
+ {
+ this.organisationUnit = organisationUnit;
+ }
+
+ public List<OrganisationUnit> getAllOrganisationUnits()
+ {
+ return allOrganisationUnits;
+ }
+
+ public void setAllOrganisationUnits( List<OrganisationUnit> allOrganisationUnits )
+ {
+ this.allOrganisationUnits = allOrganisationUnits;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-01-11 19:13:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-01-13 15:44:09 +0000
@@ -128,6 +128,11 @@
return CollectionUtils.isEmpty( organisationUnits ) ? null : organisationUnits.iterator().next();
}
+ public boolean hasOrganisationUnit()
+ {
+ return !CollectionUtils.isEmpty( organisationUnits );
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-01-07 11:37:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2011-01-13 15:44:09 +0000
@@ -68,6 +68,8 @@
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
import org.hisp.dhis.system.util.MathUtils;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
@@ -160,6 +162,13 @@
{
this.systemSettingManager = systemSettingManager;
}
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
// -------------------------------------------------------------------------
// ChartService implementation
@@ -175,8 +184,15 @@
if ( chart.getRelatives() != null )
{
- chart.setRelativePeriods( periodService.reloadPeriods( chart.getRelatives().getRelativePeriods( 1, null,
- false ) ) );
+ chart.setRelativePeriods( periodService.reloadPeriods(
+ chart.getRelatives().getRelativePeriods( 1, null, false ) ) );
+ }
+
+ User user = currentUserService.getCurrentUser();
+
+ if ( chart.isUserOrganisationUnit() && user != null && user.getOrganisationUnit() != null )
+ {
+ chart.setOrganisationUnit( user.getOrganisationUnit() );
}
chart.setFormat( format );
@@ -465,7 +481,7 @@
if ( chart != null )
{
Period selectedPeriod = chart.getAllPeriods().get( 0 );
- OrganisationUnit selectedOrganisationUnit = chart.getOrganisationUnits().get( 0 );
+ OrganisationUnit selectedOrganisationUnit = chart.getAllOrganisationUnits().get( 0 );
for ( Indicator indicator : chart.getIndicators() )
{
@@ -535,7 +551,7 @@
// Regular dataset
// ---------------------------------------------------------
- for ( OrganisationUnit unit : chart.getOrganisationUnits() )
+ for ( OrganisationUnit unit : chart.getAllOrganisationUnits() )
{
final Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ?
aggregationService.getAggregatedIndicatorValue( indicator, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), unit ) :
@@ -601,9 +617,9 @@
subTitle.setFont( subTitleFont );
- if ( chart.isDimension( DIMENSION_PERIOD ) && chart.getOrganisationUnits().size() > 0 )
+ if ( chart.isDimension( DIMENSION_PERIOD ) && chart.getAllOrganisationUnits().size() > 0 )
{
- subTitle.setText( chart.getOrganisationUnits().get( 0 ).getName() );
+ subTitle.setText( chart.getAllOrganisationUnits().get( 0 ).getName() );
}
else if ( chart.isDimension( DIMENSION_ORGANISATIONUNIT ) && chart.getAllPeriods().size() > 0 )
{
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-01-07 11:37:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-01-13 15:44:09 +0000
@@ -112,6 +112,8 @@
ref="org.hisp.dhis.options.SystemSettingManager"/>
<property name="aggregatedDataValueService"
ref="org.hisp.dhis.aggregation.AggregatedDataValueService"/>
+ <property name="currentUserService"
+ ref="org.hisp.dhis.user.CurrentUserService"/>
</bean>
<!-- Document -->
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2011-01-13 15:44:09 +0000
@@ -57,5 +57,7 @@
<property name="lastYear"/>
</component>
+ <property name="userOrganisationUnit"/>
+
</class>
</hibernate-mapping>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java 2010-07-18 15:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetChartOptionsAction.java 2011-01-13 15:44:09 +0000
@@ -112,7 +112,7 @@
{
this.organisationUnitComparator = organisationUnitComparator;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java 2011-01-13 15:44:09 +0000
@@ -152,6 +152,13 @@
this.regression = regression;
}
+ private boolean userOrganisationUnit;
+
+ public void setUserOrganisationUnit( boolean userOrganisationUnit )
+ {
+ this.userOrganisationUnit = userOrganisationUnit;
+ }
+
private List<String> selectedIndicators = new ArrayList<String>();
public void setSelectedIndicators( List<String> selectedIndicators )
@@ -254,6 +261,7 @@
chart.setVerticalLabels( verticalLabels );
chart.setHorizontalPlotOrientation( horizontalPlotOrientation );
chart.setRegression( regression );
+ chart.setUserOrganisationUnit( userOrganisationUnit );
chart.setIndicators( indicators );
chart.setPeriods( periods );
chart.setOrganisationUnits( organisationUnits );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-13 15:44:09 +0000
@@ -243,8 +243,10 @@
select_none = Clear all
tally_sheet = Tally Sheet
edit_tally_rows = (Optional) Edit tally row numbers manually
+clear = Clear
next = Next
prev = Prev
+none = None
facility = Facility
month = Month
year = Year
@@ -303,4 +305,5 @@
get_report = Get report
get_report_as_xls = Download as Excel
get_report_as_csv = Download as CSV
-get_report_as_pdf = Download as PDF
\ No newline at end of file
+get_report_as_pdf = Download as PDF
+user_organisation_unit = Include current user organisation unit
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2010-08-28 10:44:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm 2011-01-13 15:44:09 +0000
@@ -59,6 +59,12 @@
<td><label for="regression">$i18n.getString( "include_regression_line" )</label></td>
<td><input type="checkbox" id="regression" name="regression" value="true"#if( $!chart.regression ) checked#end></td>
</tr>
+ #if ( $currentUser && $currentUser.hasOrganisationUnit() )
+ <tr>
+ <td><label for="userOrganisationUnit">$i18n.getString( "user_organisation_unit" )</label></td>
+ <td><input type="checkbox" id="userOrganisationUnit" name="userOrganisationUnit" value="true"#if( $!chart.userOrganisationUnit ) checked#end></td>
+ </tr>
+ #end
<tr>
<td colspan="2" style="height:15px"></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartIndicatorModeForm.vm 2011-01-13 15:44:09 +0000
@@ -133,7 +133,7 @@
<!-- OrganisationUnit -->
<tr>
- <th colspan="2">$i18n.getString( "filter_available_organisationunits" )</th>
+ <th colspan="2">$i18n.getString( "filter_available_organisationunits" ) - <a href="javascript:clearListById( 'selectedOrganisationUnits' )">$i18n.getString( 'clear' )</a></th>
</tr>
<tr>
<td colspan="2">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartPeriodModeForm.vm 2011-01-13 15:44:09 +0000
@@ -81,7 +81,7 @@
<!-- OrganisationUnit -->
<tr>
- <th colspan="2">$i18n.getString( "filter_available_organisationunits" )</th>
+ <th colspan="2">$i18n.getString( "filter_available_organisationunits" ) - <a href="javascript:clearListById( 'selectedOrganisationUnits' )">$i18n.getString( 'clear' )</th>
</tr>
<tr>
<td colspan="2">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js 2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js 2011-01-13 15:44:09 +0000
@@ -95,7 +95,7 @@
return false;
}
- if ( !hasElements( "selectedOrganisationUnits" ) )
+ if ( !hasElements( "selectedOrganisationUnits" ) && !isChecked( "userOrganisationUnit" ) )
{
setMessage( i18n_must_select_at_least_one_unit );