Search in sources :

Example 1 with Context

use of alfio.model.TicketFieldConfiguration.Context in project alf.io by alfio-event.

the class EventManager method insertAdditionalField.

private void insertAdditionalField(Event event, AdditionalField f, int order) {
    String serializedRestrictedValues = toSerializedRestrictedValues(f);
    Optional<EventModification.AdditionalService> linkedAdditionalService = Optional.ofNullable(f.getLinkedAdditionalService());
    Integer additionalServiceId = linkedAdditionalService.map(as -> Optional.ofNullable(as.getId()).orElseGet(() -> findAdditionalService(event, as))).orElse(-1);
    Context context = linkedAdditionalService.isPresent() ? Context.ADDITIONAL_SERVICE : Context.ATTENDEE;
    int configurationId = ticketFieldRepository.insertConfiguration(event.getId(), f.getName(), order, f.getType(), serializedRestrictedValues, f.getMaxLength(), f.getMinLength(), f.isRequired(), context, additionalServiceId).getKey();
    f.getDescription().forEach((locale, value) -> ticketFieldRepository.insertDescription(configurationId, locale, Json.GSON.toJson(value)));
}
Also used : AdditionalField(alfio.model.modification.EventModification.AdditionalField) alfio.repository(alfio.repository) PaymentProxy(alfio.model.transaction.PaymentProxy) AffectedRowCountAndKey(ch.digitalfondue.npjt.AffectedRowCountAndKey) DiscountType(alfio.model.PromoCodeDiscount.DiscountType) PromoCodeDiscountWithFormattedTime(alfio.model.modification.PromoCodeDiscountWithFormattedTime) ZonedDateTime(java.time.ZonedDateTime) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) TicketStatus(alfio.model.Ticket.TicketStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collections.singletonList(java.util.Collections.singletonList) BigDecimal(java.math.BigDecimal) Json(alfio.util.Json) ErrorCode(alfio.model.result.ErrorCode) Pair(org.apache.commons.lang3.tuple.Pair) Arrays.asList(java.util.Arrays.asList) Triple(org.apache.commons.lang3.tuple.Triple) OrganizationRepository(alfio.repository.user.OrganizationRepository) Organization(alfio.model.user.Organization) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) Initializer(alfio.config.Initializer) Stream(java.util.stream.Stream) alfio.model(alfio.model) Environment(org.springframework.core.env.Environment) CollectionUtils(org.springframework.util.CollectionUtils) Configuration(alfio.model.system.Configuration) OptionalWrapper.optionally(alfio.util.OptionalWrapper.optionally) java.util(java.util) DateTimeModification.toZonedDateTime(alfio.model.modification.DateTimeModification.toZonedDateTime) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) ConfigurationManager(alfio.manager.system.ConfigurationManager) EventModification(alfio.model.modification.EventModification) Function(java.util.function.Function) TicketFieldDescriptionModification(alfio.model.modification.TicketFieldDescriptionModification) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Context(alfio.model.TicketFieldConfiguration.Context) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) Result(alfio.model.result.Result) Consumer(java.util.function.Consumer) Component(org.springframework.stereotype.Component) Collectors.toList(java.util.stream.Collectors.toList) Validate(org.apache.commons.lang3.Validate) ChronoUnit(java.time.temporal.ChronoUnit) CategoryEvaluator(alfio.manager.support.CategoryEvaluator) MonetaryUtil(alfio.util.MonetaryUtil) UserManager(alfio.manager.user.UserManager) Data(lombok.Data) Log4j2(lombok.extern.log4j.Log4j2) EventUtil(alfio.util.EventUtil) Flyway(org.flywaydb.core.Flyway) AllArgsConstructor(lombok.AllArgsConstructor) ConfigurationKeys(alfio.model.system.ConfigurationKeys) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) Context(alfio.model.TicketFieldConfiguration.Context)

Aggregations

Initializer (alfio.config.Initializer)1 CategoryEvaluator (alfio.manager.support.CategoryEvaluator)1 ConfigurationManager (alfio.manager.system.ConfigurationManager)1 UserManager (alfio.manager.user.UserManager)1 alfio.model (alfio.model)1 DiscountType (alfio.model.PromoCodeDiscount.DiscountType)1 TicketStatus (alfio.model.Ticket.TicketStatus)1 Context (alfio.model.TicketFieldConfiguration.Context)1 DateTimeModification.toZonedDateTime (alfio.model.modification.DateTimeModification.toZonedDateTime)1 EventModification (alfio.model.modification.EventModification)1 AdditionalField (alfio.model.modification.EventModification.AdditionalField)1 PromoCodeDiscountWithFormattedTime (alfio.model.modification.PromoCodeDiscountWithFormattedTime)1 TicketCategoryModification (alfio.model.modification.TicketCategoryModification)1 TicketFieldDescriptionModification (alfio.model.modification.TicketFieldDescriptionModification)1 ErrorCode (alfio.model.result.ErrorCode)1 Result (alfio.model.result.Result)1 Configuration (alfio.model.system.Configuration)1 ConfigurationKeys (alfio.model.system.ConfigurationKeys)1 PaymentProxy (alfio.model.transaction.PaymentProxy)1 Organization (alfio.model.user.Organization)1