=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-20 15:05:57 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2014-03-26 17:39:16 +0000 @@ -32,6 +32,7 @@ import java.util.Date; import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.BaseNameableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.view.DetailedView; @@ -51,7 +52,7 @@ */ @JacksonXmlRootElement( localName = "trackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0 ) public class TrackedEntityAttribute - extends BaseIdentifiableObject + extends BaseNameableObject { /** * Determines if a de-serialized file is compatible with this class. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-20 15:05:57 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java 2014-03-26 17:39:16 +0000 @@ -91,6 +91,26 @@ TrackedEntityAttribute getTrackedEntityAttributeByName( String name ); /** + * Returns a {@link TrackedEntityAttribute} with a given short name. + * + * @param name the short name of the TrackedEntityAttribute to return. + * + * @return the TrackedEntityAttribute with the given short name, or null if no + * match. + */ + TrackedEntityAttribute getTrackedEntityAttributeByShortName( String name ); + + /** + * Returns a {@link TrackedEntityAttribute} with a given code. + * + * @param name the code of the TrackedEntityAttribute to return. + * + * @return the TrackedEntityAttribute with the given code, or null if no + * match. + */ + TrackedEntityAttribute getTrackedEntityAttributeByCode( String code ); + + /** * Returns all {@link TrackedEntityAttribute} * * @return a collection of all TrackedEntityAttribute, or an empty === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java' --- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-20 15:05:57 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-26 17:39:16 +0000 @@ -99,6 +99,16 @@ return attributeStore.getByName( name ); } + public TrackedEntityAttribute getTrackedEntityAttributeByShortName( String shortName ) + { + return attributeStore.getByShortName( shortName ); + } + + public TrackedEntityAttribute getTrackedEntityAttributeByCode( String code ) + { + return attributeStore.getByShortName( code ); + } + public Collection getOptionalAttributesWithoutGroup() { return attributeStore.getOptionalAttributesWithoutGroup(); === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2014-03-24 18:52:45 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2014-03-26 17:39:16 +0000 @@ -15,6 +15,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-20 05:43:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-26 17:39:16 +0000 @@ -73,6 +73,13 @@ this.name = name; } + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + private String code; public void setCode( String code ) @@ -155,6 +162,7 @@ TrackedEntityAttribute attribute = new TrackedEntityAttribute(); attribute.setName( name ); + attribute.setShortName( shortName ); attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); attribute.setDescription( description ); attribute.setValueType( valueType ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-03-20 05:43:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-03-26 17:39:16 +0000 @@ -82,6 +82,13 @@ this.name = name; } + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + private String code; public void setCode( String code ) @@ -164,6 +171,7 @@ TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( id ); attribute.setName( name ); + attribute.setShortName( shortName ); attribute.setCode( StringUtils.isEmpty( code.trim() ) ? null : code ); attribute.setDescription( description ); attribute.setValueType( valueType ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ValidateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ValidateAttributeAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ValidateAttributeAction.java 2014-03-26 17:39:16 +0000 @@ -71,6 +71,20 @@ this.name = name; } + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private String code; + + public void setCode( String code ) + { + this.code = code; + } + private String message; public String getMessage() @@ -92,15 +106,40 @@ public String execute() throws Exception { - name = name.trim(); - - TrackedEntityAttribute match = attributeService.getTrackedEntityAttribute( name ); - - if ( match != null && (id == null || match.getId() != id.intValue()) ) - { - message = i18n.getString( "name_in_use" ); - - return INPUT; + if ( name != null ) + { + TrackedEntityAttribute match = attributeService.getTrackedEntityAttributeByName( name ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "name_in_use" ); + + return INPUT; + } + } + + if ( shortName != null ) + { + TrackedEntityAttribute match = attributeService.getTrackedEntityAttributeByShortName( shortName ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "short_name_in_use" ); + + return INPUT; + } + } + + if ( code != null ) + { + TrackedEntityAttribute match = attributeService.getTrackedEntityAttributeByCode( code ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "code_in_use" ); + + return INPUT; + } } message = i18n.getString( "everything_is_ok" ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-03-24 05:48:32 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-03-26 17:39:16 +0000 @@ -31,6 +31,8 @@ confirm_delete_tracked_entity_attribute=Are you sure you want to delete this tracked entity attribute? tracked_entity_attribute_management=Tracked entity attribute management name_in_use=Name in use +short_name_in_use=Short name in use +code_in_use=Code in use program_stage_sort_order=Program Stage Sort Order sort=Sort value_must_positive=Value must be a positive number === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-03-25 08:14:47 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-03-26 17:39:16 +0000 @@ -19,6 +19,12 @@ + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-03-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-03-26 17:39:16 +0000 @@ -1,7 +1,9 @@ jQuery(document).ready( function(){ - validation( 'addAttributeForm', function(form){ - form.submit(); - }) - - checkValueIsExist( "name", "validateAttribute.action"); - }); \ No newline at end of file + validation( 'addAttributeForm', function(form){ + form.submit(); + }) + + checkValueIsExist( "name", "validateAttribute.action"); + checkValueIsExist( "shortName", "validateAttribute.action"); + checkValueIsExist( "code", "validateAttribute.action"); +}); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-03-19 06:44:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-03-26 17:39:16 +0000 @@ -4,4 +4,6 @@ }); checkValueIsExist( "name", "validateAttribute.action", {id:getFieldValue('id')}); + checkValueIsExist( "shortName", "validateAttribute.action", {id:getFieldValue('id')}); + checkValueIsExist( "code", "validateAttribute.action", {id:getFieldValue('id')}); }); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-03-20 05:43:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-03-26 17:39:16 +0000 @@ -20,12 +20,16 @@ + $i18n.getString( "short_name" ) * + + + $i18n.getString( "code" ) $i18n.getString( "description" ) * - +