Search in sources :

Example 6 with Reservation

use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.

the class SnomedIdentifierReservationServiceImplTest method whenReservingASingleSnomedIdentifier_ThenServiceMustStoreIt.

@Test
public void whenReservingASingleSnomedIdentifier_ThenServiceMustStoreIt() throws Exception {
    final Reservation reservation = Reservations.single(Concepts.ROOT_CONCEPT);
    this.reservationService.create(SINGLE_RESERVATION, reservation);
    assertThat(this.reservationService.getReservations()).contains(reservation);
    assertThat(this.reservationService.getReservation(SINGLE_RESERVATION)).isEqualTo(reservation);
}
Also used : Reservation(com.b2international.snowowl.snomed.cis.reservations.Reservation) Test(org.junit.Test)

Example 7 with Reservation

use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.

the class SnomedIdentifierReservationServiceImpl method isReserved.

@Override
public Set<String> isReserved(Set<String> componentIdsToCheck) {
    final ImmutableSet.Builder<String> reservedIds = ImmutableSet.builder();
    final Set<SnomedIdentifier> identifiersToCheck = componentIdsToCheck.stream().map(SnomedIdentifiers::create).collect(Collectors.toSet());
    for (Reservation reservation : getReservations()) {
        reservation.intersection(identifiersToCheck).stream().map(SnomedIdentifier::toString).forEach(reservedIds::add);
    }
    return reservedIds.build();
}
Also used : Reservation(com.b2international.snowowl.snomed.cis.reservations.Reservation) ImmutableSet(com.google.common.collect.ImmutableSet) SnomedIdentifier(com.b2international.snowowl.snomed.cis.SnomedIdentifier)

Aggregations

Reservation (com.b2international.snowowl.snomed.cis.reservations.Reservation)7 Test (org.junit.Test)6 SnomedIdentifier (com.b2international.snowowl.snomed.cis.SnomedIdentifier)3 Index (com.b2international.index.Index)1 Mappings (com.b2international.index.mapping.Mappings)1 ComponentCategory (com.b2international.snowowl.core.terminology.ComponentCategory)1 ISnomedIdentifierService (com.b2international.snowowl.snomed.cis.ISnomedIdentifierService)1 SnomedIdentifierConfiguration (com.b2international.snowowl.snomed.cis.SnomedIdentifierConfiguration)1 SctId (com.b2international.snowowl.snomed.cis.domain.SctId)1 ItemIdGenerationStrategy (com.b2international.snowowl.snomed.cis.gen.ItemIdGenerationStrategy)1 SnomedIdentifierReservationServiceImpl (com.b2international.snowowl.snomed.cis.internal.reservations.SnomedIdentifierReservationServiceImpl)1 DefaultSnomedIdentifierService (com.b2international.snowowl.snomed.cis.memory.DefaultSnomedIdentifierService)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1