=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-18 15:10:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-19 06:44:30 +0000 @@ -28,23 +28,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Calendar; +import java.util.Date; + import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.view.DetailedView; +import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.common.view.WithoutOrganisationUnitsView; +import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.period.PeriodType; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** * @author Abyot Asalefew @@ -59,16 +59,27 @@ private static final long serialVersionUID = 3026922158464592390L; public static final String TYPE_DATE = "date"; + public static final String TYPE_STRING = "string"; + public static final String TYPE_INT = "number"; + public static final String VALUE_TYPE_LETTER = "letter"; + public static final String TYPE_BOOL = "bool"; + public static final String TYPE_TRUE_ONLY = "trueOnly"; + public static final String TYPE_COMBO = "combo"; + public static final String TYPE_PHONE_NUMBER = "phoneNumber"; + public static final String TYPE_TRACKER_ASSOCIATE = "trackerAssociate"; + public static final String TYPE_USERS = "users"; + public static final String TYPE_AGE = "age"; + public static final String VALUE_TYPE_LOCAL_ID = "localId"; private String description; @@ -83,7 +94,7 @@ private TrackedEntityAttributeGroup attributeGroup; - private Set attributeOptions = new HashSet(); + private OptionSet optionSet; private String expression; @@ -143,30 +154,6 @@ // Getters and setters // ------------------------------------------------------------------------- - @JsonProperty( "trackedEntityAttributeOptions" ) - @JsonView( { DetailedView.class } ) - @JacksonXmlElementWrapper( localName = "trackedEntityAttributeOptions", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "trackedEntityAttributeOption", namespace = DxfNamespaces.DXF_2_0 ) - public Set getAttributeOptions() - { - return attributeOptions == null ? new HashSet() : attributeOptions; - } - - public void setAttributeOptions( Set attributeOptions ) - { - this.attributeOptions = attributeOptions; - } - - public void addAttributeOptions( TrackedEntityAttributeOption option ) - { - if ( attributeOptions == null ) - { - attributeOptions = new HashSet(); - } - - attributeOptions.add( option ); - } - @JsonProperty @JsonView( { DetailedView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @@ -361,6 +348,19 @@ this.periodType = periodType; } + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public OptionSet getOptionSet() + { + return optionSet; + } + + public void setOptionSet( OptionSet optionSet ) + { + this.optionSet = optionSet; + } + // ------------------------------------------------------------------------- // Static methods // ------------------------------------------------------------------------- @@ -421,9 +421,6 @@ groupBy = trackedEntityAttribute.getGroupBy(); attributeGroup = trackedEntityAttribute.getAttributeGroup(); - attributeOptions.clear(); - attributeOptions.addAll( trackedEntityAttribute.getAttributeOptions() ); - expression = trackedEntityAttribute.getExpression(); displayOnVisitSchedule = trackedEntityAttribute.getDisplayOnVisitSchedule(); sortOrderInVisitSchedule = trackedEntityAttribute.getSortOrderInVisitSchedule(); === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOption.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOption.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOption.java 1970-01-01 00:00:00 +0000 @@ -1,77 +0,0 @@ -package org.hisp.dhis.trackedentity; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.hisp.dhis.common.BaseIdentifiableObject; -import org.hisp.dhis.common.DxfNamespaces; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; - -/** - * @author Viet - */ -@JacksonXmlRootElement( localName = "trackedEntityAttributeOption", namespace = DxfNamespaces.DXF_2_0 ) -public class TrackedEntityAttributeOption - extends BaseIdentifiableObject -{ - /** - * Determines if a de-serialized file is compatible with this class. - */ - private static final long serialVersionUID = 9052641474847384010L; - - private TrackedEntityAttribute attribute; - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - public TrackedEntityAttributeOption() - { - } - - // ------------------------------------------------------------------------- - // Getters and setters - // ------------------------------------------------------------------------- - - @JsonProperty - @JsonSerialize( as = BaseIdentifiableObject.class ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public TrackedEntityAttribute getAttribute() - { - return attribute; - } - - public void setAttribute( TrackedEntityAttribute attribute ) - { - this.attribute = attribute; - } -} \ No newline at end of file === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStore.java 1970-01-01 00:00:00 +0000 @@ -1,60 +0,0 @@ -package org.hisp.dhis.trackedentity; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -import org.hisp.dhis.common.GenericIdentifiableObjectStore; - -public interface TrackedEntityAttributeOptionStore - extends GenericIdentifiableObjectStore -{ - /** - * Returns a {@link TrackedEntityAttributeOption} with a given name. - * - * @param attribute {@link TrackedEntityAttribute} - * - * @param name the name of the TrackedEntityAttributeOption to return. - * - * @return the TrackedEntityAttributeOption with the given name, or null if - * no match. - */ - TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name ); - - /** - * Get all {@link TrackedEntityAttributeOption} of a - * {@link TrackedEntityAttribute} - * - * @param attribute {@link TrackedEntityAttribute} - * - * @return {@link TrackedEntityAttributeOption} - */ - Collection get( TrackedEntityAttribute attribute ); - -} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-19 06:44:30 +0000 @@ -200,60 +200,4 @@ */ int getTrackedEntityAttributeCountByName( String name ); - // ------------------------------------------------------------------------- - // TrackedEntityAttributeOption - // ------------------------------------------------------------------------- - - /** - * Adds an {@link TrackedEntityAttributeOption} - * - * @param option The to TrackedEntityAttributeOption add. - * - * @return A generated unique id of the added {@link TrackedEntityAttributeOption}. - */ - int addTrackedEntityAttributeOption( TrackedEntityAttributeOption option ); - - /** - * Updates a {@link TrackedEntityAttributeOption}. - * - * @param option the TrackedEntityAttributeOption to update. - */ - void updateTrackedEntityAttributeOption( TrackedEntityAttributeOption option ); - - /** - * Deletes a {@link TrackedEntityAttributeOption}. - * - * @param option the TrackedEntityAttributeOption to delete. - */ - void deleteTrackedEntityAttributeOption( TrackedEntityAttributeOption option ); - - /** - * Returns a {@link TrackedEntityAttributeOption} with a given name. - * - * @param attribute {@link TrackedEntityAttribute} - * @param name the name of the TrackedEntityAttributeOption to return. - * - * @return the TrackedEntityAttributeOption with the given name, or null if no - * match. - */ - TrackedEntityAttributeOption getTrackedEntityAttributeOption( TrackedEntityAttribute attribute, String name ); - - /** - * Returns a {@link TrackedEntityAttributeOption}. - * - * @param id the id of the TrackedEntityAttributeOption to return. - * - * @return the TrackedEntityAttributeOption with the given id - */ - TrackedEntityAttributeOption getTrackedEntityAttributeOption( int id ); - - /** - * Get all {@link TrackedEntityAttributeOption} of a {@link TrackedEntityAttribute} - * - * @param attribute {@link TrackedEntityAttribute} - * - * @return {@link TrackedEntityAttributeOption} - */ - Collection getTrackedEntityAttributeOption( TrackedEntityAttribute attribute ); - } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2014-03-19 06:44:30 +0000 @@ -31,7 +31,6 @@ import java.io.Serializable; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityInstance; /** @@ -55,8 +54,6 @@ private String value; - private TrackedEntityAttributeOption attributeOption; - // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -90,7 +87,6 @@ int result = 1; result = prime * result + ((entityInstance == null) ? 0 : entityInstance.hashCode()); result = prime * result + ((attribute == null) ? 0 : attribute.hashCode()); - result = prime * result + ((attributeOption == null) ? 0 : attributeOption.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; } @@ -139,18 +135,6 @@ return false; } - if ( attributeOption == null ) - { - if ( other.attributeOption != null ) - { - return false; - } - } - else if ( !attributeOption.equals( other.attributeOption ) ) - { - return false; - } - if ( value == null ) { if ( other.value != null ) @@ -170,7 +154,7 @@ public String toString() { return "[Tracked attribute=" + attribute + ", entityInstance=" + entityInstance + ", value='" + value + "'" - + ", attribute option=" + attributeOption + "]"; + + "]"; } // ------------------------------------------------------------------------- @@ -202,16 +186,6 @@ this.entityInstance = entityInstance; } - public TrackedEntityAttributeOption getAttributeOption() - { - return attributeOption; - } - - public void setAttributeOption( TrackedEntityAttributeOption attributeOption ) - { - this.attributeOption = attributeOption; - } - public void setValue( String value ) { this.value = value; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueService.java 2014-03-19 06:44:30 +0000 @@ -32,7 +32,6 @@ import java.util.Map; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityInstance; /** @@ -182,21 +181,4 @@ */ Collection getTrackedEntityInstance( TrackedEntityAttribute attribute, String value ); - /** - * Update attribute values which belong to the pre-defined attribute - * when a value pre-defined of this attribute is modified - * - * @param attributeOption TrackedEntityAttributeOption - */ - void updateTrackedEntityAttributeValues( TrackedEntityAttributeOption attributeOption ); - - /** - * Get the number of {@link TrackedEntityAttributeOption} in all - * {@link TrackedEntityAttribute} - * - * @param attributeOption TrackedEntityAttributeOption - * - * @return The number of TrackedEntityAttributeOptions - */ - int countByAttributeOption( TrackedEntityAttributeOption attributeOption ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStore.java 2014-03-18 15:10:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStore.java 2014-03-19 06:44:30 +0000 @@ -33,7 +33,6 @@ import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.program.Program; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityInstance; /** @@ -70,8 +69,8 @@ int deleteByAttribute( TrackedEntityAttribute attribute ); /** - * Retrieve a {@link TrackedEntityAttributeValue} on a {@link TrackedEntityInstance} and - * {@link TrackedEntityAttribute} + * Retrieve a {@link TrackedEntityAttributeValue} on a + * {@link TrackedEntityInstance} and {@link TrackedEntityAttribute} * * @param attribute {@link TrackedEntityAttribute} * @@ -80,7 +79,8 @@ TrackedEntityAttributeValue get( TrackedEntityInstance instance, TrackedEntityAttribute attribute ); /** - * Retrieve {@link TrackedEntityAttributeValue} of a {@link TrackedEntityInstance} + * Retrieve {@link TrackedEntityAttributeValue} of a + * {@link TrackedEntityInstance} * * @param instance TrackedEntityInstance * @@ -89,7 +89,8 @@ Collection get( TrackedEntityInstance instance ); /** - * Retrieve {@link TrackedEntityAttributeValue} of a {@link TrackedEntityInstance} + * Retrieve {@link TrackedEntityAttributeValue} of a + * {@link TrackedEntityInstance} * * @param instance TrackedEntityInstance * @@ -107,8 +108,8 @@ Collection get( Collection instances ); /** - * Search TrackedEntityAttributeValue objects by a TrackedEntityAttribute and a attribute - * value (performs partial search ) + * Search TrackedEntityAttributeValue objects by a TrackedEntityAttribute + * and a attribute value (performs partial search ) * * @param attribute TrackedEntityAttribute * @param searchText A string for searching by attribute values @@ -118,16 +119,6 @@ Collection searchByValue( TrackedEntityAttribute attribute, String searchText ); /** - * Get the number of {@link TrackedEntityAttributeOption} in all - * {@link TrackedEntityAttribute} - * - * @param attributeOption TrackedEntityAttributeOption - * - * @return The number of TrackedEntityAttributeOptions - */ - int countByAttributeOption( TrackedEntityAttributeOption attributeOption ); - - /** * Retrieve instances who have the same value on an attribute * * @param attribute TrackedEntityAttribute @@ -138,14 +129,6 @@ Collection getTrackedEntityInstances( TrackedEntityAttribute attribute, String value ); /** - * Update attribute values which belong to the pre-defined attribute - * when a value pre-defined of this attribute is modified - * - * @param attributeOption TrackedEntityAttributeOption - */ - void updateTrackedEntityAttributeValues( TrackedEntityAttributeOption attributeOption ); - - /** * Retrieve attribute values of an instance by a program * * @param instance TrackedEntityInstance === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-03-19 06:44:30 +0000 @@ -84,7 +84,6 @@ import org.hisp.dhis.sms.SmsSender; import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -1420,16 +1419,7 @@ patientAttribute.setName( name ); patientAttribute.setType( pa.getValueType() ); patientAttribute.setValue( "" ); - List optionList = new ArrayList(); - if ( pa.getAttributeOptions() != null ) - { - for ( TrackedEntityAttributeOption option : pa.getAttributeOptions() ) - { - optionList.add( option.getName() ); - } - } - - patientAttribute.setPredefinedValues( optionList ); + list.add( patientAttribute ); } return list; === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2014-03-19 06:44:30 +0000 @@ -45,7 +45,6 @@ import org.hisp.dhis.program.ProgramStageSection; import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.springframework.beans.factory.annotation.Required; public class DefaultProgramService @@ -88,9 +87,9 @@ { programs.add( getProgramLWUIT( program.getId() ) ); } - - System.out.println("Program by unit size: " + programByUnit.size()); - System.out.println("Program size: " + programs.size()); + + System.out.println( "Program by unit size: " + programByUnit.size() ); + System.out.println( "Program size: " + programs.size() ); return programs; } @@ -288,23 +287,16 @@ return pr; } - private org.hisp.dhis.api.mobile.model.PatientAttribute getPatientAttributeForMobile( ProgramTrackedEntityAttribute ppa ) + private org.hisp.dhis.api.mobile.model.PatientAttribute getPatientAttributeForMobile( + ProgramTrackedEntityAttribute ppa ) { TrackedEntityAttribute pa = ppa.getAttribute(); - List optionList = new ArrayList(); - if ( pa.getAttributeOptions() != null ) - { - for ( TrackedEntityAttributeOption pao : pa.getAttributeOptions() ) - { - optionList.add( pao.getName() ); - } - } + org.hisp.dhis.api.mobile.model.PatientAttribute mobileAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute(); mobileAttribute.setName( pa.getName() ); mobileAttribute.setMandatory( pa.isMandatory() ); mobileAttribute.setType( pa.getValueType() ); mobileAttribute.setValue( "" ); - mobileAttribute.setPredefinedValues( optionList ); if ( ppa.getDisplayedInList() ) { mobileAttribute.setDisplayedInList( true ); === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-19 06:44:30 +0000 @@ -53,13 +53,6 @@ this.attributeStore = attributeStore; } - private TrackedEntityAttributeOptionStore attributeOptionStore; - - public void setAttributeOptionStore( TrackedEntityAttributeOptionStore attributeOptionStore ) - { - this.attributeOptionStore = attributeOptionStore; - } - private ProgramService programService; public void setProgramService( ProgramService programService ) @@ -142,7 +135,7 @@ Collection result = attributeStore.getAll(); Collection programs = programService.getAllPrograms(); - + if ( result != null ) { for ( Program program : programs ) @@ -181,37 +174,5 @@ return attributeStore.getCountLikeName( name ); } - // ------------------------------------------------------------------------- - // TrackedEntityAttributeOption - // ------------------------------------------------------------------------- - - public int addTrackedEntityAttributeOption( TrackedEntityAttributeOption option ) - { - return attributeOptionStore.save( option ); - } - - public void deleteTrackedEntityAttributeOption( TrackedEntityAttributeOption option ) - { - attributeOptionStore.delete( option ); - } - - public void updateTrackedEntityAttributeOption( TrackedEntityAttributeOption option ) - { - attributeOptionStore.update( option ); - } - - public TrackedEntityAttributeOption getTrackedEntityAttributeOption( TrackedEntityAttribute attribute, String name ) - { - return attributeOptionStore.get( attribute, name ); - } - - public TrackedEntityAttributeOption getTrackedEntityAttributeOption( int id ) - { - return attributeOptionStore.get( id ); - } - - public Collection getTrackedEntityAttributeOption( TrackedEntityAttribute attribute ) - { - return attributeOptionStore.get( attribute ); - } + } === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-03-19 06:44:30 +0000 @@ -322,14 +322,14 @@ { inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">"; inputHtml += ""; - for ( TrackedEntityAttributeOption option : attribute.getAttributeOptions() ) + for ( String option : attribute.getOptionSet().getOptions() ) { - inputHtml += ""; } inputHtml += ""; } === removed file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeOptionStore.java 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ -package org.hisp.dhis.trackedentity.hibernate; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -import org.hibernate.criterion.Restrictions; -import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; -import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOptionStore; - -public class HibernateTrackedEntityAttributeOptionStore - extends HibernateIdentifiableObjectStore - implements TrackedEntityAttributeOptionStore -{ - public TrackedEntityAttributeOption get( TrackedEntityAttribute attribute, String name ) - { - return (TrackedEntityAttributeOption) getCriteria( Restrictions.eq( "name", name ), - Restrictions.eq( "attribute", attribute ) ).uniqueResult(); - } - - @SuppressWarnings( "unchecked" ) - public Collection get( TrackedEntityAttribute attribute ) - { - return getCriteria( Restrictions.eq( "attribute", attribute ) ).list(); - } -} === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java 2014-03-19 06:44:30 +0000 @@ -35,7 +35,6 @@ import java.util.Set; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.springframework.transaction.annotation.Transactional; @@ -150,8 +149,8 @@ { if ( attributeValueMap.containsKey( attributeValue.getEntityInstance().getId() ) ) { - Collection values = attributeValueMap.get( attributeValue.getEntityInstance() - .getId() ); + Collection values = attributeValueMap.get( attributeValue + .getEntityInstance().getId() ); values.add( attributeValue ); } else @@ -211,21 +210,9 @@ } @Override - public int countByAttributeOption( TrackedEntityAttributeOption attributeOption ) - { - return attributeValueStore.countByAttributeOption( attributeOption ); - } - - @Override public Collection getTrackedEntityInstance( TrackedEntityAttribute attribute, String value ) { return attributeValueStore.getTrackedEntityInstances( attribute, value ); } - @Override - public void updateTrackedEntityAttributeValues( TrackedEntityAttributeOption attributeOption ) - { - attributeValueStore.updateTrackedEntityAttributeValues( attributeOption ); - } - } === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java 2014-03-18 15:10:26 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java 2014-03-19 06:44:30 +0000 @@ -35,9 +35,8 @@ import org.hibernate.criterion.Restrictions; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.program.Program; +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityInstance; -import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueStore; @@ -112,14 +111,6 @@ } @Override - public int countByAttributeOption( TrackedEntityAttributeOption attributeOption ) - { - Number rs = (Number) getCriteria( Restrictions.eq( "attributeOption", attributeOption ) ).setProjection( - Projections.rowCount() ).uniqueResult(); - return rs != null ? rs.intValue() : 0; - } - - @Override @SuppressWarnings( "unchecked" ) public Collection getTrackedEntityInstances( TrackedEntityAttribute attribute, String value ) { @@ -129,16 +120,6 @@ } @Override - public void updateTrackedEntityAttributeValues( TrackedEntityAttributeOption attributeOption ) - { - String hql = "UPDATE TrackedEntityAttributeValue SET value=:value where attributeOption=:attributeOption"; - Query query = getQuery( hql ); - query.setString( "value", attributeOption.getName() ); - query.setEntity( "attributeOption", attributeOption ); - query.executeUpdate(); - } - - @Override @SuppressWarnings( "unchecked" ) public Collection get( TrackedEntityInstance entityInstance, Program program ) { === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-03-17 11:30:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-03-19 06:44:30 +0000 @@ -74,9 +74,11 @@ - + - + @@ -97,13 +99,6 @@ - - - - - @@ -130,13 +125,13 @@ value="org.hisp.dhis.trackedentity.TrackedEntityAudit" /> - - - + @@ -243,23 +238,20 @@ + ref="org.hisp.dhis.trackedentity.TrackedEntityService" /> - - + + - @@ -295,9 +287,8 @@ - - + + @@ -412,7 +403,6 @@ trackedentityattribute trackedentityattributegroup - trackedentityattributeoption program programstage programinstance @@ -530,11 +520,15 @@ - - + + - - + + === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2014-03-19 06:44:30 +0000 @@ -26,10 +26,8 @@ - - - - + === removed file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeOption.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeOption.hbm.xml 2014-02-15 14:06:39 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeOption.hbm.xml 1970-01-01 00:00:00 +0000 @@ -1,22 +0,0 @@ - -] - > - - - - - - - - &identifiableProperties; - - - - - - - === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2014-03-19 06:44:30 +0000 @@ -15,8 +15,5 @@ - - === removed file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java' --- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java 1970-01-01 00:00:00 +0000 @@ -1,149 +0,0 @@ -package org.hisp.dhis.trackedentity; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.hisp.dhis.DhisSpringTest; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Chau Thu Tran - * - * @version $ TrackedEntityAttributeOptionServiceTest.java Nov 5, 2013 4:25:29 PM $ - */ -public class TrackedEntityAttributeOptionServiceTest - extends DhisSpringTest -{ - @Autowired - private TrackedEntityAttributeService attributeService; - - private TrackedEntityAttributeOption attributeOptionA; - - private TrackedEntityAttributeOption attributeOptionB; - - private TrackedEntityAttributeOption attributeOptionC; - - private TrackedEntityAttribute attributeA; - - private TrackedEntityAttribute attributeB; - - @Override - public void setUpTest() - { - attributeA = createTrackedEntityAttribute( 'A' ); - attributeB = createTrackedEntityAttribute( 'B' ); - - attributeService.addTrackedEntityAttribute( attributeA ); - attributeService.addTrackedEntityAttribute( attributeB ); - - attributeOptionA = createTrackedEntityAttributeOption( 'A', attributeA ); - attributeOptionB = createTrackedEntityAttributeOption( 'B', attributeA ); - attributeOptionC = createTrackedEntityAttributeOption( 'C', attributeB ); - } - - @Test - public void testAddTrackedEntityAttributeOption() - { - int idA = attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - int idB = attributeService.addTrackedEntityAttributeOption( attributeOptionB ); - - assertNotNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - assertNotNull( attributeService.getTrackedEntityAttributeOption( idB ) ); - } - - @Test - public void testDeleteTrackedEntityAttributeGroup() - { - int idA = attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - int idB = attributeService.addTrackedEntityAttributeOption( attributeOptionB ); - - assertNotNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - assertNotNull( attributeService.getTrackedEntityAttributeOption( idB ) ); - - attributeService.deleteTrackedEntityAttributeOption( attributeOptionA ); - - assertNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - assertNotNull( attributeService.getTrackedEntityAttributeOption( idB ) ); - - attributeService.deleteTrackedEntityAttributeOption( attributeOptionB ); - - assertNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - assertNull( attributeService.getTrackedEntityAttributeOption( idB ) ); - } - - @Test - public void testUpdateTrackedEntityAttributeOption() - { - int idA = attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - - assertNotNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - - attributeOptionA.setName( "B" ); - attributeService.updateTrackedEntityAttributeOption( attributeOptionA ); - - assertEquals( "B", attributeService.getTrackedEntityAttributeOption( idA ).getName() ); - } - - @Test - public void testGetTrackedEntityAttributeGroupById() - { - int idA = attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - int idB = attributeService.addTrackedEntityAttributeOption( attributeOptionB ); - - assertEquals( attributeOptionA, attributeService.getTrackedEntityAttributeOption( idA ) ); - assertEquals( attributeOptionB, attributeService.getTrackedEntityAttributeOption( idB ) ); - } - - @Test - public void testGetTrackedEntityAttributeGroupByName() - { - int idA = attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - - assertNotNull( attributeService.getTrackedEntityAttributeOption( idA ) ); - - assertEquals( attributeOptionA, attributeService.getTrackedEntityAttributeOption( attributeA, "AttributeOptionA" ) ); - } - - @Test - public void testGetTrackedEntityAttributeOptionByAttribute() - { - attributeService.addTrackedEntityAttributeOption( attributeOptionA ); - attributeService.addTrackedEntityAttributeOption( attributeOptionB ); - attributeService.addTrackedEntityAttributeOption( attributeOptionC ); - - assertTrue( equals( attributeService.getTrackedEntityAttributeOption( attributeA ), attributeOptionA, attributeOptionB ) ); - assertTrue( equals( attributeService.getTrackedEntityAttributeOption( attributeB ), attributeOptionC ) ); - } - -} \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java' --- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueServiceTest.java 2014-03-19 06:44:30 +0000 @@ -41,7 +41,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -75,10 +74,6 @@ private TrackedEntityAttribute attributeC; - private TrackedEntityAttributeOption attributeOpionA; - - private TrackedEntityAttributeOption attributeOpionB; - private TrackedEntityInstance entityInstanceA; private TrackedEntityInstance entityInstanceB; @@ -97,10 +92,6 @@ private TrackedEntityAttributeValue attributeValueC; - private TrackedEntityAttributeValue attributeValueD; - - private TrackedEntityAttributeValue attributeValueE; - @Override public void setUpTest() { @@ -125,19 +116,9 @@ attributeService.addTrackedEntityAttribute( attributeB ); attributeService.addTrackedEntityAttribute( attributeC ); - attributeOpionA = createTrackedEntityAttributeOption( 'A', attributeC ); - attributeOpionB = createTrackedEntityAttributeOption( 'B', attributeC ); - - attributeService.addTrackedEntityAttributeOption( attributeOpionA ); - attributeService.addTrackedEntityAttributeOption( attributeOpionB ); - attributeValueA = new TrackedEntityAttributeValue( attributeA, entityInstanceA, "A" ); attributeValueB = new TrackedEntityAttributeValue( attributeB, entityInstanceA, "B" ); attributeValueC = new TrackedEntityAttributeValue( attributeA, entityInstanceB, "C" ); - attributeValueD = new TrackedEntityAttributeValue( attributeC, entityInstanceC, "AttributeOptionA" ); - attributeValueD.setAttributeOption( attributeOpionA ); - attributeValueE = new TrackedEntityAttributeValue( attributeC, entityInstanceD, "AttributeOptionB" ); - attributeValueE.setAttributeOption( attributeOpionB ); } @Test @@ -381,15 +362,4 @@ assertTrue( entityInstances.contains( entityInstanceA ) ); } - @Test - public void testCountByEntityInstanceAttributeoption() - { - attributeValueService.addTrackedEntityAttributeValue( attributeValueA ); - attributeValueService.addTrackedEntityAttributeValue( attributeValueD ); - attributeValueService.addTrackedEntityAttributeValue( attributeValueE ); - - int count = attributeValueService.countByAttributeOption( attributeOpionA ); - assertEquals( 1, count ); - } - } === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java' --- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueStoreTest.java 2014-03-19 06:44:30 +0000 @@ -40,7 +40,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -73,10 +72,6 @@ private TrackedEntityAttribute attributeC; - private TrackedEntityAttributeOption attributeOpionA; - - private TrackedEntityAttributeOption attributeOpionB; - private TrackedEntityInstance entityInstanceA; private TrackedEntityInstance entityInstanceB; @@ -91,10 +86,6 @@ private TrackedEntityAttributeValue attributeValueC; - private TrackedEntityAttributeValue attributeValueD; - - private TrackedEntityAttributeValue attributeValueE; - @Override public void setUpTest() { @@ -119,19 +110,9 @@ attributeService.addTrackedEntityAttribute( attributeB ); attributeService.addTrackedEntityAttribute( attributeC ); - attributeOpionA = createTrackedEntityAttributeOption( 'A', attributeC ); - attributeOpionB = createTrackedEntityAttributeOption( 'B', attributeC ); - - attributeService.addTrackedEntityAttributeOption( attributeOpionA ); - attributeService.addTrackedEntityAttributeOption( attributeOpionB ); - attributeValueA = new TrackedEntityAttributeValue( attributeA, entityInstanceA, "A" ); attributeValueB = new TrackedEntityAttributeValue( attributeB, entityInstanceA, "B" ); attributeValueC = new TrackedEntityAttributeValue( attributeA, entityInstanceB, "C" ); - attributeValueD = new TrackedEntityAttributeValue( attributeC, entityInstanceC, "AttributeOptionA" ); - attributeValueD.setAttributeOption( attributeOpionA ); - attributeValueE = new TrackedEntityAttributeValue( attributeC, entityInstanceD, "AttributeOptionB" ); - attributeValueE.setAttributeOption( attributeOpionB ); } @Test @@ -275,15 +256,4 @@ assertTrue( entityInstances.contains( entityInstanceA ) ); } - @Test - public void testCountByTrackedEntityAttributeoption() - { - attributeValueStore.saveVoid( attributeValueA ); - attributeValueStore.saveVoid( attributeValueD ); - attributeValueStore.saveVoid( attributeValueE ); - - int count = attributeValueStore.countByAttributeOption( attributeOpionA ); - assertEquals( 1, count ); - } - } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2014-03-19 06:44:30 +0000 @@ -86,7 +86,6 @@ import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAudit; import org.hisp.dhis.trackedentity.TrackedEntityForm; import org.hisp.dhis.trackedentity.TrackedEntityInstance; @@ -539,16 +538,7 @@ public void deleteTrackedEntityAttributeGroup( TrackedEntityAttributeGroup attributeGroup ) { } - - public String allowDeleteTrackedEntityAttributeOption( TrackedEntityAttributeOption attributeOption ) - { - return null; - } - - public void deleteTrackedEntityAttributeOption( TrackedEntityAttributeOption attributeOption ) - { - } - + public String allowDeleteRelationship( Relationship relationship ) { return null; === modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java' --- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2014-03-19 06:44:30 +0000 @@ -104,10 +104,9 @@ import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.resourcetable.ResourceTableService; import org.hisp.dhis.sqlview.SqlView; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserAuthorityGroup; @@ -1104,22 +1103,7 @@ return attribute; } - - /** - * @param uniqueCharacter A unique character to identify the object. - * @return TrackedEntityAttributeOption - */ - public static TrackedEntityAttributeOption createTrackedEntityAttributeOption( char uniqueChar, - TrackedEntityAttribute attribute ) - { - TrackedEntityAttributeOption attributeOption = new TrackedEntityAttributeOption(); - - attributeOption.setName( "AttributeOption" + uniqueChar ); - attributeOption.setAttribute( attribute ); - - return attributeOption; - } - + /** * @param uniqueCharacter A unique character to identify the object. * @return TrackedEntityAttributeGroup === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ShowEventWithRegistrationFormAction.java 2014-03-19 06:44:30 +0000 @@ -45,6 +45,7 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService; @@ -162,8 +163,8 @@ if ( trackedEntityForm != null ) { customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( trackedEntityForm - .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, - i18n, format ); + .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, i18n, + format ); } if ( customRegistrationForm == null ) @@ -173,7 +174,10 @@ programs.remove( program ); for ( Program p : programs ) { - attributesInProgram.addAll( p.getTrackedEntityAttributes() ); + for ( ProgramTrackedEntityAttribute programAttribute : p.getAttributes() ) + { + attributesInProgram.add( programAttribute.getAttribute() ); + } } attributeGroups = new ArrayList( === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddRepresentativeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddRepresentativeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddRepresentativeAction.java 2014-03-19 06:44:30 +0000 @@ -40,7 +40,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -122,15 +121,7 @@ { value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) ); } - else if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer.parseInt( value ) ); - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } + entityInstanceAttributeValues.add( attributeValue ); } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java 2014-03-19 06:44:30 +0000 @@ -47,7 +47,6 @@ import org.hisp.dhis.relationship.RelationshipTypeService; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -168,16 +167,6 @@ { value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) ); } - else if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer - .parseInt( value ) ); - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } attributeValues.add( attributeValue ); } else if ( attribute.getInherit() && relationship != null ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java 2014-03-19 06:44:30 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; @@ -111,7 +112,10 @@ if ( id != null ) { Program program = programService.getProgram( id ); - attributes = program.getTrackedEntityAttributes(); + for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ) + { + attributes.add(programAttribute.getAttribute() ); + } } else { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java 2014-03-19 06:44:30 +0000 @@ -43,6 +43,7 @@ import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.Relationship; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; @@ -91,7 +92,7 @@ @Autowired private ProgramInstanceService programInstanceService; - + private I18n i18n; private I18nFormat format; @@ -207,7 +208,7 @@ { program = programService.getProgram( programId ); trackedEntityForm = trackedEntityFormService.getTrackedEntityForm( program ); - + Collection programInstances = programInstanceService.getProgramInstances( entityInstance, program, ProgramInstance.STATUS_ACTIVE ); ProgramInstance programIntance = null; @@ -237,18 +238,21 @@ Collection programs = programService.getAllPrograms(); for ( Program p : programs ) { - for ( TrackedEntityAttribute attribute : p.getTrackedEntityAttributes() ) + for ( ProgramTrackedEntityAttribute programAttribute : p.getAttributes() ) { - if ( !attribute.getDisplayInListNoProgram() ) + if ( !programAttribute.getDisplayedInList() ) { - attributes.remove( attribute ); + attributes.remove( programAttribute.getAttribute() ); } } } } else { - attributes = program.getTrackedEntityAttributes(); + for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ) + { + attributes.add( programAttribute.getAttribute() ); + } } for ( TrackedEntityAttribute attribute : attributes ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java 2014-03-19 06:44:30 +0000 @@ -33,13 +33,11 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -179,48 +177,22 @@ { value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) ); } - + if ( attributeValue == null ) { attributeValue = new TrackedEntityAttributeValue(); attributeValue.setEntityInstance( entityInstance ); attributeValue.setAttribute( attribute ); attributeValue.setValue( value.trim() ); - - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService - .getTrackedEntityAttributeOption( Integer.parseInt( value ) ); - - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } - attributeValueService.addTrackedEntityAttributeValue( attributeValue ); - entityInstance.getAttributeValues().add( attributeValue ); } else { - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService - .getTrackedEntityAttributeOption( NumberUtils.toInt( value, 0 ) ); - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } - else - { - attributeValue.setValue( value.trim() ); - } + attributeValue.setValue( value.trim() ); attributeValueService.updateTrackedEntityAttributeValue( attributeValue ); - entityInstance.getAttributeValues().add( attributeValue ); } + + entityInstance.getAttributeValues().add( attributeValue ); } else if ( attributeValue != null ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/UpdateTrackedEntityInstanceAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/UpdateTrackedEntityInstanceAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/UpdateTrackedEntityInstanceAction.java 2014-03-19 06:44:30 +0000 @@ -35,14 +35,12 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; @@ -157,34 +155,12 @@ attributeValue.setEntityInstance( entityInstance ); attributeValue.setAttribute( attribute ); attributeValue.setValue( value.trim() ); - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService - .getTrackedEntityAttributeOption( Integer.parseInt( value ) ); - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } + valuesForSave.add( attributeValue ); } else { - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService - .getTrackedEntityAttributeOption( NumberUtils.toInt( value, 0 ) ); - if ( option != null ) - { - attributeValue.setAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - } - else - { - attributeValue.setValue( value.trim() ); - } + attributeValue.setValue( value.trim() ); valuesForUpdate.add( attributeValue ); valuesForDelete.remove( attributeValue ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ValidateTrackedEntityInstanceAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ValidateTrackedEntityInstanceAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ValidateTrackedEntityInstanceAction.java 2014-03-19 06:44:30 +0000 @@ -43,10 +43,9 @@ import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.springframework.beans.factory.annotation.Autowired; @@ -149,18 +148,8 @@ { value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) ); } - else if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer - .parseInt( value ) ); - if ( option != null ) - { - attributeValue.setValue( option.getName() ); - } - } - + attributeValue.setValue( value ); - attributeValues.add( attributeValue ); } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm 2014-02-12 10:18:42 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm 2014-03-19 06:44:30 +0000 @@ -19,8 +19,8 @@ #elseif( $attribute.valueType == "combo" ) #else === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2014-02-12 10:18:42 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2014-03-19 06:44:30 +0000 @@ -79,8 +79,8 @@ #elseif( $attribute.valueType == "combo" ) #else === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceForm.vm 2014-03-11 06:49:37 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceForm.vm 2014-03-19 06:44:30 +0000 @@ -64,8 +64,8 @@ #elseif( $attribute.valueType == "combo" ) #elseif( $attribute.valueType == "phoneNumber" ) @@ -113,8 +113,8 @@ #elseif( $attribute.valueType == "combo" ) #elseif( $attribute.valueType == "users" ) === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryenrollment/action/SaveMobileProgramEnrollmentAction.java 2014-03-19 06:44:30 +0000 @@ -37,7 +37,6 @@ import javax.servlet.http.HttpServletRequest; -import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.StrutsStatics; import org.hisp.dhis.light.utils.FormUtils; import org.hisp.dhis.light.utils.ValueUtils; @@ -50,10 +49,9 @@ import org.hisp.dhis.program.ProgramStageInstanceService; import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.system.util.MathUtils; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService; @@ -296,17 +294,6 @@ { TrackedEntityAttributeValue patientAttributeValue = new TrackedEntityAttributeValue(); - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = patientAttributeService.getTrackedEntityAttributeOption( NumberUtils.toInt( - value, 0 ) ); - - if ( option != null ) - { - patientAttributeValue.setAttributeOption( option ); - } - } - patientAttributeValue.setEntityInstance( patient ); patientAttributeValue.setAttribute( patientAttribute ); patientAttributeValue.setValue( value.trim() ); === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2014-03-19 06:44:30 +0000 @@ -36,17 +36,15 @@ import javax.servlet.http.HttpServletRequest; -import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.StrutsStatics; import org.hisp.dhis.light.utils.ValueUtils; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.system.util.MathUtils; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.util.ContextUtils; @@ -302,14 +300,13 @@ Map parameterMap = ContextUtils.getParameterMap( request ); // Add Attributes - Collection patientAttributes = patientAttributeService.getAllTrackedEntityAttributes(); + Collection patientAttributes = patientAttributeService.getAllTrackedEntityAttributes(); for ( Program program : programs ) { patientAttributes.removeAll( program.getAttributes() ); } - for ( TrackedEntityAttribute patientAttribute : patientAttributes ) { patientAttributeSet.add( patientAttribute ); @@ -339,17 +336,6 @@ { TrackedEntityAttributeValue patientAttributeValue = new TrackedEntityAttributeValue(); - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) - { - TrackedEntityAttributeOption option = patientAttributeService - .getTrackedEntityAttributeOption( NumberUtils.toInt( value, 0 ) ); - - if ( option != null ) - { - patientAttributeValue.setAttributeOption( option ); - } - } - patientAttributeValue.setEntityInstance( patient ); patientAttributeValue.setAttribute( patientAttribute ); patientAttributeValue.setValue( value.trim() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-19 06:44:30 +0000 @@ -28,13 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.List; - import org.apache.commons.lang.StringUtils; +import org.hisp.dhis.option.OptionService; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.springframework.beans.factory.annotation.Autowired; @@ -59,6 +57,9 @@ } @Autowired + private OptionService optionService; + + @Autowired private PeriodService periodService; // ------------------------------------------------------------------------- @@ -99,14 +100,7 @@ { this.mandatory = mandatory; } - - private List attrOptions; - - public void setAttrOptions( List attrOptions ) - { - this.attrOptions = attrOptions; - } - + private Boolean inherit; public void setInherit( Boolean inherit ) @@ -128,6 +122,13 @@ this.unique = unique; } + private Integer optionSetId; + + public void setOptionSetId( Integer optionSetId ) + { + this.optionSetId = optionSetId; + } + // For Local ID type private Boolean orgunitScope; @@ -161,7 +162,7 @@ TrackedEntityAttribute attribute = new TrackedEntityAttribute(); attribute.setName( name ); - attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); + attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); attribute.setDescription( description ); attribute.setValueType( valueType ); attribute.setExpression( expression ); @@ -175,7 +176,7 @@ inherit = (inherit == null) ? false : true; attribute.setInherit( inherit ); - + if ( valueType.equals( TrackedEntityAttribute.VALUE_TYPE_LOCAL_ID ) ) { orgunitScope = (orgunitScope == null) ? false : orgunitScope; @@ -195,22 +196,13 @@ attribute.setOrgunitScope( orgunitScope ); attribute.setProgramScope( programScope ); } + else if ( valueType.equals( TrackedEntityAttribute.TYPE_COMBO ) ) + { + attribute.setOptionSet( optionService.getOptionSet( optionSetId ) ); + } attributeService.addTrackedEntityAttribute( attribute ); - if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( valueType ) ) - { - TrackedEntityAttributeOption opt = null; - for ( String optionName : attrOptions ) - { - opt = new TrackedEntityAttributeOption(); - opt.setName( optionName ); - opt.setAttribute( attribute ); - attribute.addAttributeOptions( opt ); - attributeService.addTrackedEntityAttributeOption( opt ); - } - } - return SUCCESS; } } \ No newline at end of file === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/RemoveAttributeOptionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/RemoveAttributeOptionAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/RemoveAttributeOptionAction.java 1970-01-01 00:00:00 +0000 @@ -1,119 +0,0 @@ -package org.hisp.dhis.trackedentity.action.trackedentityattribute; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; -import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Viet - */ -public class RemoveAttributeOptionAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private TrackedEntityAttributeService attributeService; - - public void setAttributeService( TrackedEntityAttributeService attributeService ) - { - this.attributeService = attributeService; - } - - private TrackedEntityAttributeValueService attributeValueService; - - public void setAttributeValueService( TrackedEntityAttributeValueService attributeValueService ) - { - this.attributeValueService = attributeValueService; - } - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private int id; - - public void setId( int id ) - { - this.id = id; - } - - private String message; - - public String getMessage() - { - return message; - } - - private I18n i18n; - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - TrackedEntityAttributeOption attributeOption = attributeService.getTrackedEntityAttributeOption( id ); - - if ( attributeOption != null ) - { - int count = attributeValueService.countByAttributeOption( attributeOption ); - if ( count > 0 ) - { - message = i18n.getString( "warning_delete_tracked_entity_attribute_option" ); - return INPUT; - } - else - { - attributeService.deleteTrackedEntityAttributeOption( attributeOption ); - message = i18n.getString( "success_delete_tracked_entity_attribute_option" ); - return SUCCESS; - } - } - else - { - message = i18n.getString( "error_delete_tracked_entity_attribute_option" ); - return ERROR; - } - - } - -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddAttributeFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddAttributeFormAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAddAttributeFormAction.java 2014-03-19 06:44:30 +0000 @@ -31,8 +31,11 @@ import java.util.ArrayList; import java.util.List; +import org.hisp.dhis.option.OptionService; +import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -55,17 +58,27 @@ this.periodService = periodService; } + @Autowired + private OptionService optionService; + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- - private List periodTypes = new ArrayList(); + private List periodTypes; public List getPeriodTypes() { return periodTypes; } + private List optionSets; + + public List getOptionSets() + { + return optionSets; + } + // ------------------------------------------------------------------------- // Getters && Setters // ------------------------------------------------------------------------- @@ -75,7 +88,8 @@ throws Exception { periodTypes = periodService.getAllPeriodTypes(); - + optionSets = new ArrayList(optionService.getAllOptionSets()); + return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowUpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowUpdateAttributeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowUpdateAttributeAction.java 2014-03-19 06:44:30 +0000 @@ -32,12 +32,15 @@ import java.util.Collection; import java.util.List; +import org.hisp.dhis.option.OptionService; +import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -72,6 +75,9 @@ this.periodService = periodService; } + @Autowired + private OptionService optionService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -97,13 +103,20 @@ return programs; } - private List periodTypes = new ArrayList(); + private List periodTypes; public List getPeriodTypes() { return periodTypes; } + private List optionSets; + + public List getOptionSets() + { + return optionSets; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -119,6 +132,8 @@ periodTypes = periodService.getAllPeriodTypes(); + optionSets = new ArrayList( optionService.getAllOptionSets() ); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-03-19 06:44:30 +0000 @@ -28,19 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - import org.apache.commons.lang.StringUtils; -import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.option.OptionService; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; -import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService; import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -65,12 +58,8 @@ this.attributeService = attributeService; } - private TrackedEntityAttributeValueService attributeValueService; - - public void setAttributeValueService( TrackedEntityAttributeValueService attributeValueService ) - { - this.attributeValueService = attributeValueService; - } + @Autowired + private OptionService optionService; @Autowired private PeriodService periodService; @@ -128,11 +117,11 @@ this.unique = unique; } - private List attrOptions; + private Integer optionSetId; - public void setAttrOptions( List attrOptions ) + public void setOptionSetId( Integer optionSetId ) { - this.attrOptions = attrOptions; + this.optionSetId = optionSetId; } private Boolean inherit; @@ -182,7 +171,7 @@ TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( id ); attribute.setName( name ); - attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); + attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); attribute.setDescription( description ); attribute.setValueType( valueType ); attribute.setExpression( expression ); @@ -197,42 +186,6 @@ inherit = (inherit == null) ? false : true; attribute.setInherit( inherit ); - HttpServletRequest request = ServletActionContext.getRequest(); - - Collection attributeOptions = attributeService.getTrackedEntityAttributeOption( attribute ); - - if ( attributeOptions != null && attributeOptions.size() > 0 ) - { - String value = null; - for ( TrackedEntityAttributeOption option : attributeOptions ) - { - value = request.getParameter( PREFIX_ATTRIBUTE_OPTION + option.getId() ); - if ( StringUtils.isNotBlank( value ) ) - { - option.setName( value.trim() ); - attributeService.updateTrackedEntityAttributeOption( option ); - attributeValueService.updateTrackedEntityAttributeValues( option ); - } - } - } - - if ( attrOptions != null ) - { - TrackedEntityAttributeOption opt = null; - for ( String optionName : attrOptions ) - { - opt = attributeService.getTrackedEntityAttributeOption( attribute, optionName ); - if ( opt == null ) - { - opt = new TrackedEntityAttributeOption(); - opt.setName( optionName ); - opt.setAttribute( attribute ); - attribute.addAttributeOptions( opt ); - attributeService.addTrackedEntityAttributeOption( opt ); - } - } - } - if ( valueType.equals( TrackedEntityAttribute.VALUE_TYPE_LOCAL_ID ) ) { orgunitScope = (orgunitScope == null) ? false : orgunitScope; @@ -252,6 +205,10 @@ attribute.setOrgunitScope( orgunitScope ); attribute.setProgramScope( programScope ); } + else if ( valueType.equals( TrackedEntityAttribute.TYPE_COMBO ) ) + { + attribute.setOptionSet( optionService.getOptionSet( optionSetId ) ); + } attributeService.updateTrackedEntityAttribute( attribute ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2014-02-17 15:00:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2014-03-19 06:44:30 +0000 @@ -93,8 +93,6 @@ scope="prototype"> - - - - - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-03-05 00:59:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-03-19 06:44:30 +0000 @@ -89,7 +89,7 @@ warning_delete_tracked_entity_attribute_option=This option has relationship with tracked entity attribute values success_delete_tracked_entity_attribute_option=Deleted tracked entity attribute option successfully error_delete_tracked_entity_attribute_option=Can not find tracked entity attribute option to delete -attribute_combo_type=Predefined value +attribute_combo_type=Option set type at_least_2_option=Please add at least two attribute options combo=Predefined value related=Related @@ -483,4 +483,5 @@ create_new_tracked_entity = Create new tracked entity tracked_entity_details = Tracked entity details edit_tracked_entity = Edit tracked entity -confirm_delete_tracked_entity = Are you sure you want to delete this tracked entity? \ No newline at end of file +confirm_delete_tracked_entity = Are you sure you want to delete this tracked entity? +option_set = Option set \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2014-02-17 15:00:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2014-03-19 06:44:30 +0000 @@ -140,7 +140,7 @@ + class="org.hisp.dhis.trackedentity.action.trackedentityattribute.ShowAddAttributeFormAction"> /main.vm /dhis-web-maintenance-program/addAttributeForm.vm @@ -177,20 +177,6 @@ plainTextError - - - /dhis-web-commons/ajax/jsonResponseSuccess.vm - - - /dhis-web-commons/ajax/jsonResponseError.vm - - - /dhis-web-commons/ajax/jsonResponseInput.vm - - F_TRACKED_ENTITY_ATTRIBUTE_DELETE - - /main.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-03-19 06:44:30 +0000 @@ -1,5 +1,4 @@ -

$i18n.getString( "create_new_tracked_entity_attribute" )

@@ -54,7 +53,7 @@ - @@ -71,11 +70,14 @@ - - -
[ $i18n.getString( "add_more_option" ) ] + + + - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm 2014-03-19 06:44:30 +0000 @@ -28,8 +28,8 @@ #foreach($programAttribute in $program.programAttributes) #set($opt="") - #foreach($option in $programAttribute.attribute.attributeOptions) - #set($opt=$opt + ';' + $option.name ) + #foreach($option in $programAttribute.attribute.optionSet.options) + #set($opt=$opt + ';' + $option ) #end #end === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-03-19 06:44:30 +0000 @@ -1,21 +1,7 @@ jQuery(document).ready( function(){ validation( 'addAttributeForm', function(form){ - if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) { - form.submit(i18n_field_is_required); - } - }, function(){ - isSubmit = true; - - var fields = jQuery("#addAttributeForm").serializeArray(); - jQuery.each(fields, function(i, field) { - if( field.name.match("^attrOption")=='attrOption' && field.value == ""){ - setInnerHTML("attrMessage", i18n_field_is_required); - isSubmit = false; - } - }); - }); - - jQuery("#attributeComboRow").hide(); - + form.submit(); + }) + checkValueIsExist( "name", "validateAttribute.action"); }); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-03-19 06:44:30 +0000 @@ -60,106 +60,20 @@ removeItem( context.id, context.name, i18n_confirm_delete, 'removeAttribute.action' ); } -ATTRIBUTE_OPTION = -{ - selectValueType : function (this_) - { - if ( jQuery(this_).val() == "combo" ) - { - showById("attributeComboRow"); - if( jQuery("#attrOptionContainer").find("input").length ==0 ) - { - ATTRIBUTE_OPTION.addOption(); - ATTRIBUTE_OPTION.addOption(); - } - } - else if (jQuery(this_).val() == "calculated"){ - if( jQuery("#availableAttribute option").length == 0 ) - { - jQuery.getJSON( 'getCalattributeParams.action', { }, - function ( json ) { - var attributes = jQuery("#availableAttribute"); - attributes.append( "" ); - for ( i in json.programs ) - { - var id = "[PG:" + json.programs[i].id + ".dateOfIncident]"; - attributes.append( "" ); - var id = "[PG:" + json.programs[i].id + ".enrollmentDate]"; - attributes.append( "" ); - } - for ( i in json.attributes ) - { - var id = "[CA:" + json.attributes[i].id + "]"; - attributes.append( "" ); - } - }); - } - hideById("attributeComboRow"); - } - else - { - hideById("attributeComboRow"); - } - typeOnChange(); - }, - checkOnSubmit : function () - { - if( jQuery("#valueType").val() != "combo" ) - { - jQuery("#attrOptionContainer").children().remove(); - return true; - }else { - $("input","#attrOptionContainer").each(function(){ - if( !jQuery(this).val() ) - jQuery(this).remove(); - }); - if( $("input","#attrOptionContainer").length < 2) - { - alert(i118_at_least_2_option); - return false; - }else return true; - } - }, - addOption : function () - { - jQuery("#attrOptionContainer").append(ATTRIBUTE_OPTION.createInput()); - }, - remove : function (this_, optionId) - { - - if( jQuery(this_).siblings("input").attr("name") != "attrOptions") - { - jQuery.get("removeattributeOption.action?id="+optionId,function(data){ - if( data.response == "success") - { - jQuery(this_).parent().parent().remove(); - showSuccessMessage( data.message ); - }else - { - showErrorMessage( data.message ); - } - }); - }else - { - jQuery(this_).parent().parent().remove(); - } - }, - removeInAddForm : function(this_) - { - jQuery(this_).parent().parent().remove(); - }, - createInput : function () - { - return "[ - ]"; - } -} function typeOnChange() { - var type = getFieldValue('valueType'); - if( type == 'localId' ) { - jQuery('[name=localIdField]').show(); - } - else { - jQuery('[name=localIdField]').hide(); - } + var type = getFieldValue('valueType'); + if( type=="combo"){ + showById("optionSetRow"); + jQuery('[name=localIdField]').hide(); + } + else if( type == 'localId' ) { + jQuery('[name=localIdField]').show(); + hideById("optionSetRow"); + } + else { + jQuery('[name=localIdField]').hide(); + hideById("optionSetRow"); + } } + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-03-19 06:44:30 +0000 @@ -1,21 +1,7 @@ jQuery(document).ready( function(){ validation( 'updateAttributeForm', function(form){ - if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) { - form.submit(i18n_field_is_required); - } - }, function(){ - isSubmit = true; - - var fields = $("#addAttributeForm").serializeArray(); - jQuery.each(fields, function(i, field) { - if( field.name.match("^attrOption")=='attrOption' && field.value == ""){ - setInnerHTML("attrMessage", i18n_field_is_required); - isSubmit = false; - } - }); + form.submit(); }); - ATTRIBUTE_OPTION.selectValueType(byId("valueType")); - checkValueIsExist( "name", "validateAttribute.action", {id:getFieldValue('id')}); }); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/jsonParamsByProgram.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/jsonParamsByProgram.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/jsonParamsByProgram.vm 2014-03-19 06:44:30 +0000 @@ -13,7 +13,7 @@ { "id": "[CA:${attribute.id}]", "name": "$!encoder.jsonEncode( ${attribute.name} )", - "suggested":"$attribute.attributeOptions" + "suggested":"$!attribute.optionSet.options" }#if( $velocityCount < $size ),#end #end ] === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-03-19 06:44:30 +0000 @@ -55,7 +55,7 @@ $i18n.getString( "value_type" ) * - @@ -72,18 +72,14 @@ - - - - - #foreach($option in $attribute.attributeOptions) - - - #end -
- [ - ] -
[ $i18n.getString( "add_more_option" ) ] - + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm 2014-02-28 10:09:08 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm 2014-03-19 06:44:30 +0000 @@ -29,8 +29,8 @@ #set($attribute = '') #foreach($programAttribute in $program.programAttributes) #set($opt="") - #foreach($option in $programAttribute.attribute.attributeOptions) - #set($opt=$opt + ';' + $option.name ) + #foreach($option in $programAttribute.attribute.optionSet.options) + #set($opt=$opt + ';' + $option ) #end #end @@ -44,10 +44,10 @@ - #if($attribute.attributeOptions) + #if($attribute.optionSet.options) #else === added file 'resources/sql/create-optionset-from-tei-attribute-option.sql' --- resources/sql/create-optionset-from-tei-attribute-option.sql 1970-01-01 00:00:00 +0000 +++ resources/sql/create-optionset-from-tei-attribute-option.sql 2014-03-19 06:44:30 +0000 @@ -0,0 +1,8 @@ +INSERT INTO optionset ( optionsetid, name, lastupdated, created, version ) +select nextval('hibernate_sequence'), name || '_' || uid, now(), now(), 1 from trackedentityattribute where valuetype='combo'; + + +INSERT INTO optionsetmembers ( optionsetid, optionvalue, sort_order ) +select opt.optionsetid, teo.name,teo.trackedentityattributeoptionid from trackedentityattribute tea inner join trackedentityattributeoption teo +on tea.trackedentityattributeid=teo.trackedentityattributeid +inner join optionset opt on opt.name=tea.name || '_' || tea.uid; \ No newline at end of file