Search in sources :

Example 11 with Organization

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

the class IntegrationTestUtil method initEvent.

public static Pair<Event, String> initEvent(List<TicketCategoryModification> categories, OrganizationRepository organizationRepository, UserManager userManager, EventManager eventManager, EventRepository eventRepository, List<EventModification.AdditionalService> additionalServices) {
    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();
    userManager.createOrganization(organizationName, "org", "email@example.com");
    Organization organization = organizationRepository.findByName(organizationName).get();
    userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR, User.Type.INTERNAL);
    userManager.insertUser(organization.getId(), username + "_owner", "test", "test", "test@example.com", Role.OWNER, User.Type.INTERNAL);
    LocalDateTime expiration = LocalDateTime.now().plusDays(5).plusHours(1);
    Map<String, String> desc = new HashMap<>();
    desc.put("en", "muh description");
    desc.put("it", "muh description");
    desc.put("de", "muh description");
    EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", "url", null, eventName, "event display name", organization.getId(), "muh location", "0.0", "0.0", ZoneId.systemDefault().getId(), desc, new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), new DateTimeModification(expiration.toLocalDate(), expiration.toLocalTime()), BigDecimal.TEN, "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, Collections.singletonList(PaymentProxy.OFFLINE), categories, false, new LocationDescriptor("", "", "", ""), 7, null, additionalServices);
    eventManager.createEvent(em);
    Event event = eventManager.getSingleEvent(eventName, username);
    Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    return Pair.of(event, username);
}
Also used : LocalDateTime(java.time.LocalDateTime) Organization(alfio.model.user.Organization) DateTimeModification(alfio.model.modification.DateTimeModification) LocationDescriptor(alfio.model.modification.support.LocationDescriptor) EventModification(alfio.model.modification.EventModification) Event(alfio.model.Event)

Example 12 with Organization

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

the class TicketHelper method getConfirmationTextBuilder.

private PartialTicketTextGenerator getConfirmationTextBuilder(HttpServletRequest request, Event event, TicketReservation ticketReservation, Ticket ticket, TicketCategory ticketCategory) {
    Organization organization = organizationRepository.getById(event.getOrganizationId());
    String ticketUrl = ticketReservationManager.ticketUpdateUrl(event, ticket.getUuid());
    return TemplateProcessor.buildPartialEmail(event, organization, ticketReservation, ticketCategory, templateManager, ticketUrl, request);
}
Also used : Organization(alfio.model.user.Organization)

Example 13 with Organization

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

the class AdminReservationManager method removeTicketsFromReservation.

