dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26026
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12908: Surveillance, implemented UI option for sending alerts on interactive run
------------------------------------------------------------
revno: 12908
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-11-09 00:17:37 +0100
message:
Surveillance, implemented UI option for sending alerts on interactive run
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationRuleServiceTest.java
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/resources/org/hisp/dhis/validationrule/i18n_module.properties
dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
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/runValidationForm.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/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<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources );
+ Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> 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<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources, ValidationRuleGroup group );
+ Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> 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<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources )
+ public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources, boolean sendAlerts )
{
- return validate( startDate, endDate, sources, null );
+ return validate( startDate, endDate, sources, null, sendAlerts );
}
@Override
public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources,
- ValidationRuleGroup group )
+ ValidationRuleGroup group, boolean sendAlerts )
{
log.info( "Validate start:" + startDate + " end: " + endDate + " sources: " + sources.size() + " group: " + group );
Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
Collection<ValidationRule> rules = group != null ? group.getMembers() : getAllValidationRules();
- return Validator.validate( sources, periods, rules, null,
+ Collection<ValidationResult> 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<ValidationResult> results = validationRuleService.validate(
- getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA );
+ getDate( 2000, 2, 1 ), getDate( 2000, 6, 1 ), sourcesA, false );
Collection<ValidationResult> reference = new HashSet<ValidationResult>();
@@ -543,7 +543,7 @@
validationRuleService.addValidationRuleGroup( group );
Collection<ValidationResult> 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<ValidationResult> reference = new HashSet<ValidationResult>();
=== 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<ValidationResult> validationResults = new ArrayList<ValidationResult>();
@@ -168,7 +175,7 @@
log.info( "Validating captured data for all rules" );
validationResults = new ArrayList<ValidationResult>( 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<ValidationResult>( 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 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-validationrule/runValidationForm.vm</param>
<param name="menu">/dhis-web-validationrule/menu.vm</param>
- <param
- name="javascripts">../dhis-web-commons/oust/oust.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/runValidation.js
- </param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/runValidation.js</param>
<param name="requiredAuthorities">F_RUN_VALIDATION</param>
</action>
=== 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" ) , "'")';
</script>
@@ -51,6 +49,14 @@
</td>
</tr>
<tr>
+ <td>
+ <label for="sendAlerts">$i18n.getString( "send_alerts" )</label>
+ </td>
+ <td>
+ <input type="checkbox" id="sendAlerts" name="sendAlerts">
+ </td>
+ </tr>
+ <tr>
<td colspan="2" style="height:20px"></td>
</tr>
<tr>