← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18646: wip, add support for optionset in metadata attribute

 

------------------------------------------------------------
revno: 18646
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-20 14:08:50 +0700
message:
  wip, add support for optionset in metadata attribute
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ShowAddUpdateAttributeAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.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/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2015-03-20 07:08:50 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.common.MergeStrategy;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.option.OptionSet;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -89,6 +90,8 @@
 
     private Integer sortOrder;
 
+    private OptionSet optionSet;
+
     private Set<AttributeValue> attributeValues = new HashSet<>();
 
     public Attribute()
@@ -310,6 +313,32 @@
         this.trackedEntityAttributeAttribute = trackedEntityAttributeAttribute;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public OptionSet getOptionSet()
+    {
+        return optionSet;
+    }
+
+    public void setOptionSet( OptionSet optionSet )
+    {
+        this.optionSet = optionSet;
+    }
+
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public Integer getSortOrder()
+    {
+        return sortOrder;
+    }
+
+    public void setSortOrder( Integer sortOrder )
+    {
+        this.sortOrder = sortOrder;
+    }
+
     public Set<AttributeValue> getAttributeValues()
     {
         return attributeValues;
@@ -320,19 +349,6 @@
         this.attributeValues = attributeValues;
     }
 
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public Integer getSortOrder()
-    {
-        return sortOrder;
-    }
-
-    public void setSortOrder( Integer sortOrder )
-    {
-        this.sortOrder = sortOrder;
-    }
-
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml	2015-03-20 07:08:50 +0000
@@ -57,5 +57,8 @@
       <one-to-many class="AttributeValue" />
     </set>
 
