Search in sources :

Example 6 with SctId

use of com.b2international.snowowl.snomed.cis.domain.SctId in project snow-owl by b2ihealthcare.

the class DefaultSnomedIdentifierService method deprecate.

@Override
public Map<String, SctId> deprecate(final Set<String> componentIds) {
    LOGGER.debug("Deprecating {} component IDs.", componentIds.size());
    final Map<String, SctId> sctIds = getSctIds(componentIds);
    final Map<String, SctId> assignedOrPublishedSctIds = ImmutableMap.copyOf(Maps.filterValues(sctIds, Predicates.or(SctId::isAssigned, SctId::isPublished)));
    for (final SctId sctId : assignedOrPublishedSctIds.values()) {
        sctId.setStatus(IdentifierStatus.DEPRECATED.getSerializedName());
    }
    putSctIds(assignedOrPublishedSctIds.values());
    return ImmutableMap.copyOf(sctIds);
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId)

Example 7 with SctId

use of com.b2international.snowowl.snomed.cis.domain.SctId in project snow-owl by b2ihealthcare.

the class AbstractIdentifierServiceTest method whenDeprecatingAssignedIds_ThenTheyShouldBeDeprecated.

@Test
public void whenDeprecatingAssignedIds_ThenTheyShouldBeDeprecated() {
    try {
        final Set<String> componentIds = getIdentifierService().generate(B2I_NAMESPACE, ComponentCategory.CONCEPT, 2);
        getIdentifierService().deprecate(componentIds);
        final Collection<SctId> sctIds = getIdentifierService().getSctIds(componentIds).values();
        for (final SctId sctId : sctIds) {
            assertTrue("Status must be deprecated", IdentifierStatus.DEPRECATED.getSerializedName().equals(sctId.getStatus()));
        }
    } catch (Exception e) {
        fail(String.format("Unexpected exception was thrown: %s.", e.getMessage()));
    }
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId) Test(org.junit.Test)

Example 8 with SctId

use of com.b2international.snowowl.snomed.cis.domain.SctId in project snow-owl by b2ihealthcare.

the class AbstractIdentifierServiceTest method whenReservingIds_ThenItShouldReturnTheReservedIds.

@Test
public void whenReservingIds_ThenItShouldReturnTheReservedIds() {
    final Set<String> componentIds = Sets.newHashSet();
    try {
        componentIds.addAll(getIdentifierService().reserve(B2I_NAMESPACE, ComponentCategory.CONCEPT, 2));
        assertTrue(String.format("Component IDs size is %d instead of 2.", componentIds.size()), componentIds.size() == 2);
        final Collection<SctId> sctIds = getIdentifierService().getSctIds(componentIds).values();
        for (final SctId sctId : sctIds) {
            assertTrue("Status must be reserved", IdentifierStatus.RESERVED.getSerializedName().equals(sctId.getStatus()));
        }
    } catch (Exception e) {
        fail(String.format("Unexpected exception was thrown: %s.", e.getMessage()));
    } finally {
        if (!componentIds.isEmpty())
            getIdentifierService().release(componentIds);
    }
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId) Test(org.junit.Test)

Example 9 with SctId

use of com.b2international.snowowl.snomed.cis.domain.SctId in project snow-owl by b2ihealthcare.

the class AbstractIdentifierServiceTest method whenGeneratingIds_ThenItShouldReturnTheGeneratedIds.

@Test
public void whenGeneratingIds_ThenItShouldReturnTheGeneratedIds() {
    final Set<String> componentIds = Sets.newHashSet();
    try {
        componentIds.addAll(getIdentifierService().generate(B2I_NAMESPACE, ComponentCategory.CONCEPT, 2));
        assertTrue(String.format("Component IDs size is %d instead of 2.", componentIds.size()), componentIds.size() == 2);
        final Collection<SctId> sctIds = getIdentifierService().getSctIds(componentIds).values();
        for (final SctId sctId : sctIds) {
            assertTrue("Status must be assigned", IdentifierStatus.ASSIGNED.getSerializedName().equals(sctId.getStatus()));
        }
    } catch (Exception e) {
        fail(String.format("Unexpected exception was thrown: %s.", e.getMessage()));
    } finally {
        if (!componentIds.isEmpty())
            getIdentifierService().release(componentIds);
    }
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId) Test(org.junit.Test)

Example 10 with SctId

use of com.b2international.snowowl.snomed.cis.domain.SctId in project snow-owl by b2ihealthcare.

the class SnomedRelationshipApiTest method createRelationshipWithReservedId.

@Test
public void createRelationshipWithReservedId() {
    ISnomedIdentifierService identifierService = getServiceForClass(ISnomedIdentifierService.class);
    String relationshipId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.RELATIONSHIP, 1));
    Json requestBody = createRelationshipRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT).with("id", relationshipId).with("commitComment", "Created new relationship with reserved identifier");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(201).header("Location", endsWith("/" + relationshipId));
    SctId relationshipSctId = SnomedRequests.identifiers().prepareGet().setComponentId(relationshipId).buildAsync().execute(getBus()).getSync().first().get();
    assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), relationshipSctId.getStatus());
}
Also used : ISnomedIdentifierService(com.b2international.snowowl.snomed.cis.ISnomedIdentifierService) Json(com.b2international.commons.json.Json) SctId(com.b2international.snowowl.snomed.cis.domain.SctId) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Aggregations

SctId (com.b2international.snowowl.snomed.cis.domain.SctId)22 Test (org.junit.Test)10 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)7 IOException (java.io.IOException)7 ISnomedIdentifierService (com.b2international.snowowl.snomed.cis.ISnomedIdentifierService)4 Collection (java.util.Collection)4 HttpPost (org.apache.http.client.methods.HttpPost)4 Json (com.b2international.commons.json.Json)3 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)3 HttpGet (org.apache.http.client.methods.HttpGet)3 HttpPut (org.apache.http.client.methods.HttpPut)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ImmutableMap (com.google.common.collect.ImmutableMap)1