=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationResult.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationResult.java 2013-10-11 12:58:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationResult.java 2013-10-13 09:59:35 +0000 @@ -186,34 +186,67 @@ int result; result = source.getName().compareTo( other.source.getName() ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } result = period.getStartDate().compareTo( other.period.getStartDate() ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } result = period.getEndDate().compareTo( other.period.getEndDate() ); - if ( result != 0 ) return result; - - result = validationImportanceOrder( validationRule.getImportance() ) - - validationImportanceOrder( other.validationRule.getImportance() ); - if ( result != 0 ) return result; - - result = validationRule.getLeftSide().getDescription() - .compareTo( other.validationRule.getLeftSide().getDescription() ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } + + result = validationImportanceOrder( validationRule.getImportance() ) - validationImportanceOrder( other.validationRule.getImportance() ); + + if ( result != 0 ) + { + return result; + } + + result = validationRule.getLeftSide().getDescription().compareTo( other.validationRule.getLeftSide().getDescription() ); + + if ( result != 0 ) + { + return result; + } result = validationRule.getOperator().compareTo( other.validationRule.getOperator() ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } - result = validationRule.getRightSide().getDescription() - .compareTo( other.validationRule.getRightSide().getDescription() ); - if ( result != 0 ) return result; + result = validationRule.getRightSide().getDescription().compareTo( other.validationRule.getRightSide().getDescription() ); + + if ( result != 0 ) + { + return result; + } result = ( int ) Math.signum( Math.round( 100.0 * leftsideValue ) - Math.round( 100.0 * other.leftsideValue ) ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } result = ( int ) Math.signum( Math.round( 100.0 * rightsideValue ) - Math.round( 100.0 * other.rightsideValue ) ); - if ( result != 0 ) return result; + + if ( result != 0 ) + { + return result; + } return 0; } === 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-11 12:58:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2013-10-13 09:59:35 +0000 @@ -184,8 +184,7 @@ public Collection validate( Date startDate, Date endDate, Collection sources, ValidationRuleGroup group ) { - log.info( "Validate startDate=" + startDate + " endDate=" + endDate + " sources[" + sources.size() - + "] group=" + group.getName() ); + log.info( "Validate startDate=" + startDate + " endDate=" + endDate + " sources[" + sources.size() + "] group=" + group.getName() ); Collection periods = periodService.getPeriodsBetweenDates( startDate, endDate ); Collection rules = group.getMembers(); return validateInternal( sources, periods, rules, ValidationRunType.INTERACTIVE, null ); @@ -322,6 +321,7 @@ } executor.shutdown(); + try { executor.awaitTermination( 23, TimeUnit.HOURS ); @@ -376,8 +376,7 @@ * assigned to them. * * @param dataElements the data elements to look for - * @return all validation rules which have the data elements assigned to - * them + * @return all validation rules which have the data elements assigned. */ private Collection getValidationTypeRulesForDataElements( Set dataElements ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java 2013-10-11 12:58:30 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRunContext.java 2013-10-13 09:59:35 +0000 @@ -145,7 +145,7 @@ private void initialize( Collection sources, Collection periods, Collection rules ) { - boolean monitoringRulesPresent = false; + boolean monitoringRulesPresent = false; // Group the periods by period type. for ( Period period : periods ) @@ -156,21 +156,21 @@ for ( ValidationRule rule : rules ) { - if ( ValidationRule.RULE_TYPE_MONITORING.equals( rule.getRuleType() ) ) - { - if ( rule.getOrganisationUnitLevel() == null ) - { - log.error( "monitoring-type validationRule '" + ( rule.getName() == null ? "" : rule.getName() ) - + "' has no organisationUnitLevel." ); - continue; // Ignore rule, avoid null reference later. - } - monitoringRulesPresent = true; - } + if ( ValidationRule.RULE_TYPE_MONITORING.equals( rule.getRuleType() ) ) + { + if ( rule.getOrganisationUnitLevel() == null ) + { + log.error( "monitoring-type validationRule '" + (rule.getName() == null ? "" : rule.getName()) + + "' has no organisationUnitLevel." ); + continue; // Ignore rule, avoid null reference later. + } + + monitoringRulesPresent = true; + } // Find the period type extended for this rule PeriodTypeExtended periodTypeX = getOrCreatePeriodTypeExtended( rule.getPeriodType() ); - periodTypeX.getRules().add( rule ); // Add this rule to the period - // type ext. + periodTypeX.getRules().add( rule ); // Add to the period type ext. if ( rule.getCurrentDataElements() != null ) { @@ -205,54 +205,53 @@ // This is so we can recurse if needed to find monitoring rule values. if ( monitoringRulesPresent ) { - for ( OrganisationUnit source : new HashSet( sources ) ) - { - addSourceRecursive ( sources, source ); - } + for ( OrganisationUnit source : new HashSet( sources ) ) + { + addSourceRecursive( sources, source ); + } } - + // Get the information we need for each source. for ( OrganisationUnit source : sources ) { OrganisationUnitExtended sourceX = new OrganisationUnitExtended( source ); sourceXs.add( sourceX ); - Map> sourceElementsMap = source - .getDataElementsInDataSetsByPeriodType(); + Map> sourceElementsMap = source.getDataElementsInDataSetsByPeriodType(); for ( PeriodTypeExtended periodTypeX : periodTypeExtendedMap.values() ) { - periodTypeX.getSourceDataElements().put( source, new HashSet() ); - for ( PeriodType allowedType : periodTypeX.getAllowedPeriodTypes() ) - { - Collection sourceDataElements = sourceElementsMap.get( allowedType ); - if ( sourceDataElements != null ) - { - periodTypeX.getSourceDataElements().get( source ).addAll( sourceDataElements ); - } - } + periodTypeX.getSourceDataElements().put( source, new HashSet() ); + for ( PeriodType allowedType : periodTypeX.getAllowedPeriodTypes() ) + { + Collection sourceDataElements = sourceElementsMap.get( allowedType ); + if ( sourceDataElements != null ) + { + periodTypeX.getSourceDataElements().get( source ).addAll( sourceDataElements ); + } + } } } } /** - * If the children of this organisation unit are not in the collection, - * then add them and all their descendants if needed. + * If the children of this organisation unit are not in the collection, then + * add them and all their descendants if needed. * * @param sources organisation units to test and add to * @param source organisation unit whose children to check */ private void addSourceRecursive( Collection sources, OrganisationUnit source ) { - for ( OrganisationUnit child : source.getChildren() ) - { - if ( !sources.contains( child ) ) - { - sources.add( child ); - addSourceRecursive( sources, child ); - } - } + for ( OrganisationUnit child : source.getChildren() ) + { + if ( !sources.contains( child ) ) + { + sources.add( child ); + addSourceRecursive( sources, child ); + } + } } - + /** * Gets the PeriodTypeExtended from the context object. If not found, * creates a new PeriodTypeExtended object, puts it into the context object,