dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20901
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9754: Interpretations: storing the org unit of the user who created the intepretation in the interpreta...
------------------------------------------------------------
revno: 9754
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-02-06 16:45:08 +0200
message:
Interpretations: storing the org unit of the user who created the intepretation in the interpretation when the chart has relative org units. Then making sure the original org unit is used when rendering interpretations so that the comments refer to the same chart view.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.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-api/src/main/java/org/hisp/dhis/chart/ChartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2013-01-16 13:25:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2013-02-06 14:45:08 +0000
@@ -54,7 +54,17 @@
JFreeChart getJFreeChart( Chart chart, I18nFormat format );
- JFreeChart getJFreeChart( Chart chart, Date date, I18nFormat format );
+ /**
+ * Generates a JFreeChart.
+ *
+ * @param chart the chart to use as basis for the JFreeChart generation.
+ * @param date the date to use as basis for relative periods, can be null.
+ * @param unit the org unit to use as basis for relative units, will
+ * override the current user org unit if set, can be null.
+ * @param format the i18n format.
+ * @return a JFreeChart object.
+ */
+ JFreeChart getJFreeChart( Chart chart, Date date, OrganisationUnit unit, I18nFormat format );
JFreeChart getJFreePeriodChart( Indicator indicator, OrganisationUnit unit, boolean title, I18nFormat format );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2013-01-04 18:10:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2013-02-06 14:45:08 +0000
@@ -68,7 +68,7 @@
private Period period; // Applicable to report table and data set report
- private OrganisationUnit organisationUnit; // Applicable to report table and data set report
+ private OrganisationUnit organisationUnit; // Applicable to chart, report table and data set report
private String text;
@@ -84,9 +84,10 @@
this.created = new Date();
}
- public Interpretation( Chart chart, String text )
+ public Interpretation( Chart chart, OrganisationUnit organisationUnit, String text )
{
this.chart = chart;
+ this.organisationUnit = organisationUnit;
this.text = text;
this.created = new Date();
}
=== 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 2013-01-16 13:25:48 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-02-06 14:45:08 +0000
@@ -176,10 +176,10 @@
public JFreeChart getJFreeChart( Chart chart, I18nFormat format )
{
- return getJFreeChart( chart, null, format );
+ return getJFreeChart( chart, null, null, format );
}
- public JFreeChart getJFreeChart( Chart chart, Date date, I18nFormat format )
+ public JFreeChart getJFreeChart( Chart chart, Date date, OrganisationUnit unit, I18nFormat format )
{
if ( chart.getRelatives() != null )
{
@@ -190,12 +190,16 @@
chart.setRelativePeriods( periodService.reloadPeriods( periods ) );
}
- User user = currentUserService.getCurrentUser();
+ User currentUser = currentUserService.getCurrentUser();
- if ( user != null && user.getOrganisationUnit() != null )
+ if ( currentUser != null && chart.hasUserOrgUnit() &&
+ ( currentUser.getOrganisationUnit() != null || unit != null ) )
{
- OrganisationUnit unit = user.getOrganisationUnit();
-
+ if ( unit == null )
+ {
+ unit = currentUser.getOrganisationUnit();
+ }
+
if ( chart.isUserOrganisationUnit() )
{
chart.getRelativeOrganisationUnits().add( unit );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2012-07-14 10:40:48 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2013-02-06 14:45:08 +0000
@@ -84,13 +84,16 @@
@RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET )
public void getChart( @PathVariable( "uid" ) String uid,
@RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date date,
+ @RequestParam( value = "ou", required = false ) String ou,
@RequestParam( value = "width", defaultValue = "800", required = false ) int width,
@RequestParam( value = "height", defaultValue = "500", required = false ) int height,
HttpServletResponse response ) throws IOException, I18nManagerException
{
Chart chart = chartService.getChart( uid );
- JFreeChart jFreeChart = chartService.getJFreeChart( chart, date, i18nManager.getI18nFormat() );
+ OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
+
+ JFreeChart jFreeChart = chartService.getJFreeChart( chart, date, unit, i18nManager.getI18nFormat() );
String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png";
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2012-12-07 18:16:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2013-02-06 14:45:08 +0000
@@ -50,6 +50,8 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@@ -86,6 +88,9 @@
@Autowired
private MappingService mappingService;
+ @Autowired
+ private CurrentUserService currentUserService;
+
@Override
protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options )
{
@@ -127,7 +132,16 @@
return;
}
- Interpretation interpretation = new Interpretation( chart, text );
+ User user = currentUserService.getCurrentUser();
+
+ // ---------------------------------------------------------------------
+ // When chart has user org unit, store current user org unit with
+ // interpretation so chart will refer to the original org unit later
+ // ---------------------------------------------------------------------
+
+ OrganisationUnit unit = chart.hasUserOrgUnit() && user.hasOrganisationUnit() ? user.getOrganisationUnit() : null;
+
+ Interpretation interpretation = new Interpretation( chart, unit, text );
interpretationService.saveInterpretation( interpretation );
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm 2012-12-07 18:16:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretationFeed.vm 2013-02-06 14:45:08 +0000
@@ -11,6 +11,9 @@
#elseif( $ip.dataSetReportInterpretation )
<img src="../images/dataset.png">
#end
+
+ #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end
+ #if( $ip.period )#set( $pe = "&pe=" + $ip.period.isoDate )#else#set( $pe = "" )#end
</div>
<div class="interpretation">
<div class="interpretationName">
@@ -24,16 +27,14 @@
#if( $ip.chartInterpretation )
<a href="../dhis-web-visualizer/app/index.html?id=${ip.chart.uid}&date=${format.formatDate( $ip.created )}">
<img style="cursor:pointer"
- src="../api/charts/${ip.chart.uid}/data?date=${format.formatDate( $ip.created )}&width=530&height=300"
+ src="../api/charts/${ip.chart.uid}/data?date=${format.formatDate( $ip.created )}&width=530&height=300${ou}"
title="$i18n.getString( 'click_to_view_in_data_visualizer' )"></a>
#elseif( $ip.mapInterpretation )
<a class="bold"
title="$i18n.getString( 'click_to_view_in_gis' )"
href="../dhis-web-mapping/app/index.html?id=${ip.map.uid}">
$encoder.htmlEncode( $ip.map.name )</a>
- #elseif( $ip.reportTableInterpretation )
- #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end
- #if( $ip.period )#set( $pe = "&pe=" + $ip.period.isoDate )#else#set( $pe = "" )#end
+ #elseif( $ip.reportTableInterpretation )
<a class="bold"
title="$i18n.getString( 'click_to_view_report_table' )"
href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}${pe}${ou}">