=== 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 2015-03-31 03:17:35 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2015-11-16 22:52:04 +0000 @@ -40,19 +40,15 @@ import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import java.io.Serializable; - /** * @author Chau Thu Tran */ @JacksonXmlRootElement( localName = "programTrackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0 ) public class ProgramTrackedEntityAttribute - implements Serializable + extends BaseIdentifiableObject { - private static final long serialVersionUID = -2420475559273198337L; - - private int id; - + private Program program; + private TrackedEntityAttribute attribute; private boolean displayInList; @@ -69,23 +65,26 @@ { } - public ProgramTrackedEntityAttribute( TrackedEntityAttribute attribute, int sortOrder, boolean displayInList ) + public ProgramTrackedEntityAttribute( Program program, TrackedEntityAttribute attribute, int sortOrder, boolean displayInList ) { + this.program = program; this.attribute = attribute; this.displayInList = displayInList; } - public ProgramTrackedEntityAttribute( TrackedEntityAttribute attribute, boolean displayInList, + public ProgramTrackedEntityAttribute( Program program, TrackedEntityAttribute attribute, boolean displayInList, Boolean mandatory ) { + this.program = program; this.attribute = attribute; this.displayInList = displayInList; this.mandatory = mandatory; } - public ProgramTrackedEntityAttribute( TrackedEntityAttribute attribute, boolean displayInList, + public ProgramTrackedEntityAttribute( Program program, TrackedEntityAttribute attribute, boolean displayInList, Boolean mandatory, Boolean allowFutureDate ) { + this.program = program; this.attribute = attribute; this.displayInList = displayInList; this.mandatory = mandatory; @@ -96,27 +95,18 @@ // Getters && Setters // ------------------------------------------------------------------------- - public int getId() - { - return id; - } - - public void setId( int id ) - { - this.id = id; - } - @JsonProperty + @JsonSerialize( as = BaseIdentifiableObject.class ) @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Boolean isMandatory() + public Program getProgram() { - return mandatory; + return program; } - public void setMandatory( Boolean mandatory ) + public void setProgram( Program program ) { - this.mandatory = mandatory; + this.program = program; } @JsonProperty( "trackedEntityAttribute" ) @@ -135,6 +125,19 @@ @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Boolean isMandatory() + { + return mandatory; + } + + public void setMandatory( Boolean mandatory ) + { + this.mandatory = mandatory; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( localName = "displayInList", namespace = DxfNamespaces.DXF_2_0 ) public boolean isDisplayInList() { === 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 2015-11-16 22:52:04 +0000 @@ -0,0 +1,39 @@ +package org.hisp.dhis.program; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; + +/** + * @author Lars Helge Overland + */ +public interface ProgramTrackedEntityAttributeStore +{ + ProgramTrackedEntityAttribute get( Program program, TrackedEntityAttribute attribute ); +} === added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramTrackedEntityAttributeStore.java 2015-11-16 22:52:04 +0000 @@ -0,0 +1,52 @@ +package org.hisp.dhis.program.hibernate; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; +import org.hisp.dhis.program.ProgramTrackedEntityAttributeStore; +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; + +import org.hibernate.criterion.Restrictions; + +/** + * @author Lars Helge Overland + */ +public class HibernateProgramTrackedEntityAttributeStore + extends HibernateIdentifiableObjectStore + implements ProgramTrackedEntityAttributeStore +{ + public ProgramTrackedEntityAttribute get( Program program, TrackedEntityAttribute attribute ) + { + return (ProgramTrackedEntityAttribute) getCriteria( + Restrictions.eq( "program", program ), + Restrictions.eq( "attribute", attribute ) ).uniqueResult(); + } +} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-11-16 20:38:13 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-11-16 22:52:04 +0000 @@ -470,11 +470,18 @@ - + + + + + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml 2015-06-23 15:59:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramTrackedEntityAttribute.hbm.xml 2015-11-16 22:52:04 +0000 @@ -1,19 +1,23 @@ + "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" + [] + > - + - - + &identifiableProperties; + + + + === 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 2015-11-01 13:27:57 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-11-16 22:52:04 +0000 @@ -1169,7 +1169,7 @@ for ( TrackedEntityAttribute attribute : attributes ) { - program.getProgramAttributes().add( new ProgramTrackedEntityAttribute( attribute, i++, false ) ); + program.getProgramAttributes().add( new ProgramTrackedEntityAttribute( program, attribute, i++, false ) ); } } === 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 2015-11-02 04:27:25 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java 2015-11-16 22:52:04 +0000 @@ -329,7 +329,7 @@ TrackedEntityAttribute attribute = trackedEntityAttributeService.getTrackedEntityAttribute( Integer.parseInt( ids[1] ) ); - ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, + ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( program, attribute, personDisplayNames.get( index ), mandatory.get( index ), allowFutureDate.get( index ) ); program.getProgramAttributes().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 2015-11-02 04:27:25 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java 2015-11-16 22:52:04 +0000 @@ -354,7 +354,7 @@ { TrackedEntityAttribute attribute = trackedEntityAttributeService.getTrackedEntityAttribute( Integer .parseInt( ids[1] ) ); - ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, + ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( program, attribute, personDisplayNames.get( index ), mandatory.get( index ), allowFutureDate.get( index ) ); program.getProgramAttributes().add( programAttribute ); }