Search in sources :

Example 11 with SctId

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

the class DefaultSnomedIdentifierService method publish.

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

Example 12 with SctId

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

the class DefaultSnomedIdentifierService method buildSctId.

private SctId buildSctId(final String componentId, final IdentifierStatus status) {
    final SctId sctId = new SctId();
    sctId.setSctid(componentId);
    sctId.setStatus(status.getSerializedName());
    sctId.setSequence(SnomedIdentifiers.getItemId(componentId));
    sctId.setNamespace(SnomedIdentifiers.getNamespace(componentId));
    sctId.setPartitionId(SnomedIdentifiers.getPartitionId(componentId));
    sctId.setCheckDigit(SnomedIdentifiers.getCheckDigit(componentId));
    // TODO: Other attributes of SctId could also be set here
    return sctId;
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId)

Example 13 with SctId

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

the class DefaultSnomedIdentifierService method register.

@Override
public Map<String, SctId> register(final Set<String> componentIds) {
    if (CompareUtils.isEmpty(componentIds)) {
        return Collections.emptyMap();
    }
    LOGGER.debug("Registering {} component IDs.", componentIds.size());
    final Map<String, SctId> sctIds = getSctIds(componentIds);
    final Map<String, SctId> availableOrReservedSctIds = ImmutableMap.copyOf(Maps.filterValues(sctIds, Predicates.or(SctId::isAvailable, SctId::isReserved)));
    for (final SctId sctId : availableOrReservedSctIds.values()) {
        sctId.setStatus(IdentifierStatus.ASSIGNED.getSerializedName());
    }
    putSctIds(availableOrReservedSctIds.values());
    return ImmutableMap.copyOf(sctIds);
}
Also used : SctId(com.b2international.snowowl.snomed.cis.domain.SctId)

Example 14 with SctId

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

the class AbstractIdentifierServiceTest method whenPublishingAssignedIds_ThenTheyShouldBePublished.

@Test
public void whenPublishingAssignedIds_ThenTheyShouldBePublished() {
    try {
        final Set<String> componentIds = getIdentifierService().generate(B2I_NAMESPACE, ComponentCategory.CONCEPT, 2);
        getIdentifierService().publish(componentIds);
        final Collection<SctId> sctIds = getIdentifierService().getSctIds(componentIds).values();
        for (final SctId sctId : sctIds) {
            assertTrue("Status must be published", IdentifierStatus.PUBLISHED.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 15 with SctId

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

the class AbstractIdentifierServiceTest method whenRegisteringReservedIds_ThenTheyShouldBeRegistered.

@Test
public void whenRegisteringReservedIds_ThenTheyShouldBeRegistered() {
    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);
        getIdentifierService().register(componentIds);
        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)

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