private void removeTicketsFromReservation(TicketReservation reservation, Event event, List<Integer> ticketIds, boolean notify, String username, boolean removeReservation) {
    String reservationId = reservation.getId();
    if (notify && !ticketIds.isEmpty()) {
        Organization o = eventManager.loadOrganizer(event, username);
        ticketRepository.findByIds(ticketIds).forEach(t -> {
            if (StringUtils.isNotBlank(t.getEmail())) {
                sendTicketHasBeenRemoved(event, o, t);
            }
        });
    }
    Integer userId = userRepository.findIdByUserName(username).orElse(null);
    Date date = new Date();
    ticketIds.forEach(id -> auditingRepository.insert(reservationId, userId, event.getId(), CANCEL_TICKET, date, TICKET, id.toString()));
    ticketRepository.resetCategoryIdForUnboundedCategoriesWithTicketIds(ticketIds);
    ticketFieldRepository.deleteAllValuesForTicketIds(ticketIds);
    MapSqlParameterSource[] args = ticketIds.stream().map(id -> new MapSqlParameterSource("ticketId", id).addValue("reservationId", reservationId).addValue("eventId", event.getId()).addValue("newUuid", UUID.randomUUID().toString())).toArray(MapSqlParameterSource[]::new);
    jdbc.batchUpdate(ticketRepository.batchReleaseTickets(), args);
    if (!removeReservation) {
        // #407 update invoice/receipt model only if the reservation is still "PENDING", otherwise we could lead to accountancy problems
        if (UPDATE_INVOICE_STATUSES.contains(reservation.getStatus())) {
            updateInvoiceReceiptModel(event, reservation.getUserLanguage(), reservationId);
        }
        extensionManager.handleTicketCancelledForEvent(event, ticketRepository.findUUIDs(ticketIds));
    } else {
        extensionManager.handleReservationsCancelledForEvent(event, ticketRepository.findReservationIds(ticketIds));
    }
}
Also used : alfio.repository(alfio.repository) PaymentProxy(alfio.model.transaction.PaymentProxy) ZonedDateTime(java.time.ZonedDateTime) BiFunction(java.util.function.BiFunction) RequiredArgsConstructor(lombok.RequiredArgsConstructor) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) StringUtils(org.apache.commons.lang3.StringUtils) Collections.singletonList(java.util.Collections.singletonList) ResultStatus(alfio.model.result.Result.ResultStatus) BigDecimal(java.math.BigDecimal) Json(alfio.util.Json) ErrorCode(alfio.model.result.ErrorCode) Pair(org.apache.commons.lang3.tuple.Pair) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Triple(org.apache.commons.lang3.tuple.Triple) TemplateResource(alfio.util.TemplateResource) TICKET(alfio.model.Audit.EntityType.TICKET) StringUtils.trimToNull(org.apache.commons.lang3.StringUtils.trimToNull) Organization(alfio.model.user.Organization) TemplateManager(alfio.util.TemplateManager) Collectors(java.util.stream.Collectors) CANCEL_TICKET(alfio.model.Audit.EventType.CANCEL_TICKET) Stream(java.util.stream.Stream) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) alfio.model(alfio.model) UserRepository(alfio.repository.user.UserRepository) OptionalWrapper.optionally(alfio.util.OptionalWrapper.optionally) java.util(java.util) DuplicateReferenceException(alfio.manager.support.DuplicateReferenceException) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Function(java.util.function.Function) Attendee(alfio.model.modification.AdminReservationModification.Attendee) DateTimeModification(alfio.model.modification.DateTimeModification) TicketPriceContainer(alfio.model.decorator.TicketPriceContainer) TicketReservationStatus(alfio.model.TicketReservation.TicketReservationStatus) MessageSource(org.springframework.context.MessageSource) DateTimeModification.fromZonedDateTime(alfio.model.modification.DateTimeModification.fromZonedDateTime) TicketCategoryModification(alfio.model.modification.TicketCategoryModification) TicketsInfo(alfio.model.modification.AdminReservationModification.TicketsInfo) Result(alfio.model.result.Result) Component(org.springframework.stereotype.Component) MonetaryUtil(alfio.util.MonetaryUtil) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) Log4j2(lombok.extern.log4j.Log4j2) Category(alfio.model.modification.AdminReservationModification.Category) EventUtil.generateEmptyTickets(alfio.util.EventUtil.generateEmptyTickets) AdminReservationModification(alfio.model.modification.AdminReservationModification) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) Organization(alfio.model.user.Organization) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource)

Example 14 with Organization

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

the class ExtensionApiController method deleteEventSettingValue.

@DeleteMapping("/setting/organization/{orgShortName}/event/{shortName}/{id}")
public void deleteEventSettingValue(@PathVariable("orgShortName") String orgShortName, @PathVariable("shortName") String eventShortName, @PathVariable("id") int id, Principal principal) {
    Organization org = organizationRepository.findByName(orgShortName).orElseThrow(IllegalStateException::new);
    ensureOrganization(principal, org);
    Event event = eventRepository.findByShortName(eventShortName);
    ensureEventInOrganization(org, event);
    extensionService.deleteSettingValue(id, String.format("-%d-%d", org.getId(), event.getId()));
}
Also used : Organization(alfio.model.user.Organization) Event(alfio.model.Event)

Example 15 with Organization

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

the class ExtensionApiController method getParametersFor.

@RequestMapping(value = "/setting/organization/{orgShortName}/event/{shortName}", method = RequestMethod.GET)
public Map<Integer, List<ExtensionParameterMetadataAndValue>> getParametersFor(@PathVariable("orgShortName") String orgShortName, @PathVariable("shortName") String eventShortName, Principal principal) {
    Organization org = organizationRepository.findByName(orgShortName).orElseThrow(IllegalStateException::new);
    ensureOrganization(principal, org);
    Event event = eventRepository.findByShortName(eventShortName);
    ensureEventInOrganization(org, event);
    String pattern = String.format("-%d-%d", org.getId(), event.getId());
    return extensionService.getConfigurationParametersFor(pattern, pattern, "EVENT").stream().collect(Collectors.groupingBy(ExtensionParameterMetadataAndValue::getExtensionId));
}
Also used : Organization(alfio.model.user.Organization) 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