← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15298: Implemented Interpretations for Mobile Lite

 

------------------------------------------------------------
revno: 15298
committer: paulmarkcastillo@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2014-05-19 15:34:54 +0800
message:
  Implemented Interpretations for Mobile Lite
  https://blueprints.launchpad.net/dhis-mobile/+spec/mla-interpretations
added:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretation.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretations.java
  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/webapp/dhis-web-light/interpretation/
  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/interpretations.vm
modified:
  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/menu.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 directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation'
=== added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action'
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretation.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretation.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretation.java	2014-05-19 07:34:54 +0000
@@ -0,0 +1,112 @@
+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
+ * 
+ */
+public class GetInterpretation
+    implements Action
+{
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( GetInterpretations.class );
+
+    /**
+     * 
+     */
+    public GetInterpretation()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // 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;
+    }
+
+    // -------------------------------------------------------------------------
+    // 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;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        setInterpretation( interpretationService.getInterpretation( getInterpretationId() ) );
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretations.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretations.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/GetInterpretations.java	2014-05-19 07:34:54 +0000
@@ -0,0 +1,135 @@
+package org.hisp.dhis.light.interpretation.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+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
+ * 
+ */
+public class GetInterpretations
+    implements Action, Comparator<Interpretation>
+{
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( GetInterpretations.class );
+
+    /**
+     * 
+     */
+    public GetInterpretations()
+    {
+    }
+
+    // -------------------------------------------------------------------------
+    // 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;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    /**
+     * 
+     */
+    List<Interpretation> interpretations;
+
+    /**
+     * @return the interpretations
+     */
+    public List<Interpretation> getInterpretations()
+    {
+        return interpretations;
+    }
+
+    /**
+     * @param interpretations the interpretations to set
+     */
+    public void setInterpretations( List<Interpretation> interpretations )
+    {
+        this.interpretations = interpretations;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        List<Interpretation> tempInterpretations = interpretationService.getInterpretations();
+
+        List<Interpretation> finalInterpretations = new ArrayList<Interpretation>();
+
+        Iterator<Interpretation> i = tempInterpretations.iterator();
+        while ( i.hasNext() )
+        {
+            Interpretation currentInterpretation = i.next();
+
+            if ( currentInterpretation.getType().equals( Interpretation.TYPE_CHART ) )
+            {
+                finalInterpretations.add( currentInterpretation );
+            }
+        }
+
+        Collections.sort( finalInterpretations, this );
+
+        setInterpretations( finalInterpretations );
+
+        return SUCCESS;
+    }
+
+    @Override
+    public int compare( Interpretation o1, Interpretation o2 )
+    {
+        long time1 = o1.getCreated().getTime();
+        long time2 = o2.getCreated().getTime();
+
+        if ( time1 > time2 )
+        {
+            return -1;
+        }
+        else if ( time2 < time1 )
+        {
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/interpretation/action/PostInterpretationComment.java	2014-05-19 07:34:54 +0000
@@ -0,0 +1,136 @@
+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
+ * 
+ */
+public class PostInterpretationComment
+    implements Action
+{
+    /**
+     * 
+     */
+    private static final Log log = LogFactory.getLog( GetInterpretations.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;
+    }
+
+    // -------------------------------------------------------------------------
+    // 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;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        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-15 03:44:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2014-05-19 07:34:54 +0000
@@ -527,6 +527,24 @@
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>
 
+	<!--  Interpretations -->
+
+	<bean id="org.hisp.dhis.light.interpretation.action.GetInterpretations"
+		class="org.hisp.dhis.light.interpretation.action.GetInterpretations" scope="prototype">
+		<property name="interpretationService" ref="org.hisp.dhis.interpretation.InterpretationService" />
+	</bean>	
+
+	<bean id="org.hisp.dhis.light.interpretation.action.GetInterpretation"
+		class="org.hisp.dhis.light.interpretation.action.GetInterpretation" scope="prototype">
+		<property name="interpretationService" ref="org.hisp.dhis.interpretation.InterpretationService" />
+	</bean>	
+
+	<bean id="org.hisp.dhis.light.interpretation.action.PostInterpretationComment"
+		class="org.hisp.dhis.light.interpretation.action.PostInterpretationComment" scope="prototype">
+		<property name="interpretationService" ref="org.hisp.dhis.interpretation.InterpretationService" />
+	</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-06 06:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2014-05-19 07:34:54 +0000
@@ -140,4 +140,10 @@
 write_feedback=Write Feedback
 write_new_message=Write new message
 write_to_users=To User(s):
-write_add_to_recipients=Add to Recipient(s)
\ No newline at end of file
+write_add_to_recipients=Add to Recipient(s)
+interpretations=Interpretations
+interpretation=Interpretation
+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

=== 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-15 03:44:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2014-05-19 07:34:54 +0000
@@ -508,6 +508,27 @@
 			<param name="page">/dhis-web-light/messages.vm</param>
 		</action>
 
+
+		<!-- Interpretations -->
+		
+		<action name="getInterpretations"
+			class="org.hisp.dhis.light.interpretation.action.GetInterpretations">
+			<result name="success" type="velocity">/dhis-web-light/main.vm</result>
+			<param name="page">/dhis-web-light/interpretation/interpretations.vm</param>
+		</action>
+
+		<action name="getInterpretation"
+			class="org.hisp.dhis.light.interpretation.action.GetInterpretation">
+			<result name="success" type="velocity">/dhis-web-light/main.vm</result>
+			<param name="page">/dhis-web-light/interpretation/interpretation.vm</param>
+		</action>
+
+		<action name="postInterpretationComment"
+			class="org.hisp.dhis.light.interpretation.action.PostInterpretationComment">
+			<result name="success" type="velocity">/dhis-web-light/main.vm</result>
+			<param name="page">/dhis-web-light/interpretation/interpretation.vm</param>
+		</action>
+
 		<!-- Anonymous -->
 
 		<!-- <action name="selectAnonymousOrgUnit" class="org.hisp.dhis.light.beneficiaryregistration.action.GetBeneficiaryRegistrationOrganisationUnitAction"> -->

=== added directory 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretation.vm	2014-05-19 07:34:54 +0000
@@ -0,0 +1,54 @@
+## ============================================================================
+<h2>
+	$i18n.getString( "Interpretation" )
+</h2>
+
+<p>
+	#if($interpretation.getType() == "chart")
+		<img src="getChart.action?id=$interpretation.getChart().getId()" style="width:100%"></br>
+	#end
+</p>
+
+
+## ============================================================================
+<h3>
+	$i18n.getString( "interpretation_comment" )
+</h3>
+
+<p>
+	#foreach( $interpretationComment in $interpretation.getComments() )
+		<li>
+			$interpretationComment.getText()
+		</li>
+	#end
+</p>
+
+
+## ============================================================================
+<h3>$i18n.getString("interpretation_add_comment")</h3>
+
+<form method="POST" action="postInterpretationComment.action">
+	<input type="hidden" name="interpretationId" value="$interpretationId" />
+	<div class="header-box" align="center">
+		<p style="text-align: left;">			
+			<input type="text" size="24" name="comment" />			
+			<input type="submit" style="width: 100%;" value="$i18n.getString("interpretation_post_comment")" />
+		</p>
+	</div>
+</form>
+
+
+## ============================================================================
+<div id="footer">
+	<h2>
+		$i18n.getString( "navigate_to" )
+	</h2>
+	
+	<ul>
+		<li>
+			<a href="index.action">
+				$i18n.getString("home")
+			</a>
+		</li>
+	</ul>
+</div>

=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretations.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretations.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/interpretation/interpretations.vm	2014-05-19 07:34:54 +0000
@@ -0,0 +1,31 @@
+
+<h2>
+	$i18n.getString( "interpretations" )
+</h2>
+
+
+<i>$i18n.getString( "interpretations_support" )</i><br />
+
+<p>
+	#foreach( $interpretation in $interpretations )
+		<li>
+			<a href="getInterpretation.action?interpretationId=$interpretation.getId()">
+				$interpretation.getText()
+			</a>
+		</li>
+	#end
+</p>
+
+<div id="footer">
+	<h2>
+		$i18n.getString( "navigate_to" )
+	</h2>
+	
+	<ul>
+		<li>
+			<a href="index.action">
+				$i18n.getString("home")
+			</a>
+		</li>
+	</ul>
+</div>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm	2014-03-04 07:06:42 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm	2014-05-19 07:34:54 +0000
@@ -29,6 +29,7 @@
 	#end
 	
     <li><a href="messages.action">$i18n.getString( "messages" ) #if($unreadMessageConversationCount > 0)($unreadMessageConversationCount)#end</a></li>
+    <li><a href="getInterpretations.action">$i18n.getString( "interpretations" )</a></li>
     <li><a href="reports.action">$i18n.getString( "reports" )</a></li>
     <li><a href="settings.action">$i18n.getString( "settings" )</a></li>		
 </ul>