Search in sources :

Example 1 with DroolsDescription

use of org.snomed.snowstorm.validation.domain.DroolsDescription in project snowstorm by IHTSDO.

the class DescriptionDroolsValidationServiceTest method findMatchingDescriptionInHierarchy.

@Test
void findMatchingDescriptionInHierarchy() {
    Concept concept = new Concept("1760555000");
    concept.addAxiom(new Relationship(ISA, bodyStructureDescendant1.getId()));
    Description description = new Description("5582049016", null, true, "900000000000207008", "1760555000", "en", "900000000000013009", "Entire heart", "900000000000448009");
    org.ihtsdo.drools.domain.Concept droolConcept = new DroolsConcept(concept);
    org.ihtsdo.drools.domain.Description droolDescription = new DroolsDescription(description);
    Set<org.ihtsdo.drools.domain.Description> descriptions = validationService.findMatchingDescriptionInHierarchy(droolConcept, droolDescription);
    assertEquals(1, descriptions.size());
}
Also used : DroolsConcept(org.snomed.snowstorm.validation.domain.DroolsConcept) Concept(org.snomed.snowstorm.core.data.domain.Concept) Description(org.snomed.snowstorm.core.data.domain.Description) DroolsDescription(org.snomed.snowstorm.validation.domain.DroolsDescription) DroolsDescription(org.snomed.snowstorm.validation.domain.DroolsDescription) Relationship(org.snomed.snowstorm.core.data.domain.Relationship) DroolsConcept(org.snomed.snowstorm.validation.domain.DroolsConcept) AbstractTest(org.snomed.snowstorm.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 2 with DroolsDescription

use of org.snomed.snowstorm.validation.domain.DroolsDescription in project snowstorm by IHTSDO.

the class ConceptValidationHelper method replaceTemporaryUUIDWithSCTID.

public static List<InvalidContent> replaceTemporaryUUIDWithSCTID(final List<InvalidContent> invalidContentWarnings, final Concept concept) {
    replaceInvalidContentTemporaryUUIDWithSCTIDInConcept(invalidContentWarnings, concept);
    replaceInvalidContentTemporaryUUIDWithSCTIDIn(invalidContentWarnings, concept.getDescriptions(), (final InvalidContent invalidContentWarning, final Description description) -> {
        final Component component = invalidContentWarning.getComponent();
        if (component instanceof DroolsDescription) {
            final DroolsDescription droolsDescription = (DroolsDescription) component;
            if (description != null && description.getReleaseHash() != null && description.getReleaseHash().equals(droolsDescription.getReleaseHash())) {
                invalidContentWarning.setComponent(new DroolsDescription(description));
            }
        }
    });
    replaceInvalidContentTemporaryUUIDWithSCTIDIn(invalidContentWarnings, concept.getRelationships(), (final InvalidContent invalidContentWarning, final Relationship relationship) -> {
        final Component component = invalidContentWarning.getComponent();
        if (component instanceof DroolsRelationship) {
            final DroolsRelationship droolsRelationship = (DroolsRelationship) component;
            if (relationship != null && relationship.getReleaseHash() != null && relationship.getReleaseHash().equals(droolsRelationship.getReleaseHash())) {
                invalidContentWarning.setComponent(new DroolsRelationship(null, false, relationship));
            }
        }
    });
    replaceInvalidContentTemporaryUUIDWithSCTIDInAxiom(invalidContentWarnings, concept.getClassAxioms(), false);
    replaceInvalidContentTemporaryUUIDWithSCTIDInAxiom(invalidContentWarnings, concept.getGciAxioms(), true);
    return invalidContentWarnings;
}
Also used : DroolsDescription(org.snomed.snowstorm.validation.domain.DroolsDescription) DroolsDescription(org.snomed.snowstorm.validation.domain.DroolsDescription) InvalidContent(org.ihtsdo.drools.response.InvalidContent) DroolsRelationship(org.snomed.snowstorm.validation.domain.DroolsRelationship) Component(org.ihtsdo.drools.domain.Component) DroolsRelationship(org.snomed.snowstorm.validation.domain.DroolsRelationship)

Example 3 with DroolsDescription

use of org.snomed.snowstorm.validation.domain.DroolsDescription in project snowstorm by IHTSDO.

the class DescriptionDroolsValidationService method findDescriptionByExactTerm.

private Set<org.ihtsdo.drools.domain.Description> findDescriptionByExactTerm(String exactTerm, boolean active) {
    NativeSearchQuery query = new NativeSearchQueryBuilder().withQuery(boolQuery().must(branchCriteria.getEntityBranchCriteria(Description.class)).must(termQuery("active", active)).must(termQuery("term", exactTerm))).build();
    List<Description> matches = elasticsearchTemplate.search(query, Description.class).get().map(SearchHit::getContent).collect(Collectors.toList());
    return matches.stream().filter(description -> description.getTerm().equals(exactTerm)).map(DroolsDescription::new).collect(Collectors.toSet());
}
Also used : DroolsDescription(org.snomed.snowstorm.validation.domain.DroolsDescription) Description(org.snomed.snowstorm.core.data.domain.Description) NativeSearchQueryBuilder(org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder) NativeSearchQuery(org.springframework.data.elasticsearch.core.query.NativeSearchQuery)

Aggregations

DroolsDescription (org.snomed.snowstorm.validation.domain.DroolsDescription)3 Description (org.snomed.snowstorm.core.data.domain.Description)2 Component (org.ihtsdo.drools.domain.Component)1 InvalidContent (org.ihtsdo.drools.response.InvalidContent)1 Test (org.junit.jupiter.api.Test)1 AbstractTest (org.snomed.snowstorm.AbstractTest)1 Concept (org.snomed.snowstorm.core.data.domain.Concept)1 Relationship (org.snomed.snowstorm.core.data.domain.Relationship)1 DroolsConcept (org.snomed.snowstorm.validation.domain.DroolsConcept)1 DroolsRelationship (org.snomed.snowstorm.validation.domain.DroolsRelationship)1 NativeSearchQuery (org.springframework.data.elasticsearch.core.query.NativeSearchQuery)1 NativeSearchQueryBuilder (org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder)1