Compare commits

..

No commits in common. "287ccd9ce57d39894250138d89e2017100540439" and "0a8d4e47ac7abb99c8cae9da51d5861d175e0a29" have entirely different histories.

4 changed files with 22 additions and 95 deletions

View File

@ -7,8 +7,9 @@
<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_X" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" 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>

View File

@ -11,11 +11,11 @@ public interface IRestAPI {
// region Get // region Get
String get(String controllerName); void get(String controllerName);
String get (String controllerName, int id); void get (String controllerName, int id);
String get (String controllerName, int id, boolean bezahlt); void get (String controllerName, int id, boolean bezahlt);
//endregion //endregion

View File

@ -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.*; import com.google.gson.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 String get(String controllerName) { public void 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: " + httpResponse.body()); System.out.println("Response Body: " + test.getName());
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 String get(String controllerName, int id) { public void 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,12 +86,9 @@ 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;
} }
} }
@ -103,7 +100,7 @@ public class RestApiClient implements IRestAPI{
* @param bezahlt TODO Warum ist das hier? * @param bezahlt TODO Warum ist das hier?
*/ */
@Override @Override
public String get(String controllerName, int id, boolean bezahlt) { public void 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()
@ -118,10 +115,8 @@ 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;
} }
} }
@ -215,34 +210,4 @@ 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;
}
}
} }

View File

@ -1,16 +1,11 @@
package de.subway_surfers.vpr_app; package de.subway_surfers.vpr_app;
import RestAPISchnittstelle.IRestAPI;
import RestAPISchnittstelle.RestApiClient;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Accordion; import javafx.scene.control.Accordion;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.scene.control.TitledPane; import javafx.scene.control.TitledPane;
import javafx.scene.layout.VBox;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -33,28 +28,23 @@ public class BestelluebersichtMitarbeiter {
accordion.setStyle("-fx-box-border: transparent;"); accordion.setStyle("-fx-box-border: transparent;");
for (String i : datum) { for (String s : datum) {
Accordion gerichtAkkordion = createGerichtAkkordion(); TitledPane datumUeberschrift = new TitledPane(s, createGerichtAkkordion());
TitledPane datumUeberschrift = new TitledPane(i, gerichtAkkordion);
datumUeberschrift.getStyleClass().add("titledPaneUeberschrift"); datumUeberschrift.getStyleClass().add("titledPaneUeberschrift");
datumUeberschrift.animatedProperty().set(false); datumUeberschrift.animatedProperty().set(false);
datumUeberschrift.setPadding(new Insets(0, 0, 15, 0)); datumUeberschrift.setPadding(new Insets(0, 0, 15, 0));
//TitledPane personen = new TitledPane("Person", createPersonenAccordion());
accordion.getPanes().add(datumUeberschrift); accordion.getPanes().add(datumUeberschrift);
//gerichtAkkordion.getPanes().add(personen);
} }
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
} }
int anzahlGerichtA = 1; private Accordion createGerichtAkkordion() {
public Accordion createGerichtAkkordion() {
Accordion accordion = new Accordion(); Accordion accordion = new Accordion();
int anzahlGerichtA = 1;
int anzahlGerichtB = 15; int anzahlGerichtB = 15;
int anzahlGerichtC = 3; int anzahlGerichtC = 3;
int anzahlGerichtD = 2; int anzahlGerichtD = 2;
@ -81,7 +71,6 @@ public class BestelluebersichtMitarbeiter {
TitledPane tp = new TitledPane(); TitledPane tp = new TitledPane();
tp.setText("GerichtB " + anzahlGerichtB + "-Mal " + preisGerichtB * anzahlGerichtB + ""); tp.setText("GerichtB " + anzahlGerichtB + "-Mal " + preisGerichtB * anzahlGerichtB + "");
accordion.getPanes().addAll(tp); accordion.getPanes().addAll(tp);
} }
if (anzahlGerichtC >= 1) { if (anzahlGerichtC >= 1) {
@ -103,42 +92,14 @@ public class BestelluebersichtMitarbeiter {
} }
if(anzahlNachtischA >= 1){ if(anzahlNachtischA >= 1){
TitledPane tp = new TitledPane();
Label label2 = new Label("Hans Schwanz" + " für " + " Anja Arbeitslos"); tp.setText("NachtischB " + anzahlNachtischB + "-Mal " + preisNachtischB * anzahlNachtischB + "");
Label label3 = new Label("Drittes Label");
VBox vbox = new VBox(label2, label3);
vbox.setAlignment(Pos.CENTER_LEFT);
TitledPane tp = new TitledPane("NachtischB " + "-Mal " + preisNachtischB * anzahlGerichtB + "", vbox);
accordion.getPanes().addAll(tp); accordion.getPanes().addAll(tp);
} }
return accordion; 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) { public void onAbmelden(ActionEvent event) {
VerwaltungApplication.abmelden(); VerwaltungApplication.abmelden();
} }