35
35
import java.util.concurrent.TimeUnit;
37
37
import org.hisp.dhis.constant.ConstantService;
38
import org.hisp.dhis.dataelement.DataElementCategoryOption;
39
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
40
import org.hisp.dhis.dataelement.DataElementCategoryService;
38
41
import org.hisp.dhis.datavalue.DataValueService;
39
42
import org.hisp.dhis.expression.ExpressionService;
40
43
import org.hisp.dhis.organisationunit.OrganisationUnit;
58
61
* @param sources the organisation units in which to run the validation rules
59
62
* @param periods the periods of data to check
63
* @param attributeCombo the attribute combo to check (if restricted)
60
64
* @param rules the ValidationRules to evaluate
61
* @param runType whether this is an INTERACTIVE or SCHEDULED run
62
65
* @param lastScheduledRun date/time of the most recent successful
63
66
* scheduled monitoring run (needed only for scheduled runs)
64
67
* @param constantService Constant Service reference
65
68
* @param expressionService Expression Service reference
66
69
* @param periodService Period Service reference
67
70
* @param dataValueService Data Value Service reference
71
* @param dataElementCategoryService Data Element Category Service reference
68
72
* @return a collection of any validations that were found
70
public static Collection<ValidationResult> validate( Collection<OrganisationUnit> sources,
71
Collection<Period> periods, Collection<ValidationRule> rules, Date lastScheduledRun,
72
ConstantService constantService, ExpressionService expressionService, PeriodService periodService, DataValueService dataValueService )
74
public static Collection<ValidationResult> validate( Collection<OrganisationUnit> sources, Collection<Period> periods,
75
Collection<ValidationRule> rules, DataElementCategoryOptionCombo attributeCombo, Date lastScheduledRun,
76
ConstantService constantService, ExpressionService expressionService, PeriodService periodService,
77
DataValueService dataValueService, DataElementCategoryService dataElementCategoryService )
74
ValidationRunContext context = ValidationRunContext.getNewValidationRunContext( sources, periods, rules,
75
constantService.getConstantMap(), ValidationRunType.SCHEDULED, lastScheduledRun,
76
expressionService, periodService, dataValueService );
79
ValidationRunContext context = ValidationRunContext.getNewValidationRunContext( sources, periods,
80
attributeCombo, rules, constantService.getConstantMap(), ValidationRunType.SCHEDULED, lastScheduledRun,
81
expressionService, periodService, dataValueService, dataElementCategoryService );
78
83
int threadPoolSize = getThreadPoolSize( context );
79
84
ExecutorService executor = Executors.newFixedThreadPool( threadPoolSize );
124
131
return threadPoolSize;
135
* Reload attribute category option combos into this Hibernate context.
138
* @param dataElementCategoryService
140
private static void reloadAttributeOptionCombos( Collection<ValidationResult> results, DataElementCategoryService dataElementCategoryService )
142
for ( ValidationResult result : results )
144
result.setAttributeOptionCombo( dataElementCategoryService.getDataElementCategoryOptionCombo( result.getAttributeOptionCombo().getId() ) );