Food, User

This commit is contained in:
Malte Schulze Hobeling 2023-01-27 15:14:36 +01:00
parent b97fe83f40
commit a0eed3ce51
10 changed files with 366 additions and 100 deletions

View File

@ -84,6 +84,19 @@ public class AccountMgr {
return id; return id;
} }
protected static User getUserById(long id){
List<String> entry = Database.getEntryById("user",id);
String[] parts = entry.get(0).split(":");
Address address = getAddressById(id);
return new User(id,parts[1],parts[2],parts[4],parts[5],address,isWorker(String.valueOf(id)),isParent(String.valueOf(id)));
}
protected static Address getAddressById(long id){
List<String> entry = Database.getEntryById("address",id);
String[] parts = entry.get(0).split(":");
return new Address(Long.parseLong(parts[0]),parts[1],parts[2],parts[3],parts[4]);
}
/** /**
* creates entries in the database to match parent to child * creates entries in the database to match parent to child
* @param parentId id of parent * @param parentId id of parent

View File

@ -0,0 +1,37 @@
package com.bib.essensbestellungsverwaltung;
public class Address {
private long id;
private String street;
private String number;
private String plz;
private String city;
public long getId() {
return id;
}
public String getStreet() {
return street;
}
public String getNumber() {
return number;
}
public String getPlz() {
return plz;
}
public String getCity() {
return city;
}
public Address(long id, String street, String number, String plz, String city) {
this.id = id;
this.street = street;
this.number = number;
this.plz = plz;
this.city = city;
}
}

View File

@ -0,0 +1,25 @@
package com.bib.essensbestellungsverwaltung;
public class Allergy {
private final long id;
private final String name;
private final String handle;
public Allergy(long id, String name, String handle) {
this.id = id;
this.name = name;
this.handle = handle;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getHandle() {
return handle;
}
}

View File

@ -119,7 +119,13 @@ public class ConsoleLib {
System.out.print("Allergienummer: "); System.out.print("Allergienummer: ");
String allergies = sc.nextLine(); String allergies = sc.nextLine();
String[] allergyData = allergies.split(","); String[] allergyData = allergies.split(",");
if(FoodMgr.createFood(foodData,allergyData) < 1){ FoodType foodType = FoodMgr.getFoodTypeById(Long.parseLong(foodData[3]));
List<Allergy> allergyList = new ArrayList<>();
for (String data : allergyData) {
allergyList.add(FoodMgr.getAllergyById(Long.parseLong(data)));
}
Food food = new Food(foodData[0],foodData[1],true,foodType,allergyList);
if(FoodMgr.createFood(food) < 1){
System.out.println("Fehler"); System.out.println("Fehler");
} }
} }
@ -131,6 +137,9 @@ public class ConsoleLib {
while (id == -1){ while (id == -1){
System.out.print("Email: "); System.out.print("Email: ");
String email = sc.nextLine(); String email = sc.nextLine();
if(email.isEmpty()){
return -1;
}
System.out.print("Passwort: "); System.out.print("Passwort: ");
String pw = sc.nextLine(); String pw = sc.nextLine();
id = AccountMgr.login(email,pw); id = AccountMgr.login(email,pw);
@ -183,16 +192,25 @@ public class ConsoleLib {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: "); System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: ");
food_planData[0] = sc.nextLine(); food_planData[0] = sc.nextLine();
printConsole(FoodMgr.getVeganFood(false)); List<Food> veganMain = FoodMgr.getVeganFood(false);
for (Food food : veganMain) {
System.out.println(food.getId() + " : " + food.getName());
}
System.out.print("Veganes Hauptgericht Nr: "); System.out.print("Veganes Hauptgericht Nr: ");
food_planData[1] = sc.nextLine(); food_planData[1] = sc.nextLine();
printConsole(FoodMgr.getFood(false)); List<Food> foodMain = FoodMgr.getFood(false);
System.out.print("Zweites Hauptgericht Nr: "); System.out.print("Zweites Hauptgericht Nr: ");
food_planData[2] = sc.nextLine(); food_planData[2] = sc.nextLine();
printConsole(FoodMgr.getVeganFood(true)); List<Food> veganDessert = FoodMgr.getVeganFood(true);
for (Food food : veganDessert) {
System.out.println(food.getId() + " : " + food.getName());
}
System.out.print("Veganes Dessert Nr: "); System.out.print("Veganes Dessert Nr: ");
food_planData[3] = sc.nextLine(); food_planData[3] = sc.nextLine();
printConsole(FoodMgr.getFood(true)); List<Food> foodDessert = FoodMgr.getFood(true);
for (Food food : foodDessert) {
System.out.println(food.getId() + " : " + food.getName());
}
System.out.print("Zweites Dessert Nr: "); System.out.print("Zweites Dessert Nr: ");
food_planData[4] = sc.nextLine(); food_planData[4] = sc.nextLine();
long id = FoodMgr.createFood_plan(food_planData); long id = FoodMgr.createFood_plan(food_planData);
@ -207,7 +225,8 @@ public class ConsoleLib {
System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: "); System.out.print("Bitte geben Sie das Datum im Format YYYY-MM-DD an: ");
String date = sc.nextLine(); String date = sc.nextLine();
List<String> plan = FoodMgr.getFood_plan(date); List<String> plan = FoodMgr.getFood_plan(date);
List<String> food = new ArrayList<>(); List<String> foodList = new ArrayList<>();
Food food;
StringBuilder sb; StringBuilder sb;
for (String day : plan) { for (String day : plan) {
sb = new StringBuilder(); sb = new StringBuilder();
@ -216,23 +235,19 @@ public class ConsoleLib {
sb.append(parts[1]); sb.append(parts[1]);
sb.append(" Veganesgericht: "); sb.append(" Veganesgericht: ");
food = FoodMgr.getFoodById(Long.parseLong(parts[2])); food = FoodMgr.getFoodById(Long.parseLong(parts[2]));
String[] foodParts = food.get(0).split(":"); sb.append(food.getName());
sb.append(foodParts[1]);
sb.append(" Zweites Hauptgericht: "); sb.append(" Zweites Hauptgericht: ");
food = FoodMgr.getFoodById(Long.parseLong(parts[3])); food = FoodMgr.getFoodById(Long.parseLong(parts[3]));
foodParts = food.get(0).split(":"); sb.append(food.getName());
sb.append(foodParts[1]);
sb.append(" Veganesdessert: "); sb.append(" Veganesdessert: ");
food = FoodMgr.getFoodById(Long.parseLong(parts[4])); food = FoodMgr.getFoodById(Long.parseLong(parts[4]));
foodParts = food.get(0).split(":"); sb.append(food.getName());
sb.append(foodParts[1]);
sb.append(" Zweites Dessert: "); sb.append(" Zweites Dessert: ");
food = FoodMgr.getFoodById(Long.parseLong(parts[5])); food = FoodMgr.getFoodById(Long.parseLong(parts[5]));
foodParts = food.get(0).split(":"); sb.append(food.getName());
sb.append(foodParts[1]); foodList.add(sb.toString());
food.add(sb.toString());
} }
printConsole(food); printConsole(foodList);
} }
public static void createFood_selectionPrompt(){ public static void createFood_selectionPrompt(){

View File

@ -32,21 +32,23 @@ public class ConsoleMain {
} }
public static void defaultMenu(){ public static void defaultMenu(){
System.out.println("0: Programm beenden");
System.out.println("1: Login"); System.out.println("1: Login");
System.out.println("2: Essensplan anzeigen"); System.out.println("2: Essensplan anzeigen");
System.out.println("3: Programm beenden"); System.out.println("3: Registrieren");
System.out.print("Auswahl: "); System.out.print("Auswahl: ");
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
String selection = sc.nextLine(); String selection = sc.nextLine();
switch (selection) { switch (selection) {
case "0" -> currentUserId = -2;
case "1" -> { case "1" -> {
currentUserId = ConsoleLib.loginPrompt(); currentUserId = ConsoleLib.loginPrompt();
isWorker = AccountMgr.isWorker(String.valueOf(currentUserId)); isWorker = AccountMgr.isWorker(String.valueOf(currentUserId));
isParent = AccountMgr.isParent(String.valueOf(currentUserId)); isParent = AccountMgr.isParent(String.valueOf(currentUserId));
} }
case "2" -> ConsoleLib.showFood_planPrompt(); case "2" -> ConsoleLib.showFood_planPrompt();
case "3" -> currentUserId = -2; case "3" -> ConsoleLib.createParentPrompt();
} }
} }
@ -57,14 +59,14 @@ public class ConsoleMain {
System.out.println("3: Ein neues Kind anlegen"); System.out.println("3: Ein neues Kind anlegen");
System.out.println("4: Kind einem Elternteil zuordnen"); System.out.println("4: Kind einem Elternteil zuordnen");
System.out.println("5: Ein neues Essen anlegen"); System.out.println("5: Ein neues Essen anlegen");
System.out.println("6: Table"); System.out.println("6: Einen Essensplan erstellen");
System.out.println("7: Einen Essensplan erstellen"); System.out.println("7: Essensplan anzeigen");
System.out.println("8: Essensplan anzeigen"); System.out.println("8: Essen auswählen");
System.out.println("9: Löschen"); System.out.println("9: Bestellungen des Tages sammeln");
System.out.println("10: Essen auswählen"); System.out.println("10: Monatsabrechnung");
System.out.println("11: Bestellungen des Tages sammeln"); System.out.println("11: Preis ändern");
System.out.println("12: Monatsabrechnung"); System.out.println("x1: Table");
System.out.println("13: Preis ändern"); System.out.println("x2: Löschen");
System.out.print("Auswahl: "); System.out.print("Auswahl: ");
@ -81,14 +83,14 @@ public class ConsoleMain {
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId)); case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId)); case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
case "5" -> ConsoleLib.createFoodPrompt(); case "5" -> ConsoleLib.createFoodPrompt();
case "6" -> ConsoleLib.tablePrompt(); case "6" -> ConsoleLib.createFood_planPrompt();
case "7" -> ConsoleLib.createFood_planPrompt(); case "7" -> ConsoleLib.showFood_planPrompt();
case "8" -> ConsoleLib.showFood_planPrompt(); case "8" -> ConsoleLib.createFood_selectionPrompt();
case "9" -> ConsoleLib.deletePrompt(); case "9" -> ConsoleLib.dayOrderPrompt();
case "10" -> ConsoleLib.createFood_selectionPrompt(); case "10" -> ConsoleLib.invoicePrompt();
case "11" -> ConsoleLib.dayOrderPrompt(); case "11" -> ConsoleLib.changePricePrompt();
case "12" -> ConsoleLib.invoicePrompt(); case "x1" -> ConsoleLib.tablePrompt();
case "13" -> ConsoleLib.changePricePrompt(); case "x2" -> ConsoleLib.deletePrompt();
} }
} }
@ -96,7 +98,8 @@ public class ConsoleMain {
public static void parentMenu(){ public static void parentMenu(){
System.out.println("0: Ausloggen"); System.out.println("0: Ausloggen");
System.out.println("3: Ein neues Kind anlegen"); System.out.println("3: Ein neues Kind anlegen");
System.out.println("4: Kind einem Elternteil zuordnen"); System.out.println("7: Essensplan anzeigen");
System.out.println("8: Essen auswählen");
System.out.print("Auswahl: "); System.out.print("Auswahl: ");
@ -109,10 +112,9 @@ public class ConsoleMain {
isParent = false; isParent = false;
} }
case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId)); case "3" -> ConsoleLib.createChildPrompt(String.valueOf(currentUserId));
case "4" -> ConsoleLib.matchParentChildPrompt(String.valueOf(currentUserId));
case "6" -> ConsoleLib.tablePrompt(); case "6" -> ConsoleLib.tablePrompt();
default -> { case "7" -> ConsoleLib.showFood_planPrompt();
} case "8" -> ConsoleLib.createFood_selectionPrompt();
} }
} }

View File

@ -62,7 +62,8 @@ public class Database {
sql[2] = """ sql[2] = """
CREATE TABLE IF NOT EXISTS allergy ( CREATE TABLE IF NOT EXISTS allergy (
id integer PRIMARY KEY, id integer PRIMARY KEY,
name text UNIQUE name text UNIQUE,
handle text UNIQUE
);"""; );""";
sql[3] = """ sql[3] = """
CREATE TABLE IF NOT EXISTS severity ( CREATE TABLE IF NOT EXISTS severity (
@ -180,71 +181,71 @@ public class Database {
INSERT OR IGNORE INTO food_type (id,name) INSERT OR IGNORE INTO food_type (id,name)
VALUES ('3','Fleischhaltig');"""); VALUES ('3','Fleischhaltig');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('1','Eier');"""); VALUES('1','Eier','a');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('2','Soja');"""); VALUES('2','Soja','b');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('3','Milch');"""); VALUES('3','Milch','c');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('4','Erdnüsse');"""); VALUES('4','Erdnüsse','d');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('5','Weichtiere');"""); VALUES('5','Weichtiere','e');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('6','Krebstiere');"""); VALUES('6','Krebstiere','f');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('7','Getreide');"""); VALUES('7','Getreide','g');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('8','Senf');"""); VALUES('8','Senf','h');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('9','Sesam');"""); VALUES('9','Sesam','i');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('10','Schwefeldioxid und Sulfit');"""); VALUES('10','Schwefeldioxid und Sulfit','j');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('11','Nüsse');"""); VALUES('11','Nüsse','k');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('12','Sellerie');"""); VALUES('12','Sellerie','l');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('13','Fische');"""); VALUES('13','Fische','m');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('14','Lupinen');"""); VALUES('14','Lupinen','n');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('15','Nitrit-Pökelsalz');"""); VALUES('15','Nitrit-Pökelsalz','1');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('16','Phosphat');"""); VALUES('16','Phosphat','2');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('17','Nitrat');"""); VALUES('17','Nitrat','3');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('18','Antioxidationsmittel');"""); VALUES('18','Antioxidationsmittel','4');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('19','Farbstoff');"""); VALUES('19','Farbstoff','5');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('20','Geschmacksverstärker');"""); VALUES('20','Geschmacksverstärker','6');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('21','Süßungsmittel');"""); VALUES('21','Süßungsmittel','7');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO allergy (id,name) INSERT OR IGNORE INTO allergy (id,name,handle)
VALUES('22','Konservierungsstoff');"""); VALUES('22','Konservierungsstoff','8');""");
sqls.add(""" sqls.add("""
INSERT OR IGNORE INTO severity (id,name) INSERT OR IGNORE INTO severity (id,name)
VALUES('1','Harmlos');"""); VALUES('1','Harmlos');""");

View File

@ -0,0 +1,54 @@
package com.bib.essensbestellungsverwaltung;
import java.util.List;
public class Food {
private long id;
private String name;
private String description;
private boolean isDessert;
private FoodType foodType;
private List<Allergy> allergies;
public Food(long id, String name, String description, boolean isDessert, FoodType foodType, List<Allergy> allergies) {
this.id = id;
this.name = name;
this.description = description;
this.isDessert = isDessert;
this.foodType = foodType;
this.allergies = allergies;
}
public Food(String name, String description, boolean isDessert, FoodType foodType, List<Allergy> allergies) {
this.id = -1;
this.name = name;
this.description = description;
this.isDessert = isDessert;
this.foodType = foodType;
this.allergies = allergies;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public boolean isDessert() {
return isDessert;
}
public FoodType getFoodType() {
return foodType;
}
public List<Allergy> getAllergies() {
return allergies;
}
}

View File

@ -6,21 +6,21 @@ package com.bib.essensbestellungsverwaltung;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FoodMgr { public class FoodMgr {
/** /**
* inserts a food int to the database and creates the food_restriction entries * inserts a food int to the database and creates the food_restriction entries
* @param foodData name, description, isdessert, food_typeid
* @param allergyData allergyids
* @return id of food or -1 * @return id of food or -1
*/ */
public static long createFood(String[] foodData, String[] allergyData){ public static long createFood(Food food){
String[] foodH = {"name","description","isDessert","food_typeid"}; String[] foodH = {"name","description","isDessert","food_typeid"};
String[] food_restrictionH = {"foodid","allergyid"}; String[] food_restrictionH = {"foodid","allergyid"};
long id = Database.insert("food",foodH,foodData); String[] foodD = {food.getName(),food.getDescription(),(food.isDessert() ? "1" : "0"), String.valueOf(food.getFoodType().getId())};
if(allergyData.length > 0){ long id = Database.insert("food",foodH,foodD);
if(food.getAllergies().size() > 0){
String sId = String.valueOf(id); String sId = String.valueOf(id);
for (String allergyId : allergyData) { for (Allergy allergy : food.getAllergies()) {
String[] food_restrictionD = {sId,allergyId}; String[] food_restrictionD = {sId, String.valueOf(allergy.getId())};
Database.insert("food_restriction",food_restrictionH, food_restrictionD); Database.insert("food_restriction",food_restrictionH, food_restrictionD);
} }
} }
@ -42,10 +42,16 @@ public class FoodMgr {
* @param isDessert true for only desserts false for non desserts * @param isDessert true for only desserts false for non desserts
* @return a list of all non desserts or all desserts * @return a list of all non desserts or all desserts
*/ */
public static List<String> getFood(boolean isDessert){ public static List<Food> getFood(boolean isDessert){
String[] foodH = {"isDessert"}; String[] foodH = {"isDessert"};
String[] foodD = {(isDessert ? "1" : "0")}; String[] foodD = {(isDessert ? "1" : "0")};
return Database.select("food",foodH,foodD); List<String> entries = Database.select("food",foodH,foodD);
List<Food> foods = new ArrayList<>();
for (String entry : entries) {
String[] parts = entry.split(":");
foods.add(getFoodById(Long.parseLong(parts[0])));
}
return foods;
} }
/** /**
@ -53,10 +59,16 @@ public class FoodMgr {
* @param isDessert true for only desserts false for non desserts * @param isDessert true for only desserts false for non desserts
* @return a list of all vegan non desserts or all vegan desserts * @return a list of all vegan non desserts or all vegan desserts
*/ */
public static List<String> getVeganFood(boolean isDessert){ public static List<Food> getVeganFood(boolean isDessert){
String[] foodH = {"isDessert","food_typeid"}; String[] foodH = {"isDessert","food_typeid"};
String[] foodD = {(isDessert ? "1" : "0"),"1"}; String[] foodD = {(isDessert ? "1" : "0"),"1"};
return Database.select("food",foodH,foodD); List<String> entries = Database.select("food",foodH,foodD);
List<Food> foods = new ArrayList<>();
for (String entry : entries) {
String[] parts = entry.split(":");
foods.add(getFoodById(Long.parseLong(parts[0])));
}
return foods;
} }
/** /**
@ -70,8 +82,42 @@ public class FoodMgr {
return Database.select("food_plan",food_planH,food_planD); return Database.select("food_plan",food_planH,food_planD);
} }
public static List<String> getFoodById(long id){ public static Food getFoodById(long id){
return Database.getEntryById("food",id); List<String> entry = Database.getEntryById("food",id);
String[] parts = entry.get(0).split(":");
String name = parts[1];
String description = parts[2];
boolean isDessert;
isDessert = parts[3].equals("0");
FoodType foodType = getFoodTypeById(Long.parseLong(parts[4]));
List<Allergy> allergies = getAllergies(id);
return new Food(id,name,description,isDessert,foodType,allergies);
}
public static FoodType getFoodTypeById(long id){
List<String> entry = Database.getEntryById("foodtype",id);
String[] typeParts = entry.get(0).split(":");
return new FoodType(Long.parseLong(typeParts[0]),typeParts[1]);
}
public static Allergy getAllergyById(long id){
String[] allergyH = {"id"};
String[] allergyD = {String.valueOf(id)};
List<String> allergies = Database.select("allergy",allergyH,allergyD);
String[] allergyParts = allergies.get(0).split(":");
return new Allergy(id,allergyParts[1],allergyParts[2]);
}
public static List<Allergy> getAllergies(long foodId){
List<Allergy> allergies = new ArrayList<>();
String[] restrictionsH = {"foodid"};
String[] restrictionsD = {String.valueOf(foodId)};
List<String> restrictions = Database.select("food_restrictions",restrictionsH,restrictionsD);
for (String restriction : restrictions) {
String[] partsRestrictions = restriction.split(":");
allergies.add(getAllergyById(Long.parseLong(partsRestrictions[2])));
}
return allergies;
} }
/** /**
@ -100,11 +146,10 @@ public class FoodMgr {
List<String> food_plan = getFood_plan(date); List<String> food_plan = getFood_plan(date);
String[] food_planParts = food_plan.get(0).split(":"); String[] food_planParts = food_plan.get(0).split(":");
for(int i = 2; i < 2+4; i++){ for(int i = 2; i < 2+4; i++){
List<String> food = getFoodById(Long.parseLong(food_planParts[i])); Food food = getFoodById(Long.parseLong(food_planParts[i]));
String[] foodParts = food.get(0).split(":"); String foodName = food.getName();
String foodName = foodParts[1];
String[] food_selectionH = {"food_planid","foodid"}; String[] food_selectionH = {"food_planid","foodid"};
String[] food_selectionD = {food_planParts[0],foodParts[0]}; String[] food_selectionD = {food_planParts[0], String.valueOf(food.getId())};
int count = Database.count("food_selection",food_selectionH,food_selectionD); int count = Database.count("food_selection",food_selectionH,food_selectionD);
orders.add(foodName+":"+count); orders.add(foodName+":"+count);
} }

View File

@ -0,0 +1,19 @@
package com.bib.essensbestellungsverwaltung;
public class FoodType {
private long id;
private String name;
public FoodType(long id, String name) {
this.id = id;
this.name = name;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
}

View File

@ -0,0 +1,55 @@
package com.bib.essensbestellungsverwaltung;
public class User {
private long id;
private String name;
private String firstname;
private String password;
private String email;
private Address address;
private boolean isWorker;
private boolean isParent;
public User(long id, String name, String firstname, String password, String email, Address address, boolean isWorker, boolean isParent) {
this.id = id;
this.name = name;
this.firstname = firstname;
this.password = password;
this.email = email;
this.address = address;
this.isWorker = isWorker;
this.isParent = isParent;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getFirstname() {
return firstname;
}
public String getPassword() {
return password;
}
public String getEmail() {
return email;
}
public Address getAddress() {
return address;
}
public boolean isWorker() {
return isWorker;
}
public boolean isParent() {
return isParent;
}
}