Search in sources :

Example 1 with TicketAccessType

use of alfio.model.TicketCategory.TicketAccessType in project alf.io by alfio-event.

the class EventManager method updateEventHeader.

public void updateEventHeader(Event original, EventModification em, String username) {
    IntPredicate ownershipChecker = checkOwnershipByOrgId(username, organizationRepository);
    boolean sameOrganization = original.getOrganizationId() == em.getOrganizationId();
    Validate.isTrue(ownershipChecker.test(original.getOrganizationId()) && (sameOrganization || ownershipChecker.test(em.getOrganizationId())), "Invalid organizationId");
    int eventId = original.getId();
    Validate.isTrue(sameOrganization || groupRepository.countByEventId(eventId) == 0, "Cannot change organization because there is a group linked to this event.");
    Validate.isTrue(sameOrganization || !subscriptionRepository.hasLinkedSubscription(eventId), "Cannot change organization because there are one or more subscriptions linked.");
    boolean formatUpdated = em.getFormat() != original.getFormat();
    if (em.getFormat() == EventFormat.ONLINE && formatUpdated) {
        Validate.isTrue(original.getAllowedPaymentProxies().stream().allMatch(p -> p != PaymentProxy.ON_SITE), ERROR_ONLINE_ON_SITE_NOT_COMPATIBLE);
    }
    String timeZone = ObjectUtils.firstNonNull(em.getZoneId(), em.getGeolocation() != null ? em.getGeolocation().getTimeZone() : null);
    String latitude = ObjectUtils.firstNonNull(em.getLatitude(), em.getGeolocation() != null ? em.getGeolocation().getLatitude() : null);
    String longitude = ObjectUtils.firstNonNull(em.getLongitude(), em.getGeolocation() != null ? em.getGeolocation().getLongitude() : null);
    final ZoneId zoneId = ZoneId.of(timeZone);
    final ZonedDateTime begin = em.getBegin().toZonedDateTime(zoneId);
    final ZonedDateTime end = em.getEnd().toZonedDateTime(zoneId);
    eventRepository.updateHeader(eventId, em.getDisplayName(), em.getWebsiteUrl(), em.getExternalUrl(), em.getTermsAndConditionsUrl(), em.getPrivacyPolicyUrl(), em.getImageUrl(), em.getFileBlobId(), em.getLocation(), latitude, longitude, begin, end, timeZone, em.getOrganizationId(), em.getLocales(), em.getFormat());
    createOrUpdateEventDescription(eventId, em);
    if (!original.getBegin().equals(begin) || !original.getEnd().equals(end)) {
        fixOutOfRangeCategories(em, username, zoneId, end);
    }
    if (formatUpdated) {
        // update ticket access type for categories if the format has been updated
        var ticketAccessType = evaluateTicketAccessType(original.getFormat(), em.getFormat());
        ticketCategoryRepository.updateTicketAccessTypeForEvent(eventId, ticketAccessType);
    }
    extensionManager.handleEventHeaderUpdate(eventRepository.findById(eventId), organizationRepository.findOrganizationForUser(username, em.getOrganizationId()).orElseThrow());
}
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) ZonedDateTime(java.time.ZonedDateTime) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) AlfioMetadata(alfio.model.metadata.AlfioMetadata) TicketStatus(alfio.model.Ticket.TicketStatus) StringUtils(org.apache.commons.lang3.StringUtils) IntPredicate(java.util.function.IntPredicate) Collections.singletonList(java.util.Collections.singletonList) BigDecimal(java.math.BigDecimal) Json(alfio.util.Json) ErrorCode(alfio.model.result.ErrorCode) Arrays.asList(java.util.Arrays.asList) Profiles(org.springframework.core.env.Profiles) Triple(org.apache.commons.lang3.tuple.Triple) OrganizationRepository(alfio.repository.user.OrganizationRepository) RequestUtils(alfio.util.RequestUtils) Organization(alfio.model.user.Organization) Predicate(java.util.function.Predicate) CheckInOutputColorConfiguration(alfio.model.support.CheckInOutputColorConfiguration) EventCreationRequest(alfio.model.api.v1.admin.EventCreationRequest) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) String.format(java.lang.String.format) ConfigurationRepository(alfio.repository.system.ConfigurationRepository) SearchOptions(alfio.controller.form.SearchOptions) ColorConfiguration(alfio.model.support.CheckInOutputColorConfiguration.ColorConfiguration) Initializer(alfio.config.Initializer) Principal(java.security.Principal) Stream(java.util.stream.Stream) alfio.model(alfio.model) Environment(org.springframework.core.env.Environment) DateTimeModification.atZone(alfio.model.modification.DateTimeModification.atZone) ClockProvider(alfio.util.ClockProvider) alfio.model.modification(alfio.model.modification) IntStream(java.util.stream.IntStream) java.util(java.util) EventFormat(alfio.model.Event.EventFormat) ONCE_PER_EVENT(alfio.model.TicketCategory.TicketCheckInStrategy.ONCE_PER_EVENT) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) ConfigurationManager(alfio.manager.system.ConfigurationManager) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Objects.requireNonNullElse(java.util.Objects.requireNonNullElse) IterableUtils(org.apache.commons.collections4.IterableUtils) TicketAccessType(alfio.model.TicketCategory.TicketAccessType) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Context(alfio.model.TicketFieldConfiguration.Context) Objects.requireNonNullElseGet(java.util.Objects.requireNonNullElseGet) Result(alfio.model.result.Result) Consumer(java.util.function.Consumer) Component(org.springframework.stereotype.Component) Validate(org.apache.commons.lang3.Validate) ChronoUnit(java.time.temporal.ChronoUnit) CategoryEvaluator(alfio.manager.support.CategoryEvaluator) MonetaryUtil(alfio.util.MonetaryUtil) ExtensionCapability(alfio.manager.support.extension.ExtensionCapability) UserManager(alfio.manager.user.UserManager) Log4j2(lombok.extern.log4j.Log4j2) EventUtil(alfio.util.EventUtil) Flyway(org.flywaydb.core.Flyway) Wrappers.optionally(alfio.util.Wrappers.optionally) AllArgsConstructor(lombok.AllArgsConstructor) ConfigurationKeys(alfio.model.system.ConfigurationKeys) CHECK_IN_COLOR_CONFIGURATION(alfio.model.system.ConfigurationKeys.CHECK_IN_COLOR_CONFIGURATION) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) ZoneId(java.time.ZoneId) IntPredicate(java.util.function.IntPredicate) ZonedDateTime(java.time.ZonedDateTime)

