51
51
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
52
52
import org.hisp.dhis.constant.ConstantService;
53
53
import org.hisp.dhis.dataelement.DataElement;
54
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
55
import org.hisp.dhis.dataelement.DataElementCategoryService;
54
56
import org.hisp.dhis.dataelement.DataElementOperand;
55
57
import org.hisp.dhis.dataentryform.DataEntryFormService;
56
58
import org.hisp.dhis.dataset.DataSet;
129
131
this.dataValueService = dataValueService;
134
private DataElementCategoryService dataElementCategoryService;
136
public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
138
this.dataElementCategoryService = dataElementCategoryService;
132
141
private ConstantService constantService;
134
143
public void setConstantService( ConstantService constantService )
169
178
// -------------------------------------------------------------------------
172
public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources, boolean sendAlerts, I18nFormat format )
174
return validate( startDate, endDate, sources, null, sendAlerts, format );
178
181
public Collection<ValidationResult> validate( Date startDate, Date endDate, Collection<OrganisationUnit> sources,
179
ValidationRuleGroup group, boolean sendAlerts, I18nFormat format )
182
DataElementCategoryOptionCombo attributeCombo, ValidationRuleGroup group, boolean sendAlerts, I18nFormat format )
181
184
log.info( "Validate start:" + startDate + " end: " + endDate + " sources: " + sources.size() + " group: " + group );
183
186
Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate );
184
187
Collection<ValidationRule> rules = group != null ? group.getMembers() : getAllValidationRules();
186
Collection<ValidationResult> results = Validator.validate( sources, periods, rules, null,
187
constantService, expressionService, periodService, dataValueService );
189
Collection<ValidationResult> results = Validator.validate( sources, periods, rules, attributeCombo, null,
190
constantService, expressionService, periodService, dataValueService, dataElementCategoryService );
189
192
formatPeriods( results, format );
207
210
Collection<ValidationRule> rules = getAllValidationRules();
208
211
Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
209
212
sources.add( source );
211
return Validator.validate( sources, periods, rules, null,
212
constantService, expressionService, periodService, dataValueService );
214
return Validator.validate( sources, periods, rules, null, null,
215
constantService, expressionService, periodService, dataValueService, dataElementCategoryService );
216
public Collection<ValidationResult> validate( DataSet dataSet, Period period, OrganisationUnit source )
219
public Collection<ValidationResult> validate( DataSet dataSet, Period period, OrganisationUnit source,
220
DataElementCategoryOptionCombo attributeCombo )
218
222
log.info( "Validate data set: " + dataSet.getName() + " period: " + period.getPeriodType().getName() + " "
219
+ period.getStartDate() + " " + period.getEndDate() + " source: " + source.getName() );
223
+ period.getStartDate() + " " + period.getEndDate() + " source: " + source.getName()
224
+ " attribute combo: " + ( attributeCombo == null ? "(null)" : attributeCombo.getName() ) );
221
226
Collection<Period> periods = new ArrayList<Period>();
222
227
periods.add( period );
237
242
Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
238
243
sources.add( source );
240
return Validator.validate( sources, periods, rules, null,
241
constantService, expressionService, periodService, dataValueService );
245
return Validator.validate( sources, periods, rules, attributeCombo, null,
246
constantService, expressionService, periodService, dataValueService, dataElementCategoryService );
263
268
log.info( "Scheduled monitoring run sources: " + sources.size() + ", periods: " + periods.size() + ", rules:" + rules.size()
264
269
+ ", last run: " + ( lastScheduledRun == null ? "[none]" : lastScheduledRun ) );
266
Collection<ValidationResult> results = Validator.validate( sources, periods, rules,
267
lastScheduledRun, constantService, expressionService, periodService, dataValueService );
271
Collection<ValidationResult> results = Validator.validate( sources, periods, rules, null, lastScheduledRun,
272
constantService, expressionService, periodService, dataValueService, dataElementCategoryService );
269
274
log.info( "Validation run result count: " + results.size() );
506
511
ValidationRule rule = result.getValidationRule();
508
builder.append( result.getSource().getName() ).append( " " ).append( result.getPeriod().getName() ).append( LN ).
513
builder.append( result.getSource().getName() ).append( " " ).append( result.getPeriod().getName() ).
514
append( result.getAttributeOptionCombo().isDefault() ? "" : " " + result.getAttributeOptionCombo().getName() ).append( LN ).
509
515
append( rule.getName() ).append( " (" ).append( rule.getImportance() ).append( ") " ).append( LN ).
510
516
append( rule.getLeftSide().getDescription() ).append( ": " ).append( result.getLeftsideValue() ).append( LN ).
511
517
append( rule.getRightSide().getDescription() ).append( ": " ).append( result.getRightsideValue() ).append( LN ).append( LN );