Compare commits
	
		
			11 Commits
		
	
	
		
			0303458524
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 5d455c6291 | ||
| 93512fa4fa | |||
|   | 1d9070551e | ||
|   | cf9ba3d3f9 | ||
| 8ed1085e40 | |||
| 72412b3b47 | |||
|   | fd36d1ab97 | ||
|   | 7f96fc4b8a | ||
|   | cdafca2e54 | ||
| 8b7a611e2a | |||
| 336a6fc89d | 
							
								
								
									
										2
									
								
								.idea/.name
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/.name
									
									
									
										generated
									
									
									
								
							| @@ -1 +1 @@ | ||||
| HelloController.java | ||||
| Essensverwaltung.java | ||||
							
								
								
									
										20
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -76,6 +76,26 @@ | ||||
|                     </execution> | ||||
|                 </executions> | ||||
|             </plugin> | ||||
|             <plugin> | ||||
|                 <groupId>org.apache.maven.plugins</groupId> | ||||
|                 <artifactId>maven-shade-plugin</artifactId> | ||||
|                 <version>3.2.1</version> | ||||
|                 <executions> | ||||
|                     <execution> | ||||
|                         <phase>package</phase> | ||||
|                         <goals> | ||||
|                             <goal>shade</goal> | ||||
|                         </goals> | ||||
|                         <configuration> | ||||
|                             <transformers> | ||||
|                                 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||||
|                                     <mainClass>de.subway_surfers.vpr_app.Main</mainClass> | ||||
|                                 </transformer> | ||||
|                             </transformers> | ||||
|                         </configuration> | ||||
|                     </execution> | ||||
|                 </executions> | ||||
|             </plugin> | ||||
|         </plugins> | ||||
|     </build> | ||||
| </project> | ||||
| @@ -5,6 +5,10 @@ package Logik; | ||||
|  | ||||
| import RestAPISchnittstelle.RestApiClient; | ||||
|  | ||||
| /** | ||||
|  * @author Sven Alteköster und Samuel Wolff | ||||
|  */ | ||||
|  | ||||
| public class Account { | ||||
|  | ||||
| 	// region Felder | ||||
|   | ||||
| @@ -9,6 +9,9 @@ package Logik; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Samuel Wolff | ||||
|  */ | ||||
| public class ElternAccount extends Account { | ||||
|  | ||||
| 	// region Felder | ||||
| @@ -37,6 +40,7 @@ public class ElternAccount extends Account { | ||||
|  | ||||
| 	/** | ||||
| 	 * Lädt eine Rechnung herunter | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void rechnungHerunterladen() { | ||||
|  | ||||
| @@ -44,6 +48,7 @@ public class ElternAccount extends Account { | ||||
|  | ||||
| 	/** | ||||
| 	 * Bestellt eine Mahlzeit | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void mahlzeitBestellen() { | ||||
|  | ||||
| @@ -52,6 +57,7 @@ public class ElternAccount extends Account { | ||||
| 	/** | ||||
| 	 * Zeigt Rechnungen gefiltert an | ||||
| 	 * @param params Die Filter Argumente | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void rechnungAnzeigen(String params) { | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,9 @@ package Logik; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Samuel Wolff und Sven Alteköster | ||||
|  */ | ||||
| public class Kind { | ||||
|  | ||||
| 	// region Felder | ||||
|   | ||||
| @@ -2,6 +2,9 @@ package Logik; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Sven Alteköster | ||||
|  */ | ||||
| public class Mahlzeit { | ||||
|  | ||||
| 	private int id; | ||||
|   | ||||
| @@ -9,6 +9,9 @@ package Logik; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Samuel Wolff | ||||
|  */ | ||||
| public class MitarbeiterAccount extends Account { | ||||
|  | ||||
| 	// region Konstrukoren | ||||
| @@ -25,12 +28,12 @@ public class MitarbeiterAccount extends Account { | ||||
| 	 * @param passwort Das neue Passwort | ||||
| 	 */ | ||||
| 	public void passwortZurzecksetzen(Account other, String passwort) { | ||||
| 		// Soll das so? | ||||
| 		other.setPasswort(passwort); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Bestellt eine Mahlzeit | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void mahlzeitBestellen() { | ||||
|  | ||||
| @@ -38,6 +41,7 @@ public class MitarbeiterAccount extends Account { | ||||
|  | ||||
| 	/** | ||||
| 	 * Ändert einen Tagesplan | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void tagesplanAendern() { | ||||
|  | ||||
| @@ -59,25 +63,24 @@ public class MitarbeiterAccount extends Account { | ||||
| 	/** | ||||
| 	 * Zeigt Rechnungen gefilter nach params an | ||||
| 	 * @param params Die Filter Arguemente | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void rechnungAnzeigen(String[] params) { | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	// TODO sollte hier nicht noch ein User mitgegeben werden? | ||||
|  | ||||
| 	/** | ||||
| 	 * Weist ein Kind einem Account zu | ||||
| 	 * @param kind Das zuzuweisende Kind | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void kinderZuweisen(Kind kind) { | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	// TODO hier auch? | ||||
|  | ||||
| 	/** | ||||
| 	 * Zeigt einen Benutzer an | ||||
| 	 * @deprecated | ||||
| 	 */ | ||||
| 	public void zeigeBenutzer() { | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,9 @@ package Logik; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Sven Alteköster | ||||
|  */ | ||||
| public class Tagesplan { | ||||
|  | ||||
| 	private ArrayList<Mahlzeit> gerichte; | ||||
|   | ||||
| @@ -1,5 +1,8 @@ | ||||
| package Logik; | ||||
|  | ||||
| /** | ||||
|  * @author Sven Alteköster | ||||
|  */ | ||||
| public class Zutat { | ||||
| 	private String name; | ||||
| 	public Zutat (String name) { | ||||
|   | ||||
| @@ -7,6 +7,9 @@ | ||||
|  | ||||
| package RestAPISchnittstelle; | ||||
|  | ||||
| /** | ||||
|  * @author Samuel Wolff | ||||
|  */ | ||||
| public interface IRestAPI { | ||||
|  | ||||
| 	// region Get | ||||
|   | ||||
| @@ -34,19 +34,6 @@ public class RestApiClient implements IRestAPI{ | ||||
| 		gson = new Gson(); | ||||
| 	} | ||||
|  | ||||
| 	public static void main(String[] args){ | ||||
|  | ||||
| 		RestApiClient client1 = new RestApiClient(); | ||||
|  | ||||
| 		client1.delete("Kind", 15); | ||||
|  | ||||
|  | ||||
| 		Tagesplan t = client1.getGerichteOnTag("2023-12-17"); | ||||
|  | ||||
| 		for(Mahlzeit m : t.getGerichte()) | ||||
| 			System.out.println(m); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Methode für einen Get-Aufruf. Ruft alle Elemente einer Tabelle auf. | ||||
| 	 * | ||||
| @@ -68,8 +55,8 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 			return httpResponse.body(); | ||||
| 		} | ||||
| 		catch(ConnectException conex){ | ||||
| @@ -106,7 +93,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode() + httpResponse.body()); | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode() + httpResponse.body()); | ||||
|  | ||||
| 			return httpResponse.body(); | ||||
|  | ||||
| @@ -149,8 +136,8 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 			return httpResponse.body(); | ||||
| 		} | ||||
| 		catch(ConnectException conex){ | ||||
| @@ -191,8 +178,8 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode() + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode() + httpResponse.body()); | ||||
|  | ||||
| 			return httpResponse.body(); | ||||
|  | ||||
| @@ -234,9 +221,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 		} | ||||
| 		catch(ConnectException conex){ | ||||
| 			Alert alert = new Alert(Alert.AlertType.INFORMATION); | ||||
| @@ -259,7 +246,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 	public void post(String controllerName, String jsonData) { | ||||
| 		URI apiUri = URI.create(String.format("%s/%s", urlBase,controllerName)); | ||||
|  | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
|  | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .timeout(Duration.ofSeconds(timeout)) | ||||
| @@ -272,9 +259,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 		} | ||||
| 		catch(ConnectException conex){ | ||||
| 			Alert alert = new Alert(Alert.AlertType.INFORMATION); | ||||
| @@ -297,7 +284,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 	public void delete(String controllerName, int id) { | ||||
| 		URI apiUri = URI.create(String.format("%s/%s/%d", urlBase,controllerName, id)); | ||||
|  | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
|  | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .timeout(Duration.ofSeconds(timeout)) | ||||
| @@ -310,9 +297,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 		} | ||||
| 		catch(ConnectException conex){ | ||||
| 			Alert alert = new Alert(Alert.AlertType.INFORMATION); | ||||
| @@ -343,9 +330,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
|  | ||||
| 			JsonElement jsonElement = JsonParser.parseString(httpResponse.body()); | ||||
| 			JsonArray jsonArray = jsonElement.getAsJsonArray(); | ||||
| @@ -384,7 +371,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 		passwort = passwort.substring(1, passwort.length()-1); | ||||
|  | ||||
| 		URI apiUri = URI.create(String.format("%s/Benutzer/anmeldeVersuch?Benutzername=%s&passwort=%s", urlBase, benutzer, passwort)); | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .timeout(Duration.ofSeconds(timeout)) | ||||
| 											 .uri(apiUri) | ||||
| @@ -396,9 +383,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
| 			if(httpResponse.body().equals("true")) | ||||
| 				return true; | ||||
| 			else{ | ||||
| @@ -434,7 +421,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 	public Tagesplan getGerichteOnTag(String datum){ | ||||
|  | ||||
| 		URI apiUri = URI.create(String.format("%s/Tagesplan/getGerichteOnTag?datum=%s", urlBase, datum)); | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .timeout(Duration.ofSeconds(timeout)) | ||||
| 											 .uri(apiUri) | ||||
| @@ -446,9 +433,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
|  | ||||
| 			Tagesplan t = new Tagesplan(datum); | ||||
|  | ||||
| @@ -492,7 +479,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 	public int getGerichtIdOnTag(String name, String datum){ | ||||
|  | ||||
| 		URI apiUri = URI.create(String.format("%s/Tagesplan/getGerichtIdOnTag?name=%s&datum=%s", urlBase, name, datum)); | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .uri(apiUri) | ||||
| 											 .header("Content-Type", "application/json") | ||||
| @@ -503,9 +490,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Response Body: " + httpResponse.body()); | ||||
|  | ||||
| 			JsonElement jsonElement = JsonParser.parseString(httpResponse.body()); | ||||
|  | ||||
| @@ -528,7 +515,7 @@ public class RestApiClient implements IRestAPI{ | ||||
| 	 */ | ||||
| 	public void deleteGericht(int id){ | ||||
| 		URI apiUri = URI.create(String.format("%s/Tagesplan/%d", urlBase, id)); | ||||
| 		System.out.println(apiUri); | ||||
| 		//System.out.println(apiUri); | ||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||
| 											 .uri(apiUri) | ||||
| 											 .header("Content-Type", "application/json") | ||||
| @@ -539,9 +526,9 @@ public class RestApiClient implements IRestAPI{ | ||||
| 			// Send the request and get the response | ||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||
|  | ||||
| 			// Print the response status code and body | ||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| 			System.out.println("Delete Gericht: Response Body: " + httpResponse.body()); | ||||
| //			// Print the response status code and body | ||||
| //			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||
| //			System.out.println("Delete Gericht: Response Body: " + httpResponse.body()); | ||||
|  | ||||
|  | ||||
| 		} catch (Exception e) { | ||||
|   | ||||
| @@ -35,6 +35,10 @@ public class AccounterstellungMitarbeiter { | ||||
|  | ||||
| 	private ArrayList<Kind> kinder; | ||||
|  | ||||
| 	/** | ||||
| 	 * Initialisiert die Accounterstellungsmaske | ||||
| 	 * @author Sven Alteköster | ||||
| 	 */ | ||||
| 	public void initialize() { | ||||
| 		//Die Radiobuttons zum auswählen eines Accountypes werden einer ToggleGroup hinzugefügt | ||||
| 		accountTyp = new ToggleGroup(); | ||||
| @@ -43,6 +47,7 @@ public class AccounterstellungMitarbeiter { | ||||
|  | ||||
| 		einmalpw.setText(einmalPwGenerieren()); | ||||
|  | ||||
| 		//kinder wird initialisiert | ||||
| 		kinder = new ArrayList<>(); | ||||
| 	} | ||||
|  | ||||
| @@ -62,7 +67,7 @@ public class AccounterstellungMitarbeiter { | ||||
| 	 * @author Sven Alteköster | ||||
| 	 */ | ||||
| 	public void onAbmelden(ActionEvent actionEvent) { | ||||
| 		//VerwaltungApplication.abmelden(); | ||||
| 		VerwaltungApplication.abmelden(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| @@ -190,7 +195,6 @@ public class AccounterstellungMitarbeiter { | ||||
| 	 */ | ||||
| 	public void onSpeichern(ActionEvent actionEvent) { | ||||
| 		if (eingabenGueltig()) { | ||||
|  | ||||
| 			//speichert das aktuelle Passwort zwischen | ||||
| 			String passwort = einmalpw.getText(); | ||||
|  | ||||
| @@ -231,9 +235,6 @@ public class AccounterstellungMitarbeiter { | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			//Die Liste, zum Speichern der gespeicherten Liste wird zurückgesetzt, da die Kinder jetzt im Elternobjekt gespeichert werden | ||||
| 			kinder.clear(); | ||||
|  | ||||
| 			//Das Elternelement wird in der DB gespeichert, wenn es keinen gleichnamigen Account gibt. | ||||
| 			if (!kontoVorhanden) { | ||||
| 				api.post("Benutzer", gson.toJson(neuer)); | ||||
| @@ -245,7 +246,19 @@ public class AccounterstellungMitarbeiter { | ||||
| 				for (Kind k : ((ElternAccount)neuer).getKinder()) { | ||||
| 					//setzen des Fremdschlüssels bid | ||||
| 					k.setBid(id); | ||||
| 					api.post("Kind", gson.toJson(k)); | ||||
| 					String neues = gson.toJson(k); | ||||
|  | ||||
| 					//region hässlich | ||||
| 					neues = neues.replaceAll("ä", "ae"); | ||||
| 					neues = neues.replaceAll("ö", "oe"); | ||||
| 					neues = neues.replaceAll("ü", "ue"); | ||||
| 					neues = neues.replaceAll("Ä", "Ae"); | ||||
| 					neues = neues.replaceAll("Ö", "Oe"); | ||||
| 					neues = neues.replaceAll("Ü", "Ue"); | ||||
| 					neues = neues.replaceAll("ß", "ss"); | ||||
| 					//endregion | ||||
|  | ||||
| 					api.post("Kind", neues); | ||||
| 				} | ||||
| 			} | ||||
| 			status.setText("Daten Erfolgreich gespeichert"); | ||||
|   | ||||
| @@ -23,13 +23,18 @@ public class BestelluebersichtMitarbeiter { | ||||
| 	@FXML | ||||
| 	private Accordion accordion; | ||||
|  | ||||
| 	/** | ||||
| 	 * Initialisiert die Bestellübersicht durch Erstellung eines Accordion mit TitledPanes für verschiedene Datumsangaben. | ||||
| 	 * Geschrieben von: Stefan Groß | ||||
| 	 */ | ||||
| 	public void initialize() { | ||||
|  | ||||
| 		List<String> datum = new ArrayList<>(); | ||||
|  | ||||
| 		datum.add("15.10.1999"); | ||||
| 		datum.add("23.12.2002"); | ||||
| 		datum.add("05.01.2020"); | ||||
| 		//Placeholder für richtige Daten | ||||
| 		datum.add("15.10.2023"); | ||||
| 		datum.add("23.12.2023"); | ||||
| 		datum.add("05.01.2024"); | ||||
|  | ||||
| 		accordion.setStyle("-fx-box-border: transparent;"); | ||||
|  | ||||
| @@ -42,41 +47,33 @@ public class BestelluebersichtMitarbeiter { | ||||
| 			datumUeberschrift.animatedProperty().set(false); | ||||
| 			datumUeberschrift.setPadding(new Insets(0, 0, 15, 0)); | ||||
|  | ||||
| 			//TitledPane personen = new TitledPane("Person", createPersonenAccordion()); | ||||
| 			accordion.getPanes().add(datumUeberschrift); | ||||
| 			//gerichtAkkordion.getPanes().add(personen); | ||||
| 		} | ||||
|  | ||||
| 		scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); | ||||
| 		scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); | ||||
| 	} | ||||
|  | ||||
| 	int anzahlGerichtA = 1; | ||||
| 	/** | ||||
| 	 * Erstellt ein Accordion mit TitledPanes für die Bestellübersicht der Gerichte und Nachtische. | ||||
| 	 * Geschrieben von: Stefan Groß | ||||
| 	 */ | ||||
|  | ||||
| 	public Accordion createGerichtAkkordion() { | ||||
| 		Accordion accordion = new Accordion(); | ||||
|  | ||||
| 		//Placeholder für richtige Daten | ||||
| 		int anzahlGerichtB = 15; | ||||
| 		int anzahlGerichtC = 3; | ||||
| 		int anzahlGerichtD = 2; | ||||
|  | ||||
| 		double preisGerichtA = 4.99; | ||||
| 		double preisGerichtB = 9.99; | ||||
| 		double preisGerichtC = 3.99; | ||||
| 		double preisGerichtD = 12.49; | ||||
| 		double preisGerichtB = 4.99; | ||||
| 		double preisGerichtC = 9.99; | ||||
|  | ||||
| 		int anzahlNachtischA = 2; | ||||
| 		int anzahlNachtischB = 213; | ||||
|  | ||||
| 		double preisNachtischA = 0.49; | ||||
| 		double preisNachtischB = 99.49; | ||||
|  | ||||
|  | ||||
| 		if (anzahlGerichtA >= 1) { | ||||
| 			TitledPane tp = new TitledPane(); | ||||
| 			tp.setText("GerichtA " + anzahlGerichtA + "-Mal " + preisGerichtA * anzahlGerichtA + " €"); | ||||
| 			accordion.getPanes().addAll(tp); | ||||
| 		} | ||||
|  | ||||
| 		if (anzahlGerichtB >= 1) { | ||||
| 			TitledPane tp = new TitledPane(); | ||||
| 			tp.setText("GerichtB " + anzahlGerichtB + "-Mal " + preisGerichtB * anzahlGerichtB + " €"); | ||||
| @@ -90,12 +87,6 @@ public class BestelluebersichtMitarbeiter { | ||||
| 			accordion.getPanes().addAll(tp); | ||||
| 		} | ||||
|  | ||||
| 		if (anzahlGerichtD >= 1) { | ||||
| 			TitledPane tp = new TitledPane(); | ||||
| 			tp.setText("GerichtD " + anzahlGerichtD + "-Mal " + preisGerichtD * anzahlGerichtD + " €"); | ||||
| 			accordion.getPanes().addAll(tp); | ||||
| 		} | ||||
|  | ||||
| 		if (anzahlNachtischA >= 1) { | ||||
| 			TitledPane tp = new TitledPane(); | ||||
| 			tp.setText("NachtischA " + anzahlNachtischA + "-Mal " + preisNachtischA * anzahlNachtischA + " €"); | ||||
| @@ -104,43 +95,21 @@ public class BestelluebersichtMitarbeiter { | ||||
|  | ||||
| 		if (anzahlNachtischA >= 1) { | ||||
|  | ||||
| 			Label label2 = new Label("Hans Schwanz" + " für " + " Anja Arbeitslos"); | ||||
| 			Label label3 = new Label("Drittes Label"); | ||||
| 			Label label2 = new Label("Beispiel Eltern bestellen \"essen\" für Kind: Anja Arbeitslos"); | ||||
|  | ||||
| 			VBox vbox = new VBox(label2, label3); | ||||
| 			VBox vbox = new VBox(label2); | ||||
| 			vbox.setAlignment(Pos.CENTER_LEFT); | ||||
|  | ||||
| 			TitledPane tp = new TitledPane("NachtischB " + "-Mal " + preisNachtischB * anzahlGerichtB + " €", vbox); | ||||
| 			TitledPane tp = new TitledPane("NachtischB " + "-Mal " + preisNachtischA * anzahlGerichtB + " €", vbox); | ||||
|  | ||||
| 			accordion.getPanes().addAll(tp); | ||||
| 		} | ||||
| 		return accordion; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	public Accordion createPersonenAccordion() { | ||||
| 		Accordion accordion1 = new Accordion(); | ||||
|  | ||||
| 		for (int i = 0; i < 10; i++) { | ||||
| 			String kind = "Kind"; | ||||
| 			String elternteil = "Max Heer"; | ||||
|  | ||||
| 			Label label = new Label(); | ||||
| 			label.setText(elternteil + " für " + kind); | ||||
|  | ||||
| 			// Erstellen Sie eine TitledPane für jedes Label | ||||
| 			TitledPane titledPane = new TitledPane("Kind Informationen", label); | ||||
|  | ||||
| 			// Fügen Sie die TitledPane zur Accordion hinzu | ||||
| 			accordion1.getPanes().add(titledPane); | ||||
| 		} | ||||
|  | ||||
| 		return accordion1; | ||||
| 	} | ||||
| 	*/ | ||||
|  | ||||
| 	public void onAbmelden(ActionEvent event) { | ||||
| 		//VerwaltungApplication.abmelden(); | ||||
| 		VerwaltungApplication.abmelden(); | ||||
| 	} | ||||
|  | ||||
| 	public void onZurueck(ActionEvent actionEvent) { | ||||
|   | ||||
| @@ -92,10 +92,10 @@ public class EssensverwaltungMitarbeiterView { | ||||
| 		//solange das neu geöffnete Fenster offen ist, wird das Hauptfenster gesperrt | ||||
| 		gerichterstellung.initModality(Modality.APPLICATION_MODAL); | ||||
|  | ||||
| 		VerwaltungApplication.sceneWechseln(gerichterstellung, 400, 530, "gerichterstellung_mitarbeiter-view.fxml"); | ||||
| 		VerwaltungApplication.sceneWechseln(gerichterstellung, 500, 700, "gerichterstellung_mitarbeiter-view.fxml"); | ||||
|  | ||||
| 		gerichterstellung.minWidthProperty().set(420); | ||||
| 		gerichterstellung.minHeightProperty().set(600); | ||||
| 		gerichterstellung.minWidthProperty().set(500); | ||||
| 		gerichterstellung.minHeightProperty().set(700); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| @@ -231,7 +231,7 @@ public class EssensverwaltungMitarbeiterView { | ||||
|  | ||||
| 		t.getGerichte().remove(col); | ||||
|  | ||||
| 		System.out.println("Die Id lautet: " + id + col); | ||||
| 		//System.out.println("Die Id lautet: " + id + col); | ||||
|  | ||||
| 		cl.delete("GibtsAm", id); | ||||
| 		initGerichte(); | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import Logik.Mahlzeit; | ||||
| import Logik.Zutat; | ||||
| import RestAPISchnittstelle.RestApiClient; | ||||
| import com.google.gson.*; | ||||
| import javafx.event.ActionEvent; | ||||
| import javafx.fxml.FXML; | ||||
| import javafx.scene.control.*; | ||||
| import javafx.scene.layout.HBox; | ||||
| @@ -20,17 +19,53 @@ public class GerichterstellungMitarbeiterView { | ||||
| 	private @FXML TextField eingabeName; | ||||
| 	private @FXML Button buttonInhaltsstoffe; | ||||
| 	private @FXML TextField eingabeInhaltsstoffe; | ||||
| 	private @FXML Button speichernButton; | ||||
| 	private @FXML TextField eingabePreis; | ||||
| 	private @FXML DatePicker datePicker; | ||||
| 	private @FXML ListView<String> listViewVorschlag; | ||||
| 	private @FXML Label status; | ||||
|  | ||||
| 	private ArrayList<Zutat> zutaten; | ||||
| 	private ArrayList<Mahlzeit> mahlzeiten; | ||||
|  | ||||
| 	/** | ||||
| 	 * Füllt die Listview mit Vorschlägen und enthält den Eventlistener für das Textfeld | ||||
| 	 * Ist außerdem für die Skalierung der Buttons vom Inhaltsstoff zuständig | ||||
| 	 * Geschrieben: Sven Alteköster, Stefan Groß | ||||
| 	 * | ||||
| 	 */ | ||||
| 	public void initialize() { | ||||
| 		zutaten = new ArrayList<>(); | ||||
| 		mahlzeiten = new ArrayList<>(); | ||||
| 		datePicker.setEditable(false); | ||||
| 		//Liste mit Daten füllen | ||||
| 		mahlzeiten = getMahlzeiten(); | ||||
| 		for (Mahlzeit m : mahlzeiten) { | ||||
| 			listViewVorschlag.getItems().add(m.getName()); | ||||
| 		} | ||||
|  | ||||
| 		//Eventlistener für die Eingabe des Textfelds | ||||
| 		eingabeName.textProperty().addListener((obs, oldValue, newValue) -> { | ||||
| 			aktualisiereListView(newValue); | ||||
| 		}); | ||||
|  | ||||
| 		//Wenn ein Eintrag in der Listeview 2x angeklickt wird, werden die entsprechenden Felder mit | ||||
| 		//den Daten des Gerichts eingefügt | ||||
| 		listViewVorschlag.setOnMouseClicked(event -> { | ||||
| 			if (event.getClickCount() == 2) { | ||||
| 				String ausgewaehlterName = listViewVorschlag.getSelectionModel().getSelectedItem(); | ||||
| 				if (ausgewaehlterName != null) { | ||||
| 					for (Mahlzeit m : mahlzeiten) { | ||||
| 						if (m.getName().equals(ausgewaehlterName)) { | ||||
| 							eingabeName.setText(m.getName()); | ||||
| 							eingabePreis.setText(String.valueOf(m.getPreis())); | ||||
| 							eingabeBeschreibung.setText(m.getBeschreibung()); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}); | ||||
|  | ||||
|  | ||||
| 		//wird das Fenster vergrößert, wird das Eingabefeld für Inhaltstoffe und den Hinzufügenbutton | ||||
| 		// auf die volle breite vergrößert. | ||||
| @@ -40,9 +75,58 @@ public class GerichterstellungMitarbeiterView { | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	public void onButtonInhaltsstoffeClick(ActionEvent actionEvent) { | ||||
| 	/** | ||||
| 	 * Holt Mahlzeiten von der API für die ListView. | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 * @return Liste von Mahlzeiten | ||||
| 	 */ | ||||
| 	public ArrayList<Mahlzeit> getMahlzeiten() { | ||||
| 		ArrayList<Mahlzeit> mahlzeitenListe = new ArrayList<>(); | ||||
| 		RestApiClient restApiClient = new RestApiClient(); | ||||
| 		JsonElement je = JsonParser.parseString(restApiClient.get("Gericht")); | ||||
| 		JsonArray js = je.getAsJsonArray(); | ||||
|  | ||||
| 		for (JsonElement element : js) { | ||||
| 			JsonObject mahlzeitJson = element.getAsJsonObject(); | ||||
| 			String name = mahlzeitJson.get("name").getAsString(); | ||||
| 			float preis = mahlzeitJson.get("preis").getAsFloat(); | ||||
| 			String beschreibung = mahlzeitJson.get("beschreibung").getAsString(); | ||||
| 			Mahlzeit mahlzeit = new Mahlzeit(name, preis, beschreibung); | ||||
| 			mahlzeitenListe.add(mahlzeit); | ||||
| 		} | ||||
| 		return mahlzeitenListe; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Aktualisiert die ListView je nach Eingabe in das eingabeName-Feld | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * Getestet: | ||||
| 	 * | ||||
| 	 * @param eingabeGerichtFilter "Suchtext" für die Gerichte | ||||
| 	 */ | ||||
| 	public void aktualisiereListView(String eingabeGerichtFilter) { | ||||
| 		listViewVorschlag.getItems().clear(); | ||||
|  | ||||
| 		if (eingabeGerichtFilter == null || eingabeGerichtFilter.isEmpty()) { | ||||
| 			for (Mahlzeit m : mahlzeiten) { | ||||
| 				listViewVorschlag.getItems().add(m.getName()); | ||||
| 			} | ||||
| 		} | ||||
| 		else { | ||||
| 			for (Mahlzeit m : mahlzeiten) { | ||||
| 				if (m.getName().toLowerCase().contains(eingabeGerichtFilter.toLowerCase())) { | ||||
| 					listViewVorschlag.getItems().add(m.getName()); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public void onButtonInhaltsstoffeClick() { | ||||
| 		String text = eingabeInhaltsstoffe.getText(); | ||||
| 		if (!text.equals("")) { | ||||
| 		if (!text.isEmpty()) { | ||||
| 			eingabeInhaltsstoffe.setText(""); | ||||
|  | ||||
| 			Button neuerInhalt = new Button(); | ||||
| @@ -58,37 +142,112 @@ public class GerichterstellungMitarbeiterView { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Bei klick auf den Speichernbutton wird die Eingabe überprüft | ||||
| 	 * es werden gegebenenfalls Fehlermeldungen angezeigt und es werden Mahlzeiten bei gültigen Eingaben gespeichert | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 */ | ||||
| 	public void onSpeichernButtonClick() { | ||||
| 		String eingabe = eingabeName.getText(); | ||||
| 		String beschreibung = eingabeBeschreibung.getText(); | ||||
| 		float preis = Float.parseFloat(eingabePreis.getText()); | ||||
| 		LocalDate datum = datePicker.getValue(); | ||||
| 		StringBuilder fehlerMeldungen = new StringBuilder(); | ||||
| 		boolean istGueltig = true; | ||||
| 		float preis = 0; | ||||
|  | ||||
| 		if (!eingabe.isEmpty() && !beschreibung.isEmpty()) { | ||||
| 			resetEingabeFelder(); | ||||
| 		resetFehlerrahmen(); | ||||
|  | ||||
| 			Mahlzeit mahlzeit = new Mahlzeit(eingabe, preis, beschreibung); | ||||
| 			mahlzeiten.add(mahlzeit); | ||||
| 			status.setText("Mahlzeit hinzugefügt"); | ||||
|  | ||||
| 			int datumId = datumBearbeiten(datum); | ||||
| 			System.out.println(datumId); | ||||
|  | ||||
| 			int gerichtId = gerichteAbfragen(mahlzeit); | ||||
| 			System.out.println(gerichtId); | ||||
|  | ||||
| 			inhaltsstoff(); | ||||
| 			gibtsAm(gerichtId, datumId); | ||||
| 		if (eingabe.isEmpty()) { | ||||
| 			eingabeName.setStyle("-fx-text-box-border: #B22222; -fx-focus-color: #B22222;"); | ||||
| 			fehlerMeldungen.append("Name eingeben. "); | ||||
| 			istGueltig = false; | ||||
| 		} | ||||
|  | ||||
| 		if (beschreibung.isEmpty()) { | ||||
| 			eingabeBeschreibung.setStyle("-fx-text-box-border: #B22222; -fx-focus-color: #B22222;"); | ||||
| 			fehlerMeldungen.append("Beschreibung eingeben. "); | ||||
| 			istGueltig = false; | ||||
| 		} | ||||
|  | ||||
| 		try { | ||||
| 			preis = Float.parseFloat(eingabePreis.getText()); | ||||
| 		} | ||||
| 		catch (NumberFormatException e) { | ||||
| 			eingabePreis.setStyle("-fx-text-box-border: #B22222; -fx-focus-color: #B22222;"); | ||||
| 			fehlerMeldungen.append("Preis ist ungültig. "); | ||||
| 			istGueltig = false; | ||||
| 		} | ||||
|  | ||||
| 		LocalDate datum = datePicker.getValue(); | ||||
| 		if (datum == null) { | ||||
| 			datePicker.setStyle("-fx-border-color: #B22222;"); | ||||
| 			fehlerMeldungen.append("Gültiges Datum eingeben. "); | ||||
| 			istGueltig = false; | ||||
| 		} | ||||
|  | ||||
| 		if (zutaten.isEmpty()) { | ||||
| 			eingabeInhaltsstoffe.setStyle("-fx-border-color: #B22222;"); | ||||
| 			fehlerMeldungen.append("Inhaltsstoffe fehlen. "); | ||||
| 			istGueltig = false; | ||||
| 		} | ||||
|  | ||||
| 		if (!istGueltig) { | ||||
| 			status.setText(fehlerMeldungen.toString()); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		Mahlzeit mahlzeit = new Mahlzeit(eingabe, preis, beschreibung); | ||||
| 		mahlzeiten.add(mahlzeit); | ||||
| 		status.setText("Mahlzeit hinzugefügt"); | ||||
|  | ||||
| 		int datumId = datumBearbeiten(datum); | ||||
| 		int gerichtId = gerichteAbfragen(mahlzeit); | ||||
| 		inhaltsstoff(gerichtId); | ||||
| 		gibtsAm(gerichtId, datumId); | ||||
| 		mahlzeiten.clear(); | ||||
| 		mahlzeiten = getMahlzeiten(); | ||||
| 		aktualisiereListView(""); | ||||
| 		resetEingabeFelder(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setzt die "Fehlerrahmen" der aller Elemente zurück | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 */ | ||||
| 	private void resetFehlerrahmen() { | ||||
| 		eingabeName.setStyle(null); | ||||
| 		eingabeBeschreibung.setStyle(null); | ||||
| 		eingabePreis.setStyle(null); | ||||
| 		eingabeInhaltsstoffe.setStyle(null); | ||||
| 		datePicker.setStyle(null); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Setzt alle Eingabefelder auf einen leerwert zurück | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 */ | ||||
|  | ||||
| 	private void resetEingabeFelder() { | ||||
| 		eingabeName.setText(""); | ||||
| 		eingabeBeschreibung.setText(""); | ||||
| 		eingabePreis.setText(""); | ||||
| 		eingabeInhaltsstoffe.setText(""); | ||||
| 		zutaten.clear(); | ||||
| 		anzeigeInhaltsstoffe.getChildren().clear(); | ||||
| 		datePicker.setValue(null); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Holt oder erstellt ein Datum mithilfe der API und gibt die ID zurück. | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 * @param datum Das eingegebene Datum | ||||
| 	 * | ||||
| 	 * @return ID des Datums | ||||
| 	 */ | ||||
| 	private int datumBearbeiten(LocalDate datum) { | ||||
| 		RestApiClient restApiClient = new RestApiClient(); | ||||
| 		String datumAsString = datum.toString(); | ||||
| @@ -118,7 +277,14 @@ public class GerichterstellungMitarbeiterView { | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	public void gibtsAm(int gid, int tid){ | ||||
| 	/** | ||||
| 	 * Verwendet die API, um eine Beziehung in der Datenbank zwischen Gericht und Datum herzustellen. | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 * @param gid ID des Gerichts | ||||
| 	 * @param tid ID des Datums | ||||
| 	 */ | ||||
| 	public void gibtsAm(int gid, int tid) { | ||||
| 		RestApiClient restApiClient = new RestApiClient(); | ||||
|  | ||||
| 		JsonObject gibtsAmJson = new JsonObject(); | ||||
| @@ -128,9 +294,15 @@ public class GerichterstellungMitarbeiterView { | ||||
| 		restApiClient.post("gibtsAm", gibtsAmJson.toString()); | ||||
| 	} | ||||
|  | ||||
| 	public void inhaltsstoff() { | ||||
| 	/** | ||||
| 	 * Ruft Inhaltsstoffe ab und fügt sie zu einem Gericht hinzu. | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 * @param gerichtId ID des Gerichts | ||||
| 	 */ | ||||
|  | ||||
| 	public void inhaltsstoff(int gerichtId) { | ||||
| 		RestApiClient restApiClient = new RestApiClient(); | ||||
| 		ArrayList<Integer> ids = new ArrayList<>(); | ||||
|  | ||||
| 		for (Zutat zutat : zutaten) { | ||||
| 			JsonElement jE = JsonParser.parseString(restApiClient.get("Inhaltsstoff")); | ||||
| @@ -138,32 +310,46 @@ public class GerichterstellungMitarbeiterView { | ||||
|  | ||||
| 			int id = -1; | ||||
|  | ||||
| 			// Überprüfen, ob der Inhaltsstoff bereits existiert. | ||||
| 			// Holt Id falls er existiert | ||||
| 			for (JsonElement element : inhaltsstoffArray) { | ||||
| 				JsonObject inhatsstoff = element.getAsJsonObject(); | ||||
| 				if (inhatsstoff.get("name").getAsString().equalsIgnoreCase(zutat.getName())) { | ||||
| 					id = inhatsstoff.get("id").getAsInt(); | ||||
| 				JsonObject inhaltsstoff = element.getAsJsonObject(); | ||||
| 				if (inhaltsstoff.get("name").getAsString().equalsIgnoreCase(zutat.getName())) { | ||||
| 					id = inhaltsstoff.get("id").getAsInt(); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Fügt Inhaltsstoff hinzu, wenn er nicht existiert | ||||
| 			if (id == -1) { | ||||
| 				JsonObject neuerInhaltsstoff = new JsonObject(); | ||||
| 				neuerInhaltsstoff.addProperty("name", zutat.getName()); | ||||
| 				restApiClient.post("Inhaltsstoff", neuerInhaltsstoff.toString()); | ||||
|  | ||||
| 				// Fragt Id vom neuen Inhaltsstoff ab | ||||
| 				jE = JsonParser.parseString(restApiClient.get("Inhaltsstoff")); | ||||
| 				inhaltsstoffArray = jE.getAsJsonArray(); | ||||
|  | ||||
| 				JsonObject letzterInhaltsstoff = inhaltsstoffArray.get(inhaltsstoffArray.size() - 1).getAsJsonObject(); | ||||
| 				id = letzterInhaltsstoff.get("id").getAsInt(); | ||||
| 				System.out.println("Inhaltsstoff hinzugefügt: " + zutat.getName()); | ||||
| 			} | ||||
| 			ids.add(id); | ||||
|  | ||||
| 			// Stellt verknüpfung zur Enthälttabelle her | ||||
| 			JsonObject enthaelt = new JsonObject(); | ||||
| 			enthaelt.addProperty("iid", id); | ||||
| 			enthaelt.addProperty("gid", gerichtId); | ||||
| 			restApiClient.post("Enthaelt", enthaelt.toString()); | ||||
| 		} | ||||
| 		System.out.println("IDs der Inhaltsstoffe: " + ids); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Prüft, ob ein Gericht bereits existiert, wenn es nicht existiert wird es hinzugefügt. | ||||
| 	 * Falls es existiert wird Preis und Beschreibung aktualisiert. | ||||
| 	 * Geschrieben: Stefan Groß | ||||
| 	 * | ||||
| 	 * @param mahlzeit Die zu überprüfende oder hinzuzufügende Mahlzeit | ||||
| 	 * | ||||
| 	 * @return ID des Gerichts | ||||
| 	 */ | ||||
|  | ||||
| 	private int gerichteAbfragen(Mahlzeit mahlzeit) { | ||||
| 		RestApiClient restApiClient = new RestApiClient(); | ||||
| @@ -197,7 +383,7 @@ public class GerichterstellungMitarbeiterView { | ||||
|  | ||||
| 		restApiClient.post("Gericht", neuesGericht.toString()); | ||||
|  | ||||
| 		// ID des neu hinzugefügten Gerichts abrufen | ||||
| 		// ID des Gerichts abrufen | ||||
| 		je = JsonParser.parseString(restApiClient.get("Gericht")); | ||||
| 		js = je.getAsJsonArray(); | ||||
| 		for (JsonElement element : js) { | ||||
| @@ -208,4 +394,5 @@ public class GerichterstellungMitarbeiterView { | ||||
| 		} | ||||
| 		return -1; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| } | ||||
| @@ -31,25 +31,27 @@ public class InhaltsstoffeFilternController { | ||||
|  | ||||
| 	private ArrayList<Zutat> zutaten; | ||||
|  | ||||
| 	/** | ||||
| 	 * Initialisert sie InhaltsstoffeFiltern View | ||||
| 	 * @author Sven Alteköster | ||||
| 	 */ | ||||
| 	public void initialize(){ | ||||
|  | ||||
| 		//mehrere Inhaltsstoffe können ausgewählt werden | ||||
| 		zutatListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); | ||||
|  | ||||
| 		//Befüllen der ListView mit allen existierenden Inhaltsstoffen | ||||
| 		RestApiClient api = new RestApiClient(); | ||||
| 		String json = api.get("Inhaltsstoff"); | ||||
|  | ||||
| 		zutaten = new ArrayList<>(); | ||||
|  | ||||
| 		Gson gson = new Gson(); | ||||
|  | ||||
| 		JsonElement je = JsonParser.parseString(json); | ||||
| 		JsonArray ja = je.getAsJsonArray(); | ||||
|  | ||||
| 		for (JsonElement e : ja) { | ||||
| 			JsonObject jo = e.getAsJsonObject(); | ||||
| 			zutaten.add(gson.fromJson(jo, Zutat.class)); | ||||
| 		} | ||||
|  | ||||
| 		zutatListView.setItems(FXCollections.observableArrayList(zutaten)); | ||||
| 	} | ||||
|  | ||||
|   | ||||
							
								
								
									
										8
									
								
								src/main/java/de/subway_surfers/vpr_app/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/main/java/de/subway_surfers/vpr_app/Main.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| package de.subway_surfers.vpr_app; | ||||
|  | ||||
| public class Main { | ||||
|  | ||||
| 	public static void main(String[] args) { | ||||
| 		VerwaltungApplication.main(args); | ||||
| 	} | ||||
| } | ||||
| @@ -21,7 +21,7 @@ public class VerwaltungApplication extends Application { | ||||
|  | ||||
| 	@Override | ||||
| 	public void start(Stage stage) throws IOException { | ||||
| 		FXMLLoader fxmlLoader = new FXMLLoader(VerwaltungApplication.class.getResource("gerichterstellung_mitarbeiter-view.fxml")); | ||||
| 		FXMLLoader fxmlLoader = new FXMLLoader(VerwaltungApplication.class.getResource("login-view.fxml")); | ||||
| 		Scene scene = new Scene(fxmlLoader.load()); | ||||
|  | ||||
| 		stage.setWidth(960); | ||||
| @@ -48,7 +48,6 @@ public class VerwaltungApplication extends Application { | ||||
| 	 * Die Scene auf der aktuellen Stage wird durch die in der fxml-Datei definierte Scene ausgetauscht. | ||||
| 	 * | ||||
| 	 * Geschrieben: Sven Alteköster | ||||
| 	 * Getestet: | ||||
| 	 * | ||||
| 	 * @param fxml name der zu ladenden fxml Datei. | ||||
| 	 */ | ||||
| @@ -84,9 +83,7 @@ public class VerwaltungApplication extends Application { | ||||
| 	/** | ||||
| 	 * in einem neuen Fenster wird die in der fxml-Datei definierte Scene gesetzt. | ||||
| 	 * Die geladene Scene wird <b><u>nicht</u></b> zu der neuen Hauptstage. | ||||
| 	 * | ||||
| 	 * Geschrieben: Sven Alteköster | ||||
| 	 * Getestet: | ||||
| 	 * | ||||
| 	 * @param neue Stage auf der die Scene gesetzt werden soll | ||||
| 	 * @param width breite des neuen Fensters | ||||
|   | ||||
| @@ -1,44 +0,0 @@ | ||||
| package de.subway_surfers.vpr_app.logik; | ||||
|  | ||||
| import Logik.Zutat; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| public class Kind { | ||||
|  | ||||
| 	private String           name; | ||||
| 	private String           vorname; | ||||
| 	private int              id; | ||||
| 	private ArrayList<Zutat> filter; | ||||
|  | ||||
| 	public Kind(String name, String vorname, int id) { | ||||
| 		ArrayList<Zutat> filter = new ArrayList<>(); | ||||
| 		this.name    = name; | ||||
| 		this.vorname = vorname; | ||||
| 		this.id      = id; | ||||
| 	} | ||||
|  | ||||
| 	public String getName() { | ||||
| 		return name; | ||||
| 	} | ||||
|  | ||||
| 	public void setName(String name) { | ||||
| 		this.name = name; | ||||
| 	} | ||||
|  | ||||
| 	public String getVorname() { | ||||
| 		return vorname; | ||||
| 	} | ||||
|  | ||||
| 	public void setVorname(String vorname) { | ||||
| 		this.vorname = vorname; | ||||
| 	} | ||||
|  | ||||
| 	public int getId() { | ||||
| 		return id; | ||||
| 	} | ||||
|  | ||||
| 	public ArrayList<Zutat> getFilter() { | ||||
| 		return filter; | ||||
| 	} | ||||
| } | ||||
| @@ -18,7 +18,8 @@ | ||||
|        <VBox styleClass="gerichterstellung_felder"> | ||||
|            <TextField fx:id="eingabeName" promptText="Name des Gerichtes" focusTraversable="false"/> | ||||
|            <TextField fx:id="eingabePreis" promptText="Preis des Gerichtes" focusTraversable="false"/> | ||||
|            <TextArea fx:id="eingabeBeschreibung" promptText="Beschreibung" focusTraversable="false"/> | ||||
|            <ListView fx:id="listViewVorschlag" focusTraversable="false" minHeight="200" maxHeight="250"/> | ||||
|            <TextArea fx:id="eingabeBeschreibung" promptText="Beschreibung" focusTraversable="false" minHeight="75"/> | ||||
|            <HBox> | ||||
|                <TextField fx:id="eingabeInhaltsstoffe" promptText="Inhaltsstoffe" focusTraversable="false"/> | ||||
|                <Button fx:id="buttonInhaltsstoffe" onAction="#onButtonInhaltsstoffeClick" text="Hinzufügen"/> | ||||
|   | ||||
| @@ -25,8 +25,6 @@ | ||||
|                 <VBox styleClass="hauptmenue_buttons_links"> | ||||
|                     <Button text="Speiseplan" onAction="#onSpeiseplanClick"/> | ||||
|                     <Button text="Alle Bestellungen anzeigen" onAction="#onBestellungenAnzeigen"/> | ||||
|                     <Button text="Rechnungen herunterladen"/> | ||||
|                     <Button text="Daten importieren/Exportieren"/> | ||||
|                     <Button text="Account anlegen" onAction="#onAccountAnlegenClick"/> | ||||
|                 </VBox> | ||||
|             </left> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user