dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25503
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12675: Indentation fixes
------------------------------------------------------------
revno: 12675
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-15 14:12:59 +0200
message:
Indentation fixes
modified:
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/Validator.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java
--
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-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-10-15 07:35:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2013-10-15 12:12:59 +0000
@@ -82,8 +82,7 @@
private GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore;
- public void setValidationRuleGroupStore(
- GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore )
+ public void setValidationRuleGroupStore( GenericIdentifiableObjectStore<ValidationRuleGroup> validationRuleGroupStore )
{
this.validationRuleGroupStore = validationRuleGroupStore;
}
@@ -139,8 +138,9 @@
log.info( "Validate startDate=" + startDate + " endDate=" + endDate + " sources[" + sources.size() + "]" );
Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
Collection<ValidationRule> rules = getAllValidationRules();
+
return Validator.validate( sources, periods, rules, ValidationRunType.INTERACTIVE, null,
- constantService, expressionService, periodService, dataValueService );
+ constantService, expressionService, periodService, dataValueService );
}
public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources,
@@ -149,8 +149,9 @@
log.info( "Validate startDate=" + startDate + " endDate=" + endDate + " sources[" + sources.size() + "] group=" + group.getName() );
Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
Collection<ValidationRule> rules = group.getMembers();
+
return Validator.validate( sources, periods, rules, ValidationRunType.INTERACTIVE, null,
- constantService, expressionService, periodService, dataValueService );
+ constantService, expressionService, periodService, dataValueService );
}
public Collection<ValidationResult> validate( Date startDate, Date endDate, OrganisationUnit source )
@@ -160,8 +161,9 @@
Collection<ValidationRule> rules = getAllValidationRules();
Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
sources.add( source );
+
return Validator.validate( sources, periods, rules, ValidationRunType.INTERACTIVE, null,
- constantService, expressionService, periodService, dataValueService );
+ constantService, expressionService, periodService, dataValueService );
}
public Collection<ValidationResult> validate( DataSet dataSet, Period period, OrganisationUnit source )
@@ -172,6 +174,7 @@
periods.add( period );
Collection<ValidationRule> rules = null;
+
if ( DataSet.TYPE_CUSTOM.equals( dataSet.getDataSetType() ) )
{
rules = getRulesForDataSet( dataSet );
@@ -183,8 +186,9 @@
Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
sources.add( source );
+
return Validator.validate( sources, periods, rules, ValidationRunType.INTERACTIVE, null,
- constantService, expressionService, periodService, dataValueService );
+ constantService, expressionService, periodService, dataValueService );
}
// -------------------------------------------------------------------------
@@ -244,9 +248,9 @@
{
validationRuleOperands.clear();
validationRuleOperands.addAll( expressionService.getOperandsInExpression(
- rule.getLeftSide().getExpression() ) );
+ rule.getLeftSide().getExpression() ) );
validationRuleOperands.addAll( expressionService.getOperandsInExpression(
- rule.getRightSide().getExpression() ) );
+ rule.getRightSide().getExpression() ) );
if ( operands.containsAll( validationRuleOperands ) )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java 2013-10-15 07:35:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/Validator.java 2013-10-15 12:12:59 +0000
@@ -72,19 +72,19 @@
ConstantService constantService, ExpressionService expressionService, PeriodService periodService, DataValueService dataValueService)
{
ValidationRunContext context = ValidationRunContext.getNewValidationRunContext( sources, periods, rules,
- constantService.getConstantMap(), ValidationRunType.ALERT, lastAlertRun,
- expressionService, periodService, dataValueService);
+ constantService.getConstantMap(), ValidationRunType.ALERT, lastAlertRun,
+ expressionService, periodService, dataValueService);
int threadPoolSize = getThreadPoolSize( context );
ExecutorService executor = Executors.newFixedThreadPool( threadPoolSize );
for ( OrganisationUnitExtended sourceX : context.getSourceXs() )
{
- if ( sourceX.getToBeValidated() )
- {
- Runnable worker = new ValidatorThread( sourceX, context );
- executor.execute( worker );
- }
+ if ( sourceX.getToBeValidated() )
+ {
+ Runnable worker = new ValidatorThread( sourceX, context );
+ executor.execute( worker );
+ }
}
executor.shutdown();
@@ -97,6 +97,7 @@
{
executor.shutdownNow();
}
+
return context.getValidationResults();
}
@@ -114,6 +115,7 @@
{
threadPoolSize--;
}
+
if ( threadPoolSize > context.getCountOfSourcesToValidate() )
{
threadPoolSize = context.getCountOfSourcesToValidate();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java 2013-10-14 20:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java 2013-10-15 12:12:59 +0000
@@ -148,6 +148,7 @@
private void alertRun()
{
// Find all the rules belonging to groups that will send alerts to user roles.
+
Set<ValidationRule> rules = getAlertRules();
Collection<OrganisationUnit> sources = organisationUnitService.getAllOrganisationUnits();
@@ -182,9 +183,11 @@
private Set<ValidationRule> getAlertRules()
{
Set<ValidationRule> rules = new HashSet<ValidationRule>();
+
for ( ValidationRuleGroup validationRuleGroup : validationRuleService.getAllValidationRuleGroups() )
{
- Set<UserAuthorityGroup> userRolesToAlert = validationRuleGroup.getUserAuthorityGroupsToAlert();
+ Set<UserAuthorityGroup> userRolesToAlert = validationRuleGroup.getUserAuthorityGroupsToAlert();
+
if ( userRolesToAlert != null && !userRolesToAlert.isEmpty() )
{
rules.addAll( validationRuleGroup.getMembers() );
@@ -290,37 +293,38 @@
{
Map<User, Set<ValidationRule>> userRulesMap = getUserRulesMap();
- Map<List<ValidationResult>, Set<User>> messageMap = new HashMap<List<ValidationResult>, Set<User>>();
-
- for ( User user : userRulesMap.keySet() )
- {
- // For each user who receives alerts, find the subset of results
- // from this run.
- Collection<ValidationRule> userRules = userRulesMap.get( user );
- List<ValidationResult> userResults = new ArrayList<ValidationResult>();
-
- for ( ValidationResult result : results )
- {
- if ( userRules.contains( result.getValidationRule() ) )
- {
- userResults.add( result );
- }
- }
-
- // Group this user with any other users who have the same subset
- // of results.
- if ( !userResults.isEmpty() )
- {
- Set<User> messageReceivers = messageMap.get( userResults );
- if ( messageReceivers == null )
- {
- messageReceivers = new HashSet<User>();
- messageMap.put( userResults, messageReceivers );
- }
- messageReceivers.add( user );
- }
- }
- return messageMap;
+ Map<List<ValidationResult>, Set<User>> messageMap = new HashMap<List<ValidationResult>, Set<User>>();
+
+ for ( User user : userRulesMap.keySet() )
+ {
+ // For users receiving alerts, find the subset of results from run.
+
+ Collection<ValidationRule> userRules = userRulesMap.get( user );
+ List<ValidationResult> userResults = new ArrayList<ValidationResult>();
+
+ 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<User> messageReceivers = messageMap.get( userResults );
+ if ( messageReceivers == null )
+ {
+ messageReceivers = new HashSet<User>();
+ messageMap.put( userResults, messageReceivers );
+ }
+ messageReceivers.add( user );
+ }
+ }
+
+ return messageMap;
}
/**
@@ -332,32 +336,34 @@
*/
private Map<User, Set<ValidationRule>> getUserRulesMap()
{
- Map<User, Set<ValidationRule>> userRulesMap = new HashMap<User, Set<ValidationRule>>();
-
- for ( ValidationRuleGroup validationRuleGroup : validationRuleService.getAllValidationRuleGroups() )
- {
- Collection<UserAuthorityGroup> userRolesToAlert = validationRuleGroup.getUserAuthorityGroupsToAlert();
- if ( userRolesToAlert != null && !userRolesToAlert.isEmpty() )
- {
- for ( UserAuthorityGroup role : userRolesToAlert )
- {
- for ( UserCredentials userCredentials : role.getMembers() )
- {
- User user = userCredentials.getUser();
- Set<ValidationRule> userRules = userRulesMap.get( user );
- if ( userRules == null )
- {
- userRules = new HashSet<ValidationRule>();
- userRulesMap.put( user, userRules );
- }
- userRules.addAll( validationRuleGroup.getMembers() );
- }
- }
- }
- }
- return userRulesMap;
+ Map<User, Set<ValidationRule>> userRulesMap = new HashMap<User, Set<ValidationRule>>();
+
+ for ( ValidationRuleGroup validationRuleGroup : validationRuleService.getAllValidationRuleGroups() )
+ {
+ Collection<UserAuthorityGroup> userRolesToAlert = validationRuleGroup.getUserAuthorityGroupsToAlert();
+
+ if ( userRolesToAlert != null && !userRolesToAlert.isEmpty() )
+ {
+ for ( UserAuthorityGroup role : userRolesToAlert )
+ {
+ for ( UserCredentials userCredentials : role.getMembers() )
+ {
+ User user = userCredentials.getUser();
+ Set<ValidationRule> userRules = userRulesMap.get( user );
+ if ( userRules == null )
+ {
+ userRules = new HashSet<ValidationRule>();
+ userRulesMap.put( user, userRules );
+ }
+ userRules.addAll( validationRuleGroup.getMembers() );
+ }
+ }
+ }
+ }
+
+ return userRulesMap;
}
-
+
/**
* Generate and send an alert message containing a list of validation
* results to a set of users.
@@ -375,9 +381,9 @@
Map<String, Integer> importanceCountMap = countTheResultsByImportanceType( results );
String subject = "DHIS alerts as of " + dateTimeFormatter.format( alertRunStart ) + " - priority High "
- + (importanceCountMap.get( "high" ) == null ? 0 : importanceCountMap.get( "high" )) + ", Medium "
- + (importanceCountMap.get( "medium" ) == null ? 0 : importanceCountMap.get( "medium" )) + ", Low "
- + (importanceCountMap.get( "low" ) == null ? 0 : importanceCountMap.get( "low" ));
+ + ( importanceCountMap.get( "high" ) == null ? 0 : importanceCountMap.get( "high" ) ) + ", Medium "
+ + ( importanceCountMap.get( "medium" ) == null ? 0 : importanceCountMap.get( "medium" ) ) + ", Low "
+ + ( importanceCountMap.get( "low" ) == null ? 0 : importanceCountMap.get( "low" ) );
messageBuilder
.append( "<html>" )
@@ -413,9 +419,9 @@
}
messageBuilder
- .append( "</table>" )
- .append( "</body>" )
- .append( "</html>" );
+ .append( "</table>" )
+ .append( "</body>" )
+ .append( "</html>" );
String messageText = messageBuilder.toString();