Search in sources :

Example 6 with EventAndOrganizationId

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

the class ConfigurationManager method loadCategoryConfig.

public Map<ConfigurationKeys.SettingCategory, List<Configuration>> loadCategoryConfig(int eventId, int categoryId, String username) {
    User user = userManager.findUserByUsername(username);
    EventAndOrganizationId event = eventRepository.findEventAndOrganizationIdById(eventId);
    int organizationId = event.getOrganizationId();
    if (!userManager.isOwnerOfOrganization(user, organizationId)) {
        return Collections.emptyMap();
    }
    Map<ConfigurationKeys.SettingCategory, List<Configuration>> existing = configurationRepository.findCategoryConfiguration(organizationId, eventId, categoryId).stream().sorted().collect(groupByCategory());
    return groupByCategory(CATEGORY_CONFIGURATION, existing);
}
Also used : User(alfio.model.user.User) EventAndOrganizationId(alfio.model.EventAndOrganizationId) Collectors.toList(java.util.stream.Collectors.toList)

Example 7 with EventAndOrganizationId

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

the class ConfigurationManager method getSingleConfigForEvent.

public String getSingleConfigForEvent(int eventId, String keyAsString, String username) {
    User user = userManager.findUserByUsername(username);
    EventAndOrganizationId event = eventRepository.findEventAndOrganizationIdById(eventId);
    int organizationId = event.getOrganizationId();
    if (!userManager.isOwnerOfOrganization(user, organizationId)) {
        return null;
    }
    var key = safeValueOf(keyAsString);
    return getFirstConfigurationResult(configurationRepository.findByEventAndKey(organizationId, eventId, key.name()), keyAsString);
}
Also used : User(alfio.model.user.User) EventAndOrganizationId(alfio.model.EventAndOrganizationId)

Example 8 with EventAndOrganizationId

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

the class ConfigurationLevelTest method event.

@Test
void event() {
    ConfigurationLevel event = ConfigurationLevel.event(new EventAndOrganizationId(1, 666));
    assertTrue(event instanceof ConfigurationLevels.EventLevel);
    assertEquals(ConfigurationPathLevel.EVENT, event.getPathLevel());
    var eventLevel = (ConfigurationLevels.EventLevel) event;
    assertEquals(666, eventLevel.organizationId);
    assertEquals(1, eventLevel.eventId);
}
Also used : EventAndOrganizationId(alfio.model.EventAndOrganizationId) Test(org.junit.jupiter.api.Test)

Example 9 with EventAndOrganizationId

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

the class ConfigurationLevelTest method ticketCategory.

@Test
void ticketCategory() {
    ConfigurationLevel ticketCategory = ConfigurationLevel.ticketCategory(new EventAndOrganizationId(1, 666), 777);
    assertTrue(ticketCategory instanceof ConfigurationLevels.CategoryLevel);
    assertEquals(ConfigurationPathLevel.TICKET_CATEGORY, ticketCategory.getPathLevel());
    var categoryLevel = (ConfigurationLevels.CategoryLevel) ticketCategory;
    assertEquals(666, categoryLevel.organizationId);
    assertEquals(1, categoryLevel.eventId);
    assertEquals(777, categoryLevel.categoryId);
}
Also used : EventAndOrganizationId(alfio.model.EventAndOrganizationId) Test(org.junit.jupiter.api.Test)

Example 10 with EventAndOrganizationId

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

the class EuVatCheckerTest method init.

@BeforeEach
public void init() {
    client = mock(EUVatChecker.class);
    configurationManager = mock(ConfigurationManager.class);
    eventAndOrganizationId = mock(EventAndOrganizationId.class);
    ConfigurationLevel cl = ConfigurationLevel.event(eventAndOrganizationId);
    when(eventAndOrganizationId.getConfigurationLevel()).thenReturn(cl);
    when(configurationManager.getFor(eq(ConfigurationKeys.ENABLE_EU_VAT_DIRECTIVE), any(ConfigurationLevel.class))).thenReturn(existing(ConfigurationKeys.ENABLE_EU_VAT_DIRECTIVE, "true"));
    when(configurationManager.getFor(eq(ConfigurationKeys.ENABLE_VIES_VALIDATION), any(ConfigurationLevel.class))).thenReturn(existing(ConfigurationKeys.ENABLE_VIES_VALIDATION, "true"));
    when(configurationManager.getForSystem(ConfigurationKeys.EU_COUNTRIES_LIST)).thenReturn(existing(ConfigurationKeys.EU_COUNTRIES_LIST, "IE"));
    when(configurationManager.getFor(eq(ConfigurationKeys.COUNTRY_OF_BUSINESS), any(ConfigurationLevel.class))).thenReturn(existing(ConfigurationKeys.COUNTRY_OF_BUSINESS, "IT"));
    when(configurationManager.getFor(eq(EnumSet.of(ConfigurationKeys.ENABLE_EU_VAT_DIRECTIVE, ConfigurationKeys.COUNTRY_OF_BUSINESS, ConfigurationKeys.ENABLE_REVERSE_CHARGE_ONLINE, ConfigurationKeys.ENABLE_REVERSE_CHARGE_IN_PERSON)), any())).thenReturn(Map.of(ConfigurationKeys.ENABLE_EU_VAT_DIRECTIVE, existing(ConfigurationKeys.ENABLE_EU_VAT_DIRECTIVE, "true"), ConfigurationKeys.COUNTRY_OF_BUSINESS, existing(ConfigurationKeys.COUNTRY_OF_BUSINESS, "IT"), ConfigurationKeys.ENABLE_REVERSE_CHARGE_ONLINE, missing(ConfigurationKeys.ENABLE_REVERSE_CHARGE_ONLINE), ConfigurationKeys.ENABLE_REVERSE_CHARGE_IN_PERSON, missing(ConfigurationKeys.ENABLE_REVERSE_CHARGE_IN_PERSON)));
}
Also used : ConfigurationLevel(alfio.manager.system.ConfigurationLevel) EventAndOrganizationId(alfio.model.EventAndOrganizationId) EUVatChecker(ch.digitalfondue.vatchecker.EUVatChecker) ConfigurationManager(alfio.manager.system.ConfigurationManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

EventAndOrganizationId (alfio.model.EventAndOrganizationId)16 User (alfio.model.user.User)5 Json (alfio.util.Json)3 Test (org.junit.jupiter.api.Test)3 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)3 Ticket (alfio.model.Ticket)2 PollModification (alfio.model.modification.PollModification)2 PollOptionModification (alfio.model.modification.PollOptionModification)2 alfio.model.poll (alfio.model.poll)2 ErrorCode (alfio.model.result.ErrorCode)2 Result (alfio.model.result.Result)2 alfio.repository (alfio.repository)2 PinGenerator (alfio.util.PinGenerator)2 java.util (java.util)2 Objects.requireNonNullElse (java.util.Objects.requireNonNullElse)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 IntStream (java.util.stream.IntStream)2 AllArgsConstructor (lombok.AllArgsConstructor)2