Compare commits
	
		
			12 Commits
		
	
	
		
			0326d80a21
			...
			SvenAccoun
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 26b713309f | |||
| c5f7391631 | |||
| 17bf862890 | |||
| c08e816e93 | |||
| 72a6d9a7e5 | |||
| 92d62509de | |||
| 0f52f19fc7 | |||
| 1b2a0c0309 | |||
| 4780f4403b | |||
| 8e1084f034 | |||
| 042c78e0d4 | |||
| 2a3ac1498b | 
							
								
								
									
										3
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										3
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							| @@ -7,9 +7,8 @@ | |||||||
|         <option value="$PROJECT_DIR$/pom.xml" /> |         <option value="$PROJECT_DIR$/pom.xml" /> | ||||||
|       </list> |       </list> | ||||||
|     </option> |     </option> | ||||||
|     <option name="workspaceImportForciblyTurnedOn" value="true" /> |  | ||||||
|   </component> |   </component> | ||||||
|   <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> |   <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> | ||||||
|     <output url="file://$PROJECT_DIR$/out" /> |     <output url="file://$PROJECT_DIR$/out" /> | ||||||
|   </component> |   </component> | ||||||
| </project> | </project> | ||||||
| @@ -3,6 +3,8 @@ | |||||||
|  |  | ||||||
| package Logik; | package Logik; | ||||||
|  |  | ||||||
|  | import RestAPISchnittstelle.RestApiClient; | ||||||
|  |  | ||||||
| public class Account { | public class Account { | ||||||
|  |  | ||||||
| 	// region Felder | 	// region Felder | ||||||
| @@ -12,6 +14,8 @@ public class Account { | |||||||
|  |  | ||||||
| 	private String name; | 	private String name; | ||||||
|  |  | ||||||
|  | 	private String email; | ||||||
|  |  | ||||||
| 	private int rid; | 	private int rid; | ||||||
| 	// endregion | 	// endregion | ||||||
|  |  | ||||||
| @@ -32,6 +36,14 @@ public class Account { | |||||||
| 		this.id = id; | 		this.id = id; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	public String getEmail() { | ||||||
|  | 		return email; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void setEmail(String email) { | ||||||
|  | 		this.email = email; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	public String getBenutzername() { | 	public String getBenutzername() { | ||||||
| 		return name; | 		return name; | ||||||
| @@ -43,9 +55,10 @@ public class Account { | |||||||
| 	// endregion | 	// endregion | ||||||
|  |  | ||||||
| 	// region Konstruktoren | 	// region Konstruktoren | ||||||
| 	public Account(String passwort, String name) { | 	public Account(String passwort, String name, String email) { | ||||||
| 		this.passwort = passwort; | 		this.passwort = passwort; | ||||||
| 		this.name = name; | 		this.name = name; | ||||||
|  | 		this.email = email; | ||||||
|  |  | ||||||
| 		if(this instanceof MitarbeiterAccount) | 		if(this instanceof MitarbeiterAccount) | ||||||
| 			rid = 0; | 			rid = 0; | ||||||
| @@ -53,5 +66,4 @@ public class Account { | |||||||
| 			rid = 1; | 			rid = 1; | ||||||
| 	} | 	} | ||||||
| 	// endregion | 	// endregion | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,19 +12,10 @@ import java.util.ArrayList; | |||||||
| public class ElternAccount extends Account { | public class ElternAccount extends Account { | ||||||
|  |  | ||||||
| 	// region Felder | 	// region Felder | ||||||
| 	private String email; |  | ||||||
|  |  | ||||||
| 	private transient ArrayList<Kind> kinder; | 	private transient ArrayList<Kind> kinder; | ||||||
| 	// endregion | 	// endregion | ||||||
|  |  | ||||||
| 	// region Getter & Setter | 	// region Getter & Setter | ||||||
| 	public String getEmail() { |  | ||||||
| 		return email; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	public void setEmail(String email) { |  | ||||||
| 		this.email = email; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	public ArrayList<Kind> getKinder() { | 	public ArrayList<Kind> getKinder() { | ||||||
| 		return kinder; | 		return kinder; | ||||||
| @@ -37,8 +28,7 @@ public class ElternAccount extends Account { | |||||||
|  |  | ||||||
| 	// region Konstruktoren | 	// region Konstruktoren | ||||||
| 	public ElternAccount(String passwort, String benutzername, String email) { | 	public ElternAccount(String passwort, String benutzername, String email) { | ||||||
| 		super(passwort, benutzername); | 		super(passwort, benutzername, email); | ||||||
| 		this.email = email; |  | ||||||
| 		kinder = new ArrayList<>(); | 		kinder = new ArrayList<>(); | ||||||
| 	} | 	} | ||||||
| 	// endregion | 	// endregion | ||||||
|   | |||||||
| @@ -12,8 +12,8 @@ import java.util.ArrayList; | |||||||
| public class MitarbeiterAccount extends Account { | public class MitarbeiterAccount extends Account { | ||||||
|  |  | ||||||
| 	// region Konstrukoren | 	// region Konstrukoren | ||||||
| 	public MitarbeiterAccount(String passwort, String benutzername) { | 	public MitarbeiterAccount(String passwort, String benutzername, String email) { | ||||||
| 		super(passwort, benutzername); | 		super(passwort, benutzername, email); | ||||||
| 	} | 	} | ||||||
| 	//endregion | 	//endregion | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,11 +11,11 @@ public interface IRestAPI { | |||||||
|  |  | ||||||
| 	// region Get | 	// region Get | ||||||
|  |  | ||||||
| 	void get(String controllerName); | 	String get(String controllerName); | ||||||
|  |  | ||||||
| 	void get (String controllerName, int id); | 	String get (String controllerName, int id); | ||||||
|  |  | ||||||
| 	void get (String controllerName, int id, boolean bezahlt); | 	String get (String controllerName, int id, boolean bezahlt); | ||||||
|  |  | ||||||
| 	//endregion | 	//endregion | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets; | |||||||
|  |  | ||||||
| import Logik.ElternAccount; | import Logik.ElternAccount; | ||||||
| import Logik.Kind; | import Logik.Kind; | ||||||
| import com.google.gson.Gson; | import com.google.gson.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * noch nicht getestet |  * noch nicht getestet | ||||||
| @@ -32,8 +32,8 @@ public class RestApiClient implements IRestAPI{ | |||||||
|  |  | ||||||
| 		RestApiClient client1 = new RestApiClient(); | 		RestApiClient client1 = new RestApiClient(); | ||||||
|  |  | ||||||
| 		client1.post("Gericht", "{\"name\" : \"Svens Beine\", \"69.69\", \"beschreibung\" : \"Muss net schmegge, muss wirge\"}"); |  | ||||||
|  |  | ||||||
|  | 		System.out.println(client1.nextId("Benutzer")); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -42,7 +42,7 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 	 * @param controllerName Name des aufzurufenden Controllers | 	 * @param controllerName Name des aufzurufenden Controllers | ||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public void get(String controllerName) { | 	public String get(String controllerName) { | ||||||
| 		URI apiUri = URI.create(String.format("%s/%s", urlBase, controllerName)); | 		URI apiUri = URI.create(String.format("%s/%s", urlBase, controllerName)); | ||||||
|  |  | ||||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||||
| @@ -54,13 +54,13 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 			// Send the request and get the response | 			// Send the request and get the response | ||||||
| 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | 			HttpResponse<String> httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||||||
|  |  | ||||||
| 			Kind test = gson.fromJson(httpResponse.body(), Kind.class); |  | ||||||
|  |  | ||||||
| 			// Print the response status code and body | 			// Print the response status code and body | ||||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||||
| 			System.out.println("Response Body: " + test.getName()); | 			System.out.println("Response Body: " + httpResponse.body()); | ||||||
|  | 			return httpResponse.body(); | ||||||
| 		} catch (Exception e) { | 		} catch (Exception e) { | ||||||
| 			e.printStackTrace(); | 			e.printStackTrace(); | ||||||
|  | 			return null; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -71,7 +71,7 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 	 * @param id Id der Aufzurufenden Zeile | 	 * @param id Id der Aufzurufenden Zeile | ||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public void get(String controllerName, int id) { | 	public String get(String controllerName, int id) { | ||||||
| 		URI apiUri = URI.create(String.format("%s/%s/%s", urlBase, controllerName, id)); | 		URI apiUri = URI.create(String.format("%s/%s/%s", urlBase, controllerName, id)); | ||||||
|  |  | ||||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||||
| @@ -86,9 +86,12 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 			// Print the response status code and body | 			// 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(); | ||||||
|  |  | ||||||
| 			//System.out.println("Response Body: " + test); | 			//System.out.println("Response Body: " + test); | ||||||
| 		} catch (Exception e) { | 		} catch (Exception e) { | ||||||
| 			e.printStackTrace(); | 			e.printStackTrace(); | ||||||
|  | 			return null; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -100,7 +103,7 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 	 * @param bezahlt TODO Warum ist das hier? | 	 * @param bezahlt TODO Warum ist das hier? | ||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public void get(String controllerName, int id, boolean bezahlt) { | 	public String get(String controllerName, int id, boolean bezahlt) { | ||||||
| 		URI apiUri = URI.create(String.format("%s/%s?%s&%s", urlBase, controllerName, id, bezahlt)); | 		URI apiUri = URI.create(String.format("%s/%s?%s&%s", urlBase, controllerName, id, bezahlt)); | ||||||
|  |  | ||||||
| 		HttpRequest httpRequest = HttpRequest.newBuilder() | 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||||
| @@ -115,8 +118,10 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 			// Print the response status code and body | 			// Print the response status code and body | ||||||
| 			System.out.println("Status Code: " + httpResponse.statusCode()); | 			System.out.println("Status Code: " + httpResponse.statusCode()); | ||||||
| 			System.out.println("Response Body: " + httpResponse.body()); | 			System.out.println("Response Body: " + httpResponse.body()); | ||||||
|  | 			return httpResponse.body(); | ||||||
| 		} catch (Exception e) { | 		} catch (Exception e) { | ||||||
| 			e.printStackTrace(); | 			e.printStackTrace(); | ||||||
|  | 			return null; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -210,4 +215,34 @@ public class RestApiClient implements IRestAPI{ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	public int nextId(String controllerName){ | ||||||
|  | 		URI apiUri = URI.create(String.format("%s/%s/nextId", urlBase, controllerName)); | ||||||
|  |  | ||||||
|  | 		HttpRequest httpRequest = HttpRequest.newBuilder() | ||||||
|  | 											 .uri(apiUri) | ||||||
|  | 											 .GET() | ||||||
|  | 											 .build(); | ||||||
|  |  | ||||||
|  | 		try { | ||||||
|  | 			// 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()); | ||||||
|  |  | ||||||
|  | 			JsonElement jsonElement = JsonParser.parseString(httpResponse.body()); | ||||||
|  | 			JsonArray jsonArray = jsonElement.getAsJsonArray(); | ||||||
|  |  | ||||||
|  | 			JsonObject json = jsonArray.get(0).getAsJsonObject(); | ||||||
|  |  | ||||||
|  | 			return json.get("auto_increment").getAsInt(); | ||||||
|  |  | ||||||
|  | 		} catch (Exception e) { | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 			return -1; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| package de.subway_surfers.vpr_app; | package de.subway_surfers.vpr_app; | ||||||
|  |  | ||||||
|  | import Logik.Account; | ||||||
|  | import Logik.ElternAccount; | ||||||
|  | import Logik.Kind; | ||||||
|  | import Logik.MitarbeiterAccount; | ||||||
|  | import RestAPISchnittstelle.RestApiClient; | ||||||
| import javafx.collections.ListChangeListener; | import javafx.collections.ListChangeListener; | ||||||
| import javafx.event.ActionEvent; | import javafx.event.ActionEvent; | ||||||
| import javafx.fxml.FXML; | import javafx.fxml.FXML; | ||||||
| @@ -8,11 +13,15 @@ import javafx.scene.layout.Background; | |||||||
| import javafx.scene.layout.GridPane; | import javafx.scene.layout.GridPane; | ||||||
| import javafx.scene.layout.HBox; | import javafx.scene.layout.HBox; | ||||||
| import javafx.scene.layout.VBox; | import javafx.scene.layout.VBox; | ||||||
|  | import com.google.gson.Gson; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
| import java.util.Random; | import java.util.Random; | ||||||
|  |  | ||||||
| public class AccounterstellungMitarbeiter { | public class AccounterstellungMitarbeiter { | ||||||
|  |  | ||||||
|  | 	private @FXML TextField accountname; | ||||||
|  | 	private @FXML TextField email; | ||||||
| 	private @FXML Label status; | 	private @FXML Label status; | ||||||
| 	private @FXML Label einmalpw; | 	private @FXML Label einmalpw; | ||||||
| 	private @FXML HBox kindanzeige; | 	private @FXML HBox kindanzeige; | ||||||
| @@ -21,11 +30,17 @@ public class AccounterstellungMitarbeiter { | |||||||
| 	private @FXML RadioButton typEltern; | 	private @FXML RadioButton typEltern; | ||||||
| 	private       ToggleGroup accountTyp; | 	private       ToggleGroup accountTyp; | ||||||
|  |  | ||||||
|  | 	private ArrayList<Kind> kinder; | ||||||
|  |  | ||||||
| 	public void initialize() { | 	public void initialize() { | ||||||
|  | 		//Die Radiobuttons zum auswählen eines Accountypes werden einer ToggleGroup hinzugefügt | ||||||
| 		accountTyp = new ToggleGroup(); | 		accountTyp = new ToggleGroup(); | ||||||
| 		accountTyp.getToggles().add(typEltern); | 		accountTyp.getToggles().add(typEltern); | ||||||
| 		accountTyp.getToggles().add(typMitarbeiter); | 		accountTyp.getToggles().add(typMitarbeiter); | ||||||
|  |  | ||||||
| 		einmalpw.setText(einmalPwGenerieren()); | 		einmalpw.setText(einmalPwGenerieren()); | ||||||
|  |  | ||||||
|  | 		kinder = new ArrayList<>(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onZurueck(ActionEvent actionEvent) { | 	public void onZurueck(ActionEvent actionEvent) { | ||||||
| @@ -33,14 +48,19 @@ public class AccounterstellungMitarbeiter { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onAbmelden(ActionEvent actionEvent) { | 	public void onAbmelden(ActionEvent actionEvent) { | ||||||
| 		//VerwaltungApplication.abmelden(); | 		VerwaltungApplication.abmelden(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onTypMitarbeiter(ActionEvent actionEvent) { | 	public void onTypMitarbeiter(ActionEvent actionEvent) { | ||||||
| 		kindDaten.getChildren().clear(); | 		kindDaten.getChildren().clear(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Einfügen der Eingabefelder für Kinder, wenn der Eltern-Radiobutton ausgewählt wird | ||||||
|  | 	 * @param actionEvent | ||||||
|  | 	 */ | ||||||
| 	public void onTypEltern(ActionEvent actionEvent) { | 	public void onTypEltern(ActionEvent actionEvent) { | ||||||
|  | 		//Einfügen der Eingabefelder für Kinder | ||||||
| 		Label ueberschrift = new Label(); | 		Label ueberschrift = new Label(); | ||||||
| 		ueberschrift.setText("Daten des Kindes:"); | 		ueberschrift.setText("Daten des Kindes:"); | ||||||
| 		kindDaten.addRow(0); | 		kindDaten.addRow(0); | ||||||
| @@ -72,6 +92,7 @@ public class AccounterstellungMitarbeiter { | |||||||
| 		kindDaten.add(hinzufuegen, 1, 4); | 		kindDaten.add(hinzufuegen, 1, 4); | ||||||
|  |  | ||||||
| 		kindDaten.addRow(5); | 		kindDaten.addRow(5); | ||||||
|  | 		//wird der Button zum hinzufügen eines Kindes geclickt wird dieses Event ausgelöst | ||||||
| 		hinzufuegen.setOnAction(e -> { | 		hinzufuegen.setOnAction(e -> { | ||||||
| 			Button neues = new Button(vnameEingabe.getText()); | 			Button neues = new Button(vnameEingabe.getText()); | ||||||
|  |  | ||||||
| @@ -79,6 +100,7 @@ public class AccounterstellungMitarbeiter { | |||||||
| 			boolean gebGueltig = false; | 			boolean gebGueltig = false; | ||||||
| 			boolean nnameGueltig = false; | 			boolean nnameGueltig = false; | ||||||
|  |  | ||||||
|  | 			//Wenn alle Eingabefelder für Kinder ausgefüllt sind ist die Eingabe gültig | ||||||
| 			if (!vnameEingabe.getText().equals("")) { | 			if (!vnameEingabe.getText().equals("")) { | ||||||
| 				vnameGueltig = true; | 				vnameGueltig = true; | ||||||
| 			} | 			} | ||||||
| @@ -92,10 +114,15 @@ public class AccounterstellungMitarbeiter { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (vnameGueltig && gebGueltig && nnameGueltig) { | 			if (vnameGueltig && gebGueltig && nnameGueltig) { | ||||||
|  | 				Kind kind = new Kind(nnameEingabe.getText(), vnameEingabe.getText(), 0); | ||||||
|  | 				kinder.add(kind); | ||||||
| 				kindanzeige.getChildren().add(neues); | 				kindanzeige.getChildren().add(neues); | ||||||
|  | 				//Wird auf ein Kind in der Anzeige geclickt, wird es aus der Liste entfernt. | ||||||
| 				neues.setOnAction(a -> { | 				neues.setOnAction(a -> { | ||||||
| 					((HBox) neues.getParent()).getChildren().remove(neues); | 					((HBox) neues.getParent()).getChildren().remove(neues); | ||||||
|  | 					kinder.remove(kind); | ||||||
| 				}); | 				}); | ||||||
|  | 				//Die Eingabefelder werden zurückgesetzt | ||||||
| 				vnameEingabe.setText(""); | 				vnameEingabe.setText(""); | ||||||
| 				nnameEingabe.setText(""); | 				nnameEingabe.setText(""); | ||||||
| 				geburtstagEingabe.getEditor().setText(""); | 				geburtstagEingabe.getEditor().setText(""); | ||||||
| @@ -113,18 +140,68 @@ public class AccounterstellungMitarbeiter { | |||||||
| 		return pw; | 		return pw; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Prüft, ob in allen Textfeldern für die Eltern Text steht. | ||||||
|  | 	 * @return true, wenn kein Feld leer ist | ||||||
|  | 	 */ | ||||||
| 	private boolean eingabenGueltig() { | 	private boolean eingabenGueltig() { | ||||||
|  | 		return !accountname.getText().equals("") && !email.getText().equals("") && (typEltern.isSelected() || typMitarbeiter.isSelected()); | ||||||
| 		return true; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * | ||||||
|  | 	 * @param actionEvent | ||||||
|  | 	 */ | ||||||
| 	public void onSpeichern(ActionEvent actionEvent) { | 	public void onSpeichern(ActionEvent actionEvent) { | ||||||
| 		if (eingabenGueltig()) { | 		if (eingabenGueltig()) { | ||||||
| 			status.setText("Daten Erfolgreich gespeichert"); | 			//Zeigt generiert ein Einmalpasswort und zeigt es an | ||||||
| 			einmalpw.setText(einmalPwGenerieren()); | 			einmalpw.setText(einmalPwGenerieren()); | ||||||
|  |  | ||||||
|  | 			//Schnittstelle zur RestAPI | ||||||
|  | 			RestApiClient api = new RestApiClient(); | ||||||
|  |  | ||||||
|  | 			//id, die das Elternobjekt bekommt, dass im laufe der Methode erstellt wird | ||||||
|  | 			int id = api.nextId("Benutzer"); | ||||||
|  |  | ||||||
|  | 			//Erstellen des neuen Accounts | ||||||
|  | 			Account neuer; | ||||||
|  | 			//Handelt es sich um einen Elternaccount, werden alle Eingegebenen Kinder erstellt. | ||||||
|  | 			if (typEltern.isSelected()) { | ||||||
|  | 				neuer = new ElternAccount(String.format("%d",einmalpw.getText().hashCode()), accountname.getText(), email.getText()); | ||||||
|  | 				System.out.println(neuer.getEmail()); | ||||||
|  | 				//Kinder dem neuen Account hinzufügen | ||||||
|  | 				for (Kind k : kinder) { | ||||||
|  | 					((ElternAccount)neuer).getKinder().add(k); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			else if (typMitarbeiter.isSelected()) { | ||||||
|  | 				neuer = new MitarbeiterAccount(String.format("%d",einmalpw.getText().hashCode()), accountname.getText(), email.getText()); | ||||||
|  | 			} | ||||||
|  | 			//Ist kein Radio Button ausgewählt, wird hier abgebrochen | ||||||
|  | 			else { | ||||||
|  | 				return; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 	} | 			//Die Liste, zum Speichern der gespeicherten Liste wird zurückgesetzt, da die Kinder jetzt im Elternobjekt gespeichert werden | ||||||
|  | 			kinder.clear(); | ||||||
|  |  | ||||||
|  | 			Gson gson = new Gson(); | ||||||
|  |  | ||||||
|  | 			//Das Elternelement wird in der DB gespeichert. | ||||||
|  | 			api.post("Benutzer", gson.toJson(neuer)); | ||||||
|  |  | ||||||
|  | 			//handelt es sich um einen Elternaccount, werden alle Kind-Objekte in der DB gespeichert | ||||||
|  | 			if (neuer instanceof ElternAccount) { | ||||||
|  | 				for (Kind k : ((ElternAccount)neuer).getKinder()) { | ||||||
|  | 					//setzen des Fremdschlüssels bid | ||||||
|  | 					k.setBid(id); | ||||||
|  | 					api.post("Kind", gson.toJson(k)); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			status.setText("Daten Erfolgreich gespeichert"); | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			status.setText("Accounterstellung Fehlgeschlagen"); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,6 +9,8 @@ import javafx.scene.layout.ColumnConstraints; | |||||||
| import javafx.scene.layout.GridPane; | import javafx.scene.layout.GridPane; | ||||||
| import javafx.scene.layout.Priority; | import javafx.scene.layout.Priority; | ||||||
| import javafx.scene.layout.RowConstraints; | import javafx.scene.layout.RowConstraints; | ||||||
|  | import javafx.stage.Modality; | ||||||
|  | import javafx.stage.Stage; | ||||||
|  |  | ||||||
|  |  | ||||||
| public class EssensverwaltungMitarbeiterView { | public class EssensverwaltungMitarbeiterView { | ||||||
| @@ -39,15 +41,24 @@ public class EssensverwaltungMitarbeiterView { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onFilter(ActionEvent actionEvent) { | 	public void onFilter(ActionEvent actionEvent) { | ||||||
|  | 		Stage stage = new Stage(); | ||||||
|  | 		VerwaltungApplication.sceneWechseln(stage, 450, 400, "inhaltsstoffe_filtern-view.fxml"); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onHinzufuegen(ActionEvent actionEvent) { | 	public void onHinzufuegen(ActionEvent actionEvent) { | ||||||
|  | 		Stage gerichterstellung = new Stage(); | ||||||
|  |  | ||||||
|  | 		//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"); | ||||||
|  |  | ||||||
|  | 		gerichterstellung.minWidthProperty().set(400); | ||||||
|  | 		gerichterstellung.minHeightProperty().set(530); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void onZurueck(ActionEvent actionEvent) { | 	public void onZurueck(ActionEvent actionEvent) { | ||||||
| 		VerwaltungApplication.sceneWechseln("hauptmenue_mitarbeiter-view.fxml"); | 		VerwaltungApplication.sceneWechseln("hauptmenue_mitarbeiter-view.fxml"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ import javafx.event.ActionEvent; | |||||||
| public class HauptmenueMitarbeiterView { | public class HauptmenueMitarbeiterView { | ||||||
|  |  | ||||||
|     public void onAbmelden(ActionEvent actionEvent) { |     public void onAbmelden(ActionEvent actionEvent) { | ||||||
|         //VerwaltungApplication.abmelden(); |         VerwaltungApplication.abmelden(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void onAccountAnlegenClick(ActionEvent actionEvent) { |     public void onAccountAnlegenClick(ActionEvent actionEvent) { | ||||||
|   | |||||||
| @@ -110,7 +110,10 @@ public class VerwaltungApplication extends Application { | |||||||
|  |  | ||||||
| 			e.printStackTrace(); | 			e.printStackTrace(); | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public static void abmelden() { | ||||||
|  | 		sceneWechseln("login-view.fxml"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package de.subway_surfers.vpr_app; | package de.subway_surfers.vpr_app; | ||||||
|  |  | ||||||
|  | import Logik.Account; | ||||||
|  | import RestAPISchnittstelle.RestApiClient; | ||||||
| import javafx.event.ActionEvent; | import javafx.event.ActionEvent; | ||||||
| import javafx.fxml.FXML; | import javafx.fxml.FXML; | ||||||
| import javafx.fxml.FXMLLoader; | import javafx.fxml.FXMLLoader; | ||||||
|   | |||||||
| @@ -28,9 +28,9 @@ | |||||||
|                 <VBox styleClass="accounterstellung_links"> |                 <VBox styleClass="accounterstellung_links"> | ||||||
|                     <GridPane styleClass="accounterstellung_daten"> |                     <GridPane styleClass="accounterstellung_daten"> | ||||||
|                         <Label text="Accountname:" GridPane.rowIndex="0" GridPane.columnIndex="0"/> |                         <Label text="Accountname:" GridPane.rowIndex="0" GridPane.columnIndex="0"/> | ||||||
|                         <TextField GridPane.rowIndex="0" GridPane.columnIndex="1"/> |                         <TextField fx:id="accountname" GridPane.rowIndex="0" GridPane.columnIndex="1"/> | ||||||
|                         <Label text="E-Mail:" GridPane.rowIndex="1" GridPane.columnIndex="0"/> |                         <Label text="E-Mail:" GridPane.rowIndex="1" GridPane.columnIndex="0"/> | ||||||
|                         <TextField GridPane.rowIndex="1" GridPane.columnIndex="1"/> |                         <TextField fx:id="email" GridPane.rowIndex="1" GridPane.columnIndex="1"/> | ||||||
|                         <RadioButton fx:id="typMitarbeiter" onAction="#onTypMitarbeiter" text="Mitarbeiter" GridPane.rowIndex="2" GridPane.columnIndex="0"/> |                         <RadioButton fx:id="typMitarbeiter" onAction="#onTypMitarbeiter" text="Mitarbeiter" GridPane.rowIndex="2" GridPane.columnIndex="0"/> | ||||||
|                         <RadioButton fx:id="typEltern" onAction="#onTypEltern" text="Eltern" GridPane.rowIndex="2" GridPane.columnIndex="1"/> |                         <RadioButton fx:id="typEltern" onAction="#onTypEltern" text="Eltern" GridPane.rowIndex="2" GridPane.columnIndex="1"/> | ||||||
|                     </GridPane> |                     </GridPane> | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ | |||||||
|     -fx-padding: 20; |     -fx-padding: 20; | ||||||
| } | } | ||||||
|  |  | ||||||
| .hauptmenue_buttons_links{ | .hauptmenue_buttons_links, .gerichterstellung_felder, .filter, .main, .filter_unten{ | ||||||
|     -fx-spacing: 20; |     -fx-spacing: 20; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -73,6 +73,13 @@ | |||||||
|     -fx-vgap: 10; |     -fx-vgap: 10; | ||||||
|     -fx-hgap: 10; |     -fx-hgap: 10; | ||||||
| } | } | ||||||
|  | .test { | ||||||
|  |     -fx-padding: 10 20; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .essensuebersicht_gridlines { | ||||||
|  |      -fx-grid-lines-visible: true; | ||||||
|  | } | ||||||
|  |  | ||||||
| .accounterstellung_links { | .accounterstellung_links { | ||||||
|     -fx-spacing: 20; |     -fx-spacing: 20; | ||||||
| @@ -82,3 +89,24 @@ | |||||||
|     -fx-background-color: #FFDCDC; |     -fx-background-color: #FFDCDC; | ||||||
|     -fx-text-fill: #FFDCDC; |     -fx-text-fill: #FFDCDC; | ||||||
| } | } | ||||||
|  | .essensuebersicht_gridlines > * { | ||||||
|  |     -fx-alignment: center; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .pfeil{ | ||||||
|  |     -fx-background-color: -fx-mark-highlight-color, -fx-mark-color; | ||||||
|  |     -fx-background-insets: 0 0 -1 0, 0; | ||||||
|  |     -fx-padding: 0.25em; | ||||||
|  |     -fx-shape: "M 0 -3.5 v 7 l 4 -3.5 z"; | ||||||
|  |     -fx-pref-width: 25; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .links { | ||||||
|  |     -fx-rotate: 180; | ||||||
|  | } | ||||||
|  | .titledPaneUeberschrift > .title { | ||||||
|  |     -fx-pref-height: 50; | ||||||
|  |     -fx-padding: 10 10 16 10; | ||||||
|  |     -fx-font-size: 15; | ||||||
|  |     -fx-font-weight: bold; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user