Search in sources :

Example 11 with ValidationIssue

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());
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Example 12 with ValidationIssue

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());
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Example 13 with ValidationIssue

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());
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Example 14 with ValidationIssue

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)));
            });
        });
    }
}
Also used : EffectiveTimes(com.b2international.snowowl.core.date.EffectiveTimes) RelationshipValueType(com.b2international.snowowl.snomed.core.domain.RelationshipValueType) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) java.util(java.util) Query(com.b2international.index.query.Query) Hits(com.b2international.index.Hits) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) QueryBuilder(com.b2international.index.query.Query.QueryBuilder) SET_MEMBER(com.b2international.snowowl.core.terminology.ComponentCategory.SET_MEMBER) ValidationIssueDetailExtension(com.b2international.snowowl.core.validation.issue.ValidationIssueDetailExtension) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) Strings(com.google.common.base.Strings) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) SnomedDescriptionUtils(com.b2international.snowowl.snomed.datastore.SnomedDescriptionUtils) SnomedRequests(com.b2international.snowowl.snomed.datastore.request.SnomedRequests) Options(com.b2international.commons.options.Options) RevisionSearcher(com.b2international.index.revision.RevisionSearcher) ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) SnomedDescriptions(com.b2international.snowowl.snomed.core.domain.SnomedDescriptions) com.b2international.snowowl.snomed.datastore.index.entry(com.b2international.snowowl.snomed.datastore.index.entry) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) com.google.common.collect(com.google.common.collect) CONCEPT(com.b2international.snowowl.core.terminology.ComponentCategory.CONCEPT) SnomedTerminologyComponentConstants(com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants) Collectors(java.util.stream.Collectors) SnomedIssueDetailFilterFields(com.b2international.snowowl.snomed.validation.detail.SnomedValidationIssueDetailExtension.SnomedIssueDetailFilterFields) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) DESCRIPTION(com.b2international.snowowl.core.terminology.ComponentCategory.DESCRIPTION) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) Expressions(com.b2international.index.query.Expressions) DecimalUtils(com.b2international.index.util.DecimalUtils) SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) ValidationConfiguration(com.b2international.snowowl.core.internal.validation.ValidationConfiguration) RELATIONSHIP(com.b2international.snowowl.core.terminology.ComponentCategory.RELATIONSHIP) Expression(com.b2international.index.query.Expression) Component(com.b2international.snowowl.core.plugin.Component) Builder(com.google.common.collect.ImmutableMultimap.Builder) BranchContext(com.b2international.snowowl.core.domain.BranchContext) ComponentCategory(com.b2international.snowowl.core.terminology.ComponentCategory) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) RevisionSearcher(com.b2international.index.revision.RevisionSearcher)

Aggregations

ValidationIssue (com.b2international.snowowl.core.validation.issue.ValidationIssue)14 ValidationIssues (com.b2international.snowowl.core.validation.issue.ValidationIssues)9 Test (org.junit.Test)9 BaseRevisionIndexTest (com.b2international.index.revision.BaseRevisionIndexTest)4 Collectors (java.util.stream.Collectors)4 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)3 BranchContext (com.b2international.snowowl.core.domain.BranchContext)3 ValidationConfiguration (com.b2international.snowowl.core.internal.validation.ValidationConfiguration)3 ComponentCategory (com.b2international.snowowl.core.terminology.ComponentCategory)3 ValidationIssueDetailExtension (com.b2international.snowowl.core.validation.issue.ValidationIssueDetailExtension)3 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)2 Options (com.b2international.commons.options.Options)2 Hits (com.b2international.index.Hits)2 Expression (com.b2international.index.query.Expression)2 Expressions (com.b2international.index.query.Expressions)2 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)2 Query (com.b2international.index.query.Query)2 QueryBuilder (com.b2international.index.query.Query.QueryBuilder)2 DecimalUtils (com.b2international.index.util.DecimalUtils)2 ResourceURI (com.b2international.snowowl.core.ResourceURI)2