| 
						 
							
							
							
						 
					 | 
				
			
			 | 
			 | 
			
				@@ -1,51 +1,211 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				package de.subway_surfers.vpr_app;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				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.Button;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import javafx.scene.control.TextArea;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import javafx.scene.control.TextField;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import javafx.scene.control.*;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import javafx.scene.layout.HBox;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import javafx.scene.layout.Pane;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.time.LocalDate;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.ArrayList;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				public class GerichterstellungMitarbeiterView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private @FXML HBox anzeigeInhaltsstoffe;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private @FXML TextArea eingabeBeschreibung;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private @FXML TextField eingabeName;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private @FXML Button buttonInhaltsstoffe;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private @FXML TextField eingabeInhaltsstoffe;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private ArrayList<Zutat> zutaten;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private @FXML HBox anzeigeInhaltsstoffe;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private @FXML TextArea eingabeBeschreibung;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					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 Label status;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public void initialize() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        zutaten = new ArrayList<>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private ArrayList<Zutat> zutaten;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private ArrayList<Mahlzeit> mahlzeiten;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        //wird das Fenster vergrößert, wird das Eingabefeld für Inhaltstoffe und den Hinzufügenbutton
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // auf die volle breite vergrößert.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        ((Pane) eingabeInhaltsstoffe.getParent()).widthProperty().addListener((obs, oldValue, newValue) -> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //eingabeName, da dieses Feld immer die gesamte breite der Stage haben.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            eingabeInhaltsstoffe.setPrefWidth(eingabeName.getWidth() - buttonInhaltsstoffe.getPrefWidth());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void initialize() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						zutaten = new ArrayList<>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						mahlzeiten = new ArrayList<>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public void onButtonInhaltsstoffeClick(ActionEvent actionEvent) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        String text = eingabeInhaltsstoffe.getText();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (!text.equals("")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            eingabeInhaltsstoffe.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						//wird das Fenster vergrößert, wird das Eingabefeld für Inhaltstoffe und den Hinzufügenbutton
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// auf die volle breite vergrößert.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						((Pane) eingabeInhaltsstoffe.getParent()).widthProperty().addListener((obs, oldValue, newValue) -> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							//eingabeName, da dieses Feld immer die gesamte breite der Stage haben.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							eingabeInhaltsstoffe.setPrefWidth(eingabeName.getWidth() - buttonInhaltsstoffe.getPrefWidth());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Button neuerInhalt = new Button();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            neuerInhalt.setText(text);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            anzeigeInhaltsstoffe.getChildren().add(neuerInhalt);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void onButtonInhaltsstoffeClick(ActionEvent actionEvent) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						String text = eingabeInhaltsstoffe.getText();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (!text.equals("")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							eingabeInhaltsstoffe.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Zutat neue = new Zutat(text);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            zutaten.add(neue);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            neuerInhalt.setOnAction(e -> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ((HBox) neuerInhalt.getParent()).getChildren().remove(neuerInhalt);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                zutaten.remove(neue);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Button neuerInhalt = new Button();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							neuerInhalt.setText(text);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							anzeigeInhaltsstoffe.getChildren().add(neuerInhalt);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							Zutat neue = new Zutat(text);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							zutaten.add(neue);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							neuerInhalt.setOnAction(e -> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								((HBox) neuerInhalt.getParent()).getChildren().remove(neuerInhalt);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								zutaten.remove(neue);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void onSpeichernButtonClick() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						String eingabe = eingabeName.getText();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						String beschreibung = eingabeBeschreibung.getText();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						float preis = Float.parseFloat(eingabePreis.getText());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						LocalDate datum = datePicker.getValue();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (!eingabe.isEmpty() && !beschreibung.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							resetEingabeFelder();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							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);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private void resetEingabeFelder() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						eingabeName.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						eingabeBeschreibung.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						eingabePreis.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						eingabeInhaltsstoffe.setText("");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private int datumBearbeiten(LocalDate datum) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						RestApiClient restApiClient = new RestApiClient();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						String datumAsString = datum.toString();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonElement jsonElement = JsonParser.parseString(restApiClient.get("Tagesplan"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonArray jsonArray = jsonElement.getAsJsonArray();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (JsonElement element : jsonArray) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonObject obj = element.getAsJsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (obj.get("datum").getAsString().equals(datumAsString)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return Integer.parseInt(obj.get("id").getAsString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						restApiClient.post("Tagesplan", "{\"datum\":\"" + datumAsString + "\"}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						jsonElement = JsonParser.parseString(restApiClient.get("Tagesplan"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						jsonArray = jsonElement.getAsJsonArray();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (JsonElement element : jsonArray) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonObject obj = element.getAsJsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (obj.get("datum").getAsString().equals(datumAsString)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return Integer.parseInt(obj.get("id").getAsString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return -1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void gibtsAm(int gid, int tid){
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						RestApiClient restApiClient = new RestApiClient();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonObject gibtsAmJson = new JsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						gibtsAmJson.addProperty("tid", tid);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						gibtsAmJson.addProperty("gid", gid);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						restApiClient.post("gibtsAm", gibtsAmJson.toString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void inhaltsstoff() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						RestApiClient restApiClient = new RestApiClient();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						ArrayList<Integer> ids = new ArrayList<>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (Zutat zutat : zutaten) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonElement jE = JsonParser.parseString(restApiClient.get("Inhaltsstoff"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonArray inhaltsstoffArray = jE.getAsJsonArray();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							int id = -1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							for (JsonElement element : inhaltsstoffArray) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								JsonObject inhatsstoff = element.getAsJsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								if (inhatsstoff.get("name").getAsString().equalsIgnoreCase(zutat.getName())) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									id = inhatsstoff.get("id").getAsInt();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (id == -1) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								JsonObject neuerInhaltsstoff = new JsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								neuerInhaltsstoff.addProperty("name", zutat.getName());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								restApiClient.post("Inhaltsstoff", neuerInhaltsstoff.toString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								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);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						System.out.println("IDs der Inhaltsstoffe: " + ids);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					private int gerichteAbfragen(Mahlzeit mahlzeit) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						RestApiClient restApiClient = new RestApiClient();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonElement je = JsonParser.parseString(restApiClient.get("Gericht"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonArray js = je.getAsJsonArray();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (JsonElement element : js) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonObject mahlzeitJson = element.getAsJsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							String nameMahlzeit = mahlzeitJson.get("name").getAsString();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (nameMahlzeit.equals(mahlzeit.getName())) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								int id = Integer.parseInt(mahlzeitJson.get("id").getAsString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								// Update des existierenden Gerichts
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								JsonObject updateGericht = new JsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								updateGericht.addProperty("id", id);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								updateGericht.addProperty("name", mahlzeit.getName());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								updateGericht.addProperty("preis", mahlzeit.getPreis());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								updateGericht.addProperty("beschreibung", mahlzeit.getBeschreibung());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								restApiClient.put("Gericht", id, updateGericht.toString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return id;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// Neues Gericht zur Datenbank hinzufügen, falls es nicht existiert
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						JsonObject neuesGericht = new JsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						neuesGericht.addProperty("name", mahlzeit.getName());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						neuesGericht.addProperty("preis", mahlzeit.getPreis());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						neuesGericht.addProperty("beschreibung", mahlzeit.getBeschreibung());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						restApiClient.post("Gericht", neuesGericht.toString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// ID des neu hinzugefügten Gerichts abrufen
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						je = JsonParser.parseString(restApiClient.get("Gericht"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						js = je.getAsJsonArray();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (JsonElement element : js) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							JsonObject mahlzeitJson = element.getAsJsonObject();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (mahlzeitJson.get("name").getAsString().equals(mahlzeit.getName())) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return Integer.parseInt(mahlzeitJson.get("id").getAsString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return -1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
	
		
			
				
					
					| 
						 
							
							
							
						 
					 | 
				
			
			 | 
			 | 
			
				 
 |