Search in sources :

Example 81 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.

the class SnomedMergeConflictTest method rebaseResolvableAxiomMemberConflict.

@Test
public void rebaseResolvableAxiomMemberConflict() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String axiomOnParent = createNewRefSetMember(branchPath, concept, Concepts.REFSET_OWL_AXIOM, Map.of(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", concept, Concepts.TOPLEVEL_METADATA)));
    String axiomOnChild = createNewRefSetMember(a, concept, Concepts.REFSET_OWL_AXIOM, Map.of(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", concept, Concepts.TOPLEVEL_METADATA)));
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.MEMBER, axiomOnChild).statusCode(200);
    getComponent(a, SnomedComponentType.MEMBER, axiomOnParent).statusCode(200);
    SnomedConcept conceptOnChild = getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptOnChild.getStatedParentIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, Concepts.TOPLEVEL_METADATA);
    assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
    assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT);
    assertThat(conceptOnChild.getAncestorIdsAsString()).isEmpty();
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 82 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.

the class SnomedMergeConflictTest method rebaseResolvableIsaRelationshipConflictSameDestination.

@Test
public void rebaseResolvableIsaRelationshipConflictSameDestination() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String relationshipOnParent = createNewRelationship(branchPath, concept, Concepts.IS_A, Concepts.TOPLEVEL_METADATA);
    String relationshipOnChild = createNewRelationship(a, concept, Concepts.IS_A, Concepts.TOPLEVEL_METADATA);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnChild).statusCode(200);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnParent).statusCode(200);
    SnomedConcept conceptOnChild = getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptOnChild.getStatedParentIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, Concepts.TOPLEVEL_METADATA);
    assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
    assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT);
    assertThat(conceptOnChild.getAncestorIdsAsString()).isEmpty();
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 83 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method mergeNewConceptForwardWithChildBranchDelete.

@Test
public void mergeNewConceptForwardWithChildBranchDelete() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String conceptId = createNewConcept(a);
    merge(a, branchPath, "Merged new concept from child branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    branching.deleteBranch(a).statusCode(204);
    // getComponent(a, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    SnomedConcept concept = getConcept(conceptId, "descriptions(),relationships()");
    assertFalse(concept.getDescriptions().isEmpty());
    assertFalse(concept.getRelationships().isEmpty());
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 84 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.

the class SnomedRelationshipConverter method expandType.

private void expandType(List<SnomedRelationship> results) {
    if (expand().containsKey(SnomedRelationship.Expand.TYPE)) {
        final Options typeOptions = expand().get(SnomedRelationship.Expand.TYPE, Options.class);
        final Iterable<String> typeConceptIds = FluentIterable.from(results).transform(SnomedRelationship::getTypeId);
        context().service(SnomedConceptRequestCache.class).request(typeConceptIds, typeOptions.getOptions("expand"), locales(), typeConceptsById -> {
            for (SnomedRelationship relationship : results) {
                final String typeId = relationship.getTypeId();
                if (typeConceptsById.containsKey(typeId)) {
                    final SnomedConcept typeConcept = typeConceptsById.get(typeId);
                    ((SnomedRelationship) relationship).setType(typeConcept);
                }
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 85 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.

the class SnomedRelationshipConverter method expandSource.

private void expandSource(List<SnomedRelationship> results) {
    if (expand().containsKey(SnomedRelationship.Expand.SOURCE)) {
        final Options sourceOptions = expand().get(SnomedRelationship.Expand.SOURCE, Options.class);
        final Iterable<String> sourceConceptIds = FluentIterable.from(results).transform(SnomedRelationship::getSourceId);
        context().service(SnomedConceptRequestCache.class).request(sourceConceptIds, sourceOptions.getOptions("expand"), locales(), sourceConceptsById -> {
            for (SnomedRelationship relationship : results) {
                final String sourceId = relationship.getSourceId();
                if (sourceConceptsById.containsKey(sourceId)) {
                    final SnomedConcept sourceConcept = sourceConceptsById.get(sourceId);
                    ((SnomedRelationship) relationship).setSource(sourceConcept);
                }
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Aggregations

SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)90 Test (org.junit.Test)42 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)17 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)15 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)15 LocalDate (java.time.LocalDate)15 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)12 SnomedConcepts (com.b2international.snowowl.snomed.core.domain.SnomedConcepts)12 Options (com.b2international.commons.options.Options)10 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)10 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)9 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)8 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)8 CodeSystemRestRequests.createCodeSystem (com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem)8 List (java.util.List)8 Map (java.util.Map)8 Collectors (java.util.stream.Collectors)8 Json (com.b2international.commons.json.Json)7 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)7 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)5