dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27679
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13784: expose code in attribute UI
------------------------------------------------------------
revno: 13784
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-20 17:20:02 +0700
message:
expose code in attribute UI
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.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-01-19 05:53:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2014-01-20 10:20:02 +0000
@@ -88,6 +88,14 @@
Attribute getAttributeByName( String name );
/**
+ * Gets the attribute with the given code.
+ *
+ * @param code the code.
+ * @return the attribute with the given code.
+ */
+ Attribute getAttributeByCode( String code );
+
+ /**
* Gets all attributes.
*
* @return a set of all attributes.
=== 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-01-19 05:53:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2014-01-20 10:20:02 +0000
@@ -110,6 +110,12 @@
}
@Override
+ public Attribute getAttributeByCode( String code )
+ {
+ return i18n( i18nService, attributeStore.getByCode( code ) );
+ }
+
+ @Override
public Set<Attribute> getAllAttributes()
{
return new HashSet<Attribute>( i18n( i18nService, attributeStore.getAll() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2014-01-20 10:20:02 +0000
@@ -60,6 +60,13 @@
this.name = name;
}
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
private String valueType;
public void setValueType( String valueType )
@@ -152,6 +159,7 @@
public String execute()
{
Attribute attribute = new Attribute( name, valueType );
+ attribute.setCode( code );
attribute.setMandatory( mandatory );
attribute.setDataElementAttribute( dataElementAttribute );
attribute.setDataElementGroupAttribute( dataElementGroupAttribute );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2014-01-20 10:20:02 +0000
@@ -68,6 +68,13 @@
this.name = name;
}
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
private String valueType;
public void setValueType( String valueType )
@@ -164,6 +171,7 @@
if ( attribute != null )
{
attribute.setName( name );
+ attribute.setCode( code );
attribute.setValueType( valueType );
attribute.setMandatory( mandatory );
attribute.setDataElementAttribute( dataElementAttribute );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java 2014-01-20 10:20:02 +0000
@@ -76,6 +76,13 @@
this.name = name;
}
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
private String message;
public String getMessage()
@@ -96,7 +103,19 @@
if ( match != null && (id == null || match.getId() != id) )
{
- message = i18n.getString( "name_in_use" );
+ message = i18n.getString( "name_in_used" );
+
+ return ERROR;
+ }
+ }
+
+ if ( code != null )
+ {
+ Attribute match = attributeService.getAttributeByCode( code );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "code_in_use" );
return ERROR;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-01-20 10:20:02 +0000
@@ -188,6 +188,7 @@
update_sql_view=Update SQL view
name_is_null=Name is not allowed to be null
name_in_used=Name is in use
+code_in_use=Code is in use
language_country_in_use=The language and country set is already in use
sqlquery_is_empty=SQL statement cannot be null
sqlquery_is_invalid=This SQL statement is invalid.
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2014-01-20 10:20:02 +0000
@@ -12,6 +12,7 @@
});
checkValueIsExist( "name", "validateAttribute.action" );
+ checkValueIsExist( "code", "validateAttribute.action" );
$("#valueType").bind("change", onValueTypeChange);
$("#valueType").change();
@@ -36,6 +37,11 @@
</tr>
<tr>
+ <td><label for="code">$i18n.getString( "code" )</label></td>
+ <td><input type="text" id="code" name="code"></td>
+ </tr>
+
+ <tr>
<td><label for="mandatory">$i18n.getString( "mandatory" )</td>
<td><input type="checkbox" id="mandatory" name="mandatory" value="true" /></td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2014-01-20 10:20:02 +0000
@@ -12,6 +12,7 @@
});
checkValueIsExist( "name", "validateAttribute.action", {id: $attribute.id} );
+ checkValueIsExist( "code", "validateAttribute.action", {id: $attribute.id} );
$("#valueType").bind("change", onValueTypeChange);
$("#valueType").change();
@@ -33,7 +34,12 @@
<tr>
<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $!attribute.name )"/></td>
+ <td><input type="text" id="name" name="name" value="$!encoder.htmlEncode( $!attribute.name )"/></td>
+ </tr>
+
+ <tr>
+ <td><label for="code">$i18n.getString( "code" )</label></td>
+ <td><input type="text" id="code" name="code" value="$!encoder.htmlEncode( $!attribute.code )"/></td>
</tr>
<tr>