Search in sources :

Example 1 with AssociationTarget

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

the class SnomedMergeApiTest method mergeThenRebaseOtherTask.

@Test
public void mergeThenRebaseOtherTask() throws Exception {
    final String conceptA = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    final IBranchPath b = BranchPathUtils.createPath(branchPath, "b");
    branching.createBranch(a).statusCode(201);
    branching.createBranch(b).statusCode(201);
    Map<?, ?> inactivationRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_SAME_AS_ASSOCIATION, Concepts.FULLY_SPECIFIED_NAME)))).put("commitComment", "Inactivated concept").build();
    updateComponent(a, SnomedComponentType.CONCEPT, conceptA, inactivationRequest).statusCode(204);
    final String conceptB = createNewConcept(b);
    merge(a, branchPath, "Merge branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnParent = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnParent.getRelationships()).hasSize(1);
    assertThat(conceptAOnParent.getMembers()).hasSize(2);
    merge(branchPath, b, "Rebase branch B").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnBranchB = getComponent(b, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnBranchB.getRelationships()).hasSize(1);
    assertThat(conceptAOnBranchB.getMembers()).hasSize(2);
    getComponent(b, SnomedComponentType.CONCEPT, conceptB, "relationships()").statusCode(200).extract().as(SnomedConcept.class);
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 2 with AssociationTarget

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

the class SnomedConceptInactivationApiTest method reactivateConceptWithActiveParentAndInboundRelationship.

@Test
public void reactivateConceptWithActiveParentAndInboundRelationship() throws Exception {
    // Create two concepts, one that will be inactivated
    String conceptWithReferenceToInactivatedConcept = createNewConcept(branchPath);
    String conceptToInactivate = createNewConcept(branchPath);
    // and an inbound relationship to the inactivated concept
    String inboundStatedRelationshipId = createNewRelationship(branchPath, conceptWithReferenceToInactivatedConcept, Concepts.PART_OF, conceptToInactivate, Concepts.STATED_RELATIONSHIP);
    // and an outbound inferred relationships, which will be reactivated along with the concept
    String outboundInferredRelationshipId = createNewRelationship(branchPath, conceptToInactivate, Concepts.IS_A, Concepts.ROOT_CONCEPT, Concepts.INFERRED_RELATIONSHIP);
    // Inactivate the concept with the relationship is pointing to
    final InactivationProperties inactivationProperties = new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, conceptWithReferenceToInactivatedConcept)));
    Map<String, Object> inactivationBody = Json.object("active", false, "inactivationProperties", inactivationProperties, "commitComment", "Inactivated concept");
    updateConcept(conceptToInactivate, inactivationBody);
    assertGetConcept(conceptToInactivate, "inactivationProperties()").statusCode(200).body("active", equalTo(false)).body("inactivationProperties.inactivationIndicatorId", equalTo(Concepts.DUPLICATE)).body("inactivationProperties.associationTargets.referenceSetId", hasItem(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION)).body("inactivationProperties.associationTargets.targetComponentId", hasItem(conceptWithReferenceToInactivatedConcept));
    // Verify that the inbound relationship is inactive
    assertGetRelationship(inboundStatedRelationshipId).statusCode(200).body("active", equalTo(false));
    // Reactivate the concept
    reactivateConcept(branchPath, conceptToInactivate);
    // verify that the inferred outbound relationship is active again
    assertGetRelationship(outboundInferredRelationshipId).statusCode(200).body("active", equalTo(true));
    // Verify that the concept is active again, it has two active descriptions, no association targets, no indicator
    assertGetConcept(conceptToInactivate, "inactivationProperties()").statusCode(200).body("active", equalTo(true)).body("parentIds", // verify the the inferred and stated hierarchy is back and valid
    equalTo(List.of(Concepts.ROOT_CONCEPT))).body("statedParentIds", equalTo(List.of(Concepts.ROOT_CONCEPT))).body("ancestorIds", equalTo(List.of(IComponent.ROOT_ID))).body("statedAncestorIds", equalTo(List.of(IComponent.ROOT_ID))).body("inactivationProperties.inactivationIndicator", nullValue()).body("inactivationProperties.associationTargets", equalTo(List.of()));
    // Verify that the inbound relationship is still inactive, meaning that manual reactivation is required
    assertGetRelationship(inboundStatedRelationshipId).statusCode(200).body("active", equalTo(false));
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 3 with AssociationTarget

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

the class SnomedDescriptionApiTest method inactivateWithIndicatorAndAssociationTarget.

@Test
public void inactivateWithIndicatorAndAssociationTarget() {
    String descriptionToInactivate = createNewDescription(branchPath);
    String associationTarget = createNewDescription(branchPath);
    assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, associationTarget))));
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Aggregations

AssociationTarget (com.b2international.snowowl.snomed.core.domain.AssociationTarget)3 InactivationProperties (com.b2international.snowowl.snomed.core.domain.InactivationProperties)3 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)3 Test (org.junit.Test)3 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)1