=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2014-03-28 01:51:34 +0000 @@ -253,13 +253,13 @@ } /** - * Indicates whether this validation rule has user roles to alert. + * Indicates whether this validation rule has user groups to alert. */ - public boolean hasUserRolesToAlert() + public boolean hasUserGroupsToAlert() { for ( ValidationRuleGroup group : groups ) { - if ( group.hasUserRolesToAlert() ) + if ( group.hasUserGroupsToAlert() ) { return true; } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java 2014-03-28 01:51:34 +0000 @@ -45,6 +45,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.hisp.dhis.user.UserGroup; /** * @author Lars Helge Overland @@ -63,8 +64,10 @@ @Scanned private Set members = new HashSet(); - private Set userAuthorityGroupsToAlert = new HashSet(); - + private Set userGroupsToAlert = new HashSet(); + + private boolean alertByOrgUnits; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -104,9 +107,9 @@ /** * Indicates whether this group has user roles to alert. */ - public boolean hasUserRolesToAlert() + public boolean hasUserGroupsToAlert() { - return userAuthorityGroupsToAlert != null && !userAuthorityGroupsToAlert.isEmpty(); + return userGroupsToAlert != null && !userGroupsToAlert.isEmpty(); } // ------------------------------------------------------------------------- @@ -144,16 +147,32 @@ @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JsonView( { DetailedView.class } ) - @JacksonXmlElementWrapper( localName = "userRolesToAlert", namespace = DxfNamespaces.DXF_2_0) - @JacksonXmlProperty( localName = "userRoleToAlert", namespace = DxfNamespaces.DXF_2_0) - public Set getUserAuthorityGroupsToAlert() - { - return userAuthorityGroupsToAlert; - } - - public void setUserAuthorityGroupsToAlert( Set userAuthorityGroupsToAlert ) - { - this.userAuthorityGroupsToAlert = userAuthorityGroupsToAlert; + @JacksonXmlElementWrapper( localName = "userGroupsToAlert", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty( localName = "userGroupToAlert", namespace = DxfNamespaces.DXF_2_0) + public Set getUserGroupsToAlert() + { + return userGroupsToAlert; + } + + @JsonProperty + @JsonView( {DetailedView.class, ExportView.class} ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public void setUserGroupsToAlert( Set userGroupsToAlert ) + { + this.userGroupsToAlert = userGroupsToAlert; + } + + @JsonProperty + @JsonView( {DetailedView.class, ExportView.class} ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isAlertByOrgUnits() + { + return alertByOrgUnits; + } + + public void setAlertByOrgUnits( boolean alertByOrgUnits ) + { + this.alertByOrgUnits = alertByOrgUnits; } @Override === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-03-25 14:01:51 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-03-28 01:51:34 +0000 @@ -122,6 +122,7 @@ executeSql( "DROP TABLE loginfailure" ); executeSql( "DROP TABLE dashboarditem_trackedentitytabularreports" ); executeSql( "DROP TABLE categoryoptioncombousergroupaccesses" ); + executeSql( "DROP TABLE validationrulegroupuserrolestoalert" ); executeSql( "ALTER TABLE categoryoptioncombo drop column userid" ); executeSql( "ALTER TABLE categoryoptioncombo drop column publicaccess" ); executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" ); @@ -703,6 +704,9 @@ // update attribute.code, set to null if code='' executeSql( "UPDATE attribute SET code=NULL WHERE code=''" ); + // validation rule group, new column alertbyorgunits needs values + executeSql( "UPDATE validationrulegroup SET alertbyorgunits=false WHERE alertbyorgunits IS NULL" ); + upgradeDataValuesWithAttributeOptionCombo(); upgradeMapViewsToAnalyticalObject(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2014-03-28 01:51:34 +0000 @@ -71,8 +71,8 @@ import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.user.User; -import org.hisp.dhis.user.UserAuthorityGroup; import org.hisp.dhis.user.UserCredentials; +import org.hisp.dhis.user.UserGroup; import org.springframework.transaction.annotation.Transactional; /** @@ -269,7 +269,7 @@ Collection results = Validator.validate( sources, periods, rules, lastScheduledRun, constantService, expressionService, periodService, dataValueService ); - log.info( "Run results: " + results.size() ); + log.info( "Validation run result count: " + results.size() ); if ( !results.isEmpty() ) { @@ -296,7 +296,7 @@ for ( ValidationRuleGroup validationRuleGroup : getAllValidationRuleGroups() ) { - if ( validationRuleGroup.hasUserRolesToAlert() ) + if ( validationRuleGroup.hasUserGroupsToAlert() ) { rules.addAll( validationRuleGroup.getMembers() ); } @@ -361,11 +361,10 @@ { SortedSet results = new TreeSet( validationResults ); - Map, Set> messageMap = getMessageMap( results ); - - for ( Map.Entry, Set> entry : messageMap.entrySet() ) + Map, Set> messageMap = getMessageMap( results ); + + for ( Map.Entry, Set> entry : messageMap.entrySet() ) { - Collections.sort( entry.getKey() ); sendAlertmessage( entry.getKey(), entry.getValue(), scheduledRunStart ); } } @@ -396,82 +395,90 @@ * to assemble into a message, and the value is the set of users who * should receive this message. * - * @param results all the validation run results + * @param results all the validation run results, in a sorted set * @return map of result sets to users */ - private Map, Set> getMessageMap( Set results ) + private Map, Set> getMessageMap( SortedSet results ) { - Map> userRulesMap = getUserRulesMap(); - - Map, Set> messageMap = new HashMap, Set>(); - - for ( User user : userRulesMap.keySet() ) + Map> userResults = getUserResults( results ); + + Map, Set> messageMap = new HashMap, Set>(); + + for (Map.Entry> userResultEntry : userResults.entrySet() ) { - // For users receiving alerts, find the subset of results from run. - - Collection userRules = userRulesMap.get( user ); - List userResults = new ArrayList(); - - for ( ValidationResult result : results ) - { - if ( userRules.contains( result.getValidationRule() ) ) - { - userResults.add( result ); - } - } - - // Group this user with other users having the same result subset. - - if ( !userResults.isEmpty() ) - { - Set messageReceivers = messageMap.get( userResults ); - if ( messageReceivers == null ) - { - messageReceivers = new HashSet(); - messageMap.put( userResults, messageReceivers ); - } - messageReceivers.add( user ); - } + Set users = messageMap.get( userResultEntry.getValue() ); + + if ( users == null ) + { + users = new HashSet(); + + messageMap.put( userResultEntry.getValue(), users ); + } + users.add( userResultEntry.getKey() ); } - + return messageMap; } /** - * Constructs a Map where the key is each user who is configured to - * receive alerts, and the value is a list of rules they should receive - * results for. - * - * @return Map from users to sets of rules + * Returns a map where the key is a user and the value is a naturally-sorted + * list of results they should receive. + * + * @param results all the validation run results, in a sorted set + * @return map of users to results */ - private Map> getUserRulesMap() + private Map> getUserResults( SortedSet results ) { - Map> userRulesMap = new HashMap>(); + Map> userResults = new HashMap>(); - for ( ValidationRuleGroup validationRuleGroup : getAllValidationRuleGroups() ) + for ( ValidationResult result : results ) { - Collection userRolesToAlert = validationRuleGroup.getUserAuthorityGroupsToAlert(); - - if ( userRolesToAlert != null && !userRolesToAlert.isEmpty() ) + for ( ValidationRuleGroup ruleGroup : result.getValidationRule().getGroups() ) { - for ( UserAuthorityGroup role : userRolesToAlert ) + if ( ruleGroup.hasUserGroupsToAlert() ) { - for ( UserCredentials userCredentials : role.getMembers() ) + for ( UserGroup userGroup : ruleGroup.getUserGroupsToAlert() ) { - User user = userCredentials.getUser(); - Set userRules = userRulesMap.get( user ); - if ( userRules == null ) + for ( User user : userGroup.getMembers() ) { - userRules = new HashSet(); - userRulesMap.put( user, userRules ); + if ( !ruleGroup.isAlertByOrgUnits() || canUserAccessSource( user, result.getSource() ) ) + { + SortedSet resultSet = userResults.get ( user ); + + if ( resultSet == null ) + { + resultSet = new TreeSet(); + + userResults.put( user, resultSet ); + } + resultSet.add( result ); + } } - userRules.addAll( validationRuleGroup.getMembers() ); } } } } - - return userRulesMap; + return userResults; + } + + /** + * Determines whether a user can access an organisation unit, + * based on the organisation units to which the user has been assigned. + * + * @param user user to test + * @param source organisation unit to which the user may have access + * @return whether the user has acceess to the organisation unit + */ + private boolean canUserAccessSource( User user, OrganisationUnit source ) + { + for ( OrganisationUnit o : user.getOrganisationUnits() ) + { + if ( source == o || source.getAncestors().contains( o ) ) + { + return true; + } + } + return false; } /** @@ -482,7 +489,7 @@ * @param users users to receive these results * @param scheduledRunStart date/time when the scheduled run started */ - private void sendAlertmessage( List results, Set users, Date scheduledRunStart ) + private void sendAlertmessage( SortedSet results, Set users, Date scheduledRunStart ) { StringBuilder builder = new StringBuilder(); @@ -522,7 +529,7 @@ * @param results results to analyze * @return Mapping between importance type and result counts. */ - private Map countResultsByImportanceType ( List results ) + private Map countResultsByImportanceType ( Set results ) { Map importanceCountMap = new HashMap(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationResultToAlertFilter.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationResultToAlertFilter.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationResultToAlertFilter.java 2014-03-28 01:51:34 +0000 @@ -36,6 +36,6 @@ @Override public boolean retain( ValidationResult result ) { - return result != null && result.getValidationRule() != null && result.getValidationRule().hasUserRolesToAlert(); + return result != null && result.getValidationRule() != null && result.getValidationRule().hasUserGroupsToAlert(); } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml 2014-03-24 18:52:45 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml 2014-03-28 01:51:34 +0000 @@ -19,16 +19,18 @@ + + - - - + + + === modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-03-28 01:51:34 +0000 @@ -115,7 +115,7 @@ emptyTable( "datadictionaryindicators" ); emptyTable( "datadictionary" ); - emptyTable( "validationrulegroupuserrolestoalert" ); + emptyTable( "validationrulegroupusergroupstoalert" ); emptyTable( "validationrulegroupmembers" ); emptyTable( "validationrulegroup" ); emptyTable( "validationrule" ); === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/AddValidationRuleGroupAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/AddValidationRuleGroupAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/AddValidationRuleGroupAction.java 2014-03-28 01:51:34 +0000 @@ -30,7 +30,7 @@ import java.util.Set; -import org.hisp.dhis.user.UserService; +import org.hisp.dhis.user.UserGroupService; import org.hisp.dhis.validation.ValidationRuleGroup; import org.hisp.dhis.validation.ValidationRuleService; @@ -54,11 +54,11 @@ this.validationRuleService = validationRuleService; } - private UserService userService; + private UserGroupService userGroupService; - public void setUserService( UserService userService ) + public void setUserService( UserGroupService userGroupService ) { - this.userService = userService; + this.userGroupService = userGroupService; } // ------------------------------------------------------------------------- @@ -86,13 +86,20 @@ this.groupMembers = groupMembers; } - private Set userRolesToAlert; - - public void setUserRolesToAlert( Set userRolesToAlert ) - { - this.userRolesToAlert = userRolesToAlert; - } - + private Set userGroupsToAlert; + + public void setUserGroupsToAlert( Set userGroupsToAlert ) + { + this.userGroupsToAlert = userGroupsToAlert; + } + + private boolean alertByOrgUnits; + + public void setAlertByOrgUnits( boolean alertByOrgUnits ) + { + this.alertByOrgUnits = alertByOrgUnits; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -111,15 +118,17 @@ group.getMembers().add( validationRuleService.getValidationRule( Integer.valueOf( id ) ) ); } } - group.getUserAuthorityGroupsToAlert().clear(); + group.getUserGroupsToAlert().clear(); - if ( userRolesToAlert != null ) + if ( userGroupsToAlert != null ) { - for ( String id : userRolesToAlert ) + for ( String id : userGroupsToAlert ) { - group.getUserAuthorityGroupsToAlert().add( userService.getUserAuthorityGroup( Integer.valueOf( id ) ) ); + group.getUserGroupsToAlert().add( userGroupService.getUserGroup( Integer.valueOf( id ) ) ); } } + + group.setAlertByOrgUnits( alertByOrgUnits ); validationRuleService.addValidationRuleGroup( group ); === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/ShowUpdateValidationRuleGroupFormAction.java 2014-03-28 01:51:34 +0000 @@ -34,6 +34,8 @@ import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.user.UserAuthorityGroup; +import org.hisp.dhis.user.UserGroup; +import org.hisp.dhis.user.UserGroupService; import org.hisp.dhis.user.UserService; import org.hisp.dhis.validation.ValidationRule; import org.hisp.dhis.validation.ValidationRuleGroup; @@ -61,11 +63,11 @@ this.validationRuleService = validationRuleService; } - private UserService userService; + private UserGroupService userGroupService; - public void setUserService( UserService userService ) + public void setUserGroupService( UserGroupService userGroupService ) { - this.userService = userService; + this.userGroupService = userGroupService; } // ------------------------------------------------------------------------- @@ -104,18 +106,25 @@ return groupMembers; } - private List availableUserRolesToAlert = new ArrayList(); + private List availableUserGroupsToAlert = new ArrayList(); - public List getAvailableUserRolesToAlert() - { - return availableUserRolesToAlert; - } - - private List userRolesToAlert = new ArrayList(); - - public List getUserRolesToAlert() - { - return userRolesToAlert; + public List getAvailableUserGroupsToAlert() + { + return availableUserGroupsToAlert; + } + + private List userGroupsToAlert = new ArrayList(); + + public List getUserGroupsToAlert() + { + return userGroupsToAlert; + } + + private boolean alertByOrgUnits; + + public boolean getAlertByOrgUnits() + { + return alertByOrgUnits; } // ------------------------------------------------------------------------- @@ -130,11 +139,13 @@ Collections.sort( groupMembers, IdentifiableObjectNameComparator.INSTANCE ); - availableUserRolesToAlert = new ArrayList( userService.getAllUserAuthorityGroups() ); + availableUserGroupsToAlert = new ArrayList( userGroupService.getAllUserGroups() ); - userRolesToAlert = new ArrayList( validationRuleGroup.getUserAuthorityGroupsToAlert() ); + userGroupsToAlert = new ArrayList( validationRuleGroup.getUserGroupsToAlert() ); - Collections.sort( userRolesToAlert, IdentifiableObjectNameComparator.INSTANCE ); + Collections.sort( userGroupsToAlert, IdentifiableObjectNameComparator.INSTANCE ); + + alertByOrgUnits = validationRuleGroup.isAlertByOrgUnits(); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/UpdateValidationRuleGroupAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/UpdateValidationRuleGroupAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/validationrulegroup/UpdateValidationRuleGroupAction.java 2014-03-28 01:51:34 +0000 @@ -30,7 +30,7 @@ import java.util.Set; -import org.hisp.dhis.user.UserService; +import org.hisp.dhis.user.UserGroupService; import org.hisp.dhis.validation.ValidationRuleGroup; import org.hisp.dhis.validation.ValidationRuleService; @@ -54,11 +54,11 @@ this.validationRuleService = validationRuleService; } - private UserService userService; + private UserGroupService userGroupService; - public void setUserService( UserService userService ) + public void setUserGroupService( UserGroupService userGroupService ) { - this.userService = userService; + this.userGroupService = userGroupService; } // ------------------------------------------------------------------------- @@ -93,13 +93,20 @@ this.groupMembers = groupMembers; } - private Set userRolesToAlert; - - public void setUserRolesToAlert( Set userRolesToAlert ) - { - this.userRolesToAlert = userRolesToAlert; - } - + private Set userGroupsToAlert; + + public void setUserGroupsToAlert( Set userGroupsToAlert ) + { + this.userGroupsToAlert = userGroupsToAlert; + } + + private boolean alertByOrgUnits; + + public void setAlertByOrgUnits( boolean alertByOrgUnits ) + { + this.alertByOrgUnits = alertByOrgUnits; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -120,16 +127,18 @@ } } - group.getUserAuthorityGroupsToAlert().clear(); + group.getUserGroupsToAlert().clear(); - if ( userRolesToAlert != null ) + if ( userGroupsToAlert != null ) { - for ( String id : userRolesToAlert ) + for ( String id : userGroupsToAlert ) { - group.getUserAuthorityGroupsToAlert().add( userService.getUserAuthorityGroup( Integer.valueOf( id ) ) ); + group.getUserGroupsToAlert().add( userGroupService.getUserGroup( Integer.valueOf( id ) ) ); } } - + + group.setAlertByOrgUnits( alertByOrgUnits ); + validationRuleService.updateValidationRuleGroup( group ); return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2013-12-17 09:33:58 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2014-03-28 01:51:34 +0000 @@ -77,7 +77,7 @@ class="org.hisp.dhis.validationrule.action.validationrulegroup.AddValidationRuleGroupAction" scope="prototype"> - + - + - + "); option.text( item.name ); @@ -83,25 +83,37 @@ - + - + -
-
-
- +
+
+
+ - -

+ + + + + +
+ +
+ +

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/addValidationRuleGroupForm.js' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/addValidationRuleGroupForm.js 2013-10-13 18:23:51 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/addValidationRuleGroupForm.js 2014-03-28 01:51:34 +0000 @@ -9,7 +9,7 @@ 'beforeValidateHandler' : function() { selectAllById( 'groupMembers' ); - selectAllById( 'userRolesToAlert' ); + selectAllById( 'userGroupsToAlert' ); }, 'rules' : getValidationRules( "validationRuleGroup" ) } ); === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/updateValidationRuleGroupForm.js' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/updateValidationRuleGroupForm.js 2013-10-16 20:03:41 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/updateValidationRuleGroupForm.js 2014-03-28 01:51:34 +0000 @@ -9,7 +9,7 @@ 'beforeValidateHandler' : function() { selectAllById( 'groupMembers' ); - selectAllById( 'userRolesToAlert' ); + selectAllById( 'userGroupsToAlert' ); }, 'rules' : getValidationRules( "validationRuleGroup" ) } ); === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRuleGroup.js' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRuleGroup.js 2013-12-06 13:37:28 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRuleGroup.js 2014-03-28 01:51:34 +0000 @@ -12,7 +12,7 @@ setInnerHTML('nameField', json.validationRuleGroup.name); setInnerHTML('descriptionField', json.validationRuleGroup.description); setInnerHTML('memberCountField', json.validationRuleGroup.memberCount); - setInnerHTML('userRolesToAlertCountField', json.validationRuleGroup.userRolesToAlertCount); + setInnerHTML('userGroupsToAlertCountField', json.validationRuleGroup.userGroupsToAlertCount); showDetails(); }); @@ -40,13 +40,13 @@ $("").attr("value", id).text(availableValidationRules[id])); } - for( var id in availableUserRolesToAlert ) { - $("#availableUserRolesToAlert").append($("").attr("value", id).text(availableUserRolesToAlert[id])); + for( var id in availableUserGroupsToAlert ) { + $("#availableUserGroupsToAlert").append($("").attr("value", id).text(availableUserGroupsToAlert[id])); } - for( var id in selectedUserRolesToAlert ) { + for( var id in selectedUserGroupsToAlert ) { $("#availableValidationRules").append( - $("").attr("value", id).text(selectedUserRolesToAlert[id])); + $("").attr("value", id).text(selectedUserGroupsToAlert[id])); } } @@ -114,66 +114,66 @@ filterAvailableValidationRules(); } -function filterAvailableUserRolesToAlert() { - var filter = document.getElementById('availableUserRolesToAlertFilter').value; - var list = document.getElementById('availableUserRolesToAlert'); - - list.options.length = 0; - - for( var id in availableUserRolesToAlert ) { - var value = availableUserRolesToAlert[id]; - - if( value.toLowerCase().indexOf(filter.toLowerCase()) != -1 ) { - list.add(new Option(value, id), null); - } - } -} - -function filterSelectedUserRolesToAlert() { - var filter = document.getElementById('selectedUserRolesToAlertFilter').value; - var list = document.getElementById('selectedUserRolesToAlert'); - - list.options.length = 0; - - for( var id in selectedUserRolesToAlert ) { - var value = selectedUserRolesToAlert[id]; - - if( value.toLowerCase().indexOf(filter.toLowerCase()) != -1 ) { - list.add(new Option(value, id), null); - } - } -} - -function addSelectedUserRolesToAlert() { - var list = document.getElementById('selectedUserRolesToAlert'); - - while( list.selectedIndex != -1 ) { - var id = list.options[list.selectedIndex].value; - - list.options[list.selectedIndex].selected = false; - - selectedUserRolesToAlert[id] = availableUserRolesToAlert[id]; - - delete availableUserRolesToAlert[id]; - } - - filterAvailableUserRolesToAlert(); - filterSelectedUserRolesToAlert(); -} - -function removeSelectedUserRolesToAlert() { - var list = document.getElementById('selectedUserRolesToAlert'); - - while( list.selectedIndex != -1 ) { - var id = list.options[list.selectedIndex].value; - - list.options[list.selectedIndex].selected = false; - - availableUserRolesToAlert[id] = selectedUserRolesToAlert[id]; - - delete selectedUserRolesToAlert[id]; - } - - filterAvailableUserRolesToAlert(); - filterSelectedUserRolesToAlert(); +function filterAvailableUserGroupsToAlert() { + var filter = document.getElementById('availableUserGroupsToAlertFilter').value; + var list = document.getElementById('availableUserGroupsToAlert'); + + list.options.length = 0; + + for( var id in availableUserGroupsToAlert ) { + var value = availableUserGroupsToAlert[id]; + + if( value.toLowerCase().indexOf(filter.toLowerCase()) != -1 ) { + list.add(new Option(value, id), null); + } + } +} + +function filterSelectedUserGroupsToAlert() { + var filter = document.getElementById('selectedUserGroupsToAlertFilter').value; + var list = document.getElementById('selectedUserGroupsToAlert'); + + list.options.length = 0; + + for( var id in selectedUserGroupsToAlert ) { + var value = selectedUserGroupsToAlert[id]; + + if( value.toLowerCase().indexOf(filter.toLowerCase()) != -1 ) { + list.add(new Option(value, id), null); + } + } +} + +function addSelectedUserGroupsToAlert() { + var list = document.getElementById('selectedUserGroupsToAlert'); + + while( list.selectedIndex != -1 ) { + var id = list.options[list.selectedIndex].value; + + list.options[list.selectedIndex].selected = false; + + selectedUserGroupsToAlert[id] = availableUserGroupsToAlert[id]; + + delete availableUserGroupsToAlert[id]; + } + + filterAvailableUserGroupsToAlert(); + filterSelectedUserGroupsToAlert(); +} + +function removeSelectedUserGroupsToAlert() { + var list = document.getElementById('selectedUserGroupsToAlert'); + + while( list.selectedIndex != -1 ) { + var id = list.options[list.selectedIndex].value; + + list.options[list.selectedIndex].selected = false; + + availableUserGroupsToAlert[id] = selectedUserGroupsToAlert[id]; + + delete selectedUserGroupsToAlert[id]; + } + + filterAvailableUserGroupsToAlert(); + filterSelectedUserGroupsToAlert(); } === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/jsonValidationRuleGroup.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/jsonValidationRuleGroup.vm 2013-10-13 18:35:46 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/jsonValidationRuleGroup.vm 2014-03-28 01:51:34 +0000 @@ -4,6 +4,7 @@ "name": "$!encoder.jsonEncode( ${validationRuleGroup.name} )", "description": "$!encoder.jsonEncode( ${validationRuleGroup.description} )", "memberCount": "${validationRuleGroup.members.size()}", - "userRolesToAlertCount": "$!{validationRuleGroup.userAuthorityGroupsToAlert.size()}" + "userGroupsToAlertCount": "$!{validationRuleGroup.userGroupsToAlert.size()}", + "alertByOrgUnits": $!{validationRuleGroup.alertByOrgUnits}" } } === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleGroupForm.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleGroupForm.vm 2013-10-13 18:20:54 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleGroupForm.vm 2014-03-28 01:51:34 +0000 @@ -12,10 +12,10 @@ return option; } }); - jQuery("#availableUserRolesToAlert").dhisAjaxSelect({ - source: "../dhis-web-commons-ajax-json/getUserRoles.action", - iterator: "userRoles", - connectedTo: 'userRolesToAlert', + jQuery("#availableUserGroupsToAlert").dhisAjaxSelect({ + source: "../dhis-web-commons-ajax-json/getUserGroups.action", + iterator: "userGroups", + connectedTo: 'userGroupsToAlert', handler: function(item) { var option = jQuery(" #end + + + + + +
+ +
+

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm 2014-03-25 08:05:13 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRuleGroup.vm 2014-03-28 01:51:34 +0000 @@ -66,7 +66,7 @@




-


+