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