use of com.b2international.snowowl.core.validation.issue.ValidationIssue in project snow-owl by b2ihealthcare.
the class SnomedValidationIssueDetailTest method filterByModuleId.
@Test
public void filterByModuleId() {
final Map<String, Object> details = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_MODULE_ID, "1010101010101010");
final ValidationIssue issueWithDetails = createIssue("1122334455", details);
final ValidationIssue issueWithoutDetails = createIssue("5544332211", Collections.emptyMap());
save(issueWithDetails);
save(issueWithoutDetails);
ValidationIssues issues = ValidationRequests.issues().prepareSearch().all().filterByDetails(details).buildAsync().getRequest().execute(context);
assertComponents(issues, issueWithDetails.getAffectedComponent());
}
use of com.b2international.snowowl.core.validation.issue.ValidationIssue in project snow-owl by b2ihealthcare.
the class SnomedValidationIssueDetailTest method filterByModuleIds.
@Test
public void filterByModuleIds() {
final Map<String, Object> details = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_MODULE_ID, newArrayList("1111"));
final Map<String, Object> details2 = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_MODULE_ID, "2222");
final ValidationIssue issueWithModuleId = createIssue("111111111", details);
final ValidationIssue issueWithModuleId2 = createIssue("222222222", details2);
final ValidationIssue issueWithoutModuleId = createIssue("333333333", Collections.emptyMap());
save(issueWithModuleId);
save(issueWithModuleId2);
save(issueWithoutModuleId);
final Map<String, Object> detailsToSearch = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_MODULE_ID, newArrayList("1111", "2222"));
ValidationIssues issues = ValidationRequests.issues().prepareSearch().all().filterByDetails(detailsToSearch).buildAsync().getRequest().execute(context);
assertComponents(issues, issueWithModuleId.getAffectedComponent(), issueWithModuleId2.getAffectedComponent());
}
use of com.b2international.snowowl.core.validation.issue.ValidationIssue in project snow-owl by b2ihealthcare.
the class SnomedValidationIssueDetailTest method filterByAffectedComponentStatus.
@Test
public void filterByAffectedComponentStatus() {
final Map<String, Object> details = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_STATUS, true);
final Map<String, Object> details2 = ImmutableMap.of(SnomedIssueDetailFilterFields.COMPONENT_STATUS, false);
final ValidationIssue issueWithActiveComponent = createIssue("444444444", details);
final ValidationIssue issueWithInactiveComponent = createIssue("555555555", details2);
save(issueWithActiveComponent);
save(issueWithInactiveComponent);
ValidationIssues issues = ValidationRequests.issues().prepareSearch().all().filterByDetails(details).buildAsync().getRequest().execute(context);
assertComponents(issues, issueWithActiveComponent.getAffectedComponent());
}
use of com.b2international.snowowl.core.validation.issue.ValidationIssue in project snow-owl by b2ihealthcare.
the class SnomedValidationIssueDetailExtension method extendConceptIssueLabels.
private void extendConceptIssueLabels(BranchContext context, Collection<ValidationIssue> issues, Map<String, Object> ruleParameters) {
final RevisionSearcher searcher = context.service(RevisionSearcher.class);
final List<ValidationIssue> conceptIssues = issues.stream().filter(issue -> SnomedConcept.TYPE == issue.getAffectedComponent().getComponentType()).collect(Collectors.toList());
final Map<String, ValidationIssue> memberIssues = issues.stream().filter(issue -> SnomedReferenceSetMember.TYPE == issue.getAffectedComponent().getComponentType()).collect(Collectors.toMap(issue -> issue.getAffectedComponent().getComponentId(), issue -> issue, (issue1, issue2) -> issue1));
if (conceptIssues.isEmpty() && memberIssues.isEmpty()) {
return;
}
final Builder<String, ValidationIssue> issuesByConceptId = ImmutableMultimap.builder();
conceptIssues.forEach(issue -> issuesByConceptId.put(issue.getAffectedComponent().getComponentId(), issue));
searcher.stream(Query.select(String[].class).from(SnomedRefSetMemberIndexEntry.class).fields(SnomedRefSetMemberIndexEntry.Fields.ID, SnomedRefSetMemberIndexEntry.Fields.REFERENCED_COMPONENT_ID).where(Expressions.builder().filter(SnomedRefSetMemberIndexEntry.Expressions.active()).filter(SnomedRefSetMemberIndexEntry.Expressions.ids(memberIssues.keySet())).build()).limit(SCROLL_SIZE).build()).forEach(hits -> {
for (String[] hit : hits) {
final String memberId = hit[0];
final String containerConcpetId = hit[1];
issuesByConceptId.put(containerConcpetId, memberIssues.get(memberId));
}
});
final Multimap<String, ValidationIssue> issuesByConceptMap = issuesByConceptId.build();
final Map<String, String> affectedComponentLabelsByConcept = getAffectedComponentLabels(context, ruleParameters, issuesByConceptMap.keySet());
if (!affectedComponentLabelsByConcept.isEmpty()) {
issuesByConceptMap.keySet().forEach(conceptId -> {
issuesByConceptMap.get(conceptId).forEach(issue -> {
issue.setAffectedComponentLabels(ImmutableList.of(affectedComponentLabelsByConcept.get(conceptId)));
});
});
}
}
Aggregations