Commit 98a54f83 authored by Filip Hujer's avatar Filip Hujer
Browse files

Update marketEventInitializer

parent 9d52b304
......@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -73,18 +74,31 @@ public class MarketEventInitializer extends DomainInitializerImpl {
event.setName(location.getName() + " market");
eventService.create(event);
List<String> standTypes = List.of("Front", "Back", "Middle");
Map<String, Long> standPrices = Map.of("Front", 2000L, "Middle", 1500L, "Back", 1000L);
event.setStands(Set.of(new Stand(), new Stand(), new Stand()));
event.getStands().forEach(stand -> stand.setItemCategories(Set.of(ItemCategory.values()[faker.number().numberBetween(0,6)])));
event.getStands().forEach(stand -> stand.setStandType(
new StandType(
standTypes.get(faker.number().numberBetween(0, 3))
)));
event.getStands().forEach(stand -> stand.getStandType().setPriceInCents(standPrices.get(stand.getStandType().getName())));
List<String> standTypes = List.of("Front", "Back", "Middle", "Pre Burzujov", "Ako Strom", "Nik Ho Nechce");
Map<String, Long> standPrices = Map.of("Front", 2000L, "Middle", 1500L, "Back", 1000L, "Pre Burzujov", 5000L, "Ako Strom", 3500L, "Nik Ho Nechce", 1000L);
Set<Stand> allStands = new HashSet<>();
standTypes.forEach(standTypeName -> {
StandType standType = new StandType();
standType.setName(standTypeName);
standType.setPriceInCents(standPrices.get(standType.getName()));
standTypeService.create(standType);
Set<Stand> stands = new HashSet<>();
for (int j = 0; j < 3; j++) {
stands.add(new Stand());
}
stands.forEach(stand -> stand.setStandType(standType));
stands.forEach(stand -> stand.setItemCategories(Set.of(ItemCategory.values()[faker.number().numberBetween(0,6)])));
allStands.addAll(stands);
});
event.setStands(allStands);
event.getStands().forEach(stand -> stand.setEvent(event));
event.getStands().forEach(stand -> standTypeService.create(stand.getStandType()));
event.getStands().forEach(standService::create);
eventService.update(event);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment