dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31856
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16268: Added a new object called Option which replaces the current string-based options in OptionSet.
------------------------------------------------------------
revno: 16268
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-07-29 14:52:47 +0700
message:
Added a new object called Option which replaces the current string-based options in OptionSet.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/Option.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/option.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/option.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/sortOptionsForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionForm.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonOptions.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionSetForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/optionSet.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/optionSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionSetForm.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-api/src/main/java/org/hisp/dhis/option/Option.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.option;
+
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ Option.java Jul 28, 2014 4:28:53 PM $
+ */
+@JacksonXmlRootElement( localName = "option", namespace = DxfNamespaces.DXF_2_0 )
+public class Option
+ extends BaseIdentifiableObject
+{
+ public Option()
+ {
+ setAutoFields();
+ }
+
+ public Option( String name, String code )
+ {
+ setAutoFields();
+ this.name = name;
+ this.code = code;
+ }
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java 2014-07-29 07:52:47 +0000
@@ -37,7 +37,11 @@
public interface OptionService
{
final String ID = OptionService.class.getName();
-
+
+ // -------------------------------------------------------------------------
+ // OptionSet
+ // -------------------------------------------------------------------------
+
int saveOptionSet( OptionSet optionSet );
void updateOptionSet( OptionSet optionSet );
@@ -52,9 +56,9 @@
Collection<OptionSet> getAllOptionSets();
- List<String> getOptions( String optionSetUid, String key, Integer max );
+ List<Option> getOptions( String optionSetUid, String key, Integer max );
- List<String> getOptions( int optionSetId, String name, Integer max );
+ List<Option> getOptions( int optionSetId, String name, Integer max );
Integer getOptionSetsCountByName( String name );
@@ -63,4 +67,16 @@
Collection<OptionSet> getOptionSetsBetween( int first, int max );
Integer getOptionSetCount();
+
+ // -------------------------------------------------------------------------
+ // Option
+ // -------------------------------------------------------------------------
+
+ void updateOption( Option option );
+
+ Option getOption( int id );
+
+ Option getOptionByCode( String code );
+
+ Option getOptionValueByName( OptionSet optionSet, String name );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2014-06-07 13:35:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java 2014-07-29 07:52:47 +0000
@@ -33,6 +33,7 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
@@ -53,7 +54,7 @@
{
private static final Pattern OPTION_PATTERN = Pattern.compile( "\\[(.*)\\]" );
- private List<String> options = new ArrayList<>();
+ private List<Option> options = new ArrayList<Option>();
/**
* Indicating version number.
@@ -78,12 +79,12 @@
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "options", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "option", namespace = DxfNamespaces.DXF_2_0 )
- public List<String> getOptions()
+ public List<Option> getOptions()
{
return options;
}
- public void setOptions( List<String> options )
+ public void setOptions( List<Option> options )
{
this.options = options;
}
@@ -124,4 +125,14 @@
options.addAll( optionSet.getOptions() );
}
}
+
+ public List<String> getOptionValues()
+ {
+ List<String> result = new ArrayList<String>();
+ for( Option option : options )
+ {
+ result.add( option.getName() );
+ }
+ return result;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java 2014-07-29 07:52:47 +0000
@@ -39,6 +39,8 @@
*/
public interface OptionStore extends GenericIdentifiableObjectStore<OptionSet>
{
- List<String> getOptions( int optionSetId, String key, Integer max );
+ List<Option> getOptions( int optionSetId, String key, Integer max );
+
+ Option getOptionValueByName( OptionSet optionSet, String name );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java 2014-07-29 07:52:47 +0000
@@ -28,15 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.i18n.I18nService;
-import org.springframework.transaction.annotation.Transactional;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.i18n.I18nService;
+import org.springframework.transaction.annotation.Transactional;
/**
* @author Lars Helge Overland
@@ -56,6 +57,13 @@
this.optionStore = optionStore;
}
+ private GenericIdentifiableObjectStore<Option> optionValueStore;
+
+ public void setOptionValueStore( GenericIdentifiableObjectStore<Option> optionValueStore )
+ {
+ this.optionValueStore = optionValueStore;
+ }
+
private I18nService i18nService;
public void setI18nService( I18nService service )
@@ -64,7 +72,7 @@
}
// -------------------------------------------------------------------------
- // Implementation methods
+ // Implementation methods -
// -------------------------------------------------------------------------
public int saveOptionSet( OptionSet optionSet )
@@ -102,16 +110,16 @@
return i18n( i18nService, optionStore.getAll() );
}
- public List<String> getOptions( String optionSetUid, String key, Integer max )
+ public List<Option> getOptions( String optionSetUid, String key, Integer max )
{
OptionSet optionSet = getOptionSet( optionSetUid );
-
+
return getOptions( optionSet.getId(), key, max );
}
-
- public List<String> getOptions( int optionSetId, String key, Integer max )
+
+ public List<Option> getOptions( int optionSetId, String key, Integer max )
{
- List<String> options = null;
+ List<Option> options = null;
if ( key != null || max != null )
{
@@ -125,7 +133,7 @@
OptionSet optionSet = getOptionSet( optionSetId );
- options = new ArrayList<String>( optionSet.getOptions() );
+ options = new ArrayList<Option>( optionSet.getOptions() );
}
return options;
@@ -150,4 +158,28 @@
{
return optionStore.getCount();
}
+
+ // -------------------------------------------------------------------------
+ // Option
+ // -------------------------------------------------------------------------
+
+ public void updateOption( Option option )
+ {
+ optionValueStore.update( option );
+ }
+
+ public Option getOption( int id )
+ {
+ return i18n( i18nService, optionValueStore.get( id ) );
+ }
+
+ public Option getOptionByCode( String code )
+ {
+ return i18n( i18nService, optionValueStore.getByCode( code ) );
+ }
+
+ public Option getOptionValueByName( OptionSet optionSet, String name )
+ {
+ return i18n( i18nService, optionStore.getOptionValueByName( optionSet, name ) );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java 2014-07-29 07:52:47 +0000
@@ -31,7 +31,9 @@
import java.util.List;
import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.option.Option;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.option.OptionStore;
@@ -50,12 +52,12 @@
@SuppressWarnings( "unchecked" )
@Override
- public List<String> getOptions( int optionSetId, String key, Integer max )
+ public List<Option> getOptions( int optionSetId, String key, Integer max )
{
- String hql = "select option from OptionSet as optionset inner join optionset.options as option where optionset.id = :optionSetId ";
+ String hql = "select option from OptionSet as optionset join optionset.options as option where optionset.id = :optionSetId ";
if ( key != null )
{
- hql += " and lower(option) like lower('%" + key + "%') ";
+ hql += " and lower(option.name) like lower('%" + key + "%') ";
}
hql += " order by index(option)";
@@ -68,4 +70,15 @@
return query.list();
}
+
+ public Option getOptionValueByName( OptionSet optionSet, String name )
+ {
+ String hql = "select option from OptionSet as optionset join optionset.options as option where optionset = :optionSet and lower(option.name) = :name";
+
+ Query query = getQuery( hql );
+ query.setEntity( "optionSet", optionSet );
+ query.setString( "name", name );
+
+ return (Option) query.uniqueResult();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-07-17 12:43:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-07-29 07:52:47 +0000
@@ -41,6 +41,8 @@
import org.amplecode.quick.StatementManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
+import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.jdbc.batchhandler.RelativePeriodsBatchHandler;
@@ -164,7 +166,7 @@
// upgrade report table totals
executeSql( "UPDATE reporttable SET rowtotals = totals, coltotals = totals" );
executeSql( "ALTER TABLE reporttable DROP COLUMN totals" );
-
+
// mapping
executeSql( "DROP TABLE maporganisationunitrelation" );
executeSql( "ALTER TABLE mapview DROP COLUMN mapid" );
@@ -491,7 +493,7 @@
executeSql( "update chart set userorganisationunitchildren = false where userorganisationunitchildren is null" );
executeSql( "update chart set userorganisationunitgrandchildren = false where userorganisationunitgrandchildren is null" );
executeSql( "update chart set hidetitle = false where hidetitle is null" );
-
+
executeSql( "update eventreport set showhierarchy = false where showhierarchy is null" );
executeSql( "update eventreport set counttype = 'events' where counttype is null" );
@@ -709,7 +711,7 @@
executeSql( "UPDATE attribute SET userattribute=false WHERE userattribute IS NULL" );
executeSql( "UPDATE attribute SET usergroupattribute=false WHERE usergroupattribute IS NULL" );
executeSql( "UPDATE attribute SET datasetattribute=false WHERE datasetattribute IS NULL" );
-
+
executeSql( "ALTER TABLE trackedentityattributedimension DROP COLUMN operator" );
executeSql( "ALTER TABLE trackedentitydataelementdimension DROP COLUMN operator" );
@@ -728,7 +730,9 @@
upgradeTranslations();
executeSql( "ALTER TABLE dataelement DROP COLUMN active" );
-
+
+ updateOptionTbl();
+
log.info( "Tables updated" );
}
@@ -750,7 +754,8 @@
executeSql( "alter table datavalue drop constraint datavalue_pkey;" );
executeSql( "alter table datavalue add column attributeoptioncomboid integer;" );
- executeSql( "update datavalue set attributeoptioncomboid = " + optionComboId + " where attributeoptioncomboid is null;" );
+ executeSql( "update datavalue set attributeoptioncomboid = " + optionComboId
+ + " where attributeoptioncomboid is null;" );
executeSql( "alter table datavalue alter column attributeoptioncomboid set not null;" );
executeSql( "alter table datavalue add constraint fk_datavalue_attributeoptioncomboid foreign key (attributeoptioncomboid) references categoryoptioncombo (categoryoptioncomboid) match simple;" );
executeSql( "alter table datavalue add constraint datavalue_pkey primary key(dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid);" );
@@ -773,17 +778,18 @@
}
int optionComboId = getDefaultOptionCombo();
-
+
executeSql( "alter table completedatasetregistration drop constraint completedatasetregistration_pkey" );
executeSql( "alter table completedatasetregistration add column attributeoptioncomboid integer;" );
- executeSql( "update completedatasetregistration set attributeoptioncomboid = " + optionComboId + " where attributeoptioncomboid is null;" );
+ executeSql( "update completedatasetregistration set attributeoptioncomboid = " + optionComboId
+ + " where attributeoptioncomboid is null;" );
executeSql( "alter table completedatasetregistration alter column attributeoptioncomboid set not null;" );
executeSql( "alter table completedatasetregistration add constraint fk_completedatasetregistration_attributeoptioncomboid foreign key (attributeoptioncomboid) references categoryoptioncombo (categoryoptioncomboid) match simple;" );
executeSql( "alter table completedatasetregistration add constraint completedatasetregistration_pkey primary key(datasetid, periodid, sourceid, attributeoptioncomboid);" );
-
+
log.info( "Complete data set registration table upgraded with attributeoptioncomboid column" );
}
-
+
private void upgradeMapViewsToAnalyticalObject()
{
executeSql( "insert into mapview_dataelements ( mapviewid, sort_order, dataelementid ) select mapviewid, 0, dataelementid from mapview where dataelementid is not null" );
@@ -1017,7 +1023,7 @@
log.debug( ex );
}
}
-
+
private void upgradeTranslations()
{
final String sql = statementBuilder.getNumberOfColumnsInPrimaryKey( "translation" );
@@ -1028,7 +1034,7 @@
{
return; // translationid already set as single pkey
}
-
+
executeSql( statementBuilder.getDropPrimaryKey( "translation" ) );
executeSql( statementBuilder.getAddPrimaryKeyToExistingTable( "translation", "translationid" ) );
executeSql( statementBuilder.getDropNotNullConstraint( "translation", "objectid", "integer" ) );
@@ -1158,4 +1164,32 @@
return statementManager.getHolder().queryForInteger( sql );
}
+ private void updateOptionTbl()
+ {
+ executeSql( "INSERT INTO option( optionid, code, created, lastupdated, name, optionsetid, sort_order) "
+ + " select " + statementBuilder.getAutoIncrementValue() + ", optionvalue, now(), now() , optionvalue, optionsetid, ( sort_order + 1 ) "
+ + " from optionsetmembers " );
+
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+ ResultSet resultSet = statement.executeQuery( "select optionid from option where uid is null" );
+
+ while ( resultSet.next() )
+ {
+ int id = resultSet.getInt( "optionid" );
+ String uid = CodeGenerator.generateCode();
+ executeSql( "UPDATE option SET uid='" + uid + "' WHERE optionid=" + id );
+ }
+
+ executeSql( "drop table optionsetmembers" );
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-07-27 14:41:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-07-29 07:52:47 +0000
@@ -355,6 +355,11 @@
<property name="clazz" value="org.hisp.dhis.option.OptionSet" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
+
+ <bean id="org.hisp.dhis.option.OptionValueStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
+ <property name="clazz" value="org.hisp.dhis.option.Option" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ </bean>
<bean id="org.hisp.dhis.mapping.MapStore" class="org.hisp.dhis.mapping.hibernate.HibernateMapStore">
<property name="clazz" value="org.hisp.dhis.mapping.Map" />
@@ -676,6 +681,7 @@
<bean id="org.hisp.dhis.option.OptionService" class="org.hisp.dhis.option.DefaultOptionService">
<property name="optionStore" ref="org.hisp.dhis.option.OptionStore" />
+ <property name="optionValueStore" ref="org.hisp.dhis.option.OptionValueStore" />
<property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
</bean>
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/Option.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/Option.hbm.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/Option.hbm.xml 2014-07-29 07:52:47 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+ >
+
+<hibernate-mapping>
+ <class name="org.hisp.dhis.option.Option" table="option">
+
+ <cache usage="read-write" />
+
+ <id name="id" column="optionid">
+ <generator class="native" />
+ </id>
+ &identifiableProperties;
+
+ <property name="name" column="name" not-null="true" length="230" />
+
+ </class>
+</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml 2014-03-24 18:52:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/option/hibernate/OptionSet.hbm.xml 2014-07-29 07:52:47 +0000
@@ -18,12 +18,12 @@
<property name="name" column="name" not-null="true" unique="true" length="230" />
<property name="version" />
-
- <list name="options" table="optionsetmembers">
+
+ <list name="options" cascade="all">
<cache usage="read-write" />
<key column="optionsetid" foreign-key="fk_optionsetmembers_optionsetid" />
- <list-index column="sort_order" />
- <element type="text" column="optionvalue" />
+ <list-index column="sort_order" base="1" />
+ <one-to-many class="org.hisp.dhis.option.Option" />
</list>
<!-- Access properties -->
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java 2014-04-27 21:28:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java 2014-07-29 07:52:47 +0000
@@ -45,7 +45,7 @@
{
private OptionService optionService;
- private List<String> options = new ArrayList<String>();
+ private List<Option> options = new ArrayList<Option>();
private OptionSet optionSetA = new OptionSet( "OptionSetA" );
@@ -58,10 +58,15 @@
{
optionService = (OptionService) getBean( OptionService.ID );
- options.add( "OptA1" );
- options.add( "OptA2" );
- options.add( "OptB1" );
- options.add( "OptB2" );
+ Option option1 = new Option("OptA1","OptA1");
+ Option option2 = new Option("OptA2","OptA2");
+ Option option3 = new Option("OptB1","OptB1");
+ Option option4 = new Option("OptB2","OptB2");
+
+ options.add( option1);
+ options.add( option2);
+ options.add( option3);
+ options.add( option4);
optionSetA.setOptions( options );
optionSetB.setOptions( options );
@@ -113,8 +118,8 @@
{
int idA = optionService.saveOptionSet( optionSetA );
- List<String> options = optionService.getOptions( idA, "OptA", 10 );
-
+ List<Option> options = optionService.getOptions( idA, "OptA", 10 );
+
assertEquals( 2, options.size() );
options = optionService.getOptions( idA, "OptA1", 10 );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java 2014-07-27 12:20:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java 2014-07-29 07:52:47 +0000
@@ -51,6 +51,7 @@
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.expression.Operator;
+import org.hisp.dhis.option.Option;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -367,10 +368,16 @@
for ( OptionSet optionSet : listMap.keySet() )
{
List<String> options = new ArrayList<String>( listMap.get( optionSet ) );
- optionSet.setOptions( options );
+ List<Option> optionObj = new ArrayList<Option>();
+ for ( String opt : options )
+ {
+ Option option = new Option( opt, opt );
+ optionObj.add(option);
+ }
+ optionSet.setOptions( optionObj );
optionSets.add( optionSet );
}
-
+
return optionSets;
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/pdfform/DefaultPdfDataEntryFormService.java 2014-07-29 07:52:47 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.option.Option;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.period.CalendarPeriodType;
@@ -448,7 +449,7 @@
// TODO: This gets repeated <- Create an array of the
// options. and apply only once.
- List<String> options = optionService.getOptions( optionSet.getId(), query, MAX_OPTIONS_DISPLAYED );
+ List<Option> options = optionService.getOptions( optionSet.getId(), query, MAX_OPTIONS_DISPLAYED );
addCell_WithDropDownListField( table, rectangleDataElement, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, options.toArray( new String[0] ),
options.toArray( new String[0] ) );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2014-07-27 15:02:58 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2014-07-29 07:52:47 +0000
@@ -322,7 +322,7 @@
{
optionSet.setId( pa.getOptionSet().getId() );
optionSet.setName( pa.getOptionSet().getName() );
- optionSet.setOptions( pa.getOptionSet().getOptions() );
+// optionSet.setOptions( pa.getOptionSet().getOptions() );
mobileAttribute.setOptionSet( optionSet );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ModelMapping.java 2014-07-29 07:52:47 +0000
@@ -84,7 +84,7 @@
{
mobileOptionSet.setId( dhisOptionSet.getId() );
mobileOptionSet.setName( dhisOptionSet.getName() );
- mobileOptionSet.setOptions( dhisOptionSet.getOptions() );
+// mobileOptionSet.setOptions( dhisOptionSet.getOptions() );
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2014-06-21 09:56:19 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2014-07-29 07:52:47 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.option.Option;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
@@ -592,8 +593,9 @@
int index = 1;
- for ( String optionValue : dataElement.getOptionSet().getOptions() )
+ for ( Option option : dataElement.getOptionSet().getOptions() )
{
+ String optionValue = option.getName();
if ( index == 4 )
{
inputHTML += "</tr><tr>";
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-06-21 09:02:27 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-07-29 07:52:47 +0000
@@ -35,6 +35,7 @@
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.option.Option;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
@@ -342,14 +343,15 @@
{
inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
inputHtml += "<option value=\"\" selected>" + i18n.getString( "no_value" ) + "</option>";
- for ( String option : attribute.getOptionSet().getOptions() )
+ for ( Option option : attribute.getOptionSet().getOptions() )
{
- inputHtml += "<option value=\"" + option + "\" ";
- if ( option.equals( value ) )
+ String optionValue = option.getName();
+ inputHtml += "<option value=\"" + optionValue + "\" ";
+ if ( optionValue.equals( value ) )
{
inputHtml += " selected ";
}
- inputHtml += ">" + option + "</option>";
+ inputHtml += ">" + optionValue + "</option>";
}
inputHtml += "</select>";
}
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-07-08 17:16:48 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-07-29 07:52:47 +0000
@@ -193,7 +193,7 @@
emptyTable( "dataelementcategory" );
emptyTable( "dataelementcategoryoption" );
- emptyTable( "optionsetmembers" );
+ emptyTable( "option" );
emptyTable( "optionset" );
dropTable( "aggregateddatavalue" );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonOptions.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonOptions.vm 2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonOptions.vm 2014-07-29 07:52:47 +0000
@@ -1,2 +1,2 @@
-{ "options": [#foreach( $option in $options ){"o":"$option"}#if( $velocityCount < $options.size() ),#end #end]
+{ "options": [#foreach( $option in $options ){"o":"$option.name"}#if( $velocityCount < $options.size() ),#end #end]
}
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ AddOptionAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class AddOptionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private Integer optionSetId;
+
+ public void setOptionSetId( Integer optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ public Integer getOptionSetId()
+ {
+ return optionSetId;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ OptionSet optionSet = optionService.getOptionSet( optionSetId );
+
+ Option option = new Option( name, code );
+ optionSet.getOptions().add( option );
+
+ optionService.updateOptionSet( optionSet );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/AddOptionSetAction.java 2014-07-29 07:52:47 +0000
@@ -28,11 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import java.util.List;
+import com.opensymphony.xwork2.Action;
/**
* @author Chau Thu Tran
@@ -46,33 +45,22 @@
private OptionService optionService;
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
// -------------------------------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------------------------------
private String name;
- private List<String> options;
-
- // -------------------------------------------------------------------------------------------------
- // Setters
- // -------------------------------------------------------------------------------------------------
-
- public void setOptionService( OptionService optionService )
- {
- this.optionService = optionService;
- }
-
public void setName( String name )
{
this.name = name;
}
- public void setOptions( List<String> options )
- {
- this.options = options;
- }
-
// -------------------------------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------------------------------
@@ -82,7 +70,6 @@
throws Exception
{
OptionSet optionSet = new OptionSet( name );
- optionSet.setOptions( options );
optionSet.setVersion( 1 );
optionService.saveOptionSet( optionSet );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/GetOptionAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ GetOptionAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class GetOptionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private int optionId;
+
+ public void setOptionId( int optionId )
+ {
+ this.optionId = optionId;
+ }
+
+ private int optionSetId;
+
+ public void setOptionSetId( int optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ private OptionSet optionSet;
+
+ public OptionSet getOptionSet()
+ {
+ return optionSet;
+ }
+
+ private Option option;
+
+ public Option getOption()
+ {
+ return option;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ optionSet = optionService.getOptionSet( optionSetId );
+
+ option = optionService.getOption( optionId );
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/RemoveOptionAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ UpdateOptionAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class RemoveOptionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private int id;
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ private int optionSetId;
+
+ public void setOptionSetId( int optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ OptionSet optionSet = optionService.getOptionSet( optionSetId );
+
+ Option option = optionService.getOption( id );
+ optionSet.getOptions().remove( option );
+
+ optionService.updateOptionSet( optionSet );
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ SortOptionsAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class SortOptionsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private int optionSetId;
+
+ public void setOptionSetId( int optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ public int getOptionSetId()
+ {
+ return optionSetId;
+ }
+
+ private List<Integer> optionIds = new ArrayList<Integer>();
+
+ public void setOptionIds( List<Integer> optionIds )
+ {
+ this.optionIds = optionIds;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ try
+ {
+ OptionSet optionSet = optionService.getOptionSet( optionSetId );
+ // optionSet.getOptions().clear();
+ List<Option> options = new ArrayList<Option>();
+ for ( int optionId : optionIds )
+ {
+ Option option = optionService.getOption( optionId );
+ options.add( option );
+ }
+ optionSet.setOptions( options );
+ optionService.updateOptionSet( optionSet );
+ System.out.println( "\n optionSet: " + optionSet );
+
+ return SUCCESS;
+ }
+ catch ( Exception ex )
+ {
+ System.out.println( ex.getMessage() );
+ }
+ return ERROR;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ UpdateOptionAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class UpdateOptionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private int optionId;
+
+ public void setOptionId( int optionId )
+ {
+ this.optionId = optionId;
+ }
+
+ private int optionSetId;
+
+ public void setOptionSetId( int optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ public int getOptionSetId()
+ {
+ return optionSetId;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ Option option = optionService.getOption( optionId );
+ option.setName( name );
+ optionService.updateOption( option );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/UpdateOptionSetAction.java 2014-07-29 07:52:47 +0000
@@ -28,11 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
-import java.util.List;
+import com.opensymphony.xwork2.Action;
/**
* @author Chau Thu Tran
@@ -47,40 +46,29 @@
private OptionService optionService;
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
// -------------------------------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------------------------------
private Integer id;
- private String name;
-
- private List<String> options;
-
- // -------------------------------------------------------------------------------------------------
- // Setters
- // -------------------------------------------------------------------------------------------------
-
- public void setOptionService( OptionService optionService )
- {
- this.optionService = optionService;
- }
-
public void setId( Integer id )
{
this.id = id;
}
+ private String name;
+
public void setName( String name )
{
this.name = name;
}
- public void setOptions( List<String> options )
- {
- this.options = options;
- }
-
// -------------------------------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------------------------------
@@ -92,13 +80,6 @@
OptionSet optionSet = optionService.getOptionSet( id );
optionSet.setName( name );
- if ( !optionSet.getOptions().equals( options ) )
- {
- optionSet.setVersion( optionSet.getVersion() + 1 );
- }
-
- optionSet.setOptions( options );
-
optionService.updateOptionSet( optionSet );
return SUCCESS;
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/ValidateOptionAction.java 2014-07-29 07:52:47 +0000
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2004-2014, 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.
+ */
+
+package org.hisp.dhis.dataadmin.action.option;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.option.Option;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ ValidateOptionAction.java Jul 28, 2014 8:41:52 PM $
+ */
+public class ValidateOptionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------------------------------
+
+ private OptionService optionService;
+
+ public void setOptionService( OptionService optionService )
+ {
+ this.optionService = optionService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------------------------------
+
+ private int optionSetId;
+
+ public void setOptionSetId( int optionSetId )
+ {
+ this.optionSetId = optionSetId;
+ }
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ if ( name != null )
+ {
+ OptionSet optionSet = optionService.getOptionSet( optionSetId );
+
+ Option match = optionService.getOptionValueByName( optionSet, name );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "name_in_use" );
+
+ return ERROR;
+ }
+ }
+
+ if ( code != null )
+ {
+ Option match = optionService.getOptionByCode( code );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "name_in_use" );
+
+ return ERROR;
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2014-07-25 08:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2014-07-29 07:52:47 +0000
@@ -383,5 +383,43 @@
scope="prototype">
<property name="optionService" ref="org.hisp.dhis.option.OptionService" />
</bean>
+
+ <!-- Option -->
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.AddOptionAction"
+ class="org.hisp.dhis.dataadmin.action.option.AddOptionAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.RemoveOptionAction"
+ class="org.hisp.dhis.dataadmin.action.option.RemoveOptionAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.SortOptionsAction"
+ class="org.hisp.dhis.dataadmin.action.option.SortOptionsAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.UpdateOptionAction"
+ class="org.hisp.dhis.dataadmin.action.option.UpdateOptionAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.ValidateOptionAction"
+ class="org.hisp.dhis.dataadmin.action.option.ValidateOptionAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.dataadmin.action.option.GetOptionAction"
+ class="org.hisp.dhis.dataadmin.action.option.GetOptionAction"
+ scope="prototype">
+ <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
+ </bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-07-25 08:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-07-29 07:52:47 +0000
@@ -354,4 +354,9 @@
data_synchronization=Data synchronization
data_synchronization_strategy=Data synchronization strategy
enabled=Enabled
-last_success=Last success
\ No newline at end of file
+last_success=Last success
+option_management = Option management
+add_option = Add option
+edit_option = Edit option
+sort_options = Sort options
+available_options = Available options
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2014-03-24 19:03:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2014-07-29 07:52:47 +0000
@@ -648,5 +648,73 @@
<result name="success" type="velocity-json">/dhis-web-maintenance-dataadmin/jsonOptionSet.vm</result>
</action>
+ <!-- Option -->
+
+ <action name="option"
+ class="org.hisp.dhis.dataadmin.action.option.GetOptionSetAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-dataadmin/option.vm</param>
+ <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+ <param name="javascripts">javascript/option.js</param>
+ <param name="requiredAuthorities">F_OPTIONSET_MANAGEMENT</param>
+ </action>
+
+ <action name="showAddOptionForm" class="org.hisp.dhis.dataadmin.action.option.GetOptionSetAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-dataadmin/addOptionForm.vm</param>
+ <param name="javascripts">javascript/option.js</param>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
+ <action name="addOption"
+ class="org.hisp.dhis.dataadmin.action.option.AddOptionAction">
+ <result name="success" type="redirect">option.action?id=${optionSetId}</result>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
+ <action name="showUpdateOptionForm"
+ class="org.hisp.dhis.dataadmin.action.option.GetOptionAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-dataadmin/updateOptionForm.vm</param>
+ <param name="javascripts">javascript/option.js</param>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
+ <action name="updateOption"
+ class="org.hisp.dhis.dataadmin.action.option.UpdateOptionAction">
+ <result name="success" type="redirect">option.action?id=${optionSetId}</result>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
+ <action name="removeOption"
+ class="org.hisp.dhis.dataadmin.action.option.RemoveOptionAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm
+ </result>
+ <param name="requiredAuthorities">F_OPTIONSET_DELETE</param>
+ </action>
+
+ <action name="validateOption"
+ class="org.hisp.dhis.dataadmin.action.option.ValidateOptionAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm
+ </result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="sortOptionsForm" class="org.hisp.dhis.dataadmin.action.option.GetOptionSetAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-dataadmin/sortOptionsForm.vm</param>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
+ <action name="sortOptions"
+ class="org.hisp.dhis.dataadmin.action.option.SortOptionsAction">
+ <result name="success" type="redirect">option.action?id=${optionSetId}</result>
+ <param name="anyAuthorities">F_OPTIONSET_PUBLIC_ADD, F_OPTIONSET_PRIVATE_ADD</param>
+ </action>
+
</package>
</struts>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionForm.vm 2014-07-29 07:52:47 +0000
@@ -0,0 +1,45 @@
+<script type="text/javascript">
+ jQuery(document).ready( function() {
+ validation( 'addOptionForm', function(form){
+ form.submit();
+ });
+
+ checkValueIsExist( "name", "validateOption.action",{optionSetId:getFieldValue('optionSetId')});
+ checkValueIsExist( "code", "validateOption.action");
+ });
+
+</script>
+
+<h3>$i18n.getString( "add_option" )</h3>
+
+<form id="addOptionForm" name="addOptionForm" action="addOption.action" method="post" class="inputForm">
+ <input id='optionSetId' name='optionSetId' value='$optionSet.id' type='hidden'>
+ <table>
+ <colgroup>
+ <col width="50px" />
+ <col width="150px"/>
+ <col width="50px"/>
+ </colgroup>
+ <tr>
+ <th colspan='3'>$i18n.getString( "details" )</th>
+ </tr>
+ <tr>
+ <td><label for='name'>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td ><input type="text" id="name" name="name" class="{validate:{required:true,minlength:2}}" /></td>
+ </tr>
+ <tr>
+ <td><label for='code'>$i18n.getString( "code" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td ><input type="text" id="code" name="code" class="{validate:{required:true,minlength:2}}" /></td>
+ </tr>
+ <tr>
+ <td style="height:15px"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td colspan="2">
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em">
+ <input type="button" onclick="window.location.href='option.action?id=$optionSet.id'" value="$i18n.getString( 'cancel' )" style="width:10em"/></p>
+ </td>
+ </tr>
+ </table>
+</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionSetForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionSetForm.vm 2014-03-25 07:48:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addOptionSetForm.vm 2014-07-29 07:52:47 +0000
@@ -1,8 +1,7 @@
<script type="text/javascript">
jQuery(document).ready( function() {
- validation2( 'addOptionSetForm', function( form ){ form.submit() }, {
- 'beforeValidateHandler': function() { listValidator( 'memberValidator', 'options' ); },
- 'rules': getValidationRules("dateElementCategory")
+ validation( 'addOptionSetForm', function(form){
+ form.submit();
});
checkValueIsExist( "name", "validateOptionSet.action");
});
@@ -34,37 +33,6 @@
<tr>
<td colspan="4" style="height:15px"></td>
</tr>
- <tr>
- <th colspan="4">$i18n.getString( "options" )
- <select id="memberValidator" style="display:none"/></th>
- </tr>
- <tr>
- <td><label>$i18n.getString( "option" )</label></td>
- <td colspan="3"><input type="text" id="option" name="option"></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="button" value="$i18n.getString( 'add_option' )" onclick="addOption();" style="width:165px"/>
- <input type="button" value="$i18n.getString( 'update_option' )" onclick="updateOption();" style="width:165px"/>
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <table>
- <tr>
- <td>
- <select multiple size="10" id="options" name="options" onchange="setFieldValue('option', this.value);"></select>
- </td>
- <td>
- <a href="javascript:moveUpSelectedOption( 'options' )"><img src="../images/move_up.png" style='padding-left:5px;'/></a><br/><br/>
- <a href="javascript:moveDownSelectedOption( 'options' )"><img src="../images/move_down.png" style='padding-left:5px;'/></a><br/><br/>
- <a href="javascript:removeSelectedOption( 'options' )"><img src="../images/delete.png"/></a>
- </td>
- </tr>
- </table>
-
<tr>
<td></td>
<td colspan="3">
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/option.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/option.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/option.js 2014-07-29 07:52:47 +0000
@@ -0,0 +1,46 @@
+
+// -----------------------------------------------------------------------------
+// Update Option
+// -----------------------------------------------------------------------------
+
+function showUpdateOptionForm( context ) {
+ location.href = 'showUpdateOptionForm.action?optionId=' + context.id + '&optionSetId=' + getFieldValue('optionSetId');
+}
+
+// -----------------------------------------------------------------------------
+// Remove Option
+// -----------------------------------------------------------------------------
+
+function removeOptionSet( context ) {
+ removeItem(context.id, context.name, i18n_confirm_delete, 'removeOption.action?optionSetId=' + getFieldValue('optionSetId'));
+}
+
+// -----------------------------------------------------------------------------
+// Add options constant
+// -----------------------------------------------------------------------------
+
+function addOption() {
+ var value = getFieldValue('option');
+
+ if( value.length == 0 ) {
+ markInvalid('option', i18n_specify_option_name);
+ }
+ else if( listContainsById('options', value, true) ) {
+ markInvalid('option', i18n_option_name_already_exists);
+ }
+ else {
+ addOptionById('options', value, value);
+ }
+
+ setFieldValue('option', '');
+ $("#option").focus();
+}
+
+function updateOption() {
+ var value = getFieldValue('option');
+ jQuery('#options option:selected').val(value);
+ jQuery('#options option:selected').text(value);
+
+ setFieldValue('option', '');
+ $("#option").focus();
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/optionSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/optionSet.js 2014-06-13 09:05:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/optionSet.js 2014-07-29 07:52:47 +0000
@@ -16,6 +16,10 @@
});
}
+function showOptionList( context ) {
+ location.href = 'option.action?id=' + context.id;
+}
+
// -----------------------------------------------------------------------------
// Remove category constant
// -----------------------------------------------------------------------------
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/option.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/option.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/option.vm 2014-07-29 07:52:47 +0000
@@ -0,0 +1,85 @@
+
+#sharingDialog()
+
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+
+ dhis2.contextmenu.makeContextMenu({
+ menuId: 'contextMenu',
+ menuItemActiveClass: 'contextMenuItemActive'
+ });
+ });
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_constant" ) , "'")';
+</script>
+
+<h3>$i18n.getString( "option_management" )</h3>
+
+<div id="contextMenu" class="contextMenu">
+ <ul id="contextMenuItems" class="contextMenuItems">
+ <li data-enabled="canUpdate"><a data-target-fn="showUpdateOptionForm"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
+ <li data-enabled="canUpdate"><a data-target-fn="translateWithContext"><i class="fa fa-globe"></i> $i18n.getString( "translation_translate" )</a></li>
+ <li data-enabled="canDelete"><a data-target-fn="removeOptionSet"><i class="fa fa-trash-o"></i> $i18n.getString( "remove" )</a></li>
+ </ul>
+</div>
+
+<table class="mainPageTable">
+ <input id='optionSetId' name='optionSetId' value='$optionSet.id' type='hidden'>
+ <tr>
+ <td style="vertical-align:top">
+ <table width="100%">
+ <col>
+ <col width="120">
+ <tr>
+ <td>#filterDiv( "option" )</td>
+ <td colspan="3" style="text-align:right">
+ <input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddOptionForm.action?id=$optionSet.id'" style="width:150px"><br>
+ <input type="button" value="$i18n.getString( "sort_options" )" onclick="window.location.href='sortOptionsForm.action?id=$optionSet.id'" style="width:150px"><br>
+ <input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='optionSet.action'" style="width:150px">
+ </td>
+ </tr>
+ </table>
+ <table class="listTable">
+ <col/>
+ <thead>
+ <tr>
+ <th>$i18n.getString( "name" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #foreach( $option in $optionSet.options )
+ <tr id="tr${option.id}">
+ <td data-id="$!option.id" data-uid="$!option.uid" data-type="Option" data-name="$encoder.htmlEncode( $!option.displayName )"
+ data-can-manage="$security.canManage( $option )"
+ data-can-update="$security.canUpdate( $option )"
+ data-can-delete="$security.canDelete( $option )">
+ $encoder.htmlEncode( $!option.displayName )
+ </td>
+ </tr>
+ #end
+ </tbody>
+ </table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </td>
+
+ <td id="detailsData">
+
+ <div id="detailsArea">
+ <div id="hideDetailsArea">
+ <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"/></a>
+ </div>
+ <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
+ <p><label>$i18n.getString( "number_of_members" ):</label><br/><span id="optionCount"></span></p>
+ <p><label>$i18n.getString( "id" ):</label><br/><span id="idField"></span></p>
+ </div>
+
+ <div id="warningArea">
+ <div id="hideDetailsArea">
+ <a href="javascript:hideWarning()" title="$i18n.getString( 'hide_warning' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_warning' )"/></a>
+ </div>
+ <p><span id="warningField"></span></p>
+ </div>
+ </td>
+ </tr>
+</table>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/optionSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/optionSet.vm 2014-06-13 09:05:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/optionSet.vm 2014-07-29 07:52:47 +0000
@@ -18,6 +18,7 @@
<div id="contextMenu" class="contextMenu">
<ul id="contextMenuItems" class="contextMenuItems">
+ <li data-enabled="canManage"><a data-target-fn="showOptionList"><i class="fa fa-share"></i> $i18n.getString( "option_management" )</a></li>
<li data-enabled="canManage"><a data-target-fn="showSharingDialogWithContext"><i class="fa fa-share"></i> $i18n.getString( "sharing_settings" )</a></li>
<li data-enabled="canUpdate"><a data-target-fn="showUpdateOptionSetForm"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
<li data-enabled="canUpdate"><a data-target-fn="translateWithContext"><i class="fa fa-globe"></i> $i18n.getString( "translation_translate" )</a></li>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/sortOptionsForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/sortOptionsForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/sortOptionsForm.vm 2014-07-29 07:52:47 +0000
@@ -0,0 +1,39 @@
+
+<h3>$i18n.getString( "sort_options" )</h3>
+
+<h4>$optionSet.displayName</h4>
+
+<form id="sortOptionsForm" name="sortOptionsForm" action="sortOptions.action" method="get" class="inputForm" onsubmit="selectAllById('optionIds');">
+<input type="hidden" id="optionSetId" name="optionSetId" value="$optionSet.id" />
+
+<table>
+ <colgroup>
+ <col style='width:500px'/>
+ </colgroup>
+ <tr>
+ <th colspan='2'>$i18n.getString( "available_options" )</th>
+ </tr>
+
+ <tr>
+ <td>
+ <select style="height: 200px; width: 100%;" multiple="multiple" id="optionIds" name="optionIds" >
+ #foreach( $option in $optionSet.options )
+ <option value="$option.id">$encoder.htmlEncode( $!option.displayName )</option>
+ #end
+ </select>
+ </td>
+ <td>
+ <a href="javascript:moveUpSelectedOption( 'optionIds')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
+ <a href="javascript:moveDownSelectedOption( 'optionIds' )" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" alt="$i18n.getString( 'move_up' )"/></a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='option.action?id=$optionSet.id'" style="width:10em" />
+ </td>
+ </tr>
+</table>
+
+</form>
+
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionForm.vm 2014-07-29 07:52:47 +0000
@@ -0,0 +1,46 @@
+<script type="text/javascript">
+ jQuery(document).ready( function() {
+ validation( 'updateOptionForm', function(form){
+ form.submit();
+ });
+
+ checkValueIsExist( "name", "validateOption.action",{optionSetId:getFieldValue('optionSetId'), id: getFieldValue('optionId')});
+ checkValueIsExist( "code", "validateOption.action",{optionSetId:getFieldValue('optionSetId'), id: getFieldValue('optionId')});
+ });
+
+</script>
+
+<h3>$i18n.getString( "edit_option" )</h3>
+
+<form id="updateOptionForm" name="updateOptionForm" action="updateOption.action" method="post" class="inputForm">
+ <input id='optionSetId' name='optionSetId' value='$optionSet.id' type='hidden'>
+ <input id='optionId' name='optionId' value='$option.id' type='hidden'>
+ <table>
+ <colgroup>
+ <col width="50px" />
+ <col width="150px"/>
+ <col width="50px"/>
+ </colgroup>
+ <tr>
+ <th colspan='3'>$i18n.getString( "details" )</th>
+ </tr>
+ <tr>
+ <td><label for='name'>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td ><input type="text" id="name" name="name" value='$option.name' class="{validate:{required:true,minlength:2}}" /></td>
+ </tr>
+ <tr>
+ <td><label for='code'>$i18n.getString( "code" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td ><input type="text" id="code" name="code" readonly value='$option.code' class="{validate:{required:true,minlength:2}}" /></td>
+ </tr>
+ <tr>
+ <td style="height:15px"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td colspan="2">
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em">
+ <input type="button" onclick="window.location.href='option.action?id=$optionSet.id'" value="$i18n.getString( 'cancel' )" style="width:10em"/></p>
+ </td>
+ </tr>
+ </table>
+</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionSetForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionSetForm.vm 2012-10-18 13:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateOptionSetForm.vm 2014-07-29 07:52:47 +0000
@@ -6,9 +6,6 @@
checkValueIsExist( "name", "validateOptionSet.action",{id:getFieldValue('id')});
});
- var i18n_specify_option_name = '$encoder.jsEscape( $i18n.getString( "specify_option_name" ) , "'")';
- var i18n_option_name_already_exists = '$encoder.jsEscape( $i18n.getString( "option_name_already_exists" ) , "'")';
- var i18n_must_include_option = '$encoder.jsEscape( $i18n.getString( "must_include_option" ) , "'")';
</script>
<h3>$i18n.getString( "edit_option_set" )</h3>
@@ -31,36 +28,6 @@
<tr>
<td style="height:15px"></td>
</tr>
- <tr>
- <th colspan='3'>$i18n.getString( "options" )
- <select id="memberValidator" style="display:none"/></th>
- </tr>
- <tr>
- <td><label>$i18n.getString( "option" )</label></td>
- <td><input type="text" id="option" name="option"></td>
- </tr>
- <tr>
- <td></td>
- <td colspan="3">
- <input type="button" value="$i18n.getString( 'add_option' )" onclick="addOption();" style="width:165px"/>
- <input type="button" value="$i18n.getString( 'update_option' )" onclick="updateOption();" style="width:165px"/>
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <select multiple size="10" id="options" name="options" onchange="setFieldValue('option', this.value);">
- #foreach( $option in $optionSet.options )
- <option value='$option'>$option</option>
- #end
- </select>
- </td>
- <td>
- <a href="javascript:moveUpSelectedOption( 'options' )"><img src="../images/move_up.png" style='padding-left:5px;'/></a><br/><br/>
- <a href="javascript:moveDownSelectedOption( 'options' )"><img src="../images/move_down.png" style='padding-left:5px;'/></a><br/><br/>
- <a href="javascript:removeSelectedOption( 'options' )"><img src="../images/delete.png"/></a>
- </td>
- </tr>
<tr>
<td></td>
<td colspan="2">