dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28808
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14447: Made TrackedEntityAttribute a NameableObject. Added shortName property to object and UI. Fixed bu...
------------------------------------------------------------
revno: 14447
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-26 18:39:16 +0100
message:
Made TrackedEntityAttribute a NameableObject. Added shortName property to object and UI. Fixed bug in validation.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeService.java
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/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml
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/UpdateAttributeAction.java
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/resources/org/hisp/dhis/trackedentity/i18n_module.properties
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/javascript/addAttributeForm.js
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/updateAttibuteForm.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/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<TrackedEntityAttribute> 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 @@
<property name="name" column="name" not-null="true" unique="true" length="230" />
+ <property name="shortName" column="shortname" not-null="false" unique="true" length="50" />
+
<property name="description" />
<property name="valueType" column="valuetype" not-null="true" />
=== 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 @@
</tr>
<tr>
+ <td><label>$i18n.getString( "short_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="shortName" name="shortName" class="{validate:{required:true,rangelength:[2,50]}}"/></td>
+ <td></td>
+ </tr>
+
+ <tr>
<td><label>$i18n.getString( "code" )</label></td>
<td><input type="text" id="code" name="code"></td>
<td></td>
=== 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 @@
<td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $attribute.name )" class="{validate:{required:true,rangelength:[2,160]}}"></td>
</tr>
<tr>
+ <td>$i18n.getString( "short_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></td>
+ <td><input type="text" id="shortName" name="shortName" value="$!encoder.htmlEncode( $attribute.shortName )" class="{validate:{required:true,rangelength:[2,50]}}"></td>
+ </tr>
+ <tr>
<td>$i18n.getString( "code" )</td>
<td><input type="text" id="code" name="code" value="$!encoder.htmlEncode( $attribute.code )"></td>
</tr>
<tr>
<td>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></td>
- <td><input type="text" id="description" name="description" value="$encoder.htmlEncode( $attribute.description )" class="{validate:{required:true,minlength:2}}"></td>
+ <td><input type="text" id="description" name="description" value="$!encoder.htmlEncode( $attribute.description )" class="{validate:{required:true,minlength:2}}"></td>
</tr>
<tr>