← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3984: Remove chain from Survey and Target Module

 

------------------------------------------------------------
revno: 3984
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-22 17:17:58 +0530
message:
  Remove chain from Survey and Target Module
modified:
  local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/SelectAction.java
  local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/SelectAction.java
  local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-survey/src/main/resources/struts.xml
  local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/form.vm
  local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/targetForm.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 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/SelectAction.java'
--- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/SelectAction.java	2011-01-15 11:35:42 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/SelectAction.java	2011-06-22 11:47:58 +0000
@@ -2,13 +2,19 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.hisp.dhis.detarget.DeTarget;
+import org.hisp.dhis.detarget.DeTargetMember;
 import org.hisp.dhis.detarget.DeTargetService;
+import org.hisp.dhis.detargetdatavalue.DeTargetDataValue;
+import org.hisp.dhis.detargetdatavalue.DeTargetDataValueService;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.survey.state.SelectedStateManager;
 
 import com.opensymphony.xwork2.Action;
@@ -41,6 +47,20 @@
         this.format = format;
     }
     
+    private PeriodService periodService;
+    
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
+    private DeTargetDataValueService deTargetDataValueService;
+    
+    public void setDeTargetDataValueService( DeTargetDataValueService deTargetDataValueService )
+    {
+        this.deTargetDataValueService = deTargetDataValueService;
+    }
+    
     //--------------------------------------------------------------------------
     //Input/Output
     //--------------------------------------------------------------------------
@@ -96,13 +116,39 @@
     {
         return periods;
     }
-
-
+    
+    
+    private Map<String, DeTargetDataValue> deTargetDataValueMap;
+    
+    public Map<String, DeTargetDataValue> getDeTargetDataValueMap()
+    {
+        return deTargetDataValueMap;
+    }
+    
+    private List<DeTargetMember> deTargetmembers;
+    
+    public List<DeTargetMember> getDeTargetmembers()
+    {
+        return deTargetmembers;
+    }
+    
+    private int flage;
+    
+    public int getFlage()
+    {
+        return flage;
+    }
+
+    public void setFlage( int flage )
+    {
+        this.flage = flage;
+    }
+    
     //--------------------------------------------------------------------------
     //Action Implementation
     //--------------------------------------------------------------------------
 
-    public String execute()
+    public String execute() throws Exception
     {
         orgUnit = selectedStateManager.getSelectedOrganisationUnit();
         
@@ -178,7 +224,41 @@
 
             return SUCCESS;
         }
+        
+        getDeTargetDataEntryForm();
+        flage = 1;
         return "defaulttargetform";
     }
+    
+    public String getDeTargetDataEntryForm() throws Exception
+    {
+        deTargetDataValueMap = new HashMap<String, DeTargetDataValue>();
+        
+        OrganisationUnit orgUnit = selectedStateManager.getSelectedOrganisationUnit();
+        
+        DeTarget deTarget = selectedStateManager.getSelectedDeTarget();
+        
+        Period period = selectedStateManager.getSelectedPeriod();
+        
+        period = periodService.reloadPeriod( period );
+        
+        deTargetmembers = new ArrayList<DeTargetMember> ( deTargetService.getDeTargetMembers( deTarget ) );
+ 
+        // ---------------------------------------------------------------------
+        // Get the target Value and create a map
+        // ---------------------------------------------------------------------
 
+        Collection<DeTargetDataValue> deTargetDataValues = deTargetDataValueService.getDeTargetDataValues( deTarget, orgUnit, period );
+        
+        
+        for( DeTargetDataValue deTargetDataValue : deTargetDataValues)
+        {
+            String deOptionCombiId = deTargetDataValue.getDataelement().getId() + ":" + deTargetDataValue.getDecategoryOptionCombo().getId();
+            
+            deTargetDataValueMap.put( deOptionCombiId, deTargetDataValue );
+        }
+        
+        return SUCCESS;
+   
+    }
 }

=== modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/SelectAction.java'
--- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/SelectAction.java	2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/SelectAction.java	2011-06-22 11:47:58 +0000
@@ -30,13 +30,18 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.survey.Survey;
 import org.hisp.dhis.survey.SurveyService;
 import org.hisp.dhis.survey.comparator.SurveyNameComparator;
 import org.hisp.dhis.survey.state.SelectedStateManager;
+import org.hisp.dhis.surveydatavalue.SurveyDataValue;
+import org.hisp.dhis.surveydatavalue.SurveyDataValueService;
 
 import com.opensymphony.xwork2.ActionSupport;
 
@@ -66,7 +71,14 @@
     {
         this.surveyService = surveyService;
     }
-
+//Extra Code    
+    private SurveyDataValueService surveyDataValueService;
+    
+    public void setSurveyDataValueService ( SurveyDataValueService surveyDataValueService )
+    {
+        this.surveyDataValueService = surveyDataValueService;
+    }
+    
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -101,8 +113,48 @@
     {
         this.selectedSurveyId = selectedSurveyId;
     }
-
-       
+    
+ /*   
+    private String page;
+    
+    public String getPage()
+    {
+        return page;
+    }
+
+    public void setPage( String page )
+    {
+        this.page = page;
+    }
+
+*/    
+    private int flage;
+    
+    public int getFlage()
+    {
+        return flage;
+    }
+
+    public void setFlage( int flage )
+    {
+        this.flage = flage;
+    }
+
+    // Extra code    
+    private Map<Integer, SurveyDataValue> dataValueMap;
+
+    public Map<Integer, SurveyDataValue> getDataValueMap()
+    {
+        return dataValueMap;
+    }
+ 
+    private List<Indicator> orderedIndicators = new ArrayList<Indicator>();
+
+    public List<Indicator> getOrderedIndicators()
+    {
+        return orderedIndicators;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -121,7 +173,8 @@
             selectedSurveyId = null;
  
             selectedStateManager.clearSelectedSurvey();     
-
+            
+            //flage = 0;
             return SUCCESS;
         }
 
@@ -136,20 +189,26 @@
         // ---------------------------------------------------------------------
         // Validate selected DataSet
         // ---------------------------------------------------------------------
+        
+        
 
+        
         Survey selectedSurvey;
 
         if ( selectedSurveyId != null )
         {
+            //flage = 0;
             selectedSurvey = surveyService.getSurvey( selectedSurveyId );
         }
         else
         {
+            //flage = 0;
             selectedSurvey = selectedStateManager.getSelectedSurvey();
         }
 
         if ( selectedSurvey != null && surveys.contains( selectedSurvey ) )
         {
+            //flage = 0;
             selectedSurveyId = selectedSurvey.getId();
             selectedStateManager.setSelectedSurvey( selectedSurvey );
         }
@@ -158,12 +217,60 @@
             selectedSurveyId = null;
             
             selectedStateManager.clearSelectedSurvey();
-
-            return SUCCESS;
-        }
-        
-        
-        
-        return "defaultform";        
-    }
+            //flage = 0;
+            //page = "/dhis-web-survey/select.vm";
+            return SUCCESS;
+        }
+
+        //Extra code
+        getSurveyDataEntryForm();
+        //return defaultform;
+        flage = 1;
+       // page = "/dhis-web-survey/form.vm";
+        return "defaultform";
+        
+    }
+    
+
+    //Extra method   
+    public String getSurveyDataEntryForm() throws Exception
+    {
+       
+        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+        Survey survey = selectedStateManager.getSelectedSurvey();
+      
+        List<Indicator> indicators = new ArrayList<Indicator>(survey.getIndicators());        
+
+        if ( indicators.size() == 0 )
+        {
+            return SUCCESS;
+        }  
+
+        // ---------------------------------------------------------------------
+        // Get the DataValues and create a map
+        // ---------------------------------------------------------------------
+
+        Collection<SurveyDataValue> dataValues = surveyDataValueService.getSurveyDataValues( organisationUnit, survey );
+        
+        dataValueMap = new HashMap<Integer, SurveyDataValue>( dataValues.size() );
+
+        for ( SurveyDataValue dataValue : dataValues )
+        {
+            dataValueMap.put( dataValue.getIndicator().getId(), dataValue );
+        }
+   
+        // ---------------------------------------------------------------------
+        // Working on the display of indicators
+        // ---------------------------------------------------------------------
+
+        orderedIndicators = indicators;
+        
+        //displayPropertyHandler.handle( orderedDataElements );
+        
+        return SUCCESS;
+    }
+    
+    
+    
 }

=== modified file 'local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml	2011-06-17 10:54:43 +0000
+++ local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml	2011-06-22 11:47:58 +0000
@@ -21,7 +21,7 @@
   </bean>
  
   <!-- Actions -->
-  
+<!--  
   <bean id="org.hisp.dhis.survey.action.SelectAction"
     class="org.hisp.dhis.survey.action.SelectAction" 
     scope="prototype">
@@ -30,7 +30,20 @@
     <property name="surveyService"
       ref="org.hisp.dhis.survey.SurveyService"/>       
   </bean> 
-	
+-->
+	
+  <bean id="org.hisp.dhis.survey.action.SelectAction"
+    class="org.hisp.dhis.survey.action.SelectAction" 
+    scope="prototype">
+    <property name="selectedStateManager"
+      ref="org.hisp.dhis.survey.state.SelectedStateManager"/>
+    <property name="surveyService"
+      ref="org.hisp.dhis.survey.SurveyService"/>
+    <property name="surveyDataValueService"
+      ref="org.hisp.dhis.surveydatavalue.SurveyDataValueService"/>
+  </bean> 	
+	
+<!--		
   <bean id="org.hisp.dhis.survey.action.FormAction"
     class="org.hisp.dhis.survey.action.FormAction" 
     scope="prototype">
@@ -39,7 +52,7 @@
     <property name="surveyDataValueService"
       ref="org.hisp.dhis.surveydatavalue.SurveyDataValueService"/>      
   </bean>
- 
+ -->
   <bean id="org.hisp.dhis.survey.action.SaveValueAction"
     class="org.hisp.dhis.survey.action.SaveValueAction" 
     scope="prototype">
@@ -222,7 +235,7 @@
 	
 	
   <!-- Target -->
-  
+ <!-- 
   <bean id="org.hisp.dhis.detarget.action.SelectAction"
     class="org.hisp.dhis.detarget.action.SelectAction" 
     scope="prototype">
@@ -231,7 +244,22 @@
     <property name="deTargetService"
       ref="org.hisp.dhis.detarget.DeTargetService"/>       
   </bean> 
-    
+-->
+  <bean id="org.hisp.dhis.detarget.action.SelectAction"
+    class="org.hisp.dhis.detarget.action.SelectAction" 
+    scope="prototype">
+    <property name="selectedStateManager"
+      ref="org.hisp.dhis.survey.state.SelectedStateManager"/>
+    <property name="deTargetService"
+      ref="org.hisp.dhis.detarget.DeTargetService"/>
+    <property name="periodService"
+      ref="org.hisp.dhis.period.PeriodService"/> 
+    <property name="deTargetDataValueService"
+      ref="org.hisp.dhis.detargetdatavalue.DeTargetDataValueService"/> 	  	      
+  </bean> 	
+	
+	
+<!--	    
   <bean id="org.hisp.dhis.detarget.action.FormAction"
     class="org.hisp.dhis.detarget.action.FormAction" 
     scope="prototype">
@@ -244,7 +272,7 @@
      <property name="periodService"
       ref="org.hisp.dhis.period.PeriodService"/> 
   </bean> 
-    
+-->    
   <bean id="org.hisp.dhis.detarget.action.SavetargetValueAction"
       class="org.hisp.dhis.detarget.action.SavetargetValueAction"
       scope="prototype">

=== modified file 'local/in/dhis-web-survey/src/main/resources/struts.xml'
--- local/in/dhis-web-survey/src/main/resources/struts.xml	2011-06-17 10:54:43 +0000
+++ local/in/dhis-web-survey/src/main/resources/struts.xml	2011-06-22 11:47:58 +0000
@@ -178,7 +178,7 @@
 			class="org.hisp.dhis.survey.action.EmptyAction">
 			<result name="success" type="redirect">select.action</result>
 		</action>
-		
+<!--		
 		<action name="select" class="org.hisp.dhis.survey.action.SelectAction">
 			<interceptor-ref name="organisationUnitTreeStack"/>
 			<result name="defaultform" type="chain">defaultform</result>
@@ -191,7 +191,49 @@
 			<param name="stylesheets">
 				style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
 		</action>
+-->
+<!--
+			<action name="select" class="org.hisp.dhis.survey.action.SelectAction">
+			<interceptor-ref name="organisationUnitTreeStack"/>
+			<result name="defaultform" type="redirect">
+			  <param name="location">defaultform.action</param>
+			  <param name="selectedSurveyId">${selectedSurveyId}</param>
+			  <param name="parse">false</param>
+			</result>
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-survey/select.vm</param>
+			<param name="menu">/dhis-web-survey/menuWithTree.vm</param>
+			<param name="menuTreeHeight">350</param>
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js</param>
+			<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
+		</action>		
+-->		
+<!--		<action name="select" class="org.hisp.dhis.survey.action.SelectAction">
+			<interceptor-ref name="organisationUnitTreeStack"/>
+			<result name="success" type="velocity">/main.vm</result>-->
+			<!--<param name="page">/dhis-web-survey/select.vm</param>-->
+<!--			<param name="page">${page}</param>
+			<param name="menu">/dhis-web-survey/menuWithTree.vm</param>-->
+			<!--<result name="defaultform" type="velocity">/dhis-web-survey/form.vm</result>-->
+<!--			<param name="menuTreeHeight">350</param>
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js</param>
+			<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>		
+		</action>-->		
 		
+		<action name="select" class="org.hisp.dhis.survey.action.SelectAction">
+			<interceptor-ref name="organisationUnitTreeStack"/>
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-survey/select.vm</param>
+			<param name="menu">/dhis-web-survey/menuWithTree.vm</param>
+			<result name="defaultform" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-survey/form.vm</param>
+			<param name="menu">/dhis-web-survey/menuWithTree.vm</param>
+			<param name="menuTreeHeight">350</param>
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js</param>
+			<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>		
+		</action>		
+<!--		
+				
 		<action name="defaultform" class="org.hisp.dhis.survey.action.FormAction">
 			<interceptor-ref name="organisationUnitTreeStack"/>
 			<result name="success" type="velocity">/main.vm</result>
@@ -206,7 +248,7 @@
 			<param name="stylesheets">
 				style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
 		</action>
-		
+-->		
 		<action name="saveValue"
 			class="org.hisp.dhis.survey.action.SaveValueAction">
 			<result name="success" type="velocity-xml">status.vm</result>
@@ -263,7 +305,7 @@
             class="org.hisp.dhis.survey.action.EmptyAction">
             <result name="success" type="redirect">selectTarget.action</result>
         </action>
-        
+<!--        
         <action name="selectTarget" class="org.hisp.dhis.detarget.action.SelectAction">
             <interceptor-ref name="organisationUnitTreeStack"/>
             <result name="defaulttargetform" type="chain">defaulttargetform</result>
@@ -276,7 +318,22 @@
             <param name="stylesheets">
                 style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
         </action>   
-        
+-->
+		
+        <action name="selectTarget" class="org.hisp.dhis.detarget.action.SelectAction">
+            <interceptor-ref name="organisationUnitTreeStack"/>
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-survey/selectTarget.vm</param>
+			<param name="menu">/dhis-web-survey/menuWithTreeForDeTarget.vm</param>
+			<result name="defaulttargetform" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-survey/targetForm.vm</param>
+            <param name="menu">/dhis-web-survey/menuWithTreeForDeTarget.vm</param>
+            <param name="menuTreeHeight">350</param>
+            <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js</param>
+            <param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
+        </action>	
+		
+<!--		        
         <action name="defaulttargetform" class="org.hisp.dhis.detarget.action.FormAction">
             <interceptor-ref name="organisationUnitTreeStack"/>
             <result name="success" type="velocity">/main.vm</result>
@@ -291,7 +348,7 @@
             <param name="stylesheets">
                 style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
         </action>
-        
+-->        
         <action name="saveTargetValue"
             class="org.hisp.dhis.detarget.action.SavetargetValueAction">
             <result name="success" type="velocity-xml">status.vm</result>

=== modified file 'local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/form.vm'
--- local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/form.vm	2011-01-19 13:29:17 +0000
+++ local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/form.vm	2011-06-22 11:47:58 +0000
@@ -1,7 +1,7 @@
 
-
+##if( $flage == 0 )
 #parse( "/dhis-web-survey/select.vm" )
-
+#if( $flage == 1 )
 <table class="mainPageTable">
 	<col id="noCol" width="25">
 	<col id="indCol">	
@@ -43,7 +43,7 @@
 	#set( $tabIndex = $tabIndex + 1 )
 #end
 </table>
-
+#end
 
 
 

=== modified file 'local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/targetForm.vm'
--- local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/targetForm.vm	2011-01-15 11:35:42 +0000
+++ local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/targetForm.vm	2011-06-22 11:47:58 +0000
@@ -1,7 +1,7 @@
 
 
 #parse( "/dhis-web-survey/selectTarget.vm" )
-
+#if( $flage == 1 )
 <table class="mainPageTable">
 	<col id="noCol" width="25">
 	<col id="indCol">	
@@ -47,7 +47,7 @@
 	#set( $tabIndex = $tabIndex + 1 )
 #end
 </table>
-
+#end