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