← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15403: [NEW] Added sharing interpretations

 

------------------------------------------------------------
revno: 15403
committer: paulmarkcastillo@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2014-05-26 18:22:07 +0800
message:
  [NEW] Added sharing interpretations
  https://blueprints.launchpad.net/dhis-mobile/+spec/mla-interpretations
added:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetDashboardChartAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretation.java
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_chart.vm
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretationComment.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
  dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_charts.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretation.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
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetDashboardChartAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetDashboardChartAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dashboard/action/GetDashboardChartAction.java	2014-05-26 10:22:07 +0000
@@ -0,0 +1,70 @@
+package org.hisp.dhis.light.dashboard.action;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * 
+ * @author Paul Mark Castillo
+ * 
+ */
+public class GetDashboardChartAction
+    implements Action
+{
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( GetDashboardChartAction.class );
+
+    /**
+     * 
+     */
+    public GetDashboardChartAction()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    /**
+     * 
+     */
+    private int id;
+    
+    /**
+     * 
+     * @return
+     */
+    public int getId() {
+		return id;
+	}
+
+    /**
+     * 
+     * @param id
+     */
+	public void setId(int id) {
+    	this.id = id;
+	}
+	
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+
+
+
+	@Override
+    public String execute()
+        throws Exception
+    {
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretation.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretation.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretation.java	2014-05-26 10:22:07 +0000
@@ -0,0 +1,166 @@
+package org.hisp.dhis.light.interpretation.action;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.chart.ChartService;
+import org.hisp.dhis.interpretation.Interpretation;
+import org.hisp.dhis.interpretation.InterpretationService;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * 
+ * @author Paul Mark Castillo
+ * 
+ */
+public class PostInterpretation
+    implements Action
+{
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( PostInterpretation.class );
+
+    /**
+     * 
+     */
+    public PostInterpretation()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    /**
+     * 
+     */
+    private InterpretationService interpretationService;
+
+    /**
+     * @return the interpretationService
+     */
+    public InterpretationService getInterpretationService()
+    {
+        return interpretationService;
+    }
+
+    /**
+     * @param interpretationService the interpretationService to set
+     */
+    public void setInterpretationService( InterpretationService interpretationService )
+    {
+    	this.interpretationService = interpretationService;
+    }
+
+    /**
+     * 
+     */
+    private CurrentUserService currentUserService;
+
+    /**
+     * 
+     * @return
+     */
+    public CurrentUserService getCurrentUserService() {
+		return currentUserService;
+	}
+
+    /**
+     * 
+     * @param currentUserService
+     */
+	public void setCurrentUserService(CurrentUserService currentUserService) {
+    	this.currentUserService = currentUserService;
+	}
+
+	/**
+	 * 
+	 */
+    private ChartService chartService;
+
+    /**
+     * 
+     * @return
+     */
+	public ChartService getChartService() {
+    	return chartService;
+	}
+
+	/**
+	 * 
+	 * @param chartService
+	 */
+	public void setChartService(ChartService chartService) {
+    	this.chartService = chartService;
+	}
+    
+    
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+	/**
+	 * 
+	 */
+	private int id;
+    
+    /**
+     * 
+     * @return
+     */
+    public int getId() {
+		return id;
+	}
+
+    /**
+     * 
+     * @param id
+     */
+	public void setId(int id) {
+		this.id = id;
+	}
+
+	/**
+	 * 
+	 */
+	private String interpretation;
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	/**
+	 * 
+	 * @param interpretation
+	 */
+	public void setInterpretation(String interpretation) {
+    	this.interpretation = interpretation;
+	}
+
+    
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+    	Chart c = chartService.getChart(id);
+    	
+    	Interpretation i = new Interpretation(c, null, interpretation); 
+    	
+    	i.setUser(currentUserService.getCurrentUser());
+    	
+    	interpretationService.saveInterpretation(i);
+    	
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretationComment.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretationComment.java	2014-05-19 11:42:06 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretationComment.java	2014-05-26 10:22:07 +0000
@@ -1,22 +1,53 @@
 package org.hisp.dhis.light.interpretation.action;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationService;
 
 import com.opensymphony.xwork2.Action;
 
 /**
- * @author Paul Mark Castillo 
+ * 
+ * @author Paul Mark Castillo
+ * 
  */
 public class PostInterpretationComment
     implements Action
 {
+	
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( PostInterpretationComment.class );
+
+    /**
+     * 
+     */
+    public PostInterpretationComment()
+    {
+    }
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
+    /**
+     * 
+     */
     private InterpretationService interpretationService;
 
+    /**
+     * @return the interpretationService
+     */
+    public InterpretationService getInterpretationService()
+    {
+        return interpretationService;
+    }
+
+    /**
+     * @param interpretationService the interpretationService to set
+     */
     public void setInterpretationService( InterpretationService interpretationService )
     {
         this.interpretationService = interpretationService;
@@ -26,37 +57,66 @@
     // Input & Output
     // -------------------------------------------------------------------------
 
+    /**
+     * 
+     */
     private int interpretationId;
 
+    /**
+     * @return the interpretationId
+     */
     public int getInterpretationId()
     {
         return interpretationId;
     }
 
+    /**
+     * @param interpretationId the interpretationId to set
+     */
     public void setInterpretationId( int interpretationId )
     {
         this.interpretationId = interpretationId;
     }
 
+    /**
+     * 
+     */
     private Interpretation interpretation;
 
+    /**
+     * @return the interpretation
+     */
     public Interpretation getInterpretation()
     {
         return interpretation;
     }
 
+    /**
+     * @param interpretation the interpretation to set
+     */
     public void setInterpretation( Interpretation interpretation )
     {
         this.interpretation = interpretation;
     }
 
+    /**
+     * 
+     */
     private String comment;
 
+    /**
+     * 
+     * @return
+     */
     public String getComment()
     {
         return comment;
     }
 
+    /**
+     * 
+     * @param comment
+     */
     public void setComment( String comment )
     {
         this.comment = comment;
@@ -71,9 +131,7 @@
         throws Exception
     {
         setInterpretation( interpretationService.getInterpretation( getInterpretationId() ) );
-        
         interpretationService.addInterpretationComment( getInterpretation().getUid(), getComment() );
-        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2014-05-19 07:34:54 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2014-05-26 10:22:07 +0000
@@ -477,6 +477,10 @@
 		class="org.hisp.dhis.light.dashboard.action.GetChartAction" scope="prototype">
 		<property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.light.dashboard.action.GetDashboardChartAction"
+		class="org.hisp.dhis.light.dashboard.action.GetDashboardChartAction" scope="prototype">
+	</bean>	
 
 	<bean id="org.hisp.dhis.light.dashboard.action.GetReportParamsAction"
 		class="org.hisp.dhis.light.dashboard.action.GetReportParamsAction"
@@ -545,6 +549,13 @@
 	</bean>	
 
 
+	<bean id="org.hisp.dhis.light.interpretation.action.PostInterpretation"
+		class="org.hisp.dhis.light.interpretation.action.PostInterpretation" scope="prototype">
+		<property name="interpretationService" ref="org.hisp.dhis.interpretation.InterpretationService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="chartService" ref="org.hisp.dhis.chart.ChartService" />		
+	</bean>	
+
 	<!-- Anonymous -->
 
 	<bean id="org.hisp.dhis.light.anonymous.action.SearchOrgUnitAction"

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2014-05-19 07:34:54 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2014-05-26 10:22:07 +0000
@@ -146,4 +146,7 @@
 interpretations_support=Only charts are currently supported for interpretations.
 interpretation_comment=Comment(s):
 interpretation_add_comment=Add a comment
-interpretation_post_comment=Post comment
\ No newline at end of file
+interpretation_post_comment=Post comment
+interpretation_share=Share interpretation
+share=Share
+chart=Chart
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2014-05-19 07:34:54 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2014-05-26 10:22:07 +0000
@@ -429,6 +429,12 @@
 			</result>
 		</action>
 
+		<action name="getDashboardChart"
+			class="org.hisp.dhis.light.dashboard.action.GetDashboardChartAction">
+			<result name="success" type="velocity">/dhis-web-light/main.vm</result>
+			<param name="page">/dhis-web-light/dashboard_chart.vm</param>
+		</action>
+
 		<!-- Settings -->
 
 		<action name="settings"
@@ -529,6 +535,12 @@
 			<param name="page">/dhis-web-light/interpretation/interpretation.vm</param>
 		</action>
 
+		<action name="postInterpretation"
+			class="org.hisp.dhis.light.interpretation.action.PostInterpretation">
+			<result name="success" type="velocity">/dhis-web-light/main.vm</result>
+			<param name="page">/dhis-web-light/menu.vm</param>
+		</action>
+
 		<!-- Anonymous -->
 
 		<!-- <action name="selectAnonymousOrgUnit" class="org.hisp.dhis.light.beneficiaryregistration.action.GetBeneficiaryRegistrationOrganisationUnitAction"> -->

=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_chart.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_chart.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_chart.vm	2014-05-26 10:22:07 +0000
@@ -0,0 +1,24 @@
+## ============================================================================
+<h2>
+	$i18n.getString( "chart" )
+</h2>
+
+
+## ============================================================================
+<p>
+	<img src="getChart.action?id=$id" style="width:100%"></br>
+</p>
+
+
+## ============================================================================
+<h3>$i18n.getString("interpretation_share")</h3>
+
+<form method="POST" action="postInterpretation.action">
+	<input type="hidden" name="id" value="$id" />
+	<div class="header-box" align="center">
+		<p style="text-align: left;">			
+			<input type="text" size="24" name="interpretation" />			
+			<input type="submit" style="width: 100%;" value="$i18n.getString("share")" />
+		</p>
+	</div>
+</form>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_charts.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_charts.vm	2013-03-13 14:14:24 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_charts.vm	2014-05-26 10:22:07 +0000
@@ -6,7 +6,7 @@
 #end
 <div class="contentChartDiv">
 #foreach( $chart in $chartsForAll )
-<a href="getChart.action?id=$chart.id">$chart.name</a></br>
+<a href="getDashboardChart.action?id=$chart.id">$chart.name</a></br>
 #end
 </div>
 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretation.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretation.vm	2014-05-19 07:34:54 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretation.vm	2014-05-26 10:22:07 +0000
@@ -1,6 +1,6 @@
 ## ============================================================================
 <h2>
-	$i18n.getString( "Interpretation" )
+	$i18n.getString( "interpretation" )
 </h2>
 
 <p>