=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2013-02-26 20:18:51 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2013-03-01 04:09:26 +0000 @@ -372,7 +372,25 @@ * no DataElementGroups exist. */ Collection getAllDataElementGroups(); + + + /** + * Returns a DataElementGroup with a given shortName. + * + * @param shortName the shortName of the DataElementGroup to return. + * @return the DataElementGroup with the given shortName, or null if no match. + */ + DataElementGroup getDataElementGroupByShortName( String shortName ); + + /** + * Returns a DataElementGroup with a given code. + * + * @param code the shortName of the DataElementGroup to return. + * @return the DataElementGroup with the given code, or null if no match. + */ + DataElementGroup getDataElementGroupByCode( String code ); + /** * Returns all DataElementGroups which contain the given DataElement. * === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-02-26 20:18:51 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-03-01 04:09:26 +0000 @@ -28,6 +28,7 @@ */ import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.common.GenericNameableObjectStore; import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.i18n.I18nService; @@ -66,9 +67,9 @@ this.dataElementStore = dataElementStore; } - private GenericIdentifiableObjectStore dataElementGroupStore; + private GenericNameableObjectStore dataElementGroupStore; - public void setDataElementGroupStore( GenericIdentifiableObjectStore dataElementGroupStore ) + public void setDataElementGroupStore( GenericNameableObjectStore dataElementGroupStore ) { this.dataElementGroupStore = dataElementGroupStore; } @@ -430,14 +431,32 @@ public DataElementGroup getDataElementGroupByName( String name ) { - List dataElementGroups = new ArrayList( dataElementGroupStore.getAllEqName( name ) ); - - if ( dataElementGroups.isEmpty() ) - { - return null; - } - - return i18n( i18nService, dataElementGroups.get( 0 ) ); + List dataElementGroups = new ArrayList( + dataElementGroupStore.getAllEqName( name ) ); + + if ( dataElementGroups.isEmpty() ) + { + return null; + } + + return i18n( i18nService, dataElementGroups.get( 0 ) ); + } + + public DataElementGroup getDataElementGroupByShortName( String shortName ) + { + List dataElementGroups = new ArrayList( dataElementGroupStore.getAllEqShortName( shortName ) ); + + if ( dataElementGroups.isEmpty() ) + { + return null; + } + + return i18n( i18nService, dataElementGroups.get( 0 ) ); + } + + public DataElementGroup getDataElementGroupByCode( String code ) + { + return i18n( i18nService, dataElementGroupStore.getByCode( code ) ); } public Collection getGroupsContainingDataElement( DataElement dataElement ) @@ -525,7 +544,8 @@ public DataElementGroupSet getDataElementGroupSetByName( String name ) { - List dataElementGroupSets = new ArrayList( dataElementGroupSetStore.getAllEqName( name ) ); + List dataElementGroupSets = new ArrayList( + dataElementGroupSetStore.getAllEqName( name ) ); if ( dataElementGroupSets.isEmpty() ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroup.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroup.hbm.xml 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroup.hbm.xml 2013-03-01 04:09:26 +0000 @@ -17,6 +17,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroup.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroup.vm 2012-01-22 11:28:12 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroup.vm 2013-03-01 04:09:26 +0000 @@ -2,6 +2,8 @@ { "id": $!{dataElementGroup.id}, "name": "$!encoder.jsonEncode( ${dataElementGroup.displayName} )", + "shortName": "$!encoder.jsonEncode( ${dataElementGroup.displayShortName} )", + "code": "$!encoder.jsonEncode( ${dataElementGroup.code} )", "memberCount": "$memberCount" } } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-12-07 14:32:11 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2013-03-01 04:09:26 +0000 @@ -265,7 +265,13 @@ "alphanumericwithbasicpuncspaces" : true, "notOnlyDigits" : true, "rangelength" : [ 2, 160 ] - } + }, + "shortName" : { + "required" : true, + "rangelength" : [ 2, 40 ], + "alphanumericwithbasicpuncspaces" : true, + "notOnlyDigits" : true + }, }, "dataElementGroupSet" : { "name" : { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AddDataElementGroupAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AddDataElementGroupAction.java 2012-06-01 11:35:55 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AddDataElementGroupAction.java 2013-03-01 04:09:26 +0000 @@ -75,6 +75,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 Set groupMembers = new HashSet(); public void setGroupMembers( Set groupMembers ) @@ -106,8 +120,12 @@ public String execute() { + code = ( code != null && code.trim().length() == 0 ) ? null : code; + dataElementGroup = new DataElementGroup( name ); - + dataElementGroup.setShortName( shortName ); + dataElementGroup.setCode( code ); + for ( String id : groupMembers ) { dataElementGroup.addDataElement( dataElementService.getDataElement( Integer.parseInt( id ) ) ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/UpdateDataElementGroupAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/UpdateDataElementGroupAction.java 2012-06-01 11:35:55 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/UpdateDataElementGroupAction.java 2013-03-01 04:09:26 +0000 @@ -83,6 +83,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 Set groupMembers = new HashSet(); public void setGroupMembers( Set groupMembers ) @@ -114,8 +128,12 @@ public String execute() { + code = ( code != null && code.trim().length() == 0 ) ? null : code; + dataElementGroup = dataElementService.getDataElementGroup( id ); - + dataElementGroup.setShortName( shortName ); + dataElementGroup.setCode( code ); + if ( name != null && name.trim().length() > 0 ) { dataElementGroup.setName( name ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/ValidateDataElementGroupAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/ValidateDataElementGroupAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/ValidateDataElementGroupAction.java 2013-03-01 04:09:26 +0000 @@ -77,6 +77,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; + } + // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- @@ -106,6 +120,33 @@ return ERROR; } } + if ( shortName != null ) + { + DataElementGroup match = dataElementService.getDataElementGroupByShortName( shortName ); + + if ( match != null && (id == null || match.getId() != id) ) + { + message = i18n.getString( "short_name_in_use" ); + + return ERROR; + } + } + + if ( code != null && !code.trim().isEmpty() ) + { + DataElementGroup match = dataElementService.getDataElementGroupByCode( code ); + + if ( match != null && (id == null || match.getId() != id) ) + { + message = i18n.getString( "code_in_use" ); + + return ERROR; + } + } + + // --------------------------------------------------------------------- + // Validation success + // --------------------------------------------------------------------- message = i18n.getString( "everything_is_ok" ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm 2012-10-17 11:58:35 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm 2013-03-01 04:09:26 +0000 @@ -11,7 +11,9 @@ }); checkValueIsExist("name", "validateDataElementGroup.action"); - + checkValueIsExist( "shortName", "validateDataElementGroup.action" ); + checkValueIsExist( "code", "validateDataElementGroup.action" ); + jQuery("#availableDataElementsList").dhisAjaxSelect({ source: "../dhis-web-commons-ajax-json/getDataElements.action", iterator: "dataElements", @@ -40,6 +42,14 @@ + + + + + + + + #tblDynamicAttributes( { "attributes": $attributes } ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm 2013-02-22 04:05:11 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm 2013-03-01 04:09:26 +0000 @@ -80,6 +80,8 @@ $i18n.getString( 'hide_details' )


+


+



=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js 2011-09-27 07:36:07 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js 2013-03-01 04:09:26 +0000 @@ -20,6 +20,8 @@ { id: dataElementGroupId }, function ( json ) { setInnerHTML( 'nameField', json.dataElementGroup.name ); + setInnerHTML( 'shortNameField', json.dataElementGroup.shortName ); + setInnerHTML( 'codeField', json.dataElementGroup.code ); setInnerHTML( 'memberCountField', json.dataElementGroup.memberCount ); showDetails(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm 2012-10-17 11:58:35 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm 2013-03-01 04:09:26 +0000 @@ -14,6 +14,14 @@ checkValueIsExist( "name", "validateDataElementGroup.action", { id : getFieldValue( 'id' ) } ); + + checkValueIsExist( "shortName", "validateDataElementGroup.action", { + id : getFieldValue( 'id' ) + } ); + + checkValueIsExist( "code", "validateDataElementGroup.action", { + id : getFieldValue( 'id' ) + } ); jQuery("#availableDataElementsList").dhisAjaxSelect({ source: "../dhis-web-commons-ajax-json/getDataElements.action", @@ -45,9 +53,17 @@ - + + + + + + + + + #tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } )