Search in sources :

Example 26 with Organization

use of alfio.model.user.Organization in project alf.io by alfio-event.

the class TicketHelper method getOwnerChangeTextBuilder.

private PartialTicketTextGenerator getOwnerChangeTextBuilder(HttpServletRequest request, Ticket t, Event event) {
    Organization organization = organizationRepository.getById(event.getOrganizationId());
    String ticketUrl = ticketReservationManager.ticketUpdateUrl(event, t.getUuid());
    return TemplateProcessor.buildEmailForOwnerChange(event, t, organization, ticketUrl, templateManager, LocaleUtil.getTicketLanguage(t, request));
}
Also used : Organization(alfio.model.user.Organization)

Example 27 with Organization

use of alfio.model.user.Organization in project alf.io by alfio-event.

the class WaitingQueueManager method notifySubscription.

private void notifySubscription(Event event, CustomerName name, String email, Locale userLanguage, WaitingQueueSubscription.Type subscriptionType) {
    Organization organization = organizationRepository.getById(event.getOrganizationId());
    Map<String, Object> model = TemplateResource.buildModelForWaitingQueueJoined(organization, event, name);
    notificationManager.sendSimpleEmail(event, email, messageSource.getMessage("email-waiting-queue.subscribed.subject", new Object[] { event.getDisplayName() }, userLanguage), () -> templateManager.renderTemplate(event, TemplateResource.WAITING_QUEUE_JOINED, model, userLanguage));
    if (configurationManager.getBooleanConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ENABLE_WAITING_QUEUE_NOTIFICATION), false)) {
        String adminTemplate = messageSource.getMessage("email-waiting-queue.subscribed.admin.text", new Object[] { subscriptionType, event.getDisplayName() }, Locale.ENGLISH);
        notificationManager.sendSimpleEmail(event, organization.getEmail(), messageSource.getMessage("email-waiting-queue.subscribed.admin.subject", new Object[] { event.getDisplayName() }, Locale.ENGLISH), () -> templateManager.renderString(adminTemplate, model, Locale.ENGLISH, TemplateManager.TemplateOutput.TEXT));
    }
}
Also used : Organization(alfio.model.user.Organization)

Example 28 with Organization

use of alfio.model.user.Organization in project alf.io by alfio-event.

the class WaitingQueueSubscriptionProcessor method distributeAvailableSeats.

void distributeAvailableSeats(Event event) {
    waitingQueueManager.distributeSeats(event).forEach(triple -> {
        WaitingQueueSubscription subscription = triple.getLeft();
        Locale locale = subscription.getLocale();
        ZonedDateTime expiration = triple.getRight();
        Organization organization = eventManager.loadOrganizerUsingSystemPrincipal(event);
        String reservationId = createReservation(event, triple.getMiddle(), expiration, locale);
        String subject = messageSource.getMessage("email-waiting-queue-acquired.subject", new Object[] { event.getDisplayName() }, locale);
        String reservationUrl = ticketReservationManager.reservationUrl(reservationId, event);
        Map<String, Object> model = TemplateResource.buildModelForWaitingQueueReservationEmail(organization, event, subscription, reservationUrl, expiration);
        notificationManager.sendSimpleEmail(event, subscription.getEmailAddress(), subject, () -> templateManager.renderTemplate(event, TemplateResource.WAITING_QUEUE_RESERVATION_EMAIL, model, locale));
        waitingQueueRepository.flagAsPending(reservationId, subscription.getId());
    });
}
Also used : Organization(alfio.model.user.Organization) ZonedDateTime(java.time.ZonedDateTime) WaitingQueueSubscription(alfio.model.WaitingQueueSubscription)

Example 29 with Organization

use of alfio.model.user.Organization in project alf.io by alfio-event.

the class CustomMessageManager method preview.

private List<MessageModification> preview(Event event, List<MessageModification> input, String username) {
    Model model = new ExtendedModelMap();
    Organization organization = eventManager.loadOrganizer(event, username);
    model.addAttribute("eventName", event.getDisplayName());
    model.addAttribute("fullName", "John Doe");
    model.addAttribute("organizationName", organization.getName());
    model.addAttribute("organizationEmail", organization.getEmail());
    model.addAttribute("reservationURL", "https://this-is-the-reservation-url");
    model.addAttribute("ticketURL", "https://this-is-the-ticket-url");
    model.addAttribute("reservationID", "RESID");
    return input.stream().map(m -> MessageModification.preview(m, renderResource(m.getSubject(), model, m.getLocale(), templateManager), renderResource(m.getText(), model, m.getLocale(), templateManager), m.isAttachTicket())).collect(Collectors.toList());
}
Also used : java.util(java.util) TicketCategoryRepository(alfio.repository.TicketCategoryRepository) MessageModification(alfio.model.modification.MessageModification) Autowired(org.springframework.beans.factory.annotation.Autowired) Mailer(alfio.manager.system.Mailer) Json(alfio.util.Json) Model(org.springframework.ui.Model) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Triple(org.apache.commons.lang3.tuple.Triple) TicketRepository(alfio.repository.TicketRepository) Executor(java.util.concurrent.Executor) Organization(alfio.model.user.Organization) TemplateManager(alfio.util.TemplateManager) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) TicketReservationManager(alfio.manager.TicketReservationManager) TicketCategory(alfio.model.TicketCategory) Component(org.springframework.stereotype.Component) EventManager(alfio.manager.EventManager) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) Ticket(alfio.model.Ticket) NotificationManager(alfio.manager.NotificationManager) TicketReservation(alfio.model.TicketReservation) Log4j2(lombok.extern.log4j.Log4j2) Event(alfio.model.Event) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) Organization(alfio.model.user.Organization) Model(org.springframework.ui.Model)

Example 30 with Organization

use of alfio.model.user.Organization in project alf.io by alfio-event.

the class CustomMessageManager method sendMessages.

public void sendMessages(String eventName, Optional<Integer> categoryId, List<MessageModification> input, String username) {
    Event event = eventManager.getSingleEvent(eventName, username);
    // dry run for checking the syntax
    preview(event, input, username);
    Organization organization = eventManager.loadOrganizer(event, username);
    AtomicInteger counter = new AtomicInteger();
    Map<String, List<MessageModification>> byLanguage = input.stream().collect(Collectors.groupingBy(m -> m.getLocale().getLanguage()));
    sendMessagesExecutor.execute(() -> {
        categoryId.map(id -> ticketRepository.findConfirmedByCategoryId(event.getId(), id)).orElseGet(() -> ticketRepository.findAllConfirmed(event.getId())).stream().filter(t -> isNotBlank(t.getFullName()) && isNotBlank(t.getEmail())).parallel().map(t -> {
            Model model = new ExtendedModelMap();
            model.addAttribute("eventName", eventName);
            model.addAttribute("fullName", t.getFullName());
            model.addAttribute("organizationName", organization.getName());
            model.addAttribute("organizationEmail", organization.getEmail());
            model.addAttribute("reservationURL", ticketReservationManager.reservationUrl(t.getTicketsReservationId(), event));
            model.addAttribute("reservationID", ticketReservationManager.getShortReservationID(event, t.getTicketsReservationId()));
            model.addAttribute("ticketURL", ticketReservationManager.ticketUpdateUrl(event, t.getUuid()));
            return Triple.of(t, t.getEmail(), model);
        }).forEach(triple -> {
            Ticket ticket = triple.getLeft();
            MessageModification m = Optional.ofNullable(byLanguage.get(ticket.getUserLanguage())).orElseGet(() -> byLanguage.get(byLanguage.keySet().stream().findFirst().orElseThrow(IllegalStateException::new))).get(0);
            Model model = triple.getRight();
            String subject = renderResource(m.getSubject(), model, m.getLocale(), templateManager);
            String text = renderResource(m.getText(), model, m.getLocale(), templateManager);
            List<Mailer.Attachment> attachments = new ArrayList<>();
            if (m.isAttachTicket()) {
                ticketReservationManager.findById(ticket.getTicketsReservationId()).ifPresent(reservation -> {
                    ticketCategoryRepository.getByIdAndActive(ticket.getCategoryId()).ifPresent(ticketCategory -> {
                        attachments.add(generateTicketAttachment(ticket, reservation, ticketCategory, organization));
                    });
                });
            }
            counter.incrementAndGet();
            notificationManager.sendSimpleEmail(event, triple.getMiddle(), subject, () -> text, attachments);
        });
    });
}
Also used : java.util(java.util) TicketCategoryRepository(alfio.repository.TicketCategoryRepository) MessageModification(alfio.model.modification.MessageModification) Autowired(org.springframework.beans.factory.annotation.Autowired) Mailer(alfio.manager.system.Mailer) Json(alfio.util.Json) Model(org.springframework.ui.Model) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Triple(org.apache.commons.lang3.tuple.Triple) TicketRepository(alfio.repository.TicketRepository) Executor(java.util.concurrent.Executor) Organization(alfio.model.user.Organization) TemplateManager(alfio.util.TemplateManager) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) TicketReservationManager(alfio.manager.TicketReservationManager) TicketCategory(alfio.model.TicketCategory) Component(org.springframework.stereotype.Component) EventManager(alfio.manager.EventManager) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) Ticket(alfio.model.Ticket) NotificationManager(alfio.manager.NotificationManager) TicketReservation(alfio.model.TicketReservation) Log4j2(lombok.extern.log4j.Log4j2) Event(alfio.model.Event) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) Ticket(alfio.model.Ticket) Organization(alfio.model.user.Organization) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) MessageModification(alfio.model.modification.MessageModification) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Model(org.springframework.ui.Model) Event(alfio.model.Event)

Aggregations

Organization (alfio.model.user.Organization)30 Event (alfio.model.Event)13 TicketCategory (alfio.model.TicketCategory)7 Ticket (alfio.model.Ticket)6 Triple (org.apache.commons.lang3.tuple.Triple)6 TicketReservation (alfio.model.TicketReservation)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 Log4j2 (lombok.extern.log4j.Log4j2)4 Component (org.springframework.stereotype.Component)4 DateTimeModification (alfio.model.modification.DateTimeModification)3 LocationDescriptor (alfio.model.modification.support.LocationDescriptor)3 ZonedDateTime (java.time.ZonedDateTime)3 Collections.singletonList (java.util.Collections.singletonList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 EventManager (alfio.manager.EventManager)2 NotificationManager (alfio.manager.NotificationManager)2 TicketReservationManager (alfio.manager.TicketReservationManager)2 Mailer (alfio.manager.system.Mailer)2 alfio.model (alfio.model)2