+    <many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet" column="optionsetid"
+      foreign-key="fk_attribute_optionsetid" />
+
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2015-03-20 07:08:50 +0000
@@ -31,6 +31,9 @@
 import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 
 /**
@@ -43,12 +46,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private AttributeService attributeService;
 
-    public void setAttributeService( AttributeService attributeService )
-    {
-        this.attributeService = attributeService;
-    }
+    @Autowired
+    private OptionService optionService;
 
     // -------------------------------------------------------------------------
     // Input & Output
@@ -180,6 +182,13 @@
         this.trackedEntityAttributeAttribute = trackedEntityAttributeAttribute;
     }
 
+    private String optionSetUid;
+
+    public void setOptionSetUid( String optionSetUid )
+    {
+        this.optionSetUid = optionSetUid;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -187,6 +196,18 @@
     @Override
     public String execute()
     {
+        OptionSet optionSet = null;
+
+        if ( "option_set".equals( valueType ) )
+        {
+            optionSet = optionService.getOptionSet( optionSetUid );
+
+            if ( optionSet == null )
+            {
+                return INPUT;
+            }
+        }
+
         Attribute attribute = new Attribute( name, valueType );
         attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
         attribute.setMandatory( mandatory );
@@ -204,6 +225,7 @@
         attribute.setProgramStageAttribute( programStageAttribute );
         attribute.setTrackedEntityAttribute( trackedEntityAttribute );
         attribute.setTrackedEntityAttributeAttribute( trackedEntityAttributeAttribute );
+        attribute.setOptionSet( optionSet );
 
         attributeService.addAttribute( attribute );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java	2015-03-20 07:08:50 +0000
@@ -34,7 +34,7 @@
 import com.opensymphony.xwork2.Action;
 
 /**
- * @author mortenoh
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public class GetAttributeAction
     implements Action

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ShowAddUpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ShowAddUpdateAttributeAction.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/attribute/ShowAddUpdateAttributeAction.java	2015-03-20 07:08:50 +0000
@@ -0,0 +1,98 @@
+package org.hisp.dhis.dataadmin.action.attribute;
+
+/*
+ * Copyright (c) 2004-2015, 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 com.opensymphony.xwork2.Action;
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class ShowAddUpdateAttributeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    private AttributeService attributeService;
+
+    @Autowired
+    private OptionService optionService;
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private Attribute attribute;
+
+    public Attribute getAttribute()
+    {
+        return attribute;
+    }
+
+    private List<OptionSet> optionSets = new ArrayList<>();
+
+    public List<OptionSet> getOptionSets()
+    {
+        return optionSets;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        if ( id != null )
+        {
+            attribute = attributeService.getAttribute( id );
+        }
+
+        optionSets = new ArrayList<>( optionService.getAllOptionSets() );
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2015-03-20 07:08:50 +0000
@@ -28,10 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 
 /**
@@ -44,12 +46,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private AttributeService attributeService;
 
-    public void setAttributeService( AttributeService attributeService )
-    {
-        this.attributeService = attributeService;
-    }
+    @Autowired
+    private OptionService optionService;
 
     // -------------------------------------------------------------------------
     // Input & Output
@@ -159,7 +160,7 @@
     {
         this.userGroupAttribute = userGroupAttribute;
     }
-    
+
     private boolean programAttribute;
 
     public void setProgramAttribute( boolean programAttribute )
@@ -188,6 +189,13 @@
         this.trackedEntityAttributeAttribute = trackedEntityAttributeAttribute;
     }
 
+    private String optionSetUid;
+
+    public void setOptionSetUid( String optionSetUid )
+    {
+        this.optionSetUid = optionSetUid;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -199,6 +207,18 @@
 
         if ( attribute != null )
         {
+            if ( "option_set".equals( attribute.getValueType() ) )
+            {
+                OptionSet optionSet = optionService.getOptionSet( optionSetUid );
+
+                if ( optionSet == null )
+                {
+                    return INPUT;
+                }
+
+                attribute.setOptionSet( optionSet );
+            }
+
             attribute.setName( name );
             attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code );
             attribute.setValueType( valueType );

=== 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	2015-03-05 12:10:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2015-03-20 07:08:50 +0000
@@ -279,6 +279,9 @@
 
   <!-- Dynamic Attributes -->
 
+  <bean id="org.hisp.dhis.dataadmin.action.attribute.ShowAddUpdateAttributeAction"
+    class="org.hisp.dhis.dataadmin.action.attribute.ShowAddUpdateAttributeAction" />
+
   <bean id="org.hisp.dhis.dataadmin.action.attribute.GetAttributeListAction"
     class="org.hisp.dhis.dataadmin.action.attribute.GetAttributeListAction"
     scope="prototype">
@@ -306,7 +309,6 @@
   <bean id="org.hisp.dhis.dataadmin.action.attribute.AddAttributeAction"
     class="org.hisp.dhis.dataadmin.action.attribute.AddAttributeAction"
     scope="prototype">
-    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataadmin.action.attribute.SaveAttributeSortOrderAction"
@@ -318,7 +320,6 @@
   <bean id="org.hisp.dhis.dataadmin.action.attribute.UpdateAttributeAction"
     class="org.hisp.dhis.dataadmin.action.attribute.UpdateAttributeAction"
     scope="prototype">
-    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataadmin.action.attribute.RemoveAttributeAction"
@@ -331,7 +332,7 @@
 
   <bean id="org.hisp.dhis.dataadmin.action.scheduling.ScheduleTasksAction"
     class="org.hisp.dhis.dataadmin.action.scheduling.ScheduleTasksAction"
-    scope="prototype"/>
+    scope="prototype" />
 
   <!-- OptionSet -->
 
@@ -370,39 +371,39 @@
     scope="prototype">
     <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
   </bean>
-  
-   <!-- Option -->
+
+  <!-- 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"
+
+  <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">

=== 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	2015-03-13 18:32:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2015-03-20 07:08:50 +0000
@@ -502,14 +502,14 @@
       <param name="javascripts">javascript/attribute.js</param>
     </action>
 
-    <action name="showAddAttributeForm" class="org.hisp.dhis.dataadmin.action.NoAction">
+    <action name="showAddAttributeForm" class="org.hisp.dhis.dataadmin.action.attribute.ShowAddUpdateAttributeAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
       <param name="page">/dhis-web-maintenance-dataadmin/addAttributeForm.vm</param>
       <param name="requiredAuthorities">F_ATTRIBUTE_ADD</param>
     </action>
 
-    <action name="showUpdateAttributeForm" class="org.hisp.dhis.dataadmin.action.attribute.GetAttributeAction">
+    <action name="showUpdateAttributeForm" class="org.hisp.dhis.dataadmin.action.attribute.ShowAddUpdateAttributeAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
       <param name="page">/dhis-web-maintenance-dataadmin/updateAttributeForm.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2015-03-20 07:08:50 +0000
@@ -49,20 +49,20 @@
 	<tr>
 		<td style="vertical-align: text-top;">$i18n.getString( "assigned_to" )</td>
 		<td>
-            <input type="checkbox" id="dataElementAttribute" name="dataElementAttribute" value="true" /><label for="dataElementAttribute">$i18n.getString( 'data_element' )</label> <br />
-            <input type="checkbox" id="dataElementGroupAttribute" name="dataElementGroupAttribute" value="true" /><label for="dataElementGroupAttribute">$i18n.getString( 'data_element_group' )</label> <br />
-            <input type="checkbox" id="indicatorAttribute" name="indicatorAttribute" value="true" /><label for="indicatorAttribute">$i18n.getString( 'indicator' )</label> <br />
-            <input type="checkbox" id="indicatorGroupAttribute" name="indicatorGroupAttribute" value="true" /><label for="indicatorGroupAttribute">$i18n.getString( 'indicator_group' )</label> <br />
-            <input type="checkbox" id="dataSetAttribute" name="dataSetAttribute" value="true" /><label for="dataSetAttribute">$i18n.getString( 'data_set' )</label> <br />
-            <input type="checkbox" id="organisationUnitAttribute" name="organisationUnitAttribute" value="true" /><label for="organisationUnitAttribute">$i18n.getString( 'organisation_unit' )</label> <br />
-            <input type="checkbox" id="organisationUnitGroupAttribute" name="organisationUnitGroupAttribute" value="true" /><label for="organisationUnitGroupAttribute">$i18n.getString( 'organisation_unit_group' )</label> <br />
-            <input type="checkbox" id="organisationUnitGroupSetAttribute" name="organisationUnitGroupSetAttribute" value="true" /><label for="organisationUnitGroupSetAttribute">$i18n.getString( 'organisation_unit_group_set' )</label> <br />
-            <input type="checkbox" id="userAttribute" name="userAttribute" value="true" /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
-            <input type="checkbox" id="userGroupAttribute" name="userGroupAttribute" value="true" /><label for="userGroupAttribute">$i18n.getString( 'user_group' )</label> <br />
-            <input type="checkbox" id="programAttribute" name="programAttribute" value="true" /><label for="programAttribute">$i18n.getString( 'program' )</label> <br />
-            <input type="checkbox" id="programStageAttribute" name="programStageAttribute" value="true" /><label for="programStageAttribute">$i18n.getString( 'program_stage' )</label> <br />
-            <input type="checkbox" id="trackedEntityAttribute" name="trackedEntityAttribute" value="true" /><label for="trackedEntityAttribute">$i18n.getString( 'tracked_entity' )</label> <br />
-            <input type="checkbox" id="trackedEntityAttributeAttribute" name="trackedEntityAttributeAttribute" value="true" /><label for="trackedEntityAttributeAttribute">$i18n.getString( 'tracked_entity_attribute' )</label> <br />
+      <input type="checkbox" id="dataElementAttribute" name="dataElementAttribute" value="true" /><label for="dataElementAttribute">$i18n.getString( 'data_element' )</label> <br />
+      <input type="checkbox" id="dataElementGroupAttribute" name="dataElementGroupAttribute" value="true" /><label for="dataElementGroupAttribute">$i18n.getString( 'data_element_group' )</label> <br />
+      <input type="checkbox" id="indicatorAttribute" name="indicatorAttribute" value="true" /><label for="indicatorAttribute">$i18n.getString( 'indicator' )</label> <br />
+      <input type="checkbox" id="indicatorGroupAttribute" name="indicatorGroupAttribute" value="true" /><label for="indicatorGroupAttribute">$i18n.getString( 'indicator_group' )</label> <br />
+      <input type="checkbox" id="dataSetAttribute" name="dataSetAttribute" value="true" /><label for="dataSetAttribute">$i18n.getString( 'data_set' )</label> <br />
+      <input type="checkbox" id="organisationUnitAttribute" name="organisationUnitAttribute" value="true" /><label for="organisationUnitAttribute">$i18n.getString( 'organisation_unit' )</label> <br />
+      <input type="checkbox" id="organisationUnitGroupAttribute" name="organisationUnitGroupAttribute" value="true" /><label for="organisationUnitGroupAttribute">$i18n.getString( 'organisation_unit_group' )</label> <br />
+      <input type="checkbox" id="organisationUnitGroupSetAttribute" name="organisationUnitGroupSetAttribute" value="true" /><label for="organisationUnitGroupSetAttribute">$i18n.getString( 'organisation_unit_group_set' )</label> <br />
+      <input type="checkbox" id="userAttribute" name="userAttribute" value="true" /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
+      <input type="checkbox" id="userGroupAttribute" name="userGroupAttribute" value="true" /><label for="userGroupAttribute">$i18n.getString( 'user_group' )</label> <br />
+      <input type="checkbox" id="programAttribute" name="programAttribute" value="true" /><label for="programAttribute">$i18n.getString( 'program' )</label> <br />
+      <input type="checkbox" id="programStageAttribute" name="programStageAttribute" value="true" /><label for="programStageAttribute">$i18n.getString( 'program_stage' )</label> <br />
+      <input type="checkbox" id="trackedEntityAttribute" name="trackedEntityAttribute" value="true" /><label for="trackedEntityAttribute">$i18n.getString( 'tracked_entity' )</label> <br />
+      <input type="checkbox" id="trackedEntityAttributeAttribute" name="trackedEntityAttributeAttribute" value="true" /><label for="trackedEntityAttributeAttribute">$i18n.getString( 'tracked_entity_attribute' )</label> <br />
 		</td>
 	</tr>
 
@@ -77,10 +77,22 @@
 				<option value="integer" >$i18n.getString( "integer" )</option>
 				<option value="positive_integer">$i18n.getString( "positive_integer" )</option>
 				<option value="negative_integer">$i18n.getString( "negative_integer" )</option>
+				<option value="option_set">$i18n.getString( "option_set" )</option>
 			</select>
 		</td>
 	</tr>
 
+  <tr>
+    <td></td>
+    <td>
+      <select id="optionSet" name="optionSetUid" style="display: none;">
+        #foreach( $optionSet in $optionSets )
+        <option value="$optionSet.uid">$optionSet.displayName</option>
+        #end
+      </select>
+    </td>
+  </tr>
+
 	<tr>
 		<td colspan="2">
 			<br/>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.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/attribute.js	2015-03-20 07:08:50 +0000
@@ -1,18 +1,15 @@
 function onValueTypeChange( e ) {
   var val = $(this).find(":selected").val();
 
-  if( val == "multiple_choice" ) {
-    $("#memberValidator").addClass("required");
-    $("#multipleChoice").show();
-  }
-  else {
-    $("#memberValidator").removeClass("required");
-    $("#multipleChoice").hide();
+  if( val == "option_set" ) {
+    $('#optionSet').show();
+  } else {
+    $('#optionSet').hide();
   }
 }
 
 function showAttributeDetails( context ) {
-  jQuery.post('getAttribute.action', { id: context.id },
+  jQuery.post('getAttribute.action', {id: context.id},
     function( json ) {
       setInnerHTML('nameField', json.attribute.name);
       setInnerHTML('mandatoryField', json.attribute.mandatory);

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2015-03-19 03:43:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2015-03-20 07:08:50 +0000
@@ -78,9 +78,21 @@
 				<option value="integer" #if( $attribute.valueType == 'integer') selected="selected" #end>$i18n.getString( "integer" )</option>
 				<option value="positive_integer" #if( $attribute.valueType == 'positive_integer') selected="selected" #end>$i18n.getString( "positive_integer" )</option>
 				<option value="negative_integer" #if( $attribute.valueType == 'negative_integer') selected="selected" #end>$i18n.getString( "negative_integer" )</option>
-			</select>
-		</td>
-	</tr>
+				<option value="option_set" #if( $attribute.valueType == 'option_set') selected="selected" #end>$i18n.getString( "option_set" )</option>
+      </select>
+    </td>
+  </tr>
+
+  <tr>
+    <td></td>
+    <td>
+      <select id="optionSet" name="optionSetUid" style="display: none;">
+        #foreach( $optionSet in $optionSets )
+        <option value="$optionSet.uid" #if( $attribute.optionSet && $attribute.optionSet.uid == $optionSet.uid )selected="selected"#end>$optionSet.displayName</option>
+        #end
+      </select>
+    </td>
+  </tr>
 
 	<tr>
 		<td colspan="2">