Aggregations

Initializer (alfio.config.Initializer)1 SearchOptions (alfio.controller.form.SearchOptions)1 CategoryEvaluator (alfio.manager.support.CategoryEvaluator)1 ExtensionCapability (alfio.manager.support.extension.ExtensionCapability)1 ConfigurationManager (alfio.manager.system.ConfigurationManager)1 UserManager (alfio.manager.user.UserManager)1 alfio.model (alfio.model)1 EventFormat (alfio.model.Event.EventFormat)1 DiscountType (alfio.model.PromoCodeDiscount.DiscountType)1 TicketStatus (alfio.model.Ticket.TicketStatus)1 TicketAccessType (alfio.model.TicketCategory.TicketAccessType)1 ONCE_PER_EVENT (alfio.model.TicketCategory.TicketCheckInStrategy.ONCE_PER_EVENT)1 Context (alfio.model.TicketFieldConfiguration.Context)1 EventCreationRequest (alfio.model.api.v1.admin.EventCreationRequest)1 AlfioMetadata (alfio.model.metadata.AlfioMetadata)1 alfio.model.modification (alfio.model.modification)1 DateTimeModification.atZone (alfio.model.modification.DateTimeModification.atZone)1 AdditionalField (alfio.model.modification.EventModification.AdditionalField)1 ErrorCode (alfio.model.result.ErrorCode)1 Result (alfio.model.result.Result)1