Search in sources :

Example 1 with ISnomedIdentifierReservationService

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);
    }
}
Also used : ISnomedIdentifierReservationService(com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService)

Example 2 with ISnomedIdentifierReservationService

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);
}
Also used : SequentialItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy) SnomedIdentifierReservationServiceImpl(com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl) ISnomedIdentifierReservationService(com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService) DefaultSnomedIdentifierService(com.b2international.snowowl.snomed.cis.memory.DefaultSnomedIdentifierService) ISnomedIdentifierService(com.b2international.snowowl.snomed.cis.ISnomedIdentifierService) SnomedIdentifierConfiguration(com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration) Test(org.junit.Test)

Example 3 with ISnomedIdentifierReservationService

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);
}
Also used : SnomedIdentifierReservationServiceImpl(com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl) CisSnomedIdentifierService(com.b2international.snowowl.snomed.cis.client.CisSnomedIdentifierService) ISnomedIdentifierReservationService(com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService) SnomedIdentifierConfiguration(com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration) Before(org.junit.Before)

Example 4 with ISnomedIdentifierReservationService

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());
}
Also used : SequentialItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy) SnomedIdentifierReservationServiceImpl(com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl) SequentialItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy) ItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.ItemIdGenerationStrategy) Mappings(com.b2international.index.mapping.Mappings) ISnomedIdentifierReservationService(com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService) DefaultSnomedIdentifierService(com.b2international.snowowl.snomed.cis.memory.DefaultSnomedIdentifierService) SnomedIdentifierConfiguration(com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 5 with ISnomedIdentifierReservationService

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));
}
Also used : SequentialItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy) SnomedIdentifierReservationServiceImpl(com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl) SequentialItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy) ItemIdGenerationStrategy(com.b2international.snowowl.snomed.cis.gen.ItemIdGenerationStrategy) ISnomedIdentifierReservationService(com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService) DefaultSnomedIdentifierService(com.b2international.snowowl.snomed.cis.memory.DefaultSnomedIdentifierService) ISnomedIdentifierService(com.b2international.snowowl.snomed.cis.ISnomedIdentifierService) SnomedIdentifierConfiguration(com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration) Test(org.junit.Test)

Aggregations

ISnomedIdentifierReservationService (com.b2international.snowowl.snomed.cis.reservations.ISnomedIdentifierReservationService)12 SnomedIdentifierReservationServiceImpl (com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl)11 SnomedIdentifierConfiguration (com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration)10 SequentialItemIdGenerationStrategy (com.b2international.snowowl.snomed.cis.gen.SequentialItemIdGenerationStrategy)9 DefaultSnomedIdentifierService (com.b2international.snowowl.snomed.cis.memory.DefaultSnomedIdentifierService)9 ISnomedIdentifierService (com.b2international.snowowl.snomed.cis.ISnomedIdentifierService)8 Test (org.junit.Test)8 ItemIdGenerationStrategy (com.b2international.snowowl.snomed.cis.gen.ItemIdGenerationStrategy)6 Before (org.junit.Before)2 Mappings (com.b2international.index.mapping.Mappings)1 CisSnomedIdentifierService (com.b2international.snowowl.snomed.cis.client.CisSnomedIdentifierService)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1