dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14060
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4627: add/update attributes in DE/I/OU/U
------------------------------------------------------------
revno: 4627
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-09-21 14:46:20 +0200
message:
add/update attributes in DE/I/OU/U
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addIndicatorForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateIndicatorForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java
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/AttributeValue.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
dhis-2/dhis-support/dhis-support-system/pom.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
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/UpdateAttributeAction.java
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/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/updateAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/pom.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/AddIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ShowUpdateIndicatorFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/UpdateIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/PrepareAddOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.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 2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2011-09-21 12:46:20 +0000
@@ -47,11 +47,13 @@
private boolean mandatory;
- private boolean dataElement;
-
- private boolean indicator;
-
- private boolean organisationUnit;
+ private boolean dataElementAttribute;
+
+ private boolean indicatorAttribute;
+
+ private boolean organisationUnitAttribute;
+
+ private boolean userAttribute;
private Set<AttributeOption> attributeOptions = new HashSet<AttributeOption>();
@@ -88,34 +90,44 @@
this.mandatory = mandatory;
}
- public boolean isDataElement()
- {
- return dataElement;
- }
-
- public void setDataElement( boolean dataElement )
- {
- this.dataElement = dataElement;
- }
-
- public boolean isIndicator()
- {
- return indicator;
- }
-
- public void setIndicator( boolean indicator )
- {
- this.indicator = indicator;
- }
-
- public boolean isOrganisationUnit()
- {
- return organisationUnit;
- }
-
- public void setOrganisationUnit( boolean organisationUnit )
- {
- this.organisationUnit = organisationUnit;
+ public boolean isDataElementAttribute()
+ {
+ return dataElementAttribute;
+ }
+
+ public void setDataElementAttribute( boolean dataElementAttribute )
+ {
+ this.dataElementAttribute = dataElementAttribute;
+ }
+
+ public boolean isIndicatorAttribute()
+ {
+ return indicatorAttribute;
+ }
+
+ public void setIndicatorAttribute( boolean indicatorAttribute )
+ {
+ this.indicatorAttribute = indicatorAttribute;
+ }
+
+ public boolean isOrganisationUnitAttribute()
+ {
+ return organisationUnitAttribute;
+ }
+
+ public void setOrganisationUnitAttribute( boolean organisationUnitAttribute )
+ {
+ this.organisationUnitAttribute = organisationUnitAttribute;
+ }
+
+ public boolean isUserAttribute()
+ {
+ return userAttribute;
+ }
+
+ public void setUserAttribute( boolean userAttribute )
+ {
+ this.userAttribute = userAttribute;
}
public Set<AttributeOption> getAttributeOptions()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java 2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java 2011-09-21 12:46:20 +0000
@@ -59,4 +59,11 @@
* @return All attributes with attribute.organisationUnit = true
*/
public Set<Attribute> getOrganisationUnitAttributes();
+
+ /**
+ * Get all attributes that are enabled for users.
+ *
+ * @return All attributes with attribute.organisationUnit = true
+ */
+ public Set<Attribute> getUserAttributes();
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-08-29 21:12:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-09-21 12:46:20 +0000
@@ -33,6 +33,7 @@
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -72,7 +73,12 @@
* TODO This should have been put in UserCredentials
*/
private Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
-
+
+ /**
+ * Set of the dynamic attributes values that belong to this dataElement.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<AttributeValue>();
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
@@ -259,4 +265,14 @@
{
this.organisationUnits = organisationUnits;
}
+
+ public Set<AttributeValue> getAttributeValues()
+ {
+ return attributeValues;
+ }
+
+ public void setAttributeValues( Set<AttributeValue> attributeValues )
+ {
+ this.attributeValues = attributeValues;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java 2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java 2011-09-21 12:46:20 +0000
@@ -45,7 +45,7 @@
{
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( Attribute.class );
- criteria.add( Restrictions.eq( "dataElement", true ) );
+ criteria.add( Restrictions.eq( "dataElementAttribute", true ) );
criteria.setCacheable( true );
return new HashSet<Attribute>( criteria.list() );
@@ -56,7 +56,7 @@
{
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( Attribute.class );
- criteria.add( Restrictions.eq( "indicator", true ) );
+ criteria.add( Restrictions.eq( "indicatorAttribute", true ) );
criteria.setCacheable( true );
return new HashSet<Attribute>( criteria.list() );
@@ -67,7 +67,18 @@
{
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( Attribute.class );
- criteria.add( Restrictions.eq( "organisationUnit", true ) );
+ criteria.add( Restrictions.eq( "organisationUnitAttribute", true ) );
+ criteria.setCacheable( true );
+
+ return new HashSet<Attribute>( criteria.list() );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Set<Attribute> getUserAttributes()
+ {
+ Session session = sessionFactory.getCurrentSession();
+ Criteria criteria = session.createCriteria( Attribute.class );
+ criteria.add( Restrictions.eq( "userAttribute", true ) );
criteria.setCacheable( true );
return new HashSet<Attribute>( criteria.list() );
=== 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 2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml 2011-09-21 12:46:20 +0000
@@ -18,11 +18,13 @@
<property name="mandatory" />
- <property name="dataElement" />
-
- <property name="indicator" />
-
- <property name="organisationUnit" />
+ <property name="dataElementAttribute" />
+
+ <property name="indicatorAttribute" />
+
+ <property name="organisationUnitAttribute" />
+
+ <property name="userAttribute" />
<set name="attributeOptions" table="attributeattributeoptions">
<key column="attributeid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/AttributeValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/AttributeValue.hbm.xml 2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/AttributeValue.hbm.xml 2011-09-21 12:46:20 +0000
@@ -14,5 +14,8 @@
<property name="value" />
+ <many-to-one name="attribute" class="org.hisp.dhis.attribute.Attribute" column="attributeid"
+ foreign-key="fk_attributevalue_attributeid" />
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2011-06-11 08:15:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2011-09-21 12:46:20 +0000
@@ -29,5 +29,13 @@
foreign-key="fk_userinfo_organisationunitid" />
</set>
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="userattributevalues">
+ <cache usage="read-write" />
+ <key column="userinfoid" />
+ <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" />
+ </set>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java 2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java 2011-09-21 12:46:20 +0000
@@ -45,14 +45,14 @@
attribute1 = new Attribute();
attribute1.setName( "attribute_simple" );
attribute1.setValueType( "string" );
- attribute1.setIndicator( true );
- attribute1.setDataElement( true );
+ attribute1.setIndicatorAttribute( true );
+ attribute1.setDataElementAttribute( true );
attribute2 = new Attribute();
attribute2.setName( "attribute_with_options" );
attribute2.setValueType( "string" );
- attribute2.setOrganisationUnit( true );
- attribute2.setDataElement( true );
+ attribute2.setOrganisationUnitAttribute( true );
+ attribute2.setDataElementAttribute( true );
attribute2.addAttributeOption( new AttributeOption( "option 1" ) );
attribute2.addAttributeOption( new AttributeOption( "option 2" ) );
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml 2011-09-21 12:46:20 +0000
@@ -56,6 +56,8 @@
<cache name="org.hisp.dhis.user.User" maxElementsInMemory="200" />
+ <cache name="org.hisp.dhis.user.User.attributeValues" maxElementsInMemory="100" />
+
<cache name="org.hisp.dhis.user.UserSetting" maxElementsInMemory="200" />
<cache name="org.hisp.dhis.user.UserCredentials" maxElementsInMemory="200" />
=== modified file 'dhis-2/dhis-support/dhis-support-system/pom.xml'
--- dhis-2/dhis-support/dhis-support-system/pom.xml 2011-09-16 16:54:03 +0000
+++ dhis-2/dhis-support/dhis-support-system/pom.xml 2011-09-21 12:46:20 +0000
@@ -123,6 +123,11 @@
<groupId>velocity-tools</groupId>
<artifactId>velocity-tools</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.sf.json-lib</groupId>
+ <artifactId>json-lib</artifactId>
+ <classifier>jdk15</classifier>
+ </dependency>
</dependencies>
<properties>
<rootDir>../../</rootDir>
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java 2011-09-21 12:46:20 +0000
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.system.util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sf.json.JSONObject;
+
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.AttributeValue;
+
+/**
+ * @author mortenoh
+ */
+public class AttributeUtils
+{
+ /**
+ * Given a list of JSON formatted values (with keys: 'id' and 'value'), this
+ * method will add/update AttributeValue into the given Set.
+ *
+ * @param jsonAttributeValues List of JSON formatted values, needs two keys:
+ * id => ID of attribute this value belongs to value => Actual value
+ * @param attributeValues Set that will be updated
+ * @param attributeService
+ */
+ public static void updateAttributeValuesFromJson( Set<AttributeValue> attributeValues,
+ List<String> jsonAttributeValues, AttributeService attributeService )
+ {
+ for ( String jsonAttributeValue : jsonAttributeValues )
+ {
+ JSONObject json = JSONObject.fromObject( jsonAttributeValue );
+
+ AttributeValue attributeValue = new AttributeValue();
+ attributeValue.setId( json.getInt( "id" ) );
+ attributeValue.setValue( json.getString( "value" ) );
+
+ Attribute attribute = attributeService.getAttribute( attributeValue.getId() );
+
+ if ( attribute == null )
+ {
+ continue;
+ }
+
+ attributeValue.setAttribute( attribute );
+
+ for ( AttributeValue attributeValueItem : attributeValues )
+ {
+ if ( attributeValueItem.getAttribute().equals( attribute ) )
+ {
+ attributeValueItem.setValue( attributeValue.getValue() );
+ attributeService.updateAttributeValue( attributeValueItem );
+ attributeValue = null;
+ }
+ }
+
+ if ( attributeValue != null )
+ {
+ attributeService.addAttributeValue( attributeValue );
+ attributeValues.add( attributeValue );
+ }
+ }
+ }
+
+ /**
+ *
+ * @param attributeValues
+ * @return Map of <AttributeId, ValueString>
+ */
+ public static Map<Integer, String> getAttributeValueMap( Set<AttributeValue> attributeValues )
+ {
+ Map<Integer, String> attributeValuesMap = new HashMap<Integer, String>();
+
+ for ( AttributeValue attributeValue : attributeValues )
+ {
+ attributeValuesMap.put( attributeValue.getAttribute().getId(), attributeValue.getValue() );
+ }
+
+ return attributeValuesMap;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2011-09-21 03:42:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2011-09-21 12:46:20 +0000
@@ -156,7 +156,7 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,rangelength:[2,230]}}" style="width: 240px;" />
</td>
@@ -180,12 +180,12 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<select style="width: 244px;" id="$!args.id" name="$!name" class="{validate:{required:$args.mandatory}}">
<option value="" />
<option value="true" #if( $!args.value=="true" )selected="selected"#end>Yes</option>
- <option value="false" #if( $!args.value=="true" )selected="selected"#end>No</option>
+ <option value="false" #if( $!args.value=="false" )selected="selected"#end>No</option>
</select>
</td>
</tr>
@@ -209,12 +209,12 @@
<script type="text/javascript">
jQuery(function() {
- jQuery("#$!args.id").datepicker();
+ jQuery("#$!args.id").datepicker({ "dateFormat": "yy-mm-dd" });
});
</script>
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory}}" style="width: 240px;" />
</td>
@@ -238,7 +238,7 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,number:true}}" style="width: 240px;" />
</td>
@@ -262,7 +262,7 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,integer:true}}" style="width: 240px;" />
</td>
@@ -286,7 +286,7 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,positive_integer:true}}" style="width: 240px;" />
</td>
@@ -310,7 +310,7 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<input type="text" id="$!args.id" name="$!name" value="$!args.value" class="{validate:{required:$args.mandatory,maxlength:230,negative_integer:true}}" style="width: 240px;" />
</td>
@@ -335,12 +335,12 @@
#end
<tr>
- <td style="width: 200px;">$!args.text</td>
+ <td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
<td>
<select style="width: 244px;" id="$!args.id" name="$name" class="{validate:{required:$args.mandatory}}">
- <option value="" />
+ <option value="" #if( $choice == $args.value )selected="selected"#end />
#foreach( $choice in $args.choices )
- <option value="$choice" #if( $choice == $args.value )selected="selected"#end>$choice</option>
+ <option value="$choice" #if( $args.value == $choice )selected="selected"#end>$choice</option>
#end
</select>
</td>
@@ -349,8 +349,8 @@
#macro( tblDynamicAttributesJavascript )
var attributes = jQuery("form").find(":input[name*='attribute_']");
-var jqAttributeValues= jQuery("#attributeValues");
-jqAttributeValues.children().remove();
+var jqJsonAttributeValues= jQuery("#jsonAttributeValues");
+jqJsonAttributeValues.children().remove();
jQuery.each(attributes, function(i, item) {
var jqItem = jQuery(item);
@@ -373,7 +373,7 @@
.attr("value", json)
.attr("selected", "selected")
.text(json)
- .appendTo(jqAttributeValues);
+ .appendTo(jqJsonAttributeValues);
});
#end
@@ -385,9 +385,10 @@
*****************************************************#
#macro( tblDynamicAttributes $args )
-<select multiple="multiple" id="attributeValues" name="attributeValues" style="display: none;"></select>
+#if( $args.attributes.size() > 0 )
+<select multiple="multiple" id="jsonAttributeValues" name="jsonAttributeValues" style="display: none;"></select>
-<div id="dynamicAttributesContainer" style="margin-top: 20px;">
+<div id="dynamicAttributesContainer" style="margin-top: 10px; margin-bottom: 10px;">
<table>
#trHeader( "Dynamic Attributes" )
@@ -424,3 +425,4 @@
</table>
</div>
#end
+#end
=== 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 2011-09-08 19:22:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2011-09-21 12:46:20 +0000
@@ -79,25 +79,32 @@
this.mandatory = mandatory;
}
- private Boolean dataElement = false;
-
- public void setDataElement( Boolean dataElement )
- {
- this.dataElement = dataElement;
- }
-
- private Boolean indicator = false;
-
- public void setIndicator( Boolean indicator )
- {
- this.indicator = indicator;
- }
-
- private Boolean organisationUnit = false;
-
- public void setOrganisationUnit( Boolean organisationUnit )
- {
- this.organisationUnit = organisationUnit;
+ private Boolean dataElementAttribute = false;
+
+ public void setDataElementAttribute( Boolean dataElementAttribute )
+ {
+ this.dataElementAttribute = dataElementAttribute;
+ }
+
+ private Boolean indicatorAttribute = false;
+
+ public void setIndicatorAttribute( Boolean indicatorAttribute )
+ {
+ this.indicatorAttribute = indicatorAttribute;
+ }
+
+ private Boolean organisationUnitAttribute = false;
+
+ public void setOrganisationUnitAttribute( Boolean organisationUnitAttribute )
+ {
+ this.organisationUnitAttribute = organisationUnitAttribute;
+ }
+
+ private Boolean userAttribute = false;
+
+ public void setUserAttribute( Boolean userAttribute )
+ {
+ this.userAttribute = userAttribute;
}
private List<Integer> selectedAttributeOptions;
@@ -116,9 +123,10 @@
{
Attribute attribute = new Attribute( name, valueType );
attribute.setMandatory( mandatory );
- attribute.setDataElement( dataElement );
- attribute.setIndicator( indicator );
- attribute.setOrganisationUnit( organisationUnit );
+ attribute.setDataElementAttribute( dataElementAttribute );
+ attribute.setIndicatorAttribute( indicatorAttribute );
+ attribute.setOrganisationUnitAttribute( organisationUnitAttribute );
+ attribute.setUserAttribute( userAttribute );
Set<AttributeOption> attributeOptions = new HashSet<AttributeOption>();
=== 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 2011-09-08 19:22:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2011-09-21 12:46:20 +0000
@@ -87,27 +87,34 @@
this.mandatory = mandatory;
}
- private Boolean dataElement = false;
-
- public void setDataElement( Boolean dataElement )
- {
- this.dataElement = dataElement;
- }
-
- private Boolean indicator = false;
-
- public void setIndicator( Boolean indicator )
- {
- this.indicator = indicator;
- }
-
- private Boolean organisationUnit = false;
-
- public void setOrganisationUnit( Boolean organisationUnit )
- {
- this.organisationUnit = organisationUnit;
- }
-
+ private Boolean dataElementAttribute = false;
+
+ public void setDataElementAttribute( Boolean dataElementAttribute )
+ {
+ this.dataElementAttribute = dataElementAttribute;
+ }
+
+ private Boolean indicatorAttribute = false;
+
+ public void setIndicatorAttribute( Boolean indicatorAttribute )
+ {
+ this.indicatorAttribute = indicatorAttribute;
+ }
+
+ private Boolean organisationUnitAttribute = false;
+
+ public void setOrganisationUnitAttribute( Boolean organisationUnitAttribute )
+ {
+ this.organisationUnitAttribute = organisationUnitAttribute;
+ }
+
+ private Boolean userAttribute = false;
+
+ public void setUserAttribute( Boolean userAttribute )
+ {
+ this.userAttribute = userAttribute;
+ }
+
private List<Integer> selectedAttributeOptions = new ArrayList<Integer>();
public void setSelectedAttributeOptions( List<Integer> selectedAttributeOptions )
@@ -129,9 +136,10 @@
attribute.setName( name );
attribute.setValueType( valueType );
attribute.setMandatory( mandatory );
- attribute.setDataElement( dataElement );
- attribute.setIndicator( indicator );
- attribute.setOrganisationUnit( organisationUnit );
+ attribute.setDataElementAttribute( dataElementAttribute );
+ attribute.setIndicatorAttribute( indicatorAttribute );
+ attribute.setOrganisationUnitAttribute( organisationUnitAttribute );
+ attribute.setUserAttribute( userAttribute );
Set<AttributeOption> attributeOptions = new HashSet<AttributeOption>();
=== 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 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2011-09-21 12:46:20 +0000
@@ -346,6 +346,10 @@
mandatory = Mandatory
indicator = Indicator
organisation_unit = Organisation Unit
+user = User
+integer = Integer
+positive_integer = Positive Integer
+negative_integer = Negative Integer
create_new_attribute = Add Attribute
edit_attribute = Edit Attribute
create_new_attribute_option = Add Attribute Option
=== 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 2011-09-19 07:44:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2011-09-21 12:46:20 +0000
@@ -58,9 +58,10 @@
<tr>
<td style="vertical-align: text-top;">$i18n.getString( "assigned_to" )</td>
<td>
- <input type="checkbox" id="dataElement" name="dataElement" value="true" /><label for="dataElement">$i18n.getString( 'data_element' )</label> <br />
- <input type="checkbox" id="indicator" name="indicator" value="true" /><label for="indicator">$i18n.getString( 'indicator' )</label> <br />
- <input type="checkbox" id="organisationUnit" name="organisationUnit" value="true" /><label for="organisationUnit">$i18n.getString( 'organisation_unit' )</label> <br />
+ <input type="checkbox" id="dataElementAttribute" name="dataElementAttribute" value="true" /><label for="dataElementAttribute">$i18n.getString( 'data_element' )</label> <br />
+ <input type="checkbox" id="indicatorAttribute" name="indicatorAttribute" value="true" /><label for="indicatorAttribute">$i18n.getString( 'indicator' )</label> <br />
+ <input type="checkbox" id="organisationUnitAttribute" name="organisationUnitAttribute" value="true" /><label for="organisationUnitAttribute">$i18n.getString( 'organisation_unit' )</label> <br />
+ <input type="checkbox" id="userAttribute" name="userAttribute" value="true" /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
</td>
</tr>
=== 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 2011-09-19 07:44:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2011-09-21 12:46:20 +0000
@@ -59,9 +59,10 @@
<tr>
<td style="vertical-align: text-top;">$i18n.getString( "assigned_to" )</td>
<td>
- <input type="checkbox" id="dataElement" name="dataElement" value="true" #if( $attribute.dataElement ) checked="checked" #end /><label for="dataElement">$i18n.getString( 'data_element' )</label> <br />
- <input type="checkbox" id="indicator" name="indicator" value="true" #if( $attribute.indicator ) checked="checked" #end /><label for="indicator">$i18n.getString( 'indicator' )</label> <br />
- <input type="checkbox" id="organisationUnit" name="organisationUnit" value="true" #if( $attribute.organisationUnit ) checked="checked" #end /><label for="organisationUnit">$i18n.getString( 'organisation_unit' )</label> <br />
+ <input type="checkbox" id="dataElementAttribute" name="dataElementAttribute" value="true" #if( $attribute.dataElementAttribute ) checked="checked" #end /><label for="dataElementAttribute">$i18n.getString( 'data_element' )</label> <br />
+ <input type="checkbox" id="indicatorAttribute" name="indicatorAttribute" value="true" #if( $attribute.indicatorAttribute ) checked="checked" #end /><label for="indicatorAttribute">$i18n.getString( 'indicator' )</label> <br />
+ <input type="checkbox" id="organisationUnitAttribute" name="organisationUnitAttribute" value="true" #if( $attribute.organisationUnitAttribute ) checked="checked" #end /><label for="organisationUnitAttribute">$i18n.getString( 'organisation_unit' )</label> <br />
+ <input type="checkbox" id="userAttribute" name="userAttribute" value="true" #if( $attribute.userAttribute ) checked="checked" #end /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
</td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/pom.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/pom.xml 2011-08-28 17:52:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/pom.xml 2011-09-21 12:46:20 +0000
@@ -1,26 +1,25 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
+
<parent>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web-maintenance</artifactId>
<version>2.5-SNAPSHOT</version>
</parent>
-
+
<artifactId>dhis-web-maintenance-datadictionary</artifactId>
<packaging>war</packaging>
<name>DHIS Data Dictionary</name>
-
+
<build>
<finalName>dhis-web-maintenance-datadictionary</finalName>
</build>
-
+
<dependencies>
-
+
<!-- DHIS -->
-
+
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-api</artifactId>
@@ -46,13 +45,13 @@
<artifactId>dhis-web-commons-resources</artifactId>
<type>war</type>
</dependency>
-
+
<!-- Other -->
-
+
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
@@ -62,6 +61,7 @@
<artifactId>xpp3</artifactId>
</dependency>
</dependencies>
+
<properties>
<rootDir>../../../</rootDir>
</properties>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2011-09-20 14:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2011-09-21 12:46:20 +0000
@@ -31,10 +31,12 @@
import java.util.Collection;
import java.util.List;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.system.util.ConversionUtils;
import com.opensymphony.xwork2.Action;
@@ -63,6 +65,13 @@
this.dataElementCategoryService = dataElementCategoryService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -165,11 +174,11 @@
this.zeroIsSignificant = zeroIsSignificant;
}
- private List<String> attributeValues;
+ private List<String> jsonAttributeValues;
- public void setAttributeValues( List<String> attributeValues )
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
{
- this.attributeValues = attributeValues;
+ this.jsonAttributeValues = jsonAttributeValues;
}
// -------------------------------------------------------------------------
@@ -224,13 +233,11 @@
dataElement.setZeroIsSignificant( zeroIsSignificant );
+ AttributeUtils.updateAttributeValuesFromJson( dataElement.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
dataElementService.addDataElement( dataElement );
- for ( String attributeValue : attributeValues )
- {
- System.out.println( attributeValue );
- }
-
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java 2011-09-20 14:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java 2011-09-21 12:46:20 +0000
@@ -36,7 +36,6 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.attribute.comparator.AttributeNameComparator;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -46,6 +45,7 @@
import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboNameComparator;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
@@ -186,13 +186,7 @@
Collections.sort( attributes, new AttributeNameComparator() );
- List<AttributeValue> dataElementAttributeValues = new ArrayList<AttributeValue>(
- dataElement.getAttributeValues() );
-
- for ( AttributeValue attributeValue : dataElementAttributeValues )
- {
- attributeValues.put( attributeValue.getId(), attributeValue.getValue() );
- }
+ attributeValues = AttributeUtils.getAttributeValueMap( dataElement.getAttributeValues() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java 2011-09-20 14:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java 2011-09-21 12:46:20 +0000
@@ -32,12 +32,14 @@
import java.util.List;
import java.util.Set;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.system.util.ConversionUtils;
import com.opensymphony.xwork2.Action;
@@ -73,6 +75,13 @@
this.dataSetService = dataSetService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -189,11 +198,11 @@
this.zeroIsSignificant = zeroIsSignificant;
}
- private List<String> attributeValues;
+ private List<String> jsonAttributeValues;
- public void setAttributeValues( List<String> attributeValues )
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
{
- this.attributeValues = attributeValues;
+ this.jsonAttributeValues = jsonAttributeValues;
}
// -------------------------------------------------------------------------
@@ -253,6 +262,7 @@
dataElement.setZeroIsSignificant( zeroIsSignificant );
Set<DataSet> dataSets = dataElement.getDataSets();
+
for ( DataSet dataSet : dataSets )
{
if ( dataSet.getMobile() != null && dataSet.getMobile() )
@@ -262,13 +272,11 @@
}
}
+ AttributeUtils.updateAttributeValuesFromJson( dataElement.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
dataElementService.updateDataElement( dataElement );
- for ( String attributeValue : attributeValues )
- {
- System.out.println( attributeValue );
- }
-
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/AddIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/AddIndicatorAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/AddIndicatorAction.java 2011-09-21 12:46:20 +0000
@@ -27,15 +27,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.List;
+
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
/**
* @author Torgeir Lorange Ostby
- * @version $Id: AddIndicatorAction.java 5164 2008-05-16 12:23:58Z larshelg $
*/
public class AddIndicatorAction
implements Action
@@ -50,7 +53,14 @@
{
this.indicatorService = indicatorService;
}
-
+
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -89,7 +99,7 @@
{
this.description = description;
}
-
+
private boolean annualized;
public void setAnnualized( boolean annualized )
@@ -103,21 +113,21 @@
{
this.indicatorTypeId = indicatorTypeId;
}
-
+
private String url;
public void setUrl( String url )
{
this.url = url;
}
-
+
private String numerator;
public void setNumerator( String numerator )
{
this.numerator = numerator;
}
-
+
private String numeratorDescription;
public void setNumeratorDescription( String numeratorDescription )
@@ -153,6 +163,13 @@
this.denominatorAggregationOperator = denominatorAggregationOperator;
}
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -170,14 +187,14 @@
{
code = null;
}
-
+
if ( description != null && description.trim().length() == 0 )
{
description = null;
}
-
+
Indicator indicator = new Indicator();
-
+
indicator.setName( name );
indicator.setAlternativeName( alternativeName );
indicator.setShortName( shortName );
@@ -192,7 +209,10 @@
indicator.setDenominator( denominator );
indicator.setDenominatorDescription( denominatorDescription );
indicator.setDenominatorAggregationOperator( denominatorAggregationOperator );
-
+
+ AttributeUtils.updateAttributeValuesFromJson( indicator.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
indicatorService.addIndicator( indicator );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ShowUpdateIndicatorFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ShowUpdateIndicatorFormAction.java 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ShowUpdateIndicatorFormAction.java 2011-09-21 12:46:20 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.indicator.comparator.IndicatorTypeNameComparator;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
@@ -109,11 +110,18 @@
return indicatorTypes;
}
- public Map<Attribute, AttributeValue> attributeMap = new HashMap<Attribute, AttributeValue>();
-
- public Map<Attribute, AttributeValue> getAttributeMap()
- {
- return attributeMap;
+ private List<Attribute> attributes;
+
+ public List<Attribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public Map<Integer, String> attributeValues = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getAttributeValues()
+ {
+ return attributeValues;
}
// -------------------------------------------------------------------------
@@ -135,27 +143,11 @@
Collections.sort( indicatorTypes, new IndicatorTypeNameComparator() );
- List<AttributeValue> indicatorAttributeValues = new ArrayList<AttributeValue>( indicator.getAttributeValues() );
-
- List<Attribute> attributes = new ArrayList<Attribute>( attributeService.getIndicatorAttributes() );
+ attributes = new ArrayList<Attribute>( attributeService.getIndicatorAttributes() );
Collections.sort( attributes, new AttributeNameComparator() );
- // TODO fix this.. quite ugly and slow
- for ( Attribute key : attributes )
- {
- AttributeValue value = null;
-
- for ( AttributeValue av : indicatorAttributeValues )
- {
- if ( value.getAttribute().equals( key ) )
- {
- value = av;
- }
- }
-
- attributeMap.put( key, value );
- }
+ attributeValues = AttributeUtils.getAttributeValueMap( indicator.getAttributeValues() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/UpdateIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/UpdateIndicatorAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/UpdateIndicatorAction.java 2011-09-21 12:46:20 +0000
@@ -27,15 +27,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.List;
+
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
/**
* @author Torgeir Lorange Ostby
- * @version $Id: UpdateIndicatorAction.java 5164 2008-05-16 12:23:58Z larshelg $
*/
public class UpdateIndicatorAction
implements Action
@@ -50,7 +53,14 @@
{
this.indicatorService = indicatorService;
}
-
+
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -117,14 +127,14 @@
{
this.url = url;
}
-
+
private String numerator;
public void setNumerator( String numerator )
{
this.numerator = numerator;
}
-
+
private String numeratorDescription;
public void setNumeratorDescription( String numeratorDescription )
@@ -159,7 +169,14 @@
{
this.denominatorAggregationOperator = denominatorAggregationOperator;
}
-
+
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -167,7 +184,7 @@
public String execute()
{
Indicator indicator = indicatorService.getIndicator( id );
-
+
IndicatorType indicatorType = indicatorService.getIndicatorType( indicatorTypeId );
if ( alternativeName != null && alternativeName.trim().length() == 0 )
@@ -184,7 +201,7 @@
{
description = null;
}
-
+
indicator.setName( name );
indicator.setAlternativeName( alternativeName );
indicator.setShortName( shortName );
@@ -199,7 +216,10 @@
indicator.setDenominator( denominator );
indicator.setDenominatorDescription( denominatorDescription );
indicator.setDenominatorAggregationOperator( denominatorAggregationOperator );
-
+
+ AttributeUtils.updateAttributeValuesFromJson( indicator.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
indicatorService.updateIndicator( indicator );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java 2011-09-21 12:46:20 +0000
@@ -43,8 +43,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: GetIndicatorTypeListAction.java 3305 2007-05-14 18:55:52Z
- * larshelg $
*/
public class GetIndicatorTypeListAction
extends ActionPagingSupport<IndicatorType>
@@ -90,20 +88,20 @@
return key;
}
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
private List<Attribute> attributes;
-
+
public List<Attribute> getAttributes()
{
return attributes;
}
- public void setKey( String key )
- {
- this.key = key;
- }
-
// -------------------------------------------------------------------------
- // Action implemantation
+ // Action implementation
// -------------------------------------------------------------------------
public String execute()
@@ -125,7 +123,7 @@
Collections.sort( indicatorTypes, new IndicatorTypeNameComparator() );
- attributes = new ArrayList<Attribute>( attributeService.getDataElementAttributes() );
+ attributes = new ArrayList<Attribute>( attributeService.getIndicatorAttributes() );
Collections.sort( attributes, new AttributeNameComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml 2011-09-21 12:46:20 +0000
@@ -85,6 +85,7 @@
<property name="dataElementCategoryService">
<ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dd.action.dataelement.UpdateDataElementAction" class="org.hisp.dhis.dd.action.dataelement.UpdateDataElementAction"
@@ -98,6 +99,7 @@
<property name="dataSetService">
<ref bean="org.hisp.dhis.dataset.DataSetService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dd.action.dataelement.ShowUpdateDataElementFormAction" class="org.hisp.dhis.dd.action.dataelement.ShowUpdateDataElementFormAction"
@@ -451,38 +453,30 @@
<bean id="org.hisp.dhis.dd.action.indicator.RemoveIndicatorAction" class="org.hisp.dhis.dd.action.indicator.RemoveIndicatorAction"
scope="prototype">
- <property name="indicatorService">
- <ref bean="org.hisp.dhis.indicator.IndicatorService" />
- </property>
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
</bean>
<bean id="org.hisp.dhis.dd.action.indicator.AddIndicatorAction" class="org.hisp.dhis.dd.action.indicator.AddIndicatorAction"
scope="prototype">
- <property name="indicatorService">
- <ref bean="org.hisp.dhis.indicator.IndicatorService" />
- </property>
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dd.action.indicator.ShowUpdateIndicatorFormAction" class="org.hisp.dhis.dd.action.indicator.ShowUpdateIndicatorFormAction"
scope="prototype">
- <property name="indicatorService">
- <ref bean="org.hisp.dhis.indicator.IndicatorService" />
- </property>
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dd.action.indicator.UpdateIndicatorAction" class="org.hisp.dhis.dd.action.indicator.UpdateIndicatorAction"
scope="prototype">
- <property name="indicatorService">
- <ref bean="org.hisp.dhis.indicator.IndicatorService" />
- </property>
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dd.action.indicator.ValidateIndicatorAction" class="org.hisp.dhis.dd.action.indicator.ValidateIndicatorAction"
scope="prototype">
- <property name="indicatorService">
- <ref bean="org.hisp.dhis.indicator.IndicatorService" />
- </property>
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
</bean>
<!-- DataDictionary -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2011-09-08 19:46:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2011-09-21 12:46:20 +0000
@@ -272,8 +272,7 @@
</action>
<action name="addIndicator" class="org.hisp.dhis.dd.action.indicator.AddIndicatorAction">
- <result name="success" type="redirect">indicator.action
- </result>
+ <result name="success" type="redirect">indicator.action</result>
<param name="requiredAuthorities">F_INDICATOR_ADD</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorForm.vm 2011-05-13 01:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorForm.vm 2011-09-21 12:46:20 +0000
@@ -1,5 +1,22 @@
-<script type="text/javascript" src="javascript/addIndicatorForm.js"></script>
<script type="text/javascript">
+ jQuery( document ).ready( function()
+ {
+ validation2( 'addIndicatorForm', function( form )
+ {
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function() {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : getValidationRules( "indicator" )
+ } );
+
+ checkValueIsExist( "name", "validateIndicator.action" );
+ checkValueIsExist( "shortName", "validateIndicator.action" );
+ checkValueIsExist( "alternativeName", "validateIndicator.action" );
+ checkValueIsExist( "code", "validateIndicator.action" );
+ } );
+
var previousName = '';
</script>
@@ -77,16 +94,15 @@
<input type="hidden" id="denominator" name="denominator" class="{validate:{required:true}}"/>
</td>
</tr>
- <tr>
- <td height="20px"></td>
- <td></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicator.action'" style="width:10em"/></td>
- </tr>
</table>
+#tblDynamicAttributes( { "attributes": $attributes } )
+
+<p>
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicator.action'" style="width:10em"/>
+</p>
+
</form>
#parse( "/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm" )
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addIndicatorForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addIndicatorForm.js 2011-06-22 18:53:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addIndicatorForm.js 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-jQuery( document ).ready( function()
-{
- validation2( 'addIndicatorForm', function( form )
- {
- form.submit();
- }, {
- 'rules' : getValidationRules( "indicator" )
- } );
-
- checkValueIsExist( "name", "validateIndicator.action" );
- checkValueIsExist( "shortName", "validateIndicator.action" );
- checkValueIsExist( "alternativeName", "validateIndicator.action" );
- checkValueIsExist( "code", "validateIndicator.action" );
-} );
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateIndicatorForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateIndicatorForm.js 2011-06-22 18:53:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateIndicatorForm.js 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-jQuery( document ).ready( function()
-{
- validation2( 'updateIndicatorForm', function( form )
- {
- form.submit();
- }, {
- 'rules' : getValidationRules( "indicator" )
- } );
-
- checkValueIsExist( "name", "validateIndicator.action", {
- id : getFieldValue( 'id' )
- } );
- checkValueIsExist( "shortName", "validateIndicator.action", {
- id : getFieldValue( 'id' )
- } );
- checkValueIsExist( "alternativeName", "validateIndicator.action", {
- id : getFieldValue( 'id' )
- } );
- checkValueIsExist( "code", "validateIndicator.action", {
- id : getFieldValue( 'id' )
- } );
-} );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorForm.vm 2011-05-13 01:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorForm.vm 2011-09-21 12:46:20 +0000
@@ -1,4 +1,23 @@
-<script type="text/javascript" src="javascript/updateIndicatorForm.js"></script>
+<script type="text/javascript">
+ jQuery( document ).ready( function()
+ {
+ validation2( 'updateIndicatorForm', function( form )
+ {
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function() {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : getValidationRules( "indicator" )
+ } );
+
+ checkValueIsExist( "name", "validateIndicator.action", { id : getFieldValue( 'id' ) } );
+ checkValueIsExist( "shortName", "validateIndicator.action", { id : getFieldValue( 'id' ) } );
+ checkValueIsExist( "alternativeName", "validateIndicator.action", { id : getFieldValue( 'id' ) } );
+ checkValueIsExist( "code", "validateIndicator.action", { id : getFieldValue( 'id' ) } );
+ } );
+</script>
+
<h3>$i18n.getString( "edit_indicator" )</h3>
@@ -76,15 +95,15 @@
<input type="hidden" id="denominatorFormula" name="denominatorFormula" value="$!indicator.denominator"/>
</td>
</tr>
- <tr>
- <td height="20px"></td>
- <td></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" value="$i18n.getString( 'save' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicator.action'" style="width:10em"/></td>
- </tr>
</table>
+
+#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } )
+
+<p>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicator.action'" style="width:10em"/>
+</p>
+
</form>
-#parse( "/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm" )
\ No newline at end of file
+#parse( "/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm" )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2011-08-15 08:17:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2011-09-21 12:46:20 +0000
@@ -32,7 +32,9 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -40,6 +42,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
@@ -88,8 +91,15 @@
this.dataSetService = dataSetService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
- // Input
+ // Input & Output
// -------------------------------------------------------------------------
private String name;
@@ -190,10 +200,6 @@
this.selectedGroups = selectedGroups;
}
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
private Integer organisationUnitId;
public Integer getOrganisationUnitId()
@@ -201,6 +207,13 @@
return organisationUnitId;
}
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -235,7 +248,7 @@
parent = selectionManager.getRootOrganisationUnitsParent();
}
-
+
// ---------------------------------------------------------------------
// Create organisation unit
// ---------------------------------------------------------------------
@@ -261,17 +274,21 @@
// updated on both sides (and this side is inverse)
// ---------------------------------------------------------------------
+ AttributeUtils.updateAttributeValuesFromJson( organisationUnit.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
organisationUnitId = organisationUnitService.addOrganisationUnit( organisationUnit );
for ( String id : dataSets )
{
organisationUnit.addDataSet( dataSetService.getDataSet( Integer.parseInt( id ) ) );
}
-
+
for ( String id : selectedGroups )
{
- OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( id ) );
-
+ OrganisationUnitGroup group = organisationUnitGroupService
+ .getOrganisationUnitGroup( Integer.parseInt( id ) );
+
if ( group != null )
{
group.addOrganisationUnit( organisationUnit );
@@ -280,7 +297,7 @@
}
organisationUnitService.updateOrganisationUnit( organisationUnit );
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2011-09-21 12:46:20 +0000
@@ -35,7 +35,6 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.attribute.comparator.AttributeNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -45,6 +44,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
@@ -87,7 +87,7 @@
}
// -------------------------------------------------------------------------
- // Input/output
+ // Input & Output
// -------------------------------------------------------------------------
private Integer id;
@@ -132,11 +132,18 @@
return groupSets;
}
- public Map<Attribute, AttributeValue> attributeMap = new HashMap<Attribute, AttributeValue>();
-
- public Map<Attribute, AttributeValue> getAttributeMap()
- {
- return attributeMap;
+ private List<Attribute> attributes;
+
+ public List<Attribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public Map<Integer, String> attributeValues = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getAttributeValues()
+ {
+ return attributeValues;
}
// -------------------------------------------------------------------------
@@ -158,28 +165,11 @@
groupSets = new ArrayList<OrganisationUnitGroupSet>(
organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSetsWithMembers() );
- List<AttributeValue> organisationUnitAttributeValues = new ArrayList<AttributeValue>(
- organisationUnit.getAttributeValues() );
-
- List<Attribute> attributes = new ArrayList<Attribute>( attributeService.getOrganisationUnitAttributes() );
+ attributes = new ArrayList<Attribute>( attributeService.getDataElementAttributes() );
Collections.sort( attributes, new AttributeNameComparator() );
- // TODO fix this.. quite ugly and slow
- for ( Attribute key : attributes )
- {
- AttributeValue value = null;
-
- for ( AttributeValue av : organisationUnitAttributeValues )
- {
- if ( value.getAttribute().equals( key ) )
- {
- value = av;
- }
- }
-
- attributeMap.put( key, value );
- }
+ attributeValues = AttributeUtils.getAttributeValueMap( organisationUnit.getAttributeValues() );
Collections.sort( availableDataSets, new DataSetNameComparator() );
Collections.sort( dataSets, new DataSetNameComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/PrepareAddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/PrepareAddOrganisationUnitAction.java 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/PrepareAddOrganisationUnitAction.java 2011-09-21 12:46:20 +0000
@@ -76,9 +76,9 @@
{
this.attributeService = attributeService;
}
-
+
// -------------------------------------------------------------------------
- // Output
+ // Input & Output
// -------------------------------------------------------------------------
private Date defaultDate;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2011-09-07 14:22:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2011-09-21 12:46:20 +0000
@@ -36,6 +36,7 @@
import java.util.List;
import java.util.Set;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18nFormat;
@@ -44,6 +45,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
@@ -85,8 +87,15 @@
this.dataSetService = dataSetService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
- // Input
+ // Input & Output
// -------------------------------------------------------------------------
private Integer id;
@@ -220,6 +229,13 @@
this.orgUnitGroups = orgUnitGroups;
}
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -273,6 +289,9 @@
organisationUnit.setEmail( email );
organisationUnit.setPhoneNumber( phoneNumber );
+ AttributeUtils.updateAttributeValuesFromJson( organisationUnit.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
Set<DataSet> sets = new HashSet<DataSet>();
for ( String id : dataSets )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2011-09-21 12:46:20 +0000
@@ -49,6 +49,7 @@
<property name="selectionManager">
<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction" class="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction"
@@ -82,6 +83,7 @@
<property name="dataSetService">
<ref bean="org.hisp.dhis.dataset.DataSetService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.RemoveOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.RemoveOrganisationUnitAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2011-09-15 03:25:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2011-09-21 12:46:20 +0000
@@ -1,5 +1,22 @@
-<script type="text/javascript" src="javascript/addOrganisationUnitForm.js"></script>
<script type="text/javascript">
+ jQuery(document).ready(function() {
+ validation2('addOrganisationUnitForm', function(form) {
+ selectAllById("dataSets");
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : getValidationRules("organisationUnit")
+ });
+
+ checkValueIsExist("name", "validateOrganisationUnit.action");
+ datePickerValid('openingDate', false);
+
+ jQuery("#name").focus();
+ });
+
var previousName = '';
var adding_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "adding_the_org_unit_failed" ) , "'" )';
</script>
@@ -13,7 +30,7 @@
<th colspan="2">$i18n.getString( "details" )</th>
</tr>
<tr>
- <td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td style="width:200px"><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="name" name="name" onchange="nameChanged()" style="width:20em"/></td>
</tr>
<tr>
@@ -73,14 +90,16 @@
<td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td><input type="text" id="phoneNumber" name="phoneNumber" style="width:20em"/></td>
</tr>
- <tr>
- <td style="height:15px" colspan="2">
- </tr>
+</table>
+
+#tblDynamicAttributes( { "attributes": $attributes } )
+
+<table>
<tr>
<th colspan="2">$i18n.getString( "data_sets" )</th>
</tr>
<tr>
- <td><label for="availableDataSets">$i18n.getString( "available_data_sets" )</label></td>
+ <td style="width:200px"><label for="availableDataSets">$i18n.getString( "available_data_sets" )</label></td>
<td><select multiple id="availableDataSets" size="5" style="width:20em" ondblclick="moveSelectedById( 'availableDataSets', 'dataSets' )">
#foreach( $dataSet in $dataSets )
<option value="${dataSet.id}">$encoder.htmlEncode( $dataSet.name )</option>
@@ -94,13 +113,16 @@
<input type="button" value="$i18n.getString( 'remove' )" style="width:120px" onclick="moveSelectedById( 'dataSets', 'availableDataSets' )"/>
</td>
</tr>
+
<tr>
<td><label for="dataSets">$i18n.getString( "selected_data_sets" )</label></td>
<td><select multiple id="dataSets" name="dataSets" size="5" style="width:20em" ondblclick="moveSelectedById( 'dataSets', 'availableDataSets' )"></select></td>
</tr>
+
<tr>
<td style="height:15px" colspan="2">
</tr>
+
<tr>
<th colspan="2">$i18n.getString( "organisation_unit_groups" )</th>
</tr>
@@ -117,11 +139,11 @@
</td>
</tr>
#end
- <tr>
- <td></td>
- <td>
- <input type="submit" name="save" value="$i18n.getString( 'add' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='organisationUnit.action'" style="width:10em"/>
- </td>
- </tr>
</table>
+
+<p>
+ <input type="submit" name="save" value="$i18n.getString( 'add' )" style="width: 10em;" />
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='organisationUnit.action'" style="width: 10em;" />
+</p>
+
</form>
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js 2011-04-11 11:36:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-jQuery(document).ready(function() {
- validation2('addOrganisationUnitForm', function(form) {
- selectAllById("dataSets");
- form.submit();
-
- /*
- * if(validateFeatureType(this.coordinates, this.featureType)) {
- * form.submit(); }
- */
- /* return false; */
- }, {
- 'rules' : getValidationRules("organisationUnit")
- });
-
- checkValueIsExist("name", "validateOrganisationUnit.action");
- datePickerValid('openingDate', false);
-
- var nameField = document.getElementById('name');
- nameField.select();
- nameField.focus();
-});
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js 2011-04-11 11:36:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
-jQuery(document).ready(function() {
- validation2('updateOrganisationUnitForm', function(form) {
- selectAllById("dataSets");
- form.submit();
-
- /*
- * if(validateFeatureType(this.coordinates, this.featureType))
- * {form.submit();}
- */
- }, {
- 'rules' : getValidationRules("organisationUnit")
- });
-});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2011-09-15 03:25:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2011-09-21 12:46:20 +0000
@@ -1,7 +1,17 @@
-<script type="text/javascript" src="javascript/updateOrganisationUnitForm.js"></script>
<script type="text/javascript">
jQuery( document ).ready( function()
{
+ validation2('updateOrganisationUnitForm', function(form) {
+ selectAllById("dataSets");
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : getValidationRules("organisationUnit")
+ });
+
checkValueIsExist( "name", "validateOrganisationUnit.action", {
id : $organisationUnit.id
} );
@@ -30,7 +40,7 @@
<th colspan="2">$i18n.getString( "details" )</th>
</tr>
<tr>
- <td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td style="width:200px"><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="$encoder.htmlEncode( $organisationUnit.name )" onchange="nameChanged()" style="width:20em"></td>
</tr>
<tr>
@@ -105,14 +115,16 @@
<td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td><input type="text" id="phoneNumber" name="phoneNumber" value="$!encoder.htmlEncode( $organisationUnit.phoneNumber )" style="width:20em"></td>
</tr>
- <tr>
- <td style="height:15px" colspan="2">
- </tr>
+</table>
+
+#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } )
+
+<table>
<tr>
<th colspan="2">$i18n.getString( "data_sets" )</th>
</tr>
<tr>
- <td><label for="availableDataSets">$i18n.getString( "available_data_sets" )</label></td>
+ <td style="width:200px"><label for="availableDataSets">$i18n.getString( "available_data_sets" )</label></td>
<td>
<select multiple id="availableDataSets" size="5" style="width:20em" ondblclick="moveSelectedById( 'availableDataSets', 'dataSets' )">
#foreach( $dataSet in $availableDataSets )
@@ -158,10 +170,11 @@
<td><input type="hidden" name="orgUnitGroupSets" value="$groupSet.id"/></td>
</tr>
#end
- <tr>
- <td></td>
- <td><input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='organisationUnit.action'" style="width:10em"/></td>
- </tr>
</table>
+<p>
+ <input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:10em" />
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='organisationUnit.action'" style="width:10em"/>
+</p>
+
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java 2011-06-11 08:15:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java 2011-09-21 12:46:20 +0000
@@ -30,11 +30,14 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.security.PasswordManager;
+import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserAuthorityGroup;
@@ -45,7 +48,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: AddUserAction.java 5556 2008-08-20 11:36:20Z abyot $
*/
public class AddUserAction
implements Action
@@ -89,8 +91,15 @@
this.currentUserService = currentUserService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
- // Input
+ // Input & Output
// -------------------------------------------------------------------------
private String username;
@@ -154,6 +163,13 @@
this.selectedList = selectedList;
}
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -204,6 +220,9 @@
user.setUserCredentials( userCredentials );
+ AttributeUtils.updateAttributeValuesFromJson( user.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
userService.addUser( user );
userService.addUserCredentials( userCredentials );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java 2011-06-19 10:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java 2011-09-21 12:46:20 +0000
@@ -29,12 +29,19 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.comparator.AttributeNameComparator;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.system.filter.UserAuthorityGroupCanIssueFilter;
+import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.system.util.FilterUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
@@ -83,8 +90,15 @@
this.currentUserService = currentUserService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
- // Input
+ // Input & Output
// -------------------------------------------------------------------------
private Integer id;
@@ -94,10 +108,6 @@
this.id = id;
}
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
private UserCredentials userCredentials;
public UserCredentials getUserCredentials()
@@ -119,6 +129,20 @@
return organisationUnitGroups;
}
+ private List<Attribute> attributes;
+
+ public List<Attribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public Map<Integer, String> attributeValues = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getAttributeValues()
+ {
+ return attributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -128,7 +152,8 @@
{
userAuthorityGroups = new ArrayList<UserAuthorityGroup>( userService.getAllUserAuthorityGroups() );
- FilterUtils.filter( userAuthorityGroups, new UserAuthorityGroupCanIssueFilter( currentUserService.getCurrentUser() ) );
+ FilterUtils.filter( userAuthorityGroups,
+ new UserAuthorityGroupCanIssueFilter( currentUserService.getCurrentUser() ) );
if ( id != null )
{
@@ -142,6 +167,8 @@
userCredentials = userService.getUserCredentials( userService.getUser( id ) );
userAuthorityGroups.removeAll( userCredentials.getUserAuthorityGroups() );
+
+ attributeValues = AttributeUtils.getAttributeValueMap( user.getAttributeValues() );
}
else
{
@@ -151,6 +178,10 @@
}
}
+ attributes = new ArrayList<Attribute>( attributeService.getDataElementAttributes() );
+
+ Collections.sort( attributes, new AttributeNameComparator() );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2011-06-19 09:32:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2011-09-21 12:46:20 +0000
@@ -30,12 +30,15 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.security.PasswordManager;
+import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserAuthorityGroup;
@@ -46,7 +49,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: UpdateUserAction.java 5556 2008-08-20 11:36:20Z abyot $
*/
public class UpdateUserAction
implements Action
@@ -90,8 +92,15 @@
this.currentUserService = currentUserService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
- // Input
+ // Input & Output
// -------------------------------------------------------------------------
private Integer id;
@@ -143,6 +152,13 @@
this.selectedList = selectedList;
}
+ private List<String> jsonAttributeValues;
+
+ public void setJsonAttributeValues( List<String> jsonAttributeValues )
+ {
+ this.jsonAttributeValues = jsonAttributeValues;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -200,6 +216,9 @@
userCredentials.setPassword( passwordManager.encodePassword( userCredentials.getUsername(), rawPassword ) );
}
+ AttributeUtils.updateAttributeValuesFromJson( user.getAttributeValues(), jsonAttributeValues,
+ attributeService );
+
userService.updateUserCredentials( userCredentials );
userService.updateUser( user );
@@ -208,6 +227,7 @@
selectionManager.setSelectedOrganisationUnits( units );
}
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml 2011-09-09 06:18:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/META-INF/dhis/beans.xml 2011-09-21 12:46:20 +0000
@@ -23,6 +23,7 @@
<property name="currentUserService">
<ref bean="org.hisp.dhis.user.CurrentUserService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.user.action.DeleteCurrentUserAction" class="org.hisp.dhis.user.action.DeleteCurrentUserAction"
@@ -91,6 +92,7 @@
<property name="currentUserService">
<ref bean="org.hisp.dhis.user.CurrentUserService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.user.action.ValidateUserAction" class="org.hisp.dhis.user.action.ValidateUserAction"
@@ -113,6 +115,7 @@
<property name="currentUserService">
<ref bean="org.hisp.dhis.user.CurrentUserService" />
</property>
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.user.action.SelectOrganisationUnitGroupMembersAction" class="org.hisp.dhis.user.action.SelectOrganisationUnitGroupMembersAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm 2011-06-18 17:19:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm 2011-09-21 12:46:20 +0000
@@ -1,6 +1,25 @@
-<script type="text/javascript" src="javascript/addUserForm.js"></script>
<script type="text/javascript">
jQuery(function() {
+ validation2( 'addUserForm', function( form )
+ {
+ jQuery( "#selectedList" ).children().attr( "selected", true );
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ listValidator( 'roleValidator', 'selectedList' );
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : getValidationRules( "user" )
+ } );
+
+ checkValueIsExist( "username", "validateUser.action" );
+
+ jQuery( "#cancel" ).click( function()
+ {
+ referrerBack( "alluser.action" );
+ } );
+
jQuery("#availableList").dhisAjaxSelect({
source: "../dhis-web-commons-ajax-json/getUserRoles.action",
iterator: 'userRoles',
@@ -20,7 +39,7 @@
<form id="addUserForm" action="addUser.action" method="post" >
<table>
- <col style="width: 120px"/>
+ <col style="width: 200px"/>
<col style="width: 350px"/>
<col/>
<col style="width: 350px"/>
@@ -63,13 +82,16 @@
<td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td colspan="3"><input type="text" id="phoneNumber" name="phoneNumber" style="width:20em"></td>
</tr>
-
- <tr>
- <td colspan="4" height="10"></td>
- </tr>
-
- <tr>
- <td></td>
+</table>
+
+#tblDynamicAttributes( { "attributes": $attributes } )
+
+<table>
+ <col style="width: 450px"/>
+ <col/>
+ <col style="width: 450px"/>
+
+ <tr>
<th>$i18n.getString( "available_roles" )</th>
<th></th>
<th>$i18n.getString( "selected_roles" )
@@ -78,8 +100,6 @@
</tr>
<tr style="margin-bottom: 15px;">
- <td><label>$i18n.getString( "roles" )</label></td>
-
<td>
<select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
</td>
@@ -97,20 +117,16 @@
</tr>
<tr>
- <td><label for="selectionTree">$i18n.getString( "organisation_unit" )</label></td>
<td colspan="3">
#organisationUnitSelectionTree( true, true, true )
</td>
- </tr>
- <tr>
- <td></td>
- <td valign="top">
- <input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>
- <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em"/>
- </td>
- <td></td>
- <td></td>
+
</tr>
</table>
+<p>
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
+ <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em" />
+</p>
+
</form>
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js 2011-08-19 21:33:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-jQuery( document ).ready( function()
-{
- validation2( 'addUserForm', function( form )
- {
- jQuery( "#selectedList" ).children().attr( "selected", true );
- form.submit();
- }, {
- 'beforeValidateHandler' : function()
- {
- listValidator( 'roleValidator', 'selectedList' );
- },
- 'rules' : getValidationRules( "user" )
- } );
-
- /* remote validation */
- checkValueIsExist( "username", "validateUser.action" );
-
- jQuery( "#cancel" ).click( function()
- {
- referrerBack( "alluser.action" );
- } );
-} );
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js 2011-08-19 21:33:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
-jQuery( document ).ready( function()
-{
- var rules = getValidationRules( "user" );
- rules["rawPassword"].required = false;
- rules["retypePassword"].required = false;
-
- validation2( 'updateUserForm', function( form )
- {
- jQuery( "#selectedList" ).children().attr( "selected", true );
- form.submit();
- }, {
- 'beforeValidateHandler' : function()
- {
- listValidator( 'roleValidator', 'selectedList' );
- },
- 'rules' : rules
- } );
-
- jQuery( "#cancel" ).click( function()
- {
- referrerBack( "alluser.action" );
- } );
-} );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2011-06-22 06:16:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2011-09-21 12:46:20 +0000
@@ -1,6 +1,27 @@
-<script type="text/javascript" src="javascript/updateUserForm.js"></script>
<script type="text/javascript">
jQuery(function() {
+ var rules = getValidationRules( "user" );
+ rules["rawPassword"].required = false;
+ rules["retypePassword"].required = false;
+
+ validation2( 'updateUserForm', function( form )
+ {
+ jQuery( "#selectedList" ).children().attr( "selected", true );
+ form.submit();
+ }, {
+ 'beforeValidateHandler' : function()
+ {
+ listValidator( 'roleValidator', 'selectedList' );
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules' : rules
+ } );
+
+ jQuery( "#cancel" ).click( function()
+ {
+ referrerBack( "alluser.action" );
+ } );
+
jQuery("#availableList").dhisAjaxSelect({
source: "../dhis-web-commons-ajax-json/getUserRoles.action",
iterator: 'userRoles',
@@ -25,7 +46,7 @@
</div>
<table>
- <col style="width: 120px"/>
+ <col style="width: 200px"/>
<col style="width: 350px"/>
<col/>
<col style="width: 350px"/>
@@ -68,13 +89,16 @@
<td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td colspan="3"><input type="text" id="phoneNumber" name="phoneNumber" value="$!encoder.htmlEncode( $userCredentials.user.phoneNumber )" style="width:20em"/></td>
</tr>
-
- <tr>
- <td colspan="4" height="10"></td>
- </tr>
-
- <tr>
- <td></td>
+</table>
+
+#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } )
+
+<table>
+ <col style="width: 450px"/>
+ <col/>
+ <col style="width: 450px"/>
+
+ <tr>
<th>$i18n.getString( "available" )</th>
<th></th>
<th>$i18n.getString( "selected" )
@@ -83,7 +107,6 @@
</tr>
<tr>
- <td><label>$i18n.getString( "roles" )</label></td>
<td>
<select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
</td>
@@ -105,17 +128,15 @@
</tr>
<tr>
- <td><label for="selectionTree">$i18n.getString( "organisation_unit" )</label></td>
<td colspan="3">
#organisationUnitSelectionTree( false, true, true )
</td>
</tr>
- <tr>
- <td></td>
- <td valign="top">
- <input type="submit" value="$i18n.getString( 'save' )" style="width:10em"/>
- <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em"/>
- </td>
- </tr>
</table>
+
+<p>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
+ <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em" />
+</p>
+
</form>