Search in sources :

Example 6 with InactivationProperties

use of com.b2international.snowowl.snomed.core.domain.InactivationProperties 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 7 with InactivationProperties

use of com.b2international.snowowl.snomed.core.domain.InactivationProperties 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

InactivationProperties (com.b2international.snowowl.snomed.core.domain.InactivationProperties)7 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)7 Test (org.junit.Test)7 AssociationTarget (com.b2international.snowowl.snomed.core.domain.AssociationTarget)4 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)2 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)2 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)2 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)2 ConflictException (com.b2international.commons.exceptions.ConflictException)1 Json (com.b2international.commons.json.Json)1 TextConstants (com.b2international.index.compat.TextConstants)1 RevisionIndex (com.b2international.index.revision.RevisionIndex)1 TimestampProvider (com.b2international.index.revision.TimestampProvider)1 ApplicationContext (com.b2international.snowowl.core.ApplicationContext)1 ApplicationContext.getServiceForClass (com.b2international.snowowl.core.ApplicationContext.getServiceForClass)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 BranchPathUtils (com.b2international.snowowl.core.branch.BranchPathUtils)1 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)1 BulkRequest (com.b2international.snowowl.core.events.bulk.BulkRequest)1 BulkRequestBuilder (com.b2international.snowowl.core.events.bulk.BulkRequestBuilder)1