=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2014-03-20 05:43:18 +0000 @@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.view.DetailedView; @@ -60,6 +61,8 @@ private boolean displayedInList; + private Boolean mandatory; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -75,6 +78,15 @@ this.displayedInList = displayedInList; } + public ProgramTrackedEntityAttribute( TrackedEntityAttribute attribute, Integer sortOrder, boolean displayedInList, + Boolean mandatory ) + { + this.attribute = attribute; + this.sortOrder = sortOrder; + this.displayedInList = displayedInList; + this.mandatory = mandatory; + } + // ------------------------------------------------------------------------- // hashCode, equals and toString // ------------------------------------------------------------------------- @@ -124,6 +136,19 @@ } @JsonProperty + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Boolean getMandatory() + { + return mandatory; + } + + public void setMandatory( Boolean mandatory ) + { + this.mandatory = mandatory; + } + + @JsonProperty @JsonSerialize( as = BaseIdentifiableObject.class ) @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) @JacksonXmlProperty( localName = "personAttribute", namespace = DxfNamespaces.DXF_2_0 ) === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeService.java 2014-03-20 05:43:18 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; + +/** + * @author Chau Thu Tran + * + * @version $ ProgramTrackedEntityAttributeService.java Mar 19, 2014 2:53:34 PM + * $ + */ +public interface ProgramTrackedEntityAttributeService +{ + /** + * Get ProgramTrackedEntityAttribute by Program and TrackedEntityAttribute + * + * @param program Program + * @param attribute TrackedEntityAttribute + * + * @return ProgramTrackedEntityAttribute + */ + ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute( Program program, TrackedEntityAttribute attribute ); +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttributeStore.java 2014-03-20 05:43:18 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; + +/** + * @author Chau Thu Tran + * + * @version $ ProgramTrackedEntityAttributeStore.java Mar 19, 2014 2:54:23 PM $ + */ +public interface ProgramTrackedEntityAttributeStore +{ + /** + * Get ProgramTrackedEntityAttribute by Program and TrackedEntityAttribute + * @param program Program + * @param attribute TrackedEntityAttribute + * + * @return ProgramTrackedEntityAttribute + */ + ProgramTrackedEntityAttribute get( Program program, TrackedEntityAttribute attribute ); +} === 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-19 06:44:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-20 05:43:18 +0000 @@ -86,8 +86,6 @@ private String valueType; - private boolean mandatory; - private Boolean inherit = false; private Boolean groupBy = false; @@ -125,13 +123,12 @@ setAutoFields(); } - public TrackedEntityAttribute( String name, String description, String valueType, boolean mandatory, + public TrackedEntityAttribute( String name, String description, String valueType, Boolean inherit, Boolean displayOnVisitSchedule ) { this.name = name; this.description = description; this.valueType = valueType; - this.mandatory = mandatory; this.inherit = inherit; this.displayOnVisitSchedule = displayOnVisitSchedule; @@ -179,20 +176,7 @@ { this.groupBy = groupBy; } - - @JsonProperty - @JsonView( { DetailedView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public boolean isMandatory() - { - return mandatory; - } - - public void setMandatory( boolean mandatory ) - { - this.mandatory = mandatory; - } - + @JsonProperty @JsonView( { DetailedView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @@ -416,7 +400,6 @@ description = trackedEntityAttribute.getDescription(); valueType = trackedEntityAttribute.getValueType(); - mandatory = trackedEntityAttribute.isMandatory(); inherit = trackedEntityAttribute.getInherit(); groupBy = trackedEntityAttribute.getGroupBy(); attributeGroup = trackedEntityAttribute.getAttributeGroup(); === 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-19 06:44:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-20 05:43:18 +0000 @@ -108,19 +108,12 @@ Collection getTrackedEntityAttributesByValueType( String valueType ); /** - * Get mandatory attributes without groups + * Get attributes without groups * * @return List of attributes */ Collection getOptionalAttributesWithoutGroup(); - - /** - * Get attributes by mandatory option - * - * @param mandatory True/False value - */ - Collection getTrackedEntityAttributesByMandatory( boolean mandatory ); - + /** * Get attributes by groupBy option * === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStore.java 2014-03-20 05:43:18 +0000 @@ -50,21 +50,12 @@ Collection getByValueType( String valueType ); /** - * Get mandatory attributes without groups + * Get attributes without groups * * @return List of attributes */ Collection getOptionalAttributesWithoutGroup(); - - /** - * Get attributes by mandatory option - * - * @param mandatory True/False value - * - * @return List of attributes - */ - Collection getByMandatory( boolean mandatory ); - + /** * Get {@link TrackedEntityAttribute} without any group * === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-03-19 10:55:15 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-03-20 05:43:18 +0000 @@ -432,7 +432,7 @@ for ( ProgramTrackedEntityAttribute programTrackedEntityAttribute : program.getAttributes() ) { // TODO this will be replaced with programTrackedEntityAttribute.isMandatory when added to the model - mandatoryMap.put( programTrackedEntityAttribute.getAttribute(), programTrackedEntityAttribute.getAttribute().isMandatory() ); + mandatoryMap.put( programTrackedEntityAttribute.getAttribute(), programTrackedEntityAttribute.getMandatory() ); } for ( TrackedEntityAttributeValue value : trackedEntityInstance.getAttributeValues() ) === 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-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-03-20 05:43:18 +0000 @@ -1399,8 +1399,7 @@ for ( TrackedEntityAttribute patientAtt : getPatientAtts( null ) ) { - list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), patientAtt - .isMandatory(), new ArrayList() ) ); + list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), false, new ArrayList() ) ); } 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-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2014-03-20 05:43:18 +0000 @@ -294,7 +294,6 @@ 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( "" ); if ( ppa.getDisplayedInList() ) === added file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramTrackedEntityAttributeService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramTrackedEntityAttributeService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramTrackedEntityAttributeService.java 2014-03-20 05:43:18 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Chau Thu Tran + * + * @version $ DefaultProgramTrackedEntityAttributeService.java Mar 19, 2014 + * 2:55:57 PM $ + */ +public class DefaultProgramTrackedEntityAttributeService + implements ProgramTrackedEntityAttributeService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private ProgramTrackedEntityAttributeStore programAttributeStore; + + // ------------------------------------------------------------------------- + // Implementation methods + // ------------------------------------------------------------------------- + + @Override + public ProgramTrackedEntityAttribute getProgramTrackedEntityAttribute( Program program, + TrackedEntityAttribute atribute ) + { + return programAttributeStore.get( program, atribute ); + } + +} === added file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java 2014-03-20 05:43:18 +0000 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program.hibernate; + +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; +import org.hisp.dhis.program.ProgramTrackedEntityAttributeStore; +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; + +/** + * @author Chau Thu Tran + * + * @version $ HibernateProgramTrackedEntityAttributeStore.java Mar 19, 2014 + * 2:58:05 PM $ + */ +public class HibernateProgramTrackedEntityAttributeStore + implements ProgramTrackedEntityAttributeStore +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SessionFactory sessionFactory; + + public void setSessionFactory( SessionFactory sessionFactory ) + { + this.sessionFactory = sessionFactory; + } + + // ------------------------------------------------------------------------- + // Implemented methods + // ------------------------------------------------------------------------- + + @Override + public ProgramTrackedEntityAttribute get( Program program, TrackedEntityAttribute attribute ) + { + Session session = sessionFactory.getCurrentSession(); + + Criteria criteria = session.createCriteria( ProgramStageDataElement.class ); + criteria.add( Restrictions.eq( "program", program ) ); + criteria.add( Restrictions.eq( "attribute", attribute ) ); + + return (ProgramTrackedEntityAttribute) criteria.uniqueResult(); + } +} === 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-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-20 05:43:18 +0000 @@ -109,11 +109,6 @@ return attributeStore.getOptionalAttributesWithoutGroup(); } - public Collection getTrackedEntityAttributesByMandatory( boolean mandatory ) - { - return attributeStore.getByMandatory( mandatory ); - } - public Collection getTrackedEntityAttributesWithoutGroup() { return attributeStore.getWithoutGroup(); === 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-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-03-20 05:43:18 +0000 @@ -37,9 +37,11 @@ import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramTrackedEntityAttributeService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService; import org.hisp.dhis.user.User; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; /** @@ -86,6 +88,9 @@ this.attributeValueService = attributeValueService; } + @Autowired + private ProgramTrackedEntityAttributeService programAttributeService; + // ------------------------------------------------------------------------- // TrackedEntityForm implementation // ------------------------------------------------------------------------- @@ -195,7 +200,7 @@ } } - inputHtml = getAttributeField( inputHtml, attribute, value, i18n, index, hidden, style ); + inputHtml = getAttributeField( inputHtml, attribute, program, value, i18n, index, hidden, style ); } @@ -272,13 +277,20 @@ // Supportive methods // ------------------------------------------------------------------------- - private String getAttributeField( String inputHtml, TrackedEntityAttribute attribute, String value, I18n i18n, + private String getAttributeField( String inputHtml, TrackedEntityAttribute attribute, Program program, String value, I18n i18n, int index, String hidden, String style ) { + boolean madatory = false; + + if( program!= null) + { + madatory = programAttributeService.getProgramTrackedEntityAttribute( program, attribute ).getMandatory(); + } + inputHtml = TAG_OPEN + "input id=\"attr" + attribute.getId() + "\" name=\"attr" + attribute.getId() + "\" tabindex=\"" + index + "\" style=\"" + style + "\""; - inputHtml += "\" class=\"" + hidden + " {validate:{required:" + attribute.isMandatory(); + inputHtml += "\" class=\"" + hidden + " {validate:{required:" + madatory; if ( TrackedEntityAttribute.TYPE_INT.equals( attribute.getValueType() ) ) { inputHtml += ",number:true"; === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAttributeStore.java 2014-03-20 05:43:18 +0000 @@ -55,17 +55,9 @@ @Override @SuppressWarnings( "unchecked" ) - public Collection getByMandatory( boolean mandatory ) - { - return getCriteria( Restrictions.eq( "mandatory", mandatory ) ).list(); - } - - @Override - @SuppressWarnings( "unchecked" ) public Collection getOptionalAttributesWithoutGroup() { - return getCriteria( Restrictions.isNull( "attributeGroup" ) ).add( Restrictions.eq( "mandatory", false ) ) - .list(); + return getCriteria( Restrictions.isNull( "attributeGroup" ) ).list(); } @Override === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2014-03-19 07:31:33 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2014-03-20 05:43:18 +0000 @@ -280,6 +280,12 @@ executeSql( "ALTER TABLE trackedentityattributevalue DROP COLUMN trackedentityattributeoptionid" ); executeSql( "DROP TABLE trackedentityattributeoption" ); + + executeSql( "UPDATE program_attributes SET mandatory = trackedentityattribute.mandatory " + + "FROM program_attributes pa " + "INNER JOIN trackedentityattribute " + + "ON pa.trackedentityattributeid=trackedentityattribute.trackedentityattributeid " + + "where trackedentityattribute.mandatory is not null" ); + executeSql( "ALTER TABLE trackedentityattribute DROP COLUMN mandatory" ); } // ------------------------------------------------------------------------- @@ -424,17 +430,18 @@ private void createPersonTrackedEntity() { - int exist = jdbcTemplate.queryForObject( "SELECT count(*) FROM trackedentity where name='Person'", Integer.class ); + int exist = jdbcTemplate.queryForObject( "SELECT count(*) FROM trackedentity where name='Person'", + Integer.class ); if ( exist == 0 ) { String id = statementBuilder.getAutoIncrementValue(); - + jdbcTemplate.execute( "INSERT INTO trackedentity(trackedentityid,uid, name, description) values(" + id + ",'" + CodeGenerator.generateCode() + "','Person','Person')" ); - + jdbcTemplate.execute( "UPDATE program SET trackedentityid=" + " (SELECT trackedentityid FROM trackedentity where name='Person') where trackedentityid is null" ); - + jdbcTemplate.execute( "UPDATE trackedentityinstance SET trackedentityid=" + " (SELECT trackedentityid FROM trackedentity where name='Person') where trackedentityid is null" ); } === 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-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-03-20 05:43:18 +0000 @@ -131,6 +131,11 @@ + + + + @@ -292,6 +297,11 @@ + + + + === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml 2014-02-10 05:42:16 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml 2014-03-20 05:43:18 +0000 @@ -4,18 +4,22 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - - - - - - - - - - - - - + + + + + + + + + + + + + + + === 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-03-19 06:44:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2014-03-20 05:43:18 +0000 @@ -19,8 +19,6 @@ - - attributes = attributeStore.getByMandatory( true ); - assertEquals( 2, attributes.size() ); - assertTrue( attributes.contains( attributeA ) ); - assertTrue( attributes.contains( attributeB ) ); - } - - @Test public void testGetTrackedEntityAttributeByGroupBy() { attributeA.setGroupBy( true ); === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java' --- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2014-03-20 05:43:18 +0000 @@ -176,23 +176,6 @@ } @Test - public void testGetTrackedEntityAttributesByMandatory() - { - attributeA.setMandatory( true ); - attributeB.setMandatory( true ); - attributeC.setMandatory( false ); - - attributeService.addTrackedEntityAttribute( attributeA ); - attributeService.addTrackedEntityAttribute( attributeB ); - attributeService.addTrackedEntityAttribute( attributeC ); - - Collection attributes = attributeService.getTrackedEntityAttributesByMandatory( true ); - assertEquals( 2, attributes.size() ); - assertTrue( attributes.contains( attributeA ) ); - assertTrue( attributes.contains( attributeB ) ); - } - - @Test public void testGetTrackedEntityAttributeByGroupBy() { attributeA.setGroupBy( true ); === 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-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java 2014-03-20 05:43:18 +0000 @@ -38,7 +38,6 @@ 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; @@ -87,7 +86,7 @@ this.entityInstanceId = entityInstanceId; } - private List attributes; + private List attributes = new ArrayList(); public List getAttributes() { @@ -112,10 +111,7 @@ if ( id != null ) { Program program = programService.getProgram( id ); - for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ) - { - attributes.add(programAttribute.getAttribute() ); - } + attributes.addAll( program.getTrackedEntityAttributes() ); } 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-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java 2014-03-20 05:43:18 +0000 @@ -115,12 +115,6 @@ private List attributeGroups; - private Map identiferMap; - - private String childContactName; - - private String childContactType; - private Relationship relationship; private Map> attributeGroupsMap = new HashMap>(); @@ -179,6 +173,13 @@ return trackedEntities; } + private Map mandatoryMap = new HashMap(); + + public Map getMandatoryMap() + { + return mandatoryMap; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -246,12 +247,17 @@ } } } + + + for( TrackedEntityAttribute attribute : attributes){ + mandatoryMap.put( attribute.getId(), false ); + } } else { - for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ) - { - attributes.add( programAttribute.getAttribute() ); + attributes = program.getTrackedEntityAttributes(); + for( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ){ + mandatoryMap.put( programAttribute.getAttribute().getId(), programAttribute.getMandatory() ); } } @@ -362,21 +368,6 @@ return attributeGroups; } - public Map getIdentiferMap() - { - return identiferMap; - } - - public String getChildContactName() - { - return childContactName; - } - - public String getChildContactType() - { - return childContactType; - } - public void setEntityInstanceService( TrackedEntityInstanceService entityInstanceService ) { this.entityInstanceService = entityInstanceService; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ShowAddTrackedEntityInstanceFormAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ShowAddTrackedEntityInstanceFormAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ShowAddTrackedEntityInstanceFormAction.java 2014-03-20 05:43:18 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; import org.hisp.dhis.trackedentity.TrackedEntity; @@ -178,13 +179,6 @@ return healthWorkers; } - private List attributes = new ArrayList(); - - public List getAttributes() - { - return attributes; - } - private Map> attributesMap = new HashMap>(); public Map> getAttributesMap() @@ -276,6 +270,13 @@ return trackedEntityAttributeValueMap; } + private Map mandatoryMap = new HashMap(); + + public Map getMandatoryMap() + { + return mandatoryMap; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -341,6 +342,8 @@ } } + List attributes = new ArrayList(); + if ( customRegistrationForm == null ) { attributeGroups = new ArrayList( @@ -349,23 +352,28 @@ if ( program == null ) { - attributes = new ArrayList( attributeService.getAllTrackedEntityAttributes() ); + attributes = new ArrayList( attributeService.getTrackedEntityAttributesDisplayedInList( true ) ); Collection programs = programService.getAllPrograms(); for ( Program p : programs ) { attributes.removeAll( p.getAttributes() ); } + + for ( TrackedEntityAttribute attribute : attributes ) + { + mandatoryMap.put( attribute.getId(), false ); + } } else { attributes = program.getTrackedEntityAttributes(); + for ( ProgramTrackedEntityAttribute programAttribute : program.getAttributes() ) + { + mandatoryMap.put( programAttribute.getAttribute().getId(), programAttribute.getMandatory() ); + } } - Collection attributesInList = attributeService.getTrackedEntityAttributesDisplayedInList( true ); - attributes.removeAll( attributesInList ); - attributes.addAll( attributesInList ); - for ( TrackedEntityAttribute attribute : attributes ) { TrackedEntityAttributeGroup attributeGroup = attribute.getAttributeGroup(); === 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-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceForm.vm 2014-03-20 05:43:18 +0000 @@ -1,4 +1,3 @@ - #if( $entityInstance ) #set($trackedEntityId=$entityInstance.trackedEntity.id) #elseif( $program ) @@ -45,39 +44,41 @@ #if( $attribute ) #set($value = "") #set($value = $attributeValueMap.get($attribute.id)) + #set($mandatory = $mandatoryMap.get($attribute.id)) + #if( $mandatory ) #else #set($mandatory=false) #end - + #if( $attribute.valueType == "bool" ) - #elseif( $attribute.valueType == "trueOnly" ) - + #elseif( $attribute.valueType == "date" ) - + #elseif( $attribute.valueType == "combo" ) - #foreach ($option in $attribute.optionSet.options ) #end #elseif( $attribute.valueType == "phoneNumber" ) - + #elseif( $attribute.valueType == "trackerAssociate" ) #elseif( $attribute.valueType == "age" || $attribute.valueType == "number" ) - + #else - + #end @@ -93,9 +94,11 @@ #foreach($attribute in $attributes ) #set( $attributeValue = "" ) #set( $attributeValue = $!attributeValueMap.get( $attribute.id ) ) + #set($mandatory = $mandatoryMap.get($attribute.id)) + #if( $mandatory ) #else #set($mandatory=false) #end #if( $attribute.valueType != 'calculated') - + #if( $attribute.valueType == "bool" ) #elseif( $attribute.valueType == "date" ) - + #elseif( $attribute.valueType == "combo" ) - #foreach ($option in $attribute.optionSet.options ) #end #elseif( $attribute.valueType == "users" ) - #foreach( $user in $healthWorkers) @@ -131,7 +134,7 @@ inherit="$!attribute.inherit" #if($value=='true') checked #end onclick="toggleUnderAge(this);" class='underAge' /> #else - + #end === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntityAttribute.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntityAttribute.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntityAttribute.vm 2014-03-20 05:43:18 +0000 @@ -4,10 +4,10 @@ "name": "$!encoder.jsonEncode( ${attribute.name} )", "code": "$!encoder.jsonEncode( ${attribute.code} )", "description": "$!encoder.jsonEncode( ${attribute.description} )", - "mandatory": "$!{attribute.mandatory}", "unique": "$!{attribute.unique}", "valueType": "$!attribute.valueType", "displayInListNoProgram": "$!attribute.displayInListNoProgram", - "inherit": "$!attribute.inherit" + "inherit": "$!attribute.inherit", + "optionSet": "$!attribute.optionSet.name" } } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/ViewTrackedEntityFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/ViewTrackedEntityFormAction.java 2014-03-18 14:54:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/ViewTrackedEntityFormAction.java 2014-03-20 05:43:18 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -109,6 +110,13 @@ return attributes; } + private Collection programAttributes = new ArrayList(); + + public Collection getProgramAttributes() + { + return programAttributes; + } + private TrackedEntityForm registrationForm; public TrackedEntityForm getRegistrationForm() @@ -162,7 +170,7 @@ else { program = programService.getProgram( programId ); - attributes = program.getTrackedEntityAttributes(); + programAttributes = program.getAttributes(); registrationForm = formService.getTrackedEntityForm( program ); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.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/program/AddProgramAction.java 2014-03-20 05:43:18 +0000 @@ -100,9 +100,9 @@ this.relationshipTypeService = relationshipTypeService; } - @Autowired + @Autowired private TrackedEntityService trackedEntityService; - + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -163,6 +163,13 @@ this.personDisplayNames = personDisplayNames; } + private List mandatory = new ArrayList(); + + public void setMandatory( List mandatory ) + { + this.mandatory = mandatory; + } + private Boolean ignoreOverdueEvents; public void setIgnoreOverdueEvents( Boolean ignoreOverdueEvents ) @@ -293,7 +300,7 @@ program.setRelationshipFromA( relationshipFromA ); program.setRelationshipText( relationshipText ); - if( trackedEntityId!=null) + if ( trackedEntityId != null ) { TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId ); program.setTrackedEntity( trackedEntity ); @@ -311,7 +318,7 @@ .parseInt( ids[1] ) ); ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, - index + 1, personDisplayNames.get( index ) ); + index + 1, personDisplayNames.get( index ), mandatory.get( index ) ); program.getAttributes().add( programAttribute ); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.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/program/UpdateProgramAction.java 2014-03-20 05:43:18 +0000 @@ -166,6 +166,13 @@ this.personDisplayNames = personDisplayNames; } + private List mandatory = new ArrayList(); + + public void setMandatory( List mandatory ) + { + this.mandatory = mandatory; + } + private Boolean generateBydEnrollmentDate; public void setGeneratedByEnrollmentDate( Boolean generateBydEnrollmentDate ) @@ -346,7 +353,7 @@ TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer .parseInt( ids[1] ) ); ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, - index + 1, personDisplayNames.get( index ) ); + index + 1, personDisplayNames.get( index ), mandatory.get( index ) ); program.getAttributes().add( programAttribute ); } === 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-19 06:44:30 +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-20 05:43:18 +0000 @@ -94,13 +94,6 @@ this.valueType = valueType; } - private Boolean mandatory; - - public void setMandatory( Boolean mandatory ) - { - this.mandatory = mandatory; - } - private Boolean inherit; public void setInherit( Boolean inherit ) @@ -167,10 +160,7 @@ attribute.setValueType( valueType ); attribute.setExpression( expression ); attribute.setDisplayOnVisitSchedule( false ); - - mandatory = (mandatory == null) ? false : true; - attribute.setMandatory( mandatory ); - + unique = (unique == null) ? false : true; attribute.setUnique( unique ); === 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-19 06:44:30 +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-20 05:43:18 +0000 @@ -103,13 +103,6 @@ this.valueType = valueType; } - private Boolean mandatory; - - public void setMandatory( Boolean mandatory ) - { - this.mandatory = mandatory; - } - private Boolean unique; public void setUnique( Boolean unique ) @@ -177,9 +170,6 @@ attribute.setExpression( expression ); attribute.setDisplayOnVisitSchedule( false ); - mandatory = (mandatory == null) ? false : true; - attribute.setMandatory( mandatory ); - unique = (unique == null) ? false : true; attribute.setUnique( unique ); === 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-03-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-03-20 05:43:18 +0000 @@ -25,14 +25,6 @@ - - - - - - - - @@ -70,7 +62,7 @@ - + + @@ -253,6 +261,7 @@ $i18n.getString( "name" ) $i18n.getString( "displayed_in_list" ) + $i18n.getString( "mandatory" ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attribute.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attribute.vm 2014-03-03 08:32:11 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attribute.vm 2014-03-20 05:43:18 +0000 @@ -51,11 +51,12 @@



-




-


- +


+


+ + === 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-03-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-03-20 05:43:18 +0000 @@ -19,9 +19,7 @@ function ( json ) { setInnerHTML( 'nameField', json.attribute.name ); setInnerHTML( 'descriptionField', json.attribute.description ); - - var mandatory = ( json.attribute.mandatory == 'true') ? i18n_yes : i18n_no; - setInnerHTML( 'mandatoryField', mandatory ); + setInnerHTML( 'optionSetField', json.attribute.optionSet ); var unique = ( json.attribute.unique == 'true') ? i18n_yes : i18n_no; setInnerHTML( 'uniqueField', unique ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js 2014-02-26 15:09:48 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js 2014-03-20 05:43:18 +0000 @@ -161,9 +161,10 @@ var selectedList = jQuery("#selectedList"); jQuery("#availablePropertyIds").children().each(function( i, item ) { if( item.selected ) { - html = "" + item.text + ""; + html = "" + item.text + ""; html += "" + item.text + ""; html += " - - - - - - - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm 2014-02-17 16:09:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm 2014-03-20 05:43:18 +0000 @@ -12,7 +12,9 @@ personDisplayNames.empty(); var compulsaryIdentifier = jQuery( "#compulsaryIdentifier" ); compulsaryIdentifier.empty(); - + var mandatorySelector = jQuery( "#mandatory" ); + mandatorySelector.empty(); + if( getFieldValue('type') != 3 ){ var isDisplayed = false; jQuery("#selectedList").find("tr").each( function( i, item ){ @@ -23,6 +25,12 @@ isDisplayed = true } personDisplayNames.append( "" ); + + // mandatory + var mandatory = jQuery( item ).find( "input[name='mandatory']:first"); + checked = mandatory.attr('checked') ? true : false; + mandatorySelector.append( "" ); + }); if( jQuery("#selectedList").find("tr").length > 0 && isDisplayed ){ compulsaryIdentifier.append( ""); @@ -233,6 +241,7 @@ $i18n.getString( "select_attributes" ) + @@ -263,6 +272,7 @@ $i18n.getString( "name" ) $i18n.getString( "displayed_in_list" ) + $i18n.getString( "mandatory" ) @@ -271,6 +281,7 @@ $encoder.htmlEncode( $attribute.name ) + #end === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewTrackedEntityForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewTrackedEntityForm.vm 2014-02-26 15:09:48 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewTrackedEntityForm.vm 2014-03-20 05:43:18 +0000 @@ -122,7 +122,10 @@