dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16082
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6018: Bug fixed in survey module
------------------------------------------------------------
revno: 6018
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-02-17 17:02:11 +0530
message:
Bug fixed in survey module
modified:
local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/FormAction.java
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/FormAction.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/menuWithTree.vm
local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTreeForDeTarget.vm
local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/selectTarget.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/FormAction.java'
--- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/FormAction.java 2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/FormAction.java 2012-02-17 11:32:11 +0000
@@ -16,6 +16,7 @@
import org.hisp.dhis.detargetdatavalue.DeTargetDataValue;
import org.hisp.dhis.detargetdatavalue.DeTargetDataValueService;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -70,7 +71,7 @@
// DisplayPropertyHandler
// -------------------------------------------------------------------------
-
+ @SuppressWarnings("unused")
/*
private DisplayPropertyHandler displayPropertyHandler;
@@ -164,13 +165,138 @@
this.selectedPeriodIndex = selectedPeriodIndex;
}
-
+ // source code of SelectAction.java
+ private OrganisationUnit orgUnit;
+
+ public OrganisationUnit getOrgUnit()
+ {
+ return orgUnit;
+ }
+
+ private int flage;
+
+ public int getFlage()
+ {
+ return flage;
+ }
+
+ public void setFlage( int flage )
+ {
+ this.flage = flage;
+ }
+
+ private List<Period> periods = new ArrayList<Period>();
+
+ public Collection<Period> getPeriods()
+ {
+ return periods;
+ }
+
+ private List<DeTarget> deTargets = new ArrayList<DeTarget>();
+
+ public List<DeTarget> getDeTargets()
+ {
+ return deTargets;
+ }
+
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
+ private Period period;
+
+ public Period getPeriod()
+ {
+ return period;
+ }
//--------------------------------------------------------------------------
//Action Implementation
//--------------------------------------------------------------------------
public String execute()
{
+ // source code of SelectAction.java
+
+ orgUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ if( orgUnit == null )
+ {
+ selectedDeTargetId = null;
+
+ selectedStateManager.clearSelectedDeTarget();
+
+ return SUCCESS;
+ }
+
+ // ---------------------------------------------------------------------
+ // Load Targets
+ // ---------------------------------------------------------------------
+
+ deTargets = selectedStateManager.loadDeTargetsForSelectedOrgUnit( orgUnit );
+
+ DeTarget selectedDeTarget;
+
+ if( selectedDeTargetId != null )
+ {
+ selectedDeTarget = deTargetService.getDeTarget( selectedDeTargetId );
+ }
+ else
+ {
+ selectedDeTarget = selectedStateManager.getSelectedDeTarget();
+ }
+
+ if( selectedDeTarget != null && deTargets.contains( selectedDeTarget ) )
+ {
+ selectedDeTargetId = selectedDeTarget.getId();
+
+ selectedStateManager.setSelectedDeTarget( selectedDeTarget );
+
+ periods = selectedStateManager.getPeriodList();
+
+ for ( Period period : periods )
+ {
+ period.setName( format.formatPeriod( period ) );
+ }
+ }
+ else
+ {
+ selectedDeTargetId = null;
+
+ selectedStateManager.clearSelectedDeTarget();
+
+ return SUCCESS;
+ }
+
+ // ---------------------------------------------------------------------
+ // Validate selected period
+ // ---------------------------------------------------------------------
+
+ if ( selectedPeriodIndex == null )
+ {
+ selectedPeriodIndex = selectedStateManager.getSelectedPeriodIndex();
+
+ }
+
+ if ( selectedPeriodIndex != null && selectedPeriodIndex >= 0 )
+ {
+ selectedStateManager.setSelectedPeriodIndex( selectedPeriodIndex );
+
+ period = selectedStateManager.getSelectedPeriod();
+ }
+
+ else
+ {
+ selectedStateManager.clearSelectedPeriod();
+
+ return SUCCESS;
+ }
+ //return "defaulttargetform";
+ flage = 1;
+
+
deTargetDataValueMap = new HashMap<String, DeTargetDataValue>();
OrganisationUnit orgUnit = selectedStateManager.getSelectedOrganisationUnit();
=== 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-06-22 11:47:58 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/detarget/action/SelectAction.java 2012-02-17 11:32:11 +0000
@@ -144,6 +144,7 @@
this.flage = flage;
}
+
//--------------------------------------------------------------------------
//Action Implementation
//--------------------------------------------------------------------------
=== modified file 'local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/FormAction.java'
--- local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/FormAction.java 2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/FormAction.java 2012-02-17 11:32:11 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,6 +38,8 @@
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;
@@ -67,6 +70,14 @@
{
this.surveyDataValueService = surveyDataValueService;
}
+
+ private SurveyService surveyService;
+
+ public void setSurveyService( SurveyService surveyService )
+ {
+ this.surveyService = surveyService;
+ }
+
@SuppressWarnings("unused")
private I18n i18n;
@@ -121,7 +132,33 @@
{
return selectedSurveyId;
}
-
+ //code for Select Action
+ private OrganisationUnit organisationUnit;
+
+ public OrganisationUnit getOrganisationUnit()
+ {
+ return organisationUnit;
+ }
+
+ private List<Survey> surveys = new ArrayList<Survey>();
+
+ public Collection<Survey> getSurveys()
+ {
+ return surveys;
+ }
+
+ private int flage;
+
+ public int getFlage()
+ {
+ return flage;
+ }
+
+ public void setFlage( int flage )
+ {
+ this.flage = flage;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -130,6 +167,64 @@
throws Exception
{
+ //code for Select Action
+
+
+ // ---------------------------------------------------------------------
+ // Validate selected OrganisationUnit
+ // ---------------------------------------------------------------------
+
+ organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ //System.out.println( "---organisationUnit -- " + organisationUnit.getName() );
+
+ if ( organisationUnit == null )
+ {
+ selectedSurveyId = null;
+
+ selectedStateManager.clearSelectedSurvey();
+
+ return SUCCESS;
+ }
+
+ // ---------------------------------------------------------------------
+ // Load and Sort surveys
+ // ---------------------------------------------------------------------
+
+ surveys = selectedStateManager.loadSurveysForSelectedOrgUnit( organisationUnit );
+
+ Collections.sort( surveys, new SurveyNameComparator() );
+
+ // ---------------------------------------------------------------------
+ // Validate selected surveys
+ // ---------------------------------------------------------------------
+
+ Survey selectedSurvey;
+
+ if ( selectedSurveyId != null )
+ {
+ selectedSurvey = surveyService.getSurvey( selectedSurveyId );
+ }
+ else
+ {
+ selectedSurvey = selectedStateManager.getSelectedSurvey();
+ }
+
+ if ( selectedSurvey != null && surveys.contains( selectedSurvey ) )
+ {
+ selectedSurveyId = selectedSurvey.getId();
+ selectedStateManager.setSelectedSurvey( selectedSurvey );
+ }
+ else
+ {
+ selectedSurveyId = null;
+
+ selectedStateManager.clearSelectedSurvey();
+
+ return SUCCESS;
+ }
+ flage = 1;
+
OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
Survey survey = selectedStateManager.getSelectedSurvey();
=== 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 2011-06-22 11:47:58 +0000
+++ local/in/dhis-web-survey/src/main/java/org/hisp/dhis/survey/action/SelectAction.java 2012-02-17 11:32:11 +0000
@@ -71,7 +71,7 @@
{
this.surveyService = surveyService;
}
-//Extra Code
+ //Extra Code
private SurveyDataValueService surveyDataValueService;
public void setSurveyDataValueService ( SurveyDataValueService surveyDataValueService )
=== 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 2012-02-02 09:56:51 +0000
+++ local/in/dhis-web-survey/src/main/resources/META-INF/dhis/beans.xml 2012-02-17 11:32:11 +0000
@@ -2,7 +2,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="org.hisp.dhis.survey.action.EmptyAction"
class="org.hisp.dhis.survey.action.EmptyAction"/>
@@ -31,7 +31,7 @@
ref="org.hisp.dhis.survey.SurveyService"/>
</bean>
-->
-
+<!--
<bean id="org.hisp.dhis.survey.action.SelectAction"
class="org.hisp.dhis.survey.action.SelectAction"
scope="prototype">
@@ -42,17 +42,19 @@
<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">
<property name="selectedStateManager"
ref="org.hisp.dhis.survey.state.SelectedStateManager"/>
<property name="surveyDataValueService"
- ref="org.hisp.dhis.surveydatavalue.SurveyDataValueService"/>
+ ref="org.hisp.dhis.surveydatavalue.SurveyDataValueService"/>
+ <property name="surveyService"
+ ref="org.hisp.dhis.survey.SurveyService"/>
</bean>
- -->
+
<bean id="org.hisp.dhis.survey.action.SaveValueAction"
class="org.hisp.dhis.survey.action.SaveValueAction"
scope="prototype">
@@ -245,6 +247,7 @@
ref="org.hisp.dhis.detarget.DeTargetService"/>
</bean>
-->
+<!--
<bean id="org.hisp.dhis.detarget.action.SelectAction"
class="org.hisp.dhis.detarget.action.SelectAction"
scope="prototype">
@@ -257,9 +260,9 @@
<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">
@@ -272,7 +275,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-10-07 12:25:01 +0000
+++ local/in/dhis-web-survey/src/main/resources/struts.xml 2012-02-17 11:32:11 +0000
@@ -113,18 +113,19 @@
<result name="success" type="redirect">select.action</result>
</action>
- <action name="select" class="org.hisp.dhis.survey.action.SelectAction">
+ <action name="select" class="org.hisp.dhis.survey.action.FormAction">
<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="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="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js,javascript/tempSurvey.js</param>
<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
- </action>
+ </action>
<!--
<action name="defaultform" class="org.hisp.dhis.survey.action.FormAction">
@@ -199,16 +200,17 @@
<result name="success" type="redirect">selectTarget.action</result>
</action>
- <action name="selectTarget" class="org.hisp.dhis.detarget.action.SelectAction">
+ <action name="selectTarget" class="org.hisp.dhis.detarget.action.FormAction">
<interceptor-ref name="organisationUnitTreeStack"/>
<result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-survey/selectTarget.vm</param>
+ <param name="page">/dhis-web-survey/targetForm.vm</param>
+ <!--<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>
+ <!--<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="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="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/form.js,javascript/tempDeTarget.js</param>
<param name="stylesheets">style/dhis-web-dataentry.css,style/custom_data_entry_form_styles.css</param>
</action>
=== modified file 'local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTree.vm'
--- local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTree.vm 2011-01-17 07:45:29 +0000
+++ local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTree.vm 2012-02-17 11:32:11 +0000
@@ -8,13 +8,31 @@
<a href="index.action"><img src="images/goback.png" width="36" height="30" alt="$i18n.getString( "go_back" )"></a>
</div>
-##parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
-#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
+#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
+##parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
+<!--
<script>
+
function organisationUnitSelected( orgUnits )
{
- window.location.href = 'select.action';
+ if(orgUnits != null && orgUnits != "" )
+ {
+ window.location.href = 'select.action';
+ }
+
+
+ //window.location.href = 'select.action';
}
- selection.setListenerFunction( organisationUnitSelected );
-</script>
\ No newline at end of file
+ selection.setListenerFunction( organisationUnitSelected );
+</script>
+
+
+
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+ selection.setListenerFunction( organisationUnitSelected );
+ });
+</script>
+
+-->
=== modified file 'local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTreeForDeTarget.vm'
--- local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTreeForDeTarget.vm 2011-01-19 13:29:17 +0000
+++ local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/menuWithTreeForDeTarget.vm 2012-02-17 11:32:11 +0000
@@ -9,6 +9,8 @@
</div>
#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
##parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
+
+<!--
<script>
function organisationUnitSelected( orgUnits )
{
@@ -17,3 +19,4 @@
selection.setListenerFunction( organisationUnitSelected );
</script>
+-->
\ No newline at end of file
=== modified file 'local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/selectTarget.vm'
--- local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/selectTarget.vm 2011-01-15 11:35:42 +0000
+++ local/in/dhis-web-survey/src/main/webapp/dhis-web-survey/selectTarget.vm 2012-02-17 11:32:11 +0000
@@ -3,7 +3,7 @@
<br>
<form id="selectForm" name="selectForm" method="post" action="selectTarget.action">
-
+<input type="hidden" name="temp" id="temp" value="deTarget">
<table>
<tr>
<td><label>$i18n.getString( "organisation_unit" )</label></td>
@@ -27,9 +27,9 @@
<tr>
<td><label for="selectedPeriodIndex">$i18n.getString( "period" )</label></td>
<td>
- <input type="button" value="<<" title="$i18n.getString('earlier_periods')" onclick="previousPeriodsSelected()"/>
- <input type="button" value=">>" title="$i18n.getString('later_periods')" onclick="nextPeriodsSelected()"/><br/>
- <select id="selectedPeriodIndex" name="selectedPeriodIndex" style="min-width:350px" onchange="document.getElementById( 'selectForm' ).submit();">
+ <input type="button" value="<<" title="$i18n.getString('earlier_periods')" onclick="previousPeriodsSelected()" #if( $periods.size() == 0 ) disabled="disabled" #end />
+ <input type="button" value=">>" title="$i18n.getString('later_periods')" onclick="nextPeriodsSelected()" #if( $periods.size() == 0 ) disabled="disabled" #end /><br/>
+ <select id="selectedPeriodIndex" name="selectedPeriodIndex" style="min-width:350px" onchange="document.getElementById( 'selectForm' ).submit();" #if( $periods.size() == 0 ) disabled="disabled" #end>
<option value="-1">[$i18n.getString( "select" )]</option>
#set( $count = 0 )
#foreach( $period in $periods )