Search in sources :

Example 1 with SnomedReferenceSetMember

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

the class SnomedRefSetMemberApiTest method createAndUpdateNewModuleDependencyMembers.

@Test
public void createAndUpdateNewModuleDependencyMembers() {
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_MODULE_DEPENDENCY_TYPE, Concepts.MODULE_SCT_MODEL_COMPONENT).with("commitComment", "Created new module dependency reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMember member = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
    Json updateRequest = Json.object(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME, "20181002", SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME, "20181002", "commitComment", "Updated reference set member");
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    SnomedReferenceSetMember updatedMember = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Json(com.b2international.commons.json.Json) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 2 with SnomedReferenceSetMember

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

the class SnomedRefSetMemberApiTest method searchOWLAxiomRefsetMemberBySourceTypeDestination.

@Test
public void searchOWLAxiomRefsetMemberBySourceTypeDestination() {
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, "SubClassOf(:" + conceptId + " :" + Concepts.NAMESPACE_ROOT + ")").with("commitComment", "Created new OWL Axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMembers results = givenAuthenticatedRequest(SnomedApiTestConstants.SCT_API).queryParam("referencedComponentId", conceptId).queryParam("owlExpression.typeId", Concepts.IS_A).queryParam("owlExpression.destinationId", Concepts.NAMESPACE_ROOT).get("/{path}/members", branchPath.getPath()).then().extract().as(SnomedReferenceSetMembers.class);
    assertEquals(1, results.getItems().size());
    SnomedReferenceSetMember member = results.getItems().stream().findFirst().get();
    assertEquals(memberId, member.getId());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 3 with SnomedReferenceSetMember

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

the class SnomedRefSetMemberApiTest method createAndUpdateUnpublishedModuleDependencyMembers.

@Test
public void createAndUpdateUnpublishedModuleDependencyMembers() {
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_MODULE_DEPENDENCY_TYPE, Concepts.MODULE_SCT_MODEL_COMPONENT).with(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME, "").with(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME, "").with("commitComment", "Created new module dependency reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMember member = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
    Json updateRequest = Json.object(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME, "20181002", SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME, "20181002", "commitComment", "Updated reference set member");
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    SnomedReferenceSetMember updatedMember = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Json(com.b2international.commons.json.Json) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 4 with SnomedReferenceSetMember

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

the class SnomedConceptApiTest method testUpdateConceptDefinitionStatusWithSubClassOfAxiomMemberShouldChangeToPrimitive.

@Test
public void testUpdateConceptDefinitionStatusWithSubClassOfAxiomMemberShouldChangeToPrimitive() {
    final String conceptId = createNewConcept(branchPath);
    // Update the definition status on concept
    final Map<?, ?> definitionStatusUpdateRequestBody = Json.object("definitionStatusId", Concepts.FULLY_DEFINED, "commitComment", "Changed definition status of concept to fully defined");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, definitionStatusUpdateRequestBody).statusCode(204);
    // Add a reference set member
    final SnomedReferenceSetMember newMember = new SnomedReferenceSetMember();
    newMember.setId(UUID.randomUUID().toString());
    newMember.setActive(true);
    newMember.setRefsetId(Concepts.REFSET_OWL_AXIOM);
    newMember.setProperties(Json.object(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", conceptId, Concepts.AMBIGUOUS)));
    newMember.setType(SnomedRefSetType.OWL_AXIOM);
    newMember.setModuleId(Concepts.MODULE_SCT_CORE);
    final Json updateRequestBody = Json.object("members", SnomedReferenceSetMembers.of(Json.array(newMember)), "commitComment", "Add new reference set member via concept update");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateRequestBody).statusCode(204);
    final SnomedConcept updatedConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
    assertEquals(1, updatedConcept.getMembers().getTotal());
    // Verify that definition status was updated to FULLY DEFINED
    assertEquals(Concepts.PRIMITIVE, updatedConcept.getDefinitionStatusId());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Json(com.b2international.commons.json.Json) Test(org.junit.Test)

Example 5 with SnomedReferenceSetMember

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

the class SnomedConceptApiTest method testUpdateConceptDefinitionStatusWithEquivalentClassesAxiomMember.

@Test
public void testUpdateConceptDefinitionStatusWithEquivalentClassesAxiomMember() {
    final String conceptId = createNewConcept(branchPath);
    // Add a reference set member
    final SnomedReferenceSetMember newMember = new SnomedReferenceSetMember();
    newMember.setId(UUID.randomUUID().toString());
    newMember.setActive(true);
    newMember.setRefsetId(Concepts.REFSET_OWL_AXIOM);
    newMember.setProperties(Json.object(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("EquivalentClasses(:%s ObjectIntersectionOf(:%s :%s))", conceptId, Concepts.AMBIGUOUS, Concepts.NAMESPACE_ROOT)));
    newMember.setType(SnomedRefSetType.OWL_AXIOM);
    newMember.setModuleId(Concepts.MODULE_SCT_CORE);
    final Map<?, ?> updateRequestBody = Json.object("members", SnomedReferenceSetMembers.of(Json.array(newMember)), "commitComment", "Add new reference set member via concept update");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateRequestBody).statusCode(204);
    final SnomedConcept updatedConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
    assertEquals(1, updatedConcept.getMembers().getTotal());
    // Verify that definition status was updated to FULLY DEFINED
    assertEquals(Concepts.FULLY_DEFINED, updatedConcept.getDefinitionStatusId());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Test(org.junit.Test)

Aggregations

SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)41 Test (org.junit.Test)17 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)13 Json (com.b2international.commons.json.Json)12 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)11 SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)11 Options (com.b2international.commons.options.Options)8 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)8 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)8 List (java.util.List)8 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)7 Map (java.util.Map)7 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)6 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)5 BranchContext (com.b2international.snowowl.core.domain.BranchContext)5 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)5 ComponentCategory (com.b2international.snowowl.core.terminology.ComponentCategory)5 Collectors (java.util.stream.Collectors)5 BranchPathUtils (com.b2international.snowowl.core.branch.BranchPathUtils)4 EffectiveTimes (com.b2international.snowowl.core.date.EffectiveTimes)4