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);
}
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);
}
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));
}
}
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()));
}
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));
}
Aggregations