diff --git a/src/main/java/catering/orderCatalog/CatalogController.java b/src/main/java/catering/orderCatalog/CatalogController.java index b5facef..ee45af6 100644 --- a/src/main/java/catering/orderCatalog/CatalogController.java +++ b/src/main/java/catering/orderCatalog/CatalogController.java @@ -1,5 +1,6 @@ package catering.orderCatalog; +import catering.order.OrderType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -17,7 +18,7 @@ public class CatalogController { public CatalogController(CustomCatalogEntryRepository catalogEntryRepository) { inventory = new HashSet<>(); formCatalogEntry = new CustomCatalogEntry( - CustomCatalogEntry.EventType.EVENT_CATERING, + OrderType.EVENT_CATERING, new HashMap(), 0, 0); @@ -38,7 +39,7 @@ public class CatalogController { } @PostMapping("/catalog_editor/catalog_add") - public String catalog_add(@RequestParam CustomCatalogEntry.EventType eventType, + public String catalog_add(@RequestParam OrderType eventType, @RequestParam int minimumTimePeriod, @RequestParam int totalCost, Model model) { @@ -48,14 +49,13 @@ public class CatalogController { products.put(product.getName(), product.getAmount()); } - System.out.println("Products looks like this:" + products); catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry( eventType, products, minimumTimePeriod, totalCost)); this.formCatalogEntry = new CustomCatalogEntry( - CustomCatalogEntry.EventType.EVENT_CATERING, + OrderType.EVENT_CATERING, new HashMap(), 0, 0); @@ -95,7 +95,7 @@ public class CatalogController { @PostMapping("/catalog_editor/add_time") public String add_time(@RequestParam int minimumTimePeriod, - @RequestParam CustomCatalogEntry.EventType eventType, + @RequestParam OrderType eventType, @RequestParam Map products, Model model) { formCatalogEntry.setMinimumTimePeriod(minimumTimePeriod); @@ -107,19 +107,19 @@ public class CatalogController { public String chooseEvent(String events) { switch (events) { case "event_catering": - formCatalogEntry.setEventType(CustomCatalogEntry.EventType.EVENT_CATERING); + formCatalogEntry.setEventType(OrderType.EVENT_CATERING); break; - case "party_service": - formCatalogEntry.setEventType(CustomCatalogEntry.EventType.PARTY_SERVICE); + case "sushi_night": + formCatalogEntry.setEventType(OrderType.SUSHI_NIGHT); break; case "mobile_breakfast": - formCatalogEntry.setEventType(CustomCatalogEntry.EventType.MOBILE_BREAKFAST); + formCatalogEntry.setEventType(OrderType.MOBILE_BREAKFAST); break; case "rent_a_cook": - formCatalogEntry.setEventType(CustomCatalogEntry.EventType.RENT_A_COOK); + formCatalogEntry.setEventType(OrderType.RENT_A_COOK); break; default: - formCatalogEntry.setEventType(CustomCatalogEntry.EventType.EVENT_CATERING); + formCatalogEntry.setEventType(OrderType.EVENT_CATERING); break; } diff --git a/src/main/java/catering/orderCatalog/CustomCatalogEntry.java b/src/main/java/catering/orderCatalog/CustomCatalogEntry.java index 3eeacb2..0b5bd6b 100644 --- a/src/main/java/catering/orderCatalog/CustomCatalogEntry.java +++ b/src/main/java/catering/orderCatalog/CustomCatalogEntry.java @@ -1,16 +1,18 @@ package catering.orderCatalog; +import catering.order.OrderType; + import java.util.Map; public class CustomCatalogEntry { static int idCounter = 0; private int id; - private EventType eventType; + private OrderType eventType; private Map products; private int minimumTimePeriod; // Declared as int for simplification of the prototype. Only whole hours. private int totalCost; // Should actually accumulate the price of all items. - public CustomCatalogEntry(EventType eventType, Map products, int minimumTimePeriod, int totalCost) { + public CustomCatalogEntry(OrderType eventType, Map products, int minimumTimePeriod, int totalCost) { this.id = idCounter; idCounter++; this.eventType = eventType; @@ -23,7 +25,7 @@ public class CustomCatalogEntry { return id; } - public EventType getEventType() { + public OrderType getEventType() { return eventType; } @@ -39,7 +41,7 @@ public class CustomCatalogEntry { return totalCost; } - public void setEventType(EventType eventType) { + public void setEventType(OrderType eventType) { this.eventType = eventType; } @@ -57,11 +59,4 @@ public class CustomCatalogEntry { public void setTotalCost(int totalCost) { this.totalCost = totalCost; } - - public enum EventType { - EVENT_CATERING, - PARTY_SERVICE, - MOBILE_BREAKFAST, - RENT_A_COOK - } } diff --git a/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java b/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java index 6359cbb..dc8d47d 100644 --- a/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java +++ b/src/main/java/catering/orderCatalog/CustomCatalogEntryDataInitializer.java @@ -1,5 +1,6 @@ package catering.orderCatalog; +import catering.order.OrderType; import org.salespointframework.core.DataInitializer; import org.springframework.stereotype.Component; @@ -20,7 +21,7 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer { Map products = new HashMap<>(); products.put("Brötchen", 30); products.put("Kerze", 20); - catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(CustomCatalogEntry.EventType.EVENT_CATERING, products, 4, 500)); + catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(OrderType.EVENT_CATERING, products, 4, 500)); products = new HashMap<>(); products.put("Kuchen", 3); @@ -28,6 +29,6 @@ public class CustomCatalogEntryDataInitializer implements DataInitializer { products.put("Pizza Margherita", 1); products.put("Pizza Quattro Formaggi", 1); products.put("Ballon", 20); - catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(CustomCatalogEntry.EventType.PARTY_SERVICE, products, 2, 1000)); + catalogEntryRepository.addCatalogEntry(new CustomCatalogEntry(OrderType.RENT_A_COOK, products, 2, 1000)); } } diff --git a/src/main/resources/templates/catalog_editor.html b/src/main/resources/templates/catalog_editor.html index ae53931..c2e9ee1 100644 --- a/src/main/resources/templates/catalog_editor.html +++ b/src/main/resources/templates/catalog_editor.html @@ -13,7 +13,7 @@