=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java 2013-10-23 22:03:17 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java 2013-11-08 23:17:37 +0000 @@ -54,23 +54,25 @@ /** * Validate DataValues. * - * @param startDate the start date. - * @param endDate the end date. - * @param sources a collection of Sources. + * @param startDate the start date. + * @param endDate the end date. + * @param sources a collection of Sources. + * @param sendAlerts whether to send alerts for surveillance. * @return a collection of ValidationResults for each validation violation. */ - Collection validate( Date startDate, Date endDate, Collection sources ); + Collection validate( Date startDate, Date endDate, Collection sources, boolean sendAlerts ); /** * Validate DataValues. * - * @param startDate the start date. - * @param endDate the end date. - * @param sources a collection of Sources. - * @param group a group of ValidationRules. + * @param startDate the start date. + * @param endDate the end date. + * @param sources a collection of Sources. + * @param group a group of ValidationRules. + * @param sendAlerts whether to send alerts for surveillance. * @return a collection of ValidationResults for each validation violation. */ - Collection validate( Date startDate, Date endDate, Collection sources, ValidationRuleGroup group ); + Collection validate( Date startDate, Date endDate, Collection sources, ValidationRuleGroup group, boolean sendAlerts ); /** * Validate DataValues. === 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 2013-11-08 22:17:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2013-11-08 23:17:37 +0000 @@ -169,22 +169,29 @@ // ------------------------------------------------------------------------- @Override - public Collection validate( Date startDate, Date endDate, Collection sources ) + public Collection validate( Date startDate, Date endDate, Collection sources, boolean sendAlerts ) { - return validate( startDate, endDate, sources, null ); + return validate( startDate, endDate, sources, null, sendAlerts ); } @Override public Collection validate( Date startDate, Date endDate, Collection sources, - ValidationRuleGroup group ) + ValidationRuleGroup group, boolean sendAlerts ) { log.info( "Validate start:" + startDate + " end: " + endDate + " sources: " + sources.size() + " group: " + group ); Collection periods = periodService.getPeriodsBetweenDates( startDate, endDate ); Collection rules = group != null ? group.getMembers() : getAllValidationRules(); - return Validator.validate( sources, periods, rules, null, + Collection results = Validator.validate( sources, periods, rules, null, constantService, expressionService, periodService, dataValueService ); + + if ( sendAlerts ) + { + postAlerts( results, new Date() ); + } + + return results; } @Override === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java 2013-10-11 12:58:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java 2013-11-08 23:17:37 +0000 @@ -485,7 +485,7 @@ // insures that if they are the same as the reference results, they will appear in the same order. Collection results = validationRuleService.validate( - getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA ); + getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, false ); Collection reference = new HashSet(); @@ -543,7 +543,7 @@ validationRuleService.addValidationRuleGroup( group ); Collection results = validationRuleService.validate( - getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, group ); + getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, group, false ); Collection reference = new HashSet(); === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2013-10-16 13:41:01 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2013-11-08 23:17:37 +0000 @@ -124,6 +124,13 @@ { this.validationRuleGroupId = validationRuleGroupId; } + + private boolean sendAlerts; + + public void setSendAlerts( boolean sendAlerts ) + { + this.sendAlerts = sendAlerts; + } private List validationResults = new ArrayList(); @@ -168,7 +175,7 @@ log.info( "Validating captured data for all rules" ); validationResults = new ArrayList( validationRuleService.validate( format - .parseDate( startDate ), format.parseDate( endDate ), organisationUnits ) ); + .parseDate( startDate ), format.parseDate( endDate ), organisationUnits, sendAlerts ) ); } else { @@ -177,7 +184,7 @@ log.info( "Validating captured data for rules for group: '" + group.getName() + "'" ); validationResults = new ArrayList( validationRuleService.validate( format - .parseDate( startDate ), format.parseDate( endDate ), organisationUnits, group ) ); + .parseDate( startDate ), format.parseDate( endDate ), organisationUnits, group, sendAlerts ) ); } maxExceeded = validationResults.size() > ValidationRuleService.MAX_INTERACTIVE_ALERTS; === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2013-10-16 13:41:01 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2013-11-08 23:17:37 +0000 @@ -146,4 +146,5 @@ annual_sample_count=Annual sample count high_outliers=High outliers low_outliers=Low outliers -number_of_user_roles_to_alert=Number of user roles to alert \ No newline at end of file +number_of_user_roles_to_alert=Number of user roles to alert +send_alerts=Send alerts \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2013-10-13 16:15:28 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml 2013-11-08 23:17:37 +0000 @@ -140,9 +140,7 @@ /main.vm /dhis-web-validationrule/runValidationForm.vm /dhis-web-validationrule/menu.vm - ../dhis-web-commons/oust/oust.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/runValidation.js - + ../dhis-web-commons/oust/oust.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/runValidation.js F_RUN_VALIDATION === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js 2013-10-15 14:22:12 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js 2013-11-08 23:17:37 +0000 @@ -1,7 +1,7 @@ var startDate; var endDate; -var aggregate; var validationRuleGroupId; +var sendAlerts; var organisationUnitId; function organisationUnitSelected( ids ) @@ -13,14 +13,13 @@ { startDate = $( '#startDate' ).val(); endDate = $( '#endDate' ).val(); - aggregate = $( '#aggregate' ).val(); validationRuleGroupId = $( '#validationRuleGroupId' ).val(); + sendAlerts = $( '#sendAlerts' ).is( ':checked' ); $.getJSON( 'validateRunValidation.action', { startDate:startDate, - endDate:endDate, - aggregate:aggregate + endDate:endDate }, function( json ) { @@ -32,10 +31,10 @@ $.get( 'runValidationAction.action', { - organisationUnitId:organisationUnitId, + organisationUnitId: organisationUnitId, startDate:startDate, endDate:endDate, - validationRuleGroupId:validationRuleGroupId, - aggregate:aggregate + validationRuleGroupId: validationRuleGroupId, + sendAlerts: sendAlerts }, function( data ) { === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm 2013-10-08 19:10:40 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm 2013-11-08 23:17:37 +0000 @@ -8,8 +8,6 @@ selectionTreeSelection.setListenerFunction( organisationUnitSelected ); }); - var i18n_aggregate_data_info = '$encoder.jsEscape( $i18n.getString( "aggregate_data_info" ) , "'")'; - var i18n_captured_data_info = '$encoder.jsEscape( $i18n.getString( "captured_data_info" ) , "'")'; var i18n_analysing_please_wait = '$encoder.jsEscape( $i18n.getString( "analysing_please_wait" ) , "'")'; @@ -51,6 +49,14 @@ + + + + + + + +