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);
}
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;
}
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);
}
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()));
}
}
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);
}
}
Aggregations