=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2014-02-17 15:00:27 +0000 @@ -43,6 +43,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.relationship.RelationshipType; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; @@ -141,6 +142,8 @@ private Boolean dataEntryMethod = false; + private TrackedEntity trackedEntity; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -606,4 +609,19 @@ { this.attributes = attributes; } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlElementWrapper( localName = "trackedEntity", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "trackedEntity", namespace = DxfNamespaces.DXF_2_0 ) + public TrackedEntity getTrackedEntity() + { + return trackedEntity; + } + + public void setTrackedEntity( TrackedEntity trackedEntity ) + { + this.trackedEntity = trackedEntity; + } + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-11-14 09:36:39 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2014-02-17 15:00:27 +0000 @@ -31,6 +31,7 @@ import java.util.Collection; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.validation.ValidationCriteria; /** @@ -178,4 +179,12 @@ * @param organisationUnit {@link OrganisationUnit} */ Collection getProgramsByCurrentUser( OrganisationUnit organisationUnit ); + + /** + * Get {@link Program} by TrackedEntity + * + * @param trackedEntity {@link TrackedEntity} + */ + Collection getProgramsByTrackedEntity( TrackedEntity trackedEntity ); + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java 2013-11-04 03:13:27 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java 2014-02-17 15:00:27 +0000 @@ -30,6 +30,7 @@ import org.hisp.dhis.common.GenericNameableObjectStore; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.trackedentity.TrackedEntity; import java.util.Collection; @@ -95,4 +96,12 @@ * @return Program list */ Collection getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit ); + + /** + * Get {@link Program} by TrackedEntity + * + * @param trackedEntity {@link TrackedEntity} + */ + Collection getByTrackedEntity( TrackedEntity trackedEntity ); + } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,59 @@ +/* + * 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.trackedentity; + +import org.hisp.dhis.common.BaseNameableObject; +import org.hisp.dhis.common.DxfNamespaces; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + +/** + * @author Chau Thu Tran + * + * @version $ TrackedEntity.java Feb 14, 2014 11:52:47 PM $ + */ +@JacksonXmlRootElement( localName = "trackedEntity", namespace = DxfNamespaces.DXF_2_0 ) +public class TrackedEntity + extends BaseNameableObject +{ + private static final long serialVersionUID = 3520485123419518620L; + + // ------------------------------------------------------------------------- + // Constructor + // ------------------------------------------------------------------------- + + public TrackedEntity() + { + } + + public TrackedEntity( String name, String description ) + { + this.name = name; + this.description = description; + } +} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstance.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstance.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstance.java 2014-02-17 15:00:27 +0000 @@ -42,6 +42,7 @@ 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; @@ -58,7 +59,7 @@ private static final long serialVersionUID = 884114994005945275L; public static String SEARCH_SAPERATE = "_"; - + public static String PREFIX_TRACKED_ENTITY_ATTRIBUTE = "attr"; public static String PREFIX_PROGRAM = "prg"; @@ -77,6 +78,8 @@ private TrackedEntityInstance representative; + private TrackedEntity trackedEntity; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -152,5 +155,18 @@ attributeValues.remove( attributeValue ); attributeValue.setEntityInstance( null ); } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlElementWrapper( localName = "trackedEntity", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "trackedEntity", namespace = DxfNamespaces.DXF_2_0 ) + public TrackedEntity getTrackedEntity() + { + return trackedEntity; + } + public void setTrackedEntity( TrackedEntity trackedEntity ) + { + this.trackedEntity = trackedEntity; + } } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,94 @@ +/* + * 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.trackedentity; + +import java.util.Collection; + +/** + * @author Chau Thu Tran + * + * @version $ TrackedEntityService.java Feb 15, 2014 7:23:48 PM $ + */ +public interface TrackedEntityService +{ + String ID = TrackedEntityService.class.getName(); + + /** + * Adds an {@link TrackedEntity} + * + * @param trackedEntity The to TrackedEntity + * add. + * + * @return A generated unique id of the added + * {@link TrackedEntity}. + */ + int addTrackedEntity( TrackedEntity trackedEntity ); + + /** + * Deletes a {@link TrackedEntity}. + * + * @param trackedEntity the TrackedEntity to + * delete. + */ + void deleteTrackedEntity( TrackedEntity trackedEntity ); + + /** + * Updates a {@link TrackedEntity}. + * + * @param trackedEntity the TrackedEntity to + * update. + */ + void updateTrackedEntity( TrackedEntity trackedEntity ); + + /** + * Returns a {@link TrackedEntity}. + * + * @param id the id of the TrackedEntity to return. + * + * @return the TrackedEntity with the given id + */ + TrackedEntity getTrackedEntity( int id ); + + /** + * Returns a {@link TrackedEntity} with a given name. + * + * @param name the name of the TrackedEntity to return. + * + * @return the TrackedEntity with the given name, or null if + * no match. + */ + TrackedEntity getTrackedEntityByName( String name ); + + /** + * Returns all {@link TrackedEntity} + * + * @return a collection of all TrackedEntity, or an empty + * collection if there are no TrackedEntitys. + */ + Collection getAllTrackedEntity(); +} \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2014-02-17 15:00:27 +0000 @@ -31,6 +31,7 @@ import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.validation.ValidationCriteria; import org.springframework.transaction.annotation.Transactional; @@ -193,4 +194,9 @@ return programs; } + @Override + public Collection getProgramsByTrackedEntity( TrackedEntity trackedEntity ) + { + return i18n( i18nService, programStore.getByTrackedEntity( trackedEntity ) ); + } } === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2014-02-17 15:00:27 +0000 @@ -28,6 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + import org.hibernate.Criteria; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; @@ -35,14 +39,11 @@ import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramStore; import org.hisp.dhis.system.util.CollectionUtils; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.UserAuthorityGroup; import org.hisp.dhis.user.UserService; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - /** * @author Chau Thu Tran */ @@ -72,14 +73,14 @@ // Implemented methods // ------------------------------------------------------------------------- - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) @Override public Collection getByType( int type ) { return getCriteria( Restrictions.eq( "type", type ) ).list(); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) @Override public Collection get( int type, OrganisationUnit organisationUnit ) { @@ -112,7 +113,7 @@ { programs = getAll(); } - + return programs; } @@ -138,12 +139,12 @@ { programs = getByType( type ); } - + return programs; } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public Collection getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit ) { Criteria criteria = getCriteria(); @@ -157,4 +158,12 @@ return criteria.list(); } + + @Override + @SuppressWarnings( "unchecked" ) + public Collection getByTrackedEntity( TrackedEntity trackedEntity ) + { + return getCriteria( Restrictions.eq( "trackedEntity", trackedEntity ) ).list(); + } + } === added file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,95 @@ +/* + * 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.trackedentity; + +import java.util.Collection; + +import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Chau Thu Tran + * + * @version $ DefaultTrackedEntityService.java Feb 15, 2014 7:28:41 PM $ + */ +@Transactional +public class DefaultTrackedEntityService + implements TrackedEntityService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private GenericIdentifiableObjectStore trackedEntityStore; + + public void setTrackedEntityStore( GenericIdentifiableObjectStore trackedEntityStore ) + { + this.trackedEntityStore = trackedEntityStore; + } + + // ------------------------------------------------------------------------- + // TrackedEntity + // ------------------------------------------------------------------------- + + @Override + public int addTrackedEntity( TrackedEntity trackedEntity ) + { + return trackedEntityStore.save( trackedEntity ); + } + + @Override + public void deleteTrackedEntity( TrackedEntity trackedEntity ) + { + trackedEntityStore.delete( trackedEntity ); + } + + @Override + public void updateTrackedEntity( TrackedEntity trackedEntity ) + { + trackedEntityStore.update( trackedEntity ); + } + + @Override + public TrackedEntity getTrackedEntity( int id ) + { + return trackedEntityStore.get( id ); + } + + @Override + public TrackedEntity getTrackedEntityByName( String name ) + { + return trackedEntityStore.getByName( name ); + } + + @Override + public Collection getAllTrackedEntity() + { + return trackedEntityStore.getAll(); + } + +} === 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-02-10 11:24:32 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2014-02-17 15:00:27 +0000 @@ -38,6 +38,7 @@ import org.amplecode.quick.StatementManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataentryform.DataEntryForm; @@ -274,6 +275,8 @@ executeSql( "update userroleauthorities set authority='F_TRACKED_ENTITY_ATTRIBUTEVALUE_DELETE' where authority='F_PATIENTATTRIBUTEVALUE_DELETE'" ); executeSql( "update userroleauthorities set authority='F_TRACKED_ENTITY_INSTANCE_REMINDER_MANAGEMENT' where authority='F_PATIENT_REMINDER_MANAGEMENT'" ); + createPersonTrackedEntity(); + } // ------------------------------------------------------------------------- @@ -416,6 +419,24 @@ } } + private void createPersonTrackedEntity() + { + int exist = jdbcTemplate.queryForInt( "SELECT count(*) FROM trackedentity where name='Person'" ); + 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" ); + } + } + private int executeSql( String sql ) { try === 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-02-15 18:00:27 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml 2014-02-17 15:00:27 +0000 @@ -131,7 +131,13 @@ value="org.hisp.dhis.trackedentity.TrackedEntityAudit" /> - + + + + + + @@ -284,6 +290,12 @@ + + + + === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2014-02-17 15:00:27 +0000 @@ -6,104 +6,108 @@ > - - - - - - - - &identifiableProperties; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + &identifiableProperties; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + === added file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml 2014-02-17 15:00:27 +0000 @@ -0,0 +1,22 @@ + +] + > + + + + + + + + &identifiableProperties; + + + + + + + === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityInstance.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityInstance.hbm.xml 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityInstance.hbm.xml 2014-02-17 15:00:27 +0000 @@ -28,5 +28,9 @@ + + === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionServiceTest.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,148 @@ +/* + * 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.trackedentity; + +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.saveTrackedEntityAttribute( attributeA ); + attributeService.saveTrackedEntityAttribute( 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 === 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-02-15 03:50:30 +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,144 +0,0 @@ -/* - * 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.trackedentity; - -import org.hisp.dhis.DhisSpringTest; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import static org.junit.Assert.*; - -/** - * @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.saveTrackedEntityAttribute( attributeA ); - attributeService.saveTrackedEntityAttribute( 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 === removed file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStoreTest.java' --- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStoreTest.java 2014-02-15 03:50:30 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeOptionStoreTest.java 1970-01-01 00:00:00 +0000 @@ -1,91 +0,0 @@ -/* - * 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.trackedentity; - -import org.hisp.dhis.DhisSpringTest; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import static org.junit.Assert.*; - -/** - * @author Chau Thu Tran - * @version $ TrackedEntityAttributeOptionStoreTest.java Nov 5, 2013 4:43:12 PM $ - */ -public class TrackedEntityAttributeOptionStoreTest - 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.saveTrackedEntityAttribute( attributeA ); - attributeService.saveTrackedEntityAttribute( attributeB ); - - attributeOptionA = createTrackedEntityAttributeOption( 'A', attributeA ); - attributeOptionB = createTrackedEntityAttributeOption( 'B', attributeA ); - attributeOptionC = createTrackedEntityAttributeOption( 'C', attributeB ); - } - - @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-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-02-14 16:13:55 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/AddTrackedEntityInstanceAction.java 2014-02-17 15:00:27 +0000 @@ -39,16 +39,21 @@ import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.Relationship; import org.hisp.dhis.relationship.RelationshipService; import org.hisp.dhis.relationship.RelationshipType; 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; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -75,6 +80,12 @@ private OrganisationUnitSelectionManager selectionManager; + @Autowired + private TrackedEntityService trackedEntityService; + + @Autowired + private ProgramService programService; + private I18nFormat format; // ------------------------------------------------------------------------- @@ -89,6 +100,10 @@ private boolean relationshipFromA; + private Integer trackedEntityId; + + private Integer programId; + private String message; // ------------------------------------------------------------------------- @@ -98,13 +113,20 @@ public String execute() { OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - TrackedEntityInstance entityInstance = new TrackedEntityInstance(); - - // --------------------------------------------------------------------- - // Set location - // --------------------------------------------------------------------- - + TrackedEntity trackedEntity = null; + + if ( programId != null ) + { + Program program = programService.getProgram( programId ); + trackedEntity = program.getTrackedEntity(); + } + else + { + trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId ); + } + + entityInstance.setTrackedEntity( trackedEntity ); entityInstance.setOrganisationUnit( organisationUnit ); // --------------------------------------------------------------------- @@ -137,7 +159,8 @@ } else if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer.parseInt( value ) ); + TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer + .parseInt( value ) ); if ( option != null ) { attributeValue.setAttributeOption( option ); @@ -149,8 +172,8 @@ } } - int entityInstanceId = entityInstanceService.createTrackedEntityInstance( entityInstance, representativeId, relationshipTypeId, - attributeValues ); + int entityInstanceId = entityInstanceService.createTrackedEntityInstance( entityInstance, representativeId, + relationshipTypeId, attributeValues ); // ------------------------------------------------------------------------- // Create relationship @@ -218,6 +241,11 @@ this.selectionManager = selectionManager; } + public void setTrackedEntityId( Integer trackedEntityId ) + { + this.trackedEntityId = trackedEntityId; + } + public String getMessage() { return message; === 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-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetTrackedEntityInstanceAction.java 2014-02-17 15:00:27 +0000 @@ -44,6 +44,7 @@ import org.hisp.dhis.relationship.Relationship; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService; @@ -52,9 +53,11 @@ import org.hisp.dhis.trackedentity.TrackedEntityFormService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.trackedentity.comparator.TrackedEntityAttributeGroupSortOrderComparator; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.user.User; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -81,6 +84,9 @@ private TrackedEntityAttributeService attributeService; + @Autowired + private TrackedEntityService trackedEntityService; + private I18n i18n; private I18nFormat format; @@ -160,6 +166,13 @@ return trackedEntityForm; } + private List trackedEntities; + + public List getTrackedEntities() + { + return trackedEntities; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -168,6 +181,7 @@ throws Exception { relationshipTypes = relationshipTypeService.getAllRelationshipTypes(); + trackedEntities = new ArrayList( trackedEntityService.getAllTrackedEntity() ); entityInstance = entityInstanceService.getTrackedEntityInstance( id ); healthWorkers = entityInstance.getOrganisationUnit().getUsers(); @@ -179,9 +193,9 @@ if ( trackedEntityForm != null && trackedEntityForm.getDataEntryForm() != null ) { - customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( - trackedEntityForm.getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), - healthWorkers, null, null, i18n, format ); + customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( trackedEntityForm + .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, i18n, + format ); } } else @@ -191,9 +205,9 @@ if ( trackedEntityForm != null && trackedEntityForm.getDataEntryForm() != null ) { - customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( - trackedEntityForm.getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), - healthWorkers, null, null, i18n, format ); + customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( trackedEntityForm + .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, i18n, + format ); } } @@ -211,7 +225,7 @@ Collection programs = programService.getAllPrograms(); for ( Program p : programs ) { - for ( TrackedEntityAttribute attribute : p.getEntityAttributes()) + for ( TrackedEntityAttribute attribute : p.getEntityAttributes() ) { if ( !attribute.getDisplayInListNoProgram() ) { @@ -272,7 +286,6 @@ // Getter / Setter // ----------------------------------------------------------------------------- - public void setI18n( I18n i18n ) { this.i18n = i18n; @@ -298,13 +311,11 @@ return attributeGroupsMap; } - public Relationship getRelationship() { return relationship; } - public void setId( int id ) { this.id = id; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ProgramEnrollmentSelectAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ProgramEnrollmentSelectAction.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ProgramEnrollmentSelectAction.java 2014-02-17 15:00:27 +0000 @@ -40,6 +40,8 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -120,6 +122,7 @@ // Get all programs programs = new ArrayList( programService.getProgramsByCurrentUser( orgunit ) ); + programs.retainAll( programService.getProgramsByTrackedEntity( entityInstance.getTrackedEntity() ) ); programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); Iterator iterProgram = programs.iterator(); === 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-02-08 15:19:56 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/ShowAddTrackedEntityInstanceFormAction.java 2014-02-17 15:00:27 +0000 @@ -43,6 +43,7 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup; import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroupService; @@ -50,6 +51,7 @@ import org.hisp.dhis.trackedentity.TrackedEntityForm; import org.hisp.dhis.trackedentity.TrackedEntityFormService; import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.trackedentity.comparator.TrackedEntityAttributeGroupSortOrderComparator; import org.hisp.dhis.user.User; import org.springframework.beans.factory.annotation.Autowired; @@ -69,7 +71,7 @@ @Autowired private TrackedEntityInstanceService entityInstanceService; - + private OrganisationUnitSelectionManager selectionManager; public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) @@ -77,7 +79,6 @@ this.selectionManager = selectionManager; } - private ProgramService programService; public void setProgramService( ProgramService programService ) @@ -113,6 +114,9 @@ this.relationshipTypeService = relationshipTypeService; } + @Autowired + private TrackedEntityService trackedEntityService; + private I18n i18n; public void setI18n( I18n i18n ) @@ -255,17 +259,26 @@ return relationshipTypes; } + private List trackedEntities; + + public List getTrackedEntities() + { + return trackedEntities; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- public String execute() { - if( entityInstanceId!=null) + if ( entityInstanceId != null ) { entityInstanceUid = entityInstanceService.getTrackedEntityInstance( entityInstanceId ).getUid(); } - + + trackedEntities = new ArrayList( trackedEntityService.getAllTrackedEntity() ); + organisationUnit = selectionManager.getSelectedOrganisationUnit(); healthWorkers = organisationUnit.getUsers(); @@ -275,9 +288,9 @@ if ( trackedEntityForm != null && trackedEntityForm.getDataEntryForm() != null ) { - customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( - trackedEntityForm.getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), - healthWorkers, null, null, i18n, format ); + customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( trackedEntityForm + .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, i18n, + format ); } } else @@ -287,9 +300,9 @@ if ( trackedEntityForm != null && trackedEntityForm.getDataEntryForm() != null ) { - customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( - trackedEntityForm.getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), - healthWorkers, null, null, i18n, format ); + customRegistrationForm = trackedEntityFormService.prepareDataEntryFormForAdd( trackedEntityForm + .getDataEntryForm().getHtmlCode(), trackedEntityForm.getProgram(), healthWorkers, null, null, i18n, + format ); } } @@ -303,7 +316,7 @@ { attributes = new ArrayList( attributeService.getAllTrackedEntityAttributes() ); Collection programs = programService.getAllPrograms(); - + for ( Program p : programs ) { attributes.removeAll( p.getAttributes() ); === 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-02-14 16:13:55 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/UpdateTrackedEntityInstanceAction.java 2014-02-17 15:00:27 +0000 @@ -38,15 +38,18 @@ import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +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; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -67,7 +70,11 @@ private TrackedEntityAttributeValueService attributeValueService; - private OrganisationUnitSelectionManager selectionManager; + @Autowired + private TrackedEntityService trackedEntityService; + + @Autowired + private ProgramService programService; private I18nFormat format; @@ -81,6 +88,10 @@ private Integer relationshipTypeId; + private Integer trackedEntityId; + + private Integer programId; + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -94,15 +105,19 @@ public String execute() throws Exception { - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - - entityInstance = entityInstanceService.getTrackedEntityInstance( id ); - - // --------------------------------------------------------------------- - // Set location - // --------------------------------------------------------------------- - - entityInstance.setOrganisationUnit( organisationUnit ); + TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( id ); + TrackedEntity trackedEntity = null; + + if ( programId != null ) + { + Program program = programService.getProgram( programId ); + trackedEntity = program.getTrackedEntity(); + } + else + { + trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId ); + } + entityInstance.setTrackedEntity( trackedEntity ); // --------------------------------------------------------------------- // Save Tracked Entity Instance Attributes @@ -124,7 +139,8 @@ for ( TrackedEntityAttribute attribute : attributes ) { - String value = request.getParameter( AddTrackedEntityInstanceAction.PREFIX_ATTRIBUTE + attribute.getId() ); + String value = request.getParameter( AddTrackedEntityInstanceAction.PREFIX_ATTRIBUTE + + attribute.getId() ); if ( StringUtils.isNotBlank( value ) ) { @@ -143,8 +159,8 @@ attributeValue.setValue( value.trim() ); if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( Integer - .parseInt( value ) ); + TrackedEntityAttributeOption option = attributeService + .getTrackedEntityAttributeOption( Integer.parseInt( value ) ); if ( option != null ) { attributeValue.setAttributeOption( option ); @@ -157,8 +173,8 @@ { if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) { - TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( NumberUtils.toInt( - value, 0 ) ); + TrackedEntityAttributeOption option = attributeService + .getTrackedEntityAttributeOption( NumberUtils.toInt( value, 0 ) ); if ( option != null ) { attributeValue.setAttributeOption( option ); @@ -177,8 +193,8 @@ } } - entityInstanceService.updateTrackedEntityInstance( entityInstance, representativeId, relationshipTypeId, valuesForSave, valuesForUpdate, - valuesForDelete ); + entityInstanceService.updateTrackedEntityInstance( entityInstance, representativeId, relationshipTypeId, + valuesForSave, valuesForUpdate, valuesForDelete ); return SUCCESS; } @@ -192,6 +208,11 @@ this.format = format; } + public void setTrackedEntityService( TrackedEntityService trackedEntityService ) + { + this.trackedEntityService = trackedEntityService; + } + public void setentityInstanceService( TrackedEntityInstanceService entityInstanceService ) { this.entityInstanceService = entityInstanceService; @@ -207,11 +228,6 @@ this.attributeValueService = attributeValueService; } - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - public void setId( Integer id ) { this.id = id; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-02-14 16:13:55 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-02-17 15:00:27 +0000 @@ -469,8 +469,6 @@ - $i18n.getString( "demographics" ) -#if($trackedEntityForm.fixedAttributes.contains( 'healthWorker' )) +#if($program) + +#else - + - + + #foreach($trackedEntity in $trackedEntities) + #end - + #end - - - - - #foreach($attribute in $$trackedEntityForm.dynamicAttributes ) === 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-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceForm.vm 2014-02-17 15:00:27 +0000 @@ -12,6 +12,24 @@ {validate:{required:true}} #end #end + + $i18n.getString( "demographics" ) + + #if($program) + + #else + + + + + + + #end #foreach ($attributeGroup in $attributeGroups ) #set($attributesByGroup = $!attributesMap.get($attributeGroup.displayName)) === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntity.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntity.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonTrackedEntity.vm 2014-02-17 15:00:27 +0000 @@ -0,0 +1,7 @@ +{ "trackedEntity": + { + "id": $!{trackedEntity.id}, + "name": "$!encoder.jsonEncode( ${trackedEntity.displayName} )", + "description": "$!encoder.jsonEncode( ${trackedEntity.displayDescription} )" + } +} === 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-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java 2014-02-17 15:00:27 +0000 @@ -41,9 +41,12 @@ import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -97,6 +100,9 @@ this.relationshipTypeService = relationshipTypeService; } + @Autowired + private TrackedEntityService trackedEntityService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -227,6 +233,13 @@ this.dataEntryMethod = dataEntryMethod; } + private Integer trackedEntityId; + + public void setTrackedEntityId( Integer trackedEntityId ) + { + this.trackedEntityId = trackedEntityId; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -280,6 +293,11 @@ program.setRelationshipFromA( relationshipFromA ); program.setRelationshipText( relationshipText ); + if( trackedEntityId!=null) + { + TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId ); + program.setTrackedEntity( trackedEntity ); + } programService.addProgram( program ); int index = 0; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java 2014-02-17 15:00:27 +0000 @@ -38,10 +38,13 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -84,6 +87,9 @@ this.relationshipTypeService = relationshipTypeService; } + @Autowired + private TrackedEntityService trackedEntityService; + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -116,6 +122,13 @@ return programs; } + private List trackedEntities; + + public List getTrackedEntities() + { + return trackedEntities; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -133,6 +146,9 @@ relationshipTypes = new ArrayList( relationshipTypeService.getAllRelationshipTypes() ); Collections.sort( relationshipTypes, IdentifiableObjectNameComparator.INSTANCE ); + trackedEntities = new ArrayList(trackedEntityService.getAllTrackedEntity()); + Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE ); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java 2014-02-10 05:42:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java 2014-02-17 15:00:27 +0000 @@ -41,10 +41,13 @@ import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityService; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -87,6 +90,9 @@ this.relationshipTypeService = relationshipTypeService; } + @Autowired + private TrackedEntityService trackedEntityService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -176,6 +182,13 @@ return programs; } + private List trackedEntities; + + public List getTrackedEntities() + { + return trackedEntities; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -201,6 +214,9 @@ relationshipTypes = new ArrayList( relationshipTypeService.getAllRelationshipTypes() ); Collections.sort( relationshipTypes, IdentifiableObjectNameComparator.INSTANCE ); + trackedEntities = new ArrayList( trackedEntityService.getAllTrackedEntity() ); + Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE ); + return SUCCESS; } } === 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-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java 2014-02-17 15:00:27 +0000 @@ -36,9 +36,12 @@ import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -74,6 +77,9 @@ this.relationshipTypeService = relationshipTypeService; } + @Autowired + private TrackedEntityService trackedEntityService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -251,6 +257,13 @@ this.dataEntryMethod = dataEntryMethod; } + private Integer trackedEntityId; + + public void setTrackedEntityId( Integer trackedEntityId ) + { + this.trackedEntityId = trackedEntityId; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -307,6 +320,16 @@ program.setRelationshipFromA( relationshipFromA ); program.setRelationshipText( relationshipText ); + if ( trackedEntityId != null ) + { + TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId ); + program.setTrackedEntity( trackedEntity ); + } + else if ( program.getTrackedEntity() != null ) + { + program.setTrackedEntity( null ); + } + if ( program.getAttributes() != null ) { program.getAttributes().clear(); === added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity' === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/AddTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/AddTrackedEntityAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/AddTrackedEntityAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,83 @@ +/* + * 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.trackedentity.action.trackedentity; + +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ AddTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class AddTrackedEntityAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + TrackedEntity trackedEntity = new TrackedEntity( name, description ); + + trackedEntityService.addTrackedEntity( trackedEntity ); + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,82 @@ +/* + * 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.trackedentity.action.trackedentity; + +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ GetTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class GetTrackedEntityAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private TrackedEntity trackedEntity; + + public TrackedEntity getTrackedEntity() + { + return trackedEntity; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + trackedEntity = trackedEntityService.getTrackedEntity( id ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,82 @@ +/* + * 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.trackedentity.action.trackedentity; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ AddTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class GetTrackedEntityListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private List trackedEntities; + + public List getTrackedEntities() + { + return trackedEntities; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + trackedEntities = new ArrayList( trackedEntityService.getAllTrackedEntity() ); + + Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,84 @@ +/* + * 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.trackedentity.action.trackedentity; + +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ RemoveTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class RemoveTrackedEntityAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private TrackedEntity trackedEntity; + + public TrackedEntity getTrackedEntity() + { + return trackedEntity; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( id ); + + trackedEntityService.deleteTrackedEntity( trackedEntity ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/UpdateTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/UpdateTrackedEntityAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/UpdateTrackedEntityAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,95 @@ +/* + * 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.trackedentity.action.trackedentity; + +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ UpdateTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class UpdateTrackedEntityAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( id ); + + trackedEntity.setName( name ); + + trackedEntity.setDescription( description ); + + trackedEntityService.updateTrackedEntity( trackedEntity ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ValidateTrackedEntityAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ValidateTrackedEntityAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/ValidateTrackedEntityAction.java 2014-02-17 15:00:27 +0000 @@ -0,0 +1,107 @@ +package org.hisp.dhis.trackedentity.action.trackedentity; + +/* + * 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. + */ + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.trackedentity.TrackedEntity; +import org.hisp.dhis.trackedentity.TrackedEntityService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ ValidateTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $ + */ +public class ValidateTrackedEntityAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + @Autowired + private TrackedEntityService trackedEntityService; + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + 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 + { + name = name.trim(); + + TrackedEntity match = trackedEntityService.getTrackedEntityByName( name ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "name_in_use" ); + + return INPUT; + } + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } +} === 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-14 16:13:55 +0000 +++ 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 @@ -1129,4 +1129,43 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === 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-02-16 13:04:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-02-17 15:00:27 +0000 @@ -396,7 +396,6 @@ tracked_entity_attribute_visit_schedule_form = Tracked entity attribute visit schedule intro_tracked_entity_attribute_visit_schedule = Configure which tracked entity attributes are added to the visit schedule. Gives better overview when used for tracking. selected_program_stages = Selected program stages -tracked_entity = Tracked entity orgunit_registered = Organisation unit phone number all_users_in_orgunit_registered = All users in organisation unit registered date_in_future = Date in future @@ -477,4 +476,11 @@ display_in_list_no_program = Display in list without program manage_attributes_with_no_program = Manage attributes with no program tracked_entity_attributes_displayed_in_list = Tracked entity attributes displayed in list -unique = Unique \ No newline at end of file +unique = Unique +tracked_entity = Tracked Entity +tracked_entity_management = Tracked entity management +intro_tracked_entity = Allow multiple types of entities to be tracked in the same db. Examples of tracked entities: person, commodity, medicine, student, labtest... +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 === 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-10 11:24:32 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2014-02-17 15:00:27 +0000 @@ -1174,5 +1174,72 @@ + + + + /main.vm + /dhis-web-maintenance-program/trackedEntity.vm + /dhis-web-maintenance-program/menu.vm + javascript/trackedEntity.js + F_TRACKED_ENTITY_MANAGEMENT + + + + /main.vm + /dhis-web-maintenance-program/addTrackedEntity.vm + javascript/trackedEntity.js + F_TRACKED_ENTITY_ADD + + + + trackedEntity.action + + F_TRACKED_ENTITY_ADD + + + + /main.vm + /dhis-web-maintenance-program/updateTrackedEntity.vm + javascript/trackedEntity.js + F_TRACKED_ENTITY_UPDATE + + + + trackedEntity.action + + F_TRACKED_ENTITY_UPDATE + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + F_TRACKED_ENTITY_DELETE + + + + + /dhis-web-commons/ajax/jsonTrackedEntity.vm + + plainTextError + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + /dhis-web-commons/ajax/jsonResponseError.vm + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm 2014-01-23 14:18:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm 2014-02-17 15:00:27 +0000 @@ -88,6 +88,19 @@ + + + + + + + + $i18n.getString( "enrollment_details" ) @@ -158,7 +171,7 @@ -