use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class TerminologyTreeTest method getProximalPrimitiveParentsOfDefiningConceptWithPrimitiveAncestor.
@Test
public void getProximalPrimitiveParentsOfDefiningConceptWithPrimitiveAncestor() throws Exception {
final TerminologyTree tree = new TestTree().addNode(N1, true, null, newHashSet(N2)).addNode(N2, false, newHashSet(N1), newHashSet(N3)).addNode(N3, false, newHashSet(N2)).build();
final SnomedConcept n1 = tree.getNode(N1);
assertThat(tree.getProximalPrimitiveParents(N3)).containsOnly(n1);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedMergeApiTest method rebaseMultipleChangesFromParent.
@Test
public void rebaseMultipleChangesFromParent() throws Exception {
final String concept = createNewConcept(branchPath);
final IBranchPath task = BranchPathUtils.createPath(branchPath, "task1");
branching.createBranch(task).statusCode(201);
String newParentDescription1 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
String newChildDescription1 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription1).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription1).statusCode(200);
String newParentDescription2 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
String newChildDescription2 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription2).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription2).statusCode(200);
String newParentDescription3 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
String newChildDescription3 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription3).statusCode(200);
getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription3).statusCode(200);
SnomedConcept finalConcept = getComponent(task, SnomedComponentType.CONCEPT, concept, "descriptions(),preferredDescriptions()").statusCode(200).extract().as(SnomedConcept.class);
// 2 default + 6 newly added
assertThat(finalConcept.getDescriptions()).hasSize(8);
assertThat(finalConcept.getPreferredDescriptions()).hasSize(8);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept 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);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedMergeConflictTest method rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations.
@Test
public void rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations() 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.CONCEPT_MODEL_DATA_ATTRIBUTE);
String relationshipOnChild = createNewRelationship(a, concept, Concepts.IS_A, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
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.CONCEPT_MODEL_DATA_ATTRIBUTE, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT, Concepts.LINKAGE, Concepts.ATTRIBUTE, Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.TOPLEVEL_METADATA);
assertThat(conceptOnChild.getAncestorIdsAsString()).isEmpty();
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedComponentInactivationApiTest method reuseConceptAndDescriptionInactivationIndicators.
@Test
public void reuseConceptAndDescriptionInactivationIndicators() throws Exception {
// create a concept
String conceptId = createNewConcept(branchPath);
SnomedConcept concept = getConcept(conceptId, "descriptions()");
// add pending move to concept and descriptions
Map<?, ?> pendingMoveUpdate = ImmutableMap.of("inactivationProperties", new InactivationProperties(Concepts.PENDING_MOVE, null), "commitComment", "Set to Pending Move");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, pendingMoveUpdate).statusCode(204);
for (SnomedDescription description : concept.getDescriptions()) {
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, description.getId(), pendingMoveUpdate).statusCode(204);
}
// XXX intentionally using the members() expand here to check duplication
SnomedConcept pendingMoveConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
// verify and collect inactivation indicator members
SnomedReferenceSetMember conceptInactivationIndicatorMember = getIndicatorMember(pendingMoveConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
SnomedReferenceSetMember fsnInactivationIndicatorMember = null;
SnomedReferenceSetMember ptInactivationIndicatorMember = null;
for (SnomedDescription description : pendingMoveConcept.getDescriptions()) {
if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
fsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
} else if (Concepts.SYNONYM.equals(description.getTypeId())) {
ptInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
} else {
throw new UnsupportedOperationException();
}
}
Map<?, ?> inactivationConceptRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, null)).put("commitComment", "Inactivated concept").build();
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, inactivationConceptRequest).statusCode(204);
// XXX intentionally using the members() expand here to check duplication/member issues
SnomedConcept inactivatedConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
SnomedReferenceSetMember afterInactivationConceptInactivationIndicatorMember = getIndicatorMember(inactivatedConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
SnomedReferenceSetMember afterInactivationFsnInactivationIndicatorMember = null;
SnomedReferenceSetMember afterInactivationPtInactivationIndicatorMember = null;
for (SnomedDescription description : inactivatedConcept.getDescriptions()) {
if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
afterInactivationFsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
} else if (Concepts.SYNONYM.equals(description.getTypeId())) {
afterInactivationPtInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
} else {
throw new UnsupportedOperationException();
}
}
assertEquals(conceptInactivationIndicatorMember.getId(), afterInactivationConceptInactivationIndicatorMember.getId());
assertEquals(null, afterInactivationConceptInactivationIndicatorMember.getEffectiveTime());
assertEquals(false, afterInactivationConceptInactivationIndicatorMember.isReleased());
assertEquals(Concepts.DUPLICATE, afterInactivationConceptInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
assertEquals(fsnInactivationIndicatorMember.getId(), afterInactivationFsnInactivationIndicatorMember.getId());
assertEquals(null, afterInactivationFsnInactivationIndicatorMember.getEffectiveTime());
assertEquals(false, afterInactivationFsnInactivationIndicatorMember.isReleased());
assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationFsnInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
assertEquals(ptInactivationIndicatorMember.getId(), afterInactivationPtInactivationIndicatorMember.getId());
assertEquals(null, afterInactivationPtInactivationIndicatorMember.getEffectiveTime());
assertEquals(false, afterInactivationPtInactivationIndicatorMember.isReleased());
assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationPtInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
}
Aggregations