Search in sources :

Example 6 with AdminReservationModification

use of alfio.model.modification.AdminReservationModification in project alf.io by alfio-event.

the class AdminReservationRequestManager method spread.

private Stream<AdminReservationModification> spread(AdminReservationModification src, boolean single) {
    if (single) {
        return Stream.of(src);
    }
    return src.getTicketsInfo().stream().flatMap(ti -> ti.getAttendees().stream().map(a -> Pair.of(a, new AdminReservationModification.TicketsInfo(ti.getCategory(), singletonList(a), ti.isAddSeatsIfNotAvailable(), ti.isUpdateAttendees())))).map(p -> {
        AdminReservationModification.Attendee attendee = p.getLeft();
        String language = StringUtils.defaultIfBlank(attendee.getLanguage(), src.getLanguage());
        CustomerData cd = new CustomerData(attendee.getFirstName(), attendee.getLastName(), attendee.getEmailAddress(), null, language);
        return new AdminReservationModification(src.getExpiration(), cd, singletonList(p.getRight()), language, src.isUpdateContactData(), src.getNotification());
    });
}
Also used : TransactionDefinition(org.springframework.transaction.TransactionDefinition) RequiredArgsConstructor(lombok.RequiredArgsConstructor) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) StringUtils(org.apache.commons.lang3.StringUtils) Collections.singletonList(java.util.Collections.singletonList) Json(alfio.util.Json) ErrorCode(alfio.model.result.ErrorCode) Pair(org.apache.commons.lang3.tuple.Pair) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Triple(org.apache.commons.lang3.tuple.Triple) Optional.ofNullable(java.util.Optional.ofNullable) User(alfio.model.user.User) UUID(java.util.UUID) CustomerData(alfio.model.modification.AdminReservationModification.CustomerData) EventRepository(alfio.repository.EventRepository) Collectors(java.util.stream.Collectors) Result(alfio.model.result.Result) Component(org.springframework.stereotype.Component) List(java.util.List) Stream(java.util.stream.Stream) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) alfio.model(alfio.model) UserRepository(alfio.repository.user.UserRepository) AdminReservationRequestRepository(alfio.repository.AdminReservationRequestRepository) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) Log4j2(lombok.extern.log4j.Log4j2) AdminReservationModification(alfio.model.modification.AdminReservationModification) OptionalWrapper.optionally(alfio.util.OptionalWrapper.optionally) Transactional(org.springframework.transaction.annotation.Transactional) AdminReservationModification(alfio.model.modification.AdminReservationModification) CustomerData(alfio.model.modification.AdminReservationModification.CustomerData)

Aggregations

AdminReservationModification (alfio.model.modification.AdminReservationModification)6 Collections.singletonList (java.util.Collections.singletonList)6 alfio.model (alfio.model)5 ErrorCode (alfio.model.result.ErrorCode)5 Result (alfio.model.result.Result)5 UserRepository (alfio.repository.user.UserRepository)5 Json (alfio.util.Json)5 OptionalWrapper.optionally (alfio.util.OptionalWrapper.optionally)5 Collectors (java.util.stream.Collectors)5 Stream (java.util.stream.Stream)5 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5 Log4j2 (lombok.extern.log4j.Log4j2)5 StringUtils (org.apache.commons.lang3.StringUtils)5 Pair (org.apache.commons.lang3.tuple.Pair)5 Triple (org.apache.commons.lang3.tuple.Triple)5 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)5 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)5 Component (org.springframework.stereotype.Component)5 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)5 Transactional (org.springframework.transaction.annotation.Transactional)5