use of org.activityinfo.ui.client.component.form.field.hierarchy.Level in project activityinfo by bedatadriven.
the class HierarchyClassImporter method validateInstance.
@Override
public void validateInstance(SourceRow row, List<ValidationResult> results) {
// Start from the leaf level and work our way up to the parent levels
for (Level level : levels) {
InstanceScoreSource scoreSource = scoreSources.get(level.getFormId());
if (scoreSource != null) {
InstanceScorer instanceScorer = new InstanceScorer(scoreSource);
final InstanceScorer.Score score = instanceScorer.score(row);
final int bestMatchIndex = score.getBestMatchIndex();
if (bestMatchIndex != -1) {
for (int i = 0; i < sourceColumns.size(); i++) {
String matched = scoreSource.getReferenceValues().get(bestMatchIndex)[i];
final ValidationResult converted = ValidationResult.converted(matched, score.getBestScores()[i]);
converted.setRef(new RecordRef(level.getFormId(), scoreSource.getReferenceInstanceIds().get(bestMatchIndex)));
results.add(converted);
}
return;
}
}
}
for (int i = 0; i < sourceColumns.size(); i++) {
results.add(ValidationResult.error("No match"));
}
}
Aggregations