use of com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService in project snow-owl by b2ihealthcare.
the class SnomedIdentifierPlugin method run.
@Override
public void run(SnowOwlConfiguration configuration, Environment env) throws Exception {
if (env.isServer()) {
final ISnomedIdentifierReservationService reservationService = env.service(ISnomedIdentifierReservationService.class);
final SnomedIdentifierConfiguration conf = configuration.getModuleConfig(SnomedIdentifierConfiguration.class);
registerSnomedIdentifierService(conf, env, reservationService);
}
}
use of com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService in project snow-owl by b2ihealthcare.
the class DefaultSnomedIdentifierServiceRegressionTest method testQuadraticProbing_wraparound.
@Test
public void testQuadraticProbing_wraparound() throws Exception {
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
final SequentialItemIdGenerationStrategy idGenerationStrategy = new SequentialItemIdGenerationStrategy(reservationService);
// next free itemId is 99999997
idGenerationStrategy.getOrCreateCounter("1000154", ComponentCategory.CONCEPT).setCounter(99999997L);
final ISnomedIdentifierService identifiers = new DefaultSnomedIdentifierService(store, idGenerationStrategy, reservationService, new SnomedIdentifierConfiguration());
assertEquals("999999971000154106", Iterables.getOnlyElement(identifiers.generate("1000154", ComponentCategory.CONCEPT, 1)));
// 99999998 and 2 becomes registered
identifiers.register(ImmutableSet.of("999999981000154108", "21000154106"));
// Attempt 1, quantity 2, 99999998 - 0
// Attempt 2, quantity 1, 2 - 2
// Attempt 3, quantity 1, 6 - 6
List<String> actualIds = ImmutableList.copyOf(identifiers.generate("1000154", ComponentCategory.CONCEPT, 2));
List<String> expectedIds = ImmutableList.of("999999991000154105", "11000154102");
assertEquals(expectedIds, actualIds);
}
use of com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService in project snow-owl by b2ihealthcare.
the class CisSnomedIdentifierServiceTest method init.
@Before
public void init() {
final SnomedIdentifierConfiguration conf = new SnomedIdentifierConfiguration();
conf.setCisBaseUrl("http://107.170.101.181:3000");
conf.setCisContextRoot("api");
conf.setCisClientSoftwareKey("Snow Owl dev. tests");
conf.setCisUserName("snowowl-dev-b2i");
conf.setCisPassword("hAAYLYMX5gc98SDEz9cr");
conf.setCisTimeBetweenPollTries(1000);
conf.setCisNumberOfPollTries(5);
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
service = new CisSnomedIdentifierService(conf, reservationService, mapper);
}
use of com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService in project snow-owl by b2ihealthcare.
the class DefaultSnomedIdentifierServiceTest method init.
@Before
public void init() {
store = Indexes.createIndex(UUID.randomUUID().toString(), new ObjectMapper(), new Mappings(SctId.class));
store.admin().create();
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
final ItemIdGenerationStrategy idGenerationStrategy = new SequentialItemIdGenerationStrategy(reservationService);
service = new DefaultSnomedIdentifierService(store, idGenerationStrategy, reservationService, new SnomedIdentifierConfiguration());
}
use of com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService in project snow-owl by b2ihealthcare.
the class DefaultSnomedIdentifierServiceRegressionTest method issue_SO_2138_testItemIdsReturnedInSequence.
@Test
public void issue_SO_2138_testItemIdsReturnedInSequence() throws Exception {
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
final ItemIdGenerationStrategy idGenerationStrategy = new SequentialItemIdGenerationStrategy(reservationService);
final ISnomedIdentifierService identifiers = new DefaultSnomedIdentifierService(store, idGenerationStrategy, reservationService, new SnomedIdentifierConfiguration());
List<String> actualIds = ImmutableList.copyOf(identifiers.generate(INT_NAMESPACE, ComponentCategory.CONCEPT, 3));
List<String> expectedIds = ImmutableList.of("100005", "101009", "102002");
assertEquals(expectedIds, actualIds);
actualIds = ImmutableList.copyOf(identifiers.generate(B2I_NAMESPACE, ComponentCategory.CONCEPT, 3));
expectedIds = ImmutableList.of("11000129102", "21000129106", "31000129108");
assertEquals(expectedIds, actualIds);
// Make a surprise return to the INT namespace here
assertEquals("103007", Iterables.getFirst(identifiers.generate(INT_NAMESPACE, ComponentCategory.CONCEPT, 1), null));
}
Aggregations