------------------------------------------------------------ revno: 17788 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Tue 2014-12-23 19:03:44 +0100 message: finished program attribute impl modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm 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/ShowAddProgramFormAction.java 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/UpdateProgramAction.java 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/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/updateProgramForm.vm
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2014-12-23 18:03:44 +0000 @@ -172,6 +172,13 @@ Set<Attribute> getUserGroupAttributes(); /** + * Gets attributes which are associated with programs. + * + * @return a set of attributes which are associated with programs. + */ + Set<Attribute> getProgramAttributes(); + + /** * Gets the number of attributes. * * @return the number of attributes. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeStore.java 2014-12-23 18:03:44 +0000 @@ -28,10 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.GenericNameableObjectStore; + import java.util.Set; -import org.hisp.dhis.common.GenericNameableObjectStore; - /** * @author mortenoh */ @@ -42,7 +42,7 @@ /** * Get all attributes that are enabled for data elements. - * + * * @return All attributes with attribute.dataElement = true */ Set<Attribute> getDataElementAttributes(); @@ -56,7 +56,7 @@ /** * Get all attributes that are enabled for indicators. - * + * * @return All attributes with attribute.indicator = true */ Set<Attribute> getIndicatorAttributes(); @@ -77,7 +77,7 @@ /** * Get all attributes that are enabled for organisation units. - * + * * @return All attributes with attribute.organisationUnit = true */ Set<Attribute> getOrganisationUnitAttributes(); @@ -98,7 +98,7 @@ /** * Get all attributes that are enabled for users. - * + * * @return All attributes with attribute.organisationUnit = true */ Set<Attribute> getUserAttributes(); @@ -109,4 +109,11 @@ * @return All attributes with attribute.organisationUnitGroup = true */ Set<Attribute> getUserGroupAttributes(); + + /** + * Get all attributes that are enabled for program. + * + * @return All attributes with attribute.program = true + */ + Set<Attribute> getProgramAttributes(); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2014-09-08 13:02:43 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2014-12-23 18:03:44 +0000 @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.i18n.I18nUtils.i18n; - import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.i18n.I18nService; import org.springframework.transaction.annotation.Transactional; @@ -37,6 +35,8 @@ import java.util.HashSet; import java.util.Set; +import static org.hisp.dhis.i18n.I18nUtils.i18n; + /** * @author mortenoh */ @@ -130,54 +130,60 @@ @Override public Set<Attribute> getDataElementGroupAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getDataElementGroupAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getDataElementGroupAttributes() ) ); } @Override public Set<Attribute> getIndicatorAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getIndicatorAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getIndicatorAttributes() ) ); } @Override public Set<Attribute> getIndicatorGroupAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getIndicatorGroupAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getIndicatorGroupAttributes() ) ); } @Override public Set<Attribute> getDataSetAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getDataSetAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getDataSetAttributes() ) ); } @Override public Set<Attribute> getOrganisationUnitAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getOrganisationUnitAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getOrganisationUnitAttributes() ) ); } @Override public Set<Attribute> getOrganisationUnitGroupAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getOrganisationUnitGroupAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getOrganisationUnitGroupAttributes() ) ); } @Override public Set<Attribute> getOrganisationUnitGroupSetAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getOrganisationUnitGroupSetAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getOrganisationUnitGroupSetAttributes() ) ); } @Override public Set<Attribute> getUserAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getUserAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getUserAttributes() ) ); } @Override public Set<Attribute> getUserGroupAttributes() { - return new HashSet<>( i18n( i18nService,attributeStore.getUserGroupAttributes())); + return new HashSet<>( i18n( i18nService, attributeStore.getUserGroupAttributes() ) ); + } + + @Override + public Set<Attribute> getProgramAttributes() + { + return new HashSet<>( i18n( i18nService, attributeStore.getProgramAttributes() ) ); } @Override @@ -195,13 +201,13 @@ @Override public Set<Attribute> getAttributesBetween( int first, int max ) { - return new HashSet<>( i18n( i18nService, attributeStore.getAllOrderedName( first, max ) )); + return new HashSet<>( i18n( i18nService, attributeStore.getAllOrderedName( first, max ) ) ); } @Override public Set<Attribute> getAttributesBetweenByName( String name, int first, int max ) { - return new HashSet<>( i18n( i18nService, attributeStore.getAllLikeName( name, first, max ) )); + return new HashSet<>( i18n( i18nService, attributeStore.getAllLikeName( name, first, max ) ) ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java 2014-12-23 18:03:44 +0000 @@ -28,14 +28,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.HashSet; -import java.util.Set; - import org.hibernate.criterion.Restrictions; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.attribute.AttributeStore; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; +import java.util.HashSet; +import java.util.Set; + /** * @author mortenoh */ @@ -112,4 +112,11 @@ { return new HashSet<Attribute>( getCriteria( Restrictions.eq( "userGroupAttribute", true ) ).list() ); } + + @Override + @SuppressWarnings( "unchecked" ) + public Set<Attribute> getProgramAttributes() + { + return new HashSet<Attribute>( getCriteria( Restrictions.eq( "programAttribute", true ) ).list() ); + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm 2014-09-24 07:43:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm 2014-12-23 18:03:44 +0000 @@ -13,8 +13,8 @@ { setFieldValue( 'submitCategoryComboId', getFieldValue( 'selectedCategoryComboId' ) ); setFieldValue( 'submitValueType', getFieldValue( 'valueType' ) ); - enable('aggregationOperatorSelect'); - #tblDynamicAttributesJavascript() + enable('aggregationOperatorSelect'); + #tblDynamicAttributesJavascript() }, 'rules' : getValidationRules( "dataElement" ) } ); === 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-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java 2014-12-23 18:03:44 +0000 @@ -28,10 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; @@ -41,6 +39,7 @@ import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -48,7 +47,9 @@ import org.hisp.dhis.trackedentity.TrackedEntityService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** * @author Abyot Asalefew Gizaw @@ -65,44 +66,27 @@ // Dependency // ------------------------------------------------------------------------- + @Autowired private ProgramService programService; - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - + @Autowired private ProgramStageService programStageService; - public void setProgramStageService( ProgramStageService programStageService ) - { - this.programStageService = programStageService; - } - + @Autowired private ProgramInstanceService programInstanceService; - public void setProgramInstanceService( ProgramInstanceService programInstanceService ) - { - this.programInstanceService = programInstanceService; - } - - private TrackedEntityAttributeService attributeService; - - public void setAttributeService( TrackedEntityAttributeService attributeService ) - { - this.attributeService = attributeService; - } - + @Autowired + private TrackedEntityAttributeService trackedEntityAttributeService; + + @Autowired private RelationshipTypeService relationshipTypeService; - public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) - { - this.relationshipTypeService = relationshipTypeService; - } - @Autowired private TrackedEntityService trackedEntityService; + @Autowired + private AttributeService attributeService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -247,6 +231,13 @@ this.trackedEntityId = trackedEntityId; } + private List<String> jsonAttributeValues = new ArrayList<>(); + + public void setJsonAttributeValues( List<String> jsonAttributeValues ) + { + this.jsonAttributeValues = jsonAttributeValues; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -315,7 +306,7 @@ if ( ids[0].equals( TrackedEntityInstance.PREFIX_TRACKED_ENTITY_ATTRIBUTE ) ) { - TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer + TrackedEntityAttribute attribute = trackedEntityAttributeService.getTrackedEntityAttribute( Integer .parseInt( ids[1] ) ); ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, @@ -327,6 +318,11 @@ index++; } + if ( jsonAttributeValues != null ) + { + AttributeUtils.updateAttributeValuesFromJson( program.getAttributeValues(), jsonAttributeValues, attributeService ); + } + programService.updateProgram( program ); if ( program.getType().equals( Program.SINGLE_EVENT_WITH_REGISTRATION ) === 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-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java 2014-12-23 18:03:44 +0000 @@ -28,15 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.Attribute; +import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -45,11 +45,14 @@ import org.hisp.dhis.user.UserGroupService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Abyot Asalefew Gizaw - * @version $Id$ */ public class ShowAddProgramFormAction implements Action @@ -65,11 +68,11 @@ this.programService = programService; } - private TrackedEntityAttributeService attributeService; + private TrackedEntityAttributeService trackedEntityAttributeService; - public void setAttributeService( TrackedEntityAttributeService attributeService ) + public void setTrackedEntityAttributeService( TrackedEntityAttributeService trackedEntityAttributeService ) { - this.attributeService = attributeService; + this.trackedEntityAttributeService = trackedEntityAttributeService; } private UserGroupService userGroupService; @@ -89,6 +92,9 @@ @Autowired private TrackedEntityService trackedEntityService; + @Autowired + private AttributeService attributeService; + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -128,6 +134,20 @@ return trackedEntities; } + private List<Attribute> attributes; + + public List<Attribute> getAttributes() + { + return attributes; + } + + private Map<Integer, String> attributeValues = new HashMap<>(); + + public Map<Integer, String> getAttributeValues() + { + return attributeValues; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -136,10 +156,11 @@ public String execute() { programs = new ArrayList<>( programService.getAllPrograms() ); + programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE ); - availableAttributes = new ArrayList<>( attributeService.getAllTrackedEntityAttributes() ); + availableAttributes = new ArrayList<>( trackedEntityAttributeService.getAllTrackedEntityAttributes() ); Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE ); userGroups = new ArrayList<>( userGroupService.getAllUserGroups() ); @@ -148,9 +169,11 @@ relationshipTypes = new ArrayList<>( relationshipTypeService.getAllRelationshipTypes() ); Collections.sort( relationshipTypes, IdentifiableObjectNameComparator.INSTANCE ); - trackedEntities = new ArrayList<>(trackedEntityService.getAllTrackedEntity()); + trackedEntities = new ArrayList<>( trackedEntityService.getAllTrackedEntity() ); Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE ); + attributes = new ArrayList<>( attributeService.getProgramAttributes() ); + 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-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java 2014-12-23 18:03:44 +0000 @@ -28,10 +28,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.Attribute; +import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; @@ -40,6 +39,7 @@ import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -48,7 +48,11 @@ import org.hisp.dhis.user.UserGroupService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Chau Thu Tran @@ -68,11 +72,11 @@ this.programService = programService; } - private TrackedEntityAttributeService attributeService; + private TrackedEntityAttributeService trackedEntityAttributeService; - public void setAttributeService( TrackedEntityAttributeService attributeService ) + public void setTrackedEntityAttributeService( TrackedEntityAttributeService trackedEntityAttributeService ) { - this.attributeService = attributeService; + this.trackedEntityAttributeService = trackedEntityAttributeService; } private UserGroupService userGroupService; @@ -92,6 +96,9 @@ @Autowired private TrackedEntityService trackedEntityService; + @Autowired + private AttributeService attributeService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -188,6 +195,20 @@ return trackedEntities; } + private List<Attribute> attributes; + + public List<Attribute> getAttributes() + { + return attributes; + } + + private Map<Integer, String> attributeValues = new HashMap<>(); + + public Map<Integer, String> getAttributeValues() + { + return attributeValues; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -198,13 +219,15 @@ { program = programService.getProgram( id ); - availableAttributes = new ArrayList<>( attributeService.getAllTrackedEntityAttributes() ); - - for ( ProgramTrackedEntityAttribute programAttribue : program.getProgramAttributes() ) + attributeValues = AttributeUtils.getAttributeValueMap( program.getAttributeValues() ); + + availableAttributes = new ArrayList<>( trackedEntityAttributeService.getAllTrackedEntityAttributes() ); + + for ( ProgramTrackedEntityAttribute programTrackedEntityAttribute : program.getProgramAttributes() ) { - availableAttributes.remove( programAttribue.getAttribute() ); + availableAttributes.remove( programTrackedEntityAttribute.getAttribute() ); } - + Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE ); programs = new ArrayList<>( programService.getAllPrograms() ); @@ -220,6 +243,8 @@ trackedEntities = new ArrayList<>( trackedEntityService.getAllTrackedEntity() ); Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE ); + attributes = new ArrayList<>( attributeService.getProgramAttributes() ); + 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-10-16 06:17:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/UpdateProgramAction.java 2014-12-23 18:03:44 +0000 @@ -28,14 +28,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.List; - +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.attribute.AttributeService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; +import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -43,7 +43,8 @@ import org.hisp.dhis.trackedentity.TrackedEntityService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.List; /** * @author Abyot Asalefew Gizaw @@ -56,30 +57,21 @@ // Dependency // ------------------------------------------------------------------------- + @Autowired private ProgramService programService; - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - private TrackedEntityAttributeService attributeService; - - public void setAttributeService( TrackedEntityAttributeService attributeService ) - { - this.attributeService = attributeService; - } - + @Autowired + private TrackedEntityAttributeService trackedEntityAttributeService; + + @Autowired private RelationshipTypeService relationshipTypeService; - public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService ) - { - this.relationshipTypeService = relationshipTypeService; - } - @Autowired private TrackedEntityService trackedEntityService; + @Autowired + private AttributeService attributeService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -259,6 +251,13 @@ this.allowFutureDate = allowFutureDate; } + private List<String> jsonAttributeValues = new ArrayList<>(); + + public void setJsonAttributeValues( List<String> jsonAttributeValues ) + { + this.jsonAttributeValues = jsonAttributeValues; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -336,7 +335,7 @@ if ( ids[0].equals( TrackedEntityInstance.PREFIX_TRACKED_ENTITY_ATTRIBUTE ) ) { - TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer + TrackedEntityAttribute attribute = trackedEntityAttributeService.getTrackedEntityAttribute( Integer .parseInt( ids[1] ) ); ProgramTrackedEntityAttribute programAttribute = new ProgramTrackedEntityAttribute( attribute, personDisplayNames.get( index ), mandatory.get( index ), allowFutureDate.get( index ) ); @@ -353,7 +352,12 @@ } program.increaseVersion(); //TODO make more fine-grained - + + if ( jsonAttributeValues != null ) + { + AttributeUtils.updateAttributeValuesFromJson( program.getAttributeValues(), jsonAttributeValues, attributeService ); + } + programService.updateProgram( program ); 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-12-04 06:39:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2014-12-23 18:03:44 +0000 @@ -173,13 +173,11 @@ <bean id="org.hisp.dhis.trackedentity.action.program.AddProgramAction" class="org.hisp.dhis.trackedentity.action.program.AddProgramAction" scope="prototype"> - <property name="programService" ref="org.hisp.dhis.program.ProgramService" /> - <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" /> - <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" /> - <property name="attributeService" - ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeService" /> - <property name="relationshipTypeService" - ref="org.hisp.dhis.relationship.RelationshipTypeService" /> + </bean> + + <bean id="org.hisp.dhis.trackedentity.action.program.UpdateProgramAction" + class="org.hisp.dhis.trackedentity.action.program.UpdateProgramAction" + scope="prototype"> </bean> <bean id="org.hisp.dhis.trackedentity.action.program.GetProgramListAction" @@ -215,7 +213,7 @@ class="org.hisp.dhis.trackedentity.action.program.ShowAddProgramFormAction" scope="prototype"> <property name="programService" ref="org.hisp.dhis.program.ProgramService" /> - <property name="attributeService" + <property name="trackedEntityAttributeService" ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeService" /> <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" /> <property name="relationshipTypeService" @@ -227,23 +225,13 @@ class="org.hisp.dhis.trackedentity.action.program.ShowUpdateProgramFormAction" scope="prototype"> <property name="programService" ref="org.hisp.dhis.program.ProgramService" /> - <property name="attributeService" + <property name="trackedEntityAttributeService" ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeService" /> <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" /> <property name="relationshipTypeService" ref="org.hisp.dhis.relationship.RelationshipTypeService" /> </bean> - <bean id="org.hisp.dhis.trackedentity.action.program.UpdateProgramAction" - class="org.hisp.dhis.trackedentity.action.program.UpdateProgramAction" - scope="prototype"> - <property name="programService" ref="org.hisp.dhis.program.ProgramService" /> - <property name="attributeService" - ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeService" /> - <property name="relationshipTypeService" - ref="org.hisp.dhis.relationship.RelationshipTypeService" /> - </bean> - <bean id="org.hisp.dhis.trackedentity.action.program.ValidateProgramAction" class="org.hisp.dhis.trackedentity.action.program.ValidateProgramAction" === 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-08-26 12:43:04 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramForm.vm 2014-12-23 18:03:44 +0000 @@ -11,6 +11,8 @@ },{ 'beforeValidateHandler' : function() { + #tblDynamicAttributesJavascript() + var selectedPropertyIds = jQuery( "#selectedPropertyIds" ); selectedPropertyIds.empty(); var personDisplayNames = jQuery( "#personDisplayNames" ); @@ -183,7 +185,7 @@ </tr> <tr name='nonAnonymous'> - <td><label for="relationshipFromA">$i18n.getString("who_is_the_new_relative_to_the_existing_tracked_entity_instance")</a></td> + <td><label for="relationshipFromA">$i18n.getString("who_is_the_new_relative_to_the_existing_tracked_entity_instance")</label></td> <td> <select type='text' id='relationshipFromA' name='relationshipFromA'></select> </td> @@ -216,6 +218,8 @@ </table> <br /> +#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } ) +<br /> <table name='nonAnonymous' class='multiEvents'> <colgroup> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm 2014-11-03 13:35:42 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramForm.vm 2014-12-23 18:03:44 +0000 @@ -9,6 +9,8 @@ },{ 'beforeValidateHandler' : function() { + #tblDynamicAttributesJavascript() + var selectedPropertyIds = jQuery( "#selectedPropertyIds" ); selectedPropertyIds.empty(); var personDisplayNames = jQuery( "#personDisplayNames" ); @@ -229,9 +231,11 @@ </tbody> </table> - <br /> +<br /> +#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } ) +<br /> - <table name='nonAnonymous' class='multiEvents'> +<table name='nonAnonymous' class='multiEvents'> <colgroup> <col style="width:400px;"/> <col/>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp