dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12166
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3674: added editdataset action, removed all old chaining
------------------------------------------------------------
revno: 3674
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-05-19 19:07:20 +0200
message:
added editdataset action, removed all old chaining
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.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-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java 2011-05-19 17:07:20 +0000
@@ -0,0 +1,172 @@
+package org.hisp.dhis.dataset.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
+import org.hisp.dhis.period.OnChangePeriodType;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author mortenoh
+ */
+public class EditDataSetFormAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private Comparator<Indicator> indicatorComparator;
+
+ public void setIndicatorComparator( Comparator<Indicator> indicatorComparator )
+ {
+ this.indicatorComparator = indicatorComparator;
+ }
+
+ private Comparator<DataElement> dataElementComparator;
+
+ public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
+ {
+ this.dataElementComparator = dataElementComparator;
+ }
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & output
+ // -------------------------------------------------------------------------
+
+ private Integer dataSetId;
+
+ public void setDataSetId( Integer dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
+ private List<PeriodType> periodTypes;
+
+ public List<PeriodType> getPeriodTypes()
+ {
+ return periodTypes;
+ }
+
+ public void setPeriodTypes( List<PeriodType> periodTypes )
+ {
+ this.periodTypes = periodTypes;
+ }
+
+ private DataSet dataSet;
+
+ public DataSet getDataSet()
+ {
+ return dataSet;
+ }
+
+ private List<DataElement> dataElements;
+
+ public List<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ private List<Indicator> indicators;
+
+ public List<Indicator> getIndicators()
+ {
+ return indicators;
+ }
+
+ // -------------------------------------------------------------------------
+ // Execute
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ periodTypes = periodService.getAllPeriodTypes();
+
+ Iterator<PeriodType> iterator = periodTypes.iterator();
+
+ while ( iterator.hasNext() )
+ {
+ if ( iterator.next().getName().equalsIgnoreCase( OnChangePeriodType.NAME ) )
+ {
+ iterator.remove();
+ }
+ }
+
+ if ( dataSetId != null )
+ {
+ dataSet = dataSetService.getDataSet( dataSetId );
+ dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+ indicators = new ArrayList<Indicator>( dataSet.getIndicators() );
+ }
+
+ Collections.sort( dataElements, dataElementComparator );
+
+ Collections.sort( indicators, indicatorComparator );
+
+ displayPropertyHandler.handle( dataElements );
+
+ displayPropertyHandler.handle( indicators );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-05-16 14:25:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2011-05-19 17:07:20 +0000
@@ -253,6 +253,16 @@
<ref bean="org.hisp.dhis.dataset.DataSetService"/>
</property>
</bean>
+
+ <bean id="org.hisp.dhis.dataset.action.EditDataSetFormAction"
+ class="org.hisp.dhis.dataset.action.EditDataSetFormAction" scope="prototype">
+ <property name="dataSetService">
+ <ref bean="org.hisp.dhis.dataset.DataSetService"/>
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService"/>
+ </property>
+ </bean>
<bean id="org.hisp.dhis.dataset.action.AddDataSetAction"
class="org.hisp.dhis.dataset.action.AddDataSetAction" scope="prototype">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2011-05-19 16:20:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2011-05-19 17:07:20 +0000
@@ -139,30 +139,32 @@
<!-- Show edit DataSet form chain -->
<action name="editDataSetForm"
- class="org.hisp.dhis.dataset.action.DataElementListFilteredByGroup">
- <result name="success" type="chain">indicatorListFilteredByGroup</result>
- <param name="requiredAuthorities">F_DATASET_UPDATE</param>
- </action>
-
- <action name="indicatorListFilteredByGroup"
- class="org.hisp.dhis.dataset.action.IndicatorListFilteredByGroup">
- <result name="success" type="chain">getDataSetEditChain</result>
- <param name="requiredAuthorities">F_DATASET_UPDATE</param>
- </action>
-
- <action name="getDataSetEditChain"
- class="org.hisp.dhis.dataset.action.GetDataSetAction">
- <result name="success" type="chain">periodTypeListEditChain</result>
- <param name="requiredAuthorities">F_DATASET_UPDATE</param>
- </action>
-
- <action name="periodTypeListEditChain"
- class="org.hisp.dhis.dataset.action.PeriodTypeListAction">
+ class="org.hisp.dhis.dataset.action.EditDataSetFormAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-dataset/editDataSet.vm</param>
<param name="javascripts">javascript/shortName.js,javascript/dataSet.js</param>
<param name="requiredAuthorities">F_DATASET_UPDATE</param>
</action>
+
+<!-- <action name="indicatorListFilteredByGroup" -->
+<!-- class="org.hisp.dhis.dataset.action.IndicatorListFilteredByGroup"> -->
+<!-- <result name="success" type="chain">getDataSetEditChain</result> -->
+<!-- <param name="requiredAuthorities">F_DATASET_UPDATE</param> -->
+<!-- </action> -->
+
+<!-- <action name="getDataSetEditChain" -->
+<!-- class="org.hisp.dhis.dataset.action.GetDataSetAction"> -->
+<!-- <result name="success" type="chain">periodTypeListEditChain</result> -->
+<!-- <param name="requiredAuthorities">F_DATASET_UPDATE</param> -->
+<!-- </action> -->
+
+<!-- <action name="periodTypeListEditChain" -->
+<!-- class="org.hisp.dhis.dataset.action.PeriodTypeListAction"> -->
+<!-- <result name="success" type="velocity">/main.vm</result> -->
+<!-- <param name="page">/dhis-web-maintenance-dataset/editDataSet.vm</param> -->
+<!-- <param name="javascripts">javascript/shortName.js,javascript/dataSet.js</param> -->
+<!-- <param name="requiredAuthorities">F_DATASET_UPDATE</param> -->
+<!-- </action> -->
<!-- Validation, add, update, and delete -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-05-19 16:03:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2011-05-19 17:07:20 +0000
@@ -157,7 +157,7 @@
</td>
<td>
<select id="dataElementsSelectedList" name="dataElementsSelectedList" multiple="multiple" style="min-width:20em;height:20em">
- #foreach ( $availableDataElement in $dataSetDataElements )
+ #foreach ( $availableDataElement in $dataElements )
<option value="$availableDataElement.id">$encoder.htmlEncode( $availableDataElement.name )</option>
#end
</select>
@@ -206,7 +206,7 @@
</td>
<td>
<select id="indicatorsSelectedList" name="indicatorsSelectedList" multiple="multiple" style="min-width:20em;height:20em">
- #foreach ( $availableIndicator in $dataSetIndicators )
+ #foreach ( $availableIndicator in $indicators )
<option value="$availableIndicator.id">$encoder.htmlEncode( $availableIndicator.name )</option>
#end
</select>