Compare commits
14 Commits
0132077c62
...
141d294b79
Author | SHA1 | Date | |
---|---|---|---|
141d294b79 | |||
2269f05f52 | |||
78505097db | |||
7a119a8aed | |||
22e7d30678 | |||
3c0ebd24d7 | |||
f649b618cf | |||
6e6183bf38 | |||
947f31f20e | |||
7c8b1fefb7 | |||
b12de1cd2e | |||
097cce14e8 | |||
226255f75a | |||
d574849407 |
@ -12,6 +12,7 @@ import javafx.util.converter.LocalTimeStringConverter;
|
|||||||
import res.DataController;
|
import res.DataController;
|
||||||
import res.Event;
|
import res.Event;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -65,8 +66,8 @@ public class CreateEventController {
|
|||||||
ComboBoxPriotity.getSelectionModel().getSelectedIndex(),
|
ComboBoxPriotity.getSelectionModel().getSelectedIndex(),
|
||||||
toggleBtnIsFullDay.isSelected(),
|
toggleBtnIsFullDay.isSelected(),
|
||||||
toggleBtnIsPrivate.isSelected(),
|
toggleBtnIsPrivate.isSelected(),
|
||||||
timeStart.getValue().toString(),
|
timeStart.getValue(),
|
||||||
timeEnd.getValue().toString(),
|
timeEnd.getValue(),
|
||||||
datePickerDate.getValue().atStartOfDay(),
|
datePickerDate.getValue().atStartOfDay(),
|
||||||
(int) DataController.USER_ID
|
(int) DataController.USER_ID
|
||||||
);
|
);
|
||||||
|
@ -12,25 +12,33 @@ import java.util.Objects;
|
|||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml"));
|
|
||||||
|
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 1200, 700);
|
System.out.println("Ignore 'Illegal reflective access operation'-Warning. See https://github.com/sshahine/JFoenix/issues/1170");
|
||||||
scene.getStylesheets().add(Objects.requireNonNull(
|
|
||||||
MainApplication.class.getResource("main-view.css")).toExternalForm());
|
|
||||||
stage.setTitle("SharePlaner");
|
|
||||||
stage.setScene(scene);
|
|
||||||
|
|
||||||
|
// Load login-scene
|
||||||
FXMLLoader fxmlLoaderLogin = new FXMLLoader(MainApplication.class.getResource("../users/login.fxml"));
|
FXMLLoader fxmlLoaderLogin = new FXMLLoader(MainApplication.class.getResource("../users/login.fxml"));
|
||||||
Scene sceneLogin = new Scene(fxmlLoaderLogin.load(), 650, 500);
|
Scene sceneLogin = new Scene(fxmlLoaderLogin.load(), 650, 500);
|
||||||
sceneLogin.getStylesheets().add(Objects.requireNonNull(
|
sceneLogin.getStylesheets().add(Objects.requireNonNull(
|
||||||
MainApplication.class.getResource("../users/login.css")).toExternalForm());
|
MainApplication.class.getResource("../users/login.css")).toExternalForm()
|
||||||
|
);
|
||||||
Stage stageLogin = new Stage();
|
Stage stageLogin = new Stage();
|
||||||
stageLogin.setTitle("Anmelden");
|
stageLogin.setTitle("Anmelden");
|
||||||
stageLogin.setScene(sceneLogin);
|
stageLogin.setScene(sceneLogin);
|
||||||
stageLogin.showAndWait();
|
stageLogin.showAndWait();
|
||||||
|
|
||||||
if (DataController.USER_ID >= 0) {
|
if (DataController.USER_ID >= 0) {
|
||||||
|
// Load main-scene
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml"));
|
||||||
|
|
||||||
|
Scene scene = new Scene(fxmlLoader.load(), 1200, 700);
|
||||||
|
scene.getStylesheets().add(Objects.requireNonNull(
|
||||||
|
MainApplication.class.getResource("main-view.css")).toExternalForm()
|
||||||
|
);
|
||||||
|
stage.setTitle("SharePlaner");
|
||||||
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
|
System.out.println("Logged in...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataController dataController = new DataController();
|
DataController dataController = new DataController();
|
||||||
ArrayList<Event> eventList = dataController.getAllVisibleEvents();
|
ArrayList<Event> eventList = dataController.getAllVisibleEvents(weekStartDateTime, weekStartDateTime.plusDays(7));
|
||||||
|
|
||||||
for (Event event : eventList) {
|
for (Event event : eventList) {
|
||||||
addEvent(event);
|
addEvent(event);
|
||||||
@ -166,7 +166,7 @@ public class MainController {
|
|||||||
deleteBtn.getStyleClass().add("deleteEventBtn");
|
deleteBtn.getStyleClass().add("deleteEventBtn");
|
||||||
deleteBtn.setOnAction(e -> {
|
deleteBtn.setOnAction(e -> {
|
||||||
DataController dataController = new DataController();
|
DataController dataController = new DataController();
|
||||||
dataController.deleteEvent(event.getId());
|
dataController.deleteEvent(event.getOwnerId(), event.getId(), event.getDate());
|
||||||
updateEvents();
|
updateEvents();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
55
client/app/src/main/java/users/CreateUserController.java
Normal file
55
client/app/src/main/java/users/CreateUserController.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package users;
|
||||||
|
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CreateUserController {
|
||||||
|
|
||||||
|
public TextField textName;
|
||||||
|
public TextField textPassword;
|
||||||
|
public TextField textPasswordSecond;
|
||||||
|
public ToggleButton checkButtonIsAdmin;
|
||||||
|
public TextField textLogin;
|
||||||
|
public TextField textForename;
|
||||||
|
public Label labelError;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void createUser(ActionEvent event) {
|
||||||
|
if (textLogin.getText().trim().isEmpty()){
|
||||||
|
labelError.setText("Bitte Login Namen angeben");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (textForename.getText().trim().isEmpty()) {
|
||||||
|
labelError.setText("Bitte Vornamen eingeben!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (textName.getText().trim().isEmpty()) {
|
||||||
|
labelError.setText("Bitte Nachnamen eingeben!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (textPassword.getText().trim().isEmpty()) {
|
||||||
|
labelError.setText("Bitte Passwort eingeben!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||||
|
labelError.setText("Passwörter stimmen nicht überein!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void abortBtnClick(ActionEvent event) {
|
||||||
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
}
|
56
client/app/src/main/resources/users/create-user.css
Normal file
56
client/app/src/main/resources/users/create-user.css
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
* {
|
||||||
|
-fx-base-background-color: #2B2D42;
|
||||||
|
-fx-base1-background-color: #525E74;
|
||||||
|
|
||||||
|
-fx-main-border-color: #B0B0B0;
|
||||||
|
-fx-main-text-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GridPane{
|
||||||
|
-fx-background-color: #3E415F;
|
||||||
|
-fx-padding: 20px;
|
||||||
|
-fx-font-size: 20px;
|
||||||
|
-fx-font-family: Segoe UI;
|
||||||
|
|
||||||
|
-fx-border-insets: 1;
|
||||||
|
-fx-border-color: #B0B0B0;
|
||||||
|
-fx-border-style: solid;
|
||||||
|
-fx-border-width: 2;
|
||||||
|
-fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mainLabel{
|
||||||
|
-fx-padding: 10px;
|
||||||
|
-fx-max-width: 400px;
|
||||||
|
-fx-min-width: 400px;
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
-fx-alignment: top-center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Label{
|
||||||
|
-fx-text-fill: white;
|
||||||
|
-fx-max-width: 150px;
|
||||||
|
-fx-min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textField{
|
||||||
|
-fx-max-width: 400px;
|
||||||
|
-fx-min-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.errorMessage{
|
||||||
|
-fx-max-width: 400px;
|
||||||
|
-fx-min-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button{
|
||||||
|
-fx-max-width: 150px;
|
||||||
|
-fx-min-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btnLogin{
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
}
|
||||||
|
|
56
client/app/src/main/resources/users/create-user.fxml
Normal file
56
client/app/src/main/resources/users/create-user.fxml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<GridPane xmlns="http://javafx.com/javafx"
|
||||||
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="users.CreateUserController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
</rowConstraints>
|
||||||
|
|
||||||
|
<Label styleClass="mainLabel" GridPane.columnIndex="2" >User anlegen</Label>
|
||||||
|
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="1" GridPane.columnIndex="1">Login:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="2" GridPane.columnIndex="1">Vorname:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="3" GridPane.columnIndex="1">Nachname:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="4" GridPane.columnIndex="1">Passwort:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="5" GridPane.columnIndex="1">Passwort wiederholen:</Label>
|
||||||
|
|
||||||
|
<Label styleClass="inputLabelAdmin" GridPane.rowIndex="6" GridPane.columnIndex="1">Admin:</Label>
|
||||||
|
|
||||||
|
<TextField fx:id="textLogin" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="textForename" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
|
<TextField fx:id="textName" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
|
<TextField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
|
<TextField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
|
|
||||||
|
<ToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
||||||
|
|
||||||
|
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
|
||||||
|
|
||||||
|
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="100" left="100"/>
|
||||||
|
</HBox.margin>
|
||||||
|
<Button onAction="#abortBtnClick">Abbrechen</Button>
|
||||||
|
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button>
|
||||||
|
|
||||||
|
</HBox>
|
||||||
|
</GridPane>
|
||||||
|
|
@ -7,4 +7,5 @@ dependencies {
|
|||||||
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
||||||
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
|
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
|
||||||
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
|
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
|
||||||
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
|
||||||
}
|
}
|
||||||
|
27
client/data/src/main/java/helper/Tuple.java
Normal file
27
client/data/src/main/java/helper/Tuple.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package helper;
|
||||||
|
|
||||||
|
public class Tuple<X, Y> {
|
||||||
|
public final X key;
|
||||||
|
public final Y value;
|
||||||
|
|
||||||
|
public Tuple(X key, Y value) {
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public X getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Y getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Tuple{" +
|
||||||
|
"key=" + key +
|
||||||
|
", value=" + value +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package res;
|
package res;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import helper.Tuple;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -10,6 +12,7 @@ import java.io.OutputStream;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class DataController {
|
public class DataController {
|
||||||
@ -22,6 +25,7 @@ public class DataController {
|
|||||||
|
|
||||||
private static final String LOGIN_ENDPOINT = "http://localhost:8080/user/login";
|
private static final String LOGIN_ENDPOINT = "http://localhost:8080/user/login";
|
||||||
private static final String ALL_USERS_ENDPOINT = "http://localhost:8080/user/all";
|
private static final String ALL_USERS_ENDPOINT = "http://localhost:8080/user/all";
|
||||||
|
private static final String HEADER_TEST_ENDPOINT = "http://localhost:8080/vpr/header-test";
|
||||||
|
|
||||||
private final HttpRequest httpRequest;
|
private final HttpRequest httpRequest;
|
||||||
|
|
||||||
@ -31,16 +35,28 @@ public class DataController {
|
|||||||
|
|
||||||
public boolean login(String username, String password) {
|
public boolean login(String username, String password) {
|
||||||
try {
|
try {
|
||||||
USER_ID = Long.parseLong(httpRequest.sendPostRequest(
|
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||||
LOGIN_ENDPOINT,
|
LOGIN_ENDPOINT,
|
||||||
"login=" + username
|
"login=" + username
|
||||||
+ "&password=" + password,
|
+ "&password=" + password,
|
||||||
false
|
false
|
||||||
));
|
);
|
||||||
|
String[] data = response.getValue().split("\\s+");
|
||||||
|
|
||||||
|
USER_ID = Long.parseLong(data[1]);
|
||||||
|
HttpRequest.TOKEN = data[0];
|
||||||
|
|
||||||
|
Tuple<Integer, String> auth = httpRequest.sendPostRequest(
|
||||||
|
HEADER_TEST_ENDPOINT,
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
System.out.println("auth " + auth);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return USER_ID >= 0;
|
return USER_ID >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,34 +68,35 @@ public class DataController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteEvent(int eventId) {
|
public void deleteEvent(int userId, int eventId, LocalDateTime date) {
|
||||||
try {
|
try {
|
||||||
System.out.println(httpRequest.sendPostRequest(DELETE_EVENT_ENDPOINT, "eventId=" + eventId, true));
|
System.out.println("DELETE: userId=" + userId + "&eventId=" + eventId + "&date=" + date.toLocalDate());
|
||||||
|
System.out.println(httpRequest.sendPostRequest(
|
||||||
|
DELETE_EVENT_ENDPOINT,
|
||||||
|
"userId=" + userId + "&eventId=" + eventId + "&date=" + date.toLocalDate(),
|
||||||
|
true
|
||||||
|
));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Event> getAllVisibleEvents() {
|
public ArrayList<Event> getAllVisibleEvents(LocalDateTime startDate, LocalDateTime endDate) {
|
||||||
ArrayList<Event> eventList = new ArrayList<>();
|
ArrayList<Event> eventList = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String jsonResponse = httpRequest.sendPostRequest(ALL_EVENTS_ENDPOINT, "userId=" + USER_ID, true);
|
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||||
|
ALL_EVENTS_ENDPOINT,
|
||||||
|
"userId=" + USER_ID + "&startDate=" + startDate.toLocalDate() + "&endDate=" + endDate.toLocalDate(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
String jsonResponse = response.getValue();
|
||||||
System.out.println(jsonResponse);
|
System.out.println(jsonResponse);
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
//String json = "{ \"color\" : \"Black\", \"type\" : \"BMW\" }";
|
objectMapper.findAndRegisterModules();
|
||||||
|
eventList = (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>(){});
|
||||||
|
|
||||||
for (Object obj : objectMapper.readValue(jsonResponse, Object[].class)) {
|
|
||||||
ArrayList<Object> list = new ArrayList<>();
|
|
||||||
if (obj.getClass().isArray()) {
|
|
||||||
list = (ArrayList<Object>) Arrays.asList((Object[]) obj);
|
|
||||||
} else if (obj instanceof Collection) {
|
|
||||||
list = new ArrayList<>((Collection<?>) obj);
|
|
||||||
}
|
|
||||||
eventList.add(new Event(list));
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -108,7 +125,6 @@ public class DataController {
|
|||||||
|
|
||||||
// Parse JSON
|
// Parse JSON
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
//String json = "{ \"color\" : \"Black\", \"type\" : \"BMW\" }";
|
|
||||||
|
|
||||||
return objectMapper.readValue(jsonString, Event[].class);
|
return objectMapper.readValue(jsonString, Event[].class);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,13 @@ package res;
|
|||||||
|
|
||||||
import com.sun.jdi.event.StepEvent;
|
import com.sun.jdi.event.StepEvent;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.sql.SQLOutput;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -43,6 +46,10 @@ public class Event {
|
|||||||
u.name AS uname
|
u.name AS uname
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public Event() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Event(ArrayList<Object> arr) {
|
public Event(ArrayList<Object> arr) {
|
||||||
id = (int) arr.get(0);
|
id = (int) arr.get(0);
|
||||||
name = (String) arr.get(1);
|
name = (String) arr.get(1);
|
||||||
@ -59,15 +66,44 @@ public class Event {
|
|||||||
ownerName = arr.get(8) + " " + arr.get(9);
|
ownerName = arr.get(8) + " " + arr.get(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Event(String name,
|
public Event(
|
||||||
|
int id,
|
||||||
|
String name,
|
||||||
int priority,
|
int priority,
|
||||||
boolean isFullDay,
|
boolean isFullDay,
|
||||||
boolean isPrivate,
|
boolean isPrivate,
|
||||||
String start,
|
String start,
|
||||||
String end,
|
String end,
|
||||||
|
String date,
|
||||||
|
int ownerId,
|
||||||
|
String ownerName
|
||||||
|
) {
|
||||||
|
this.ownerId = ownerId;
|
||||||
|
this.ownerName = ownerName;
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.priority = priority;
|
||||||
|
this.isFullDay = isFullDay;
|
||||||
|
|
||||||
|
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||||
|
this.date = LocalDateTime.parse(date + " 00:00", formatter);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event(String name,
|
||||||
|
int priority,
|
||||||
|
boolean isFullDay,
|
||||||
|
boolean isPrivate,
|
||||||
|
LocalTime start,
|
||||||
|
LocalTime end,
|
||||||
LocalDateTime date,
|
LocalDateTime date,
|
||||||
int ownerId
|
int ownerId
|
||||||
) throws IllegalArgumentException {
|
) throws IllegalArgumentException {
|
||||||
|
|
||||||
|
System.out.println("Create Event");
|
||||||
if (name.length() < 3) {
|
if (name.length() < 3) {
|
||||||
throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben.");
|
throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben.");
|
||||||
}
|
}
|
||||||
@ -108,8 +144,8 @@ public class Event {
|
|||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.isFullDay = isFullDay;
|
this.isFullDay = isFullDay;
|
||||||
this.isPrivate = isPrivate;
|
this.isPrivate = isPrivate;
|
||||||
this.start = start;
|
if (start != null) this.start = start.toString();
|
||||||
this.end = end;
|
if (start != null) this.end = end.toString();
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.ownerId = ownerId;
|
this.ownerId = ownerId;
|
||||||
}
|
}
|
||||||
@ -174,8 +210,9 @@ public class Event {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDate(LocalDateTime date) {
|
public void setDate(String date) {
|
||||||
this.date = date;
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||||
|
this.date = LocalDateTime.parse(date + " 00:00", formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOwnerId() {
|
public int getOwnerId() {
|
||||||
@ -209,7 +246,7 @@ public class Event {
|
|||||||
"&name=" + getName() +
|
"&name=" + getName() +
|
||||||
"&start=" + getStart() +
|
"&start=" + getStart() +
|
||||||
"&end=" + getEnd() +
|
"&end=" + getEnd() +
|
||||||
"&prority=" + getPriority() +
|
"&priority=" + getPriority() +
|
||||||
"&isFullDay=" + isFullDay() +
|
"&isFullDay=" + isFullDay() +
|
||||||
"&isPrivate=" + isPrivate();
|
"&isPrivate=" + isPrivate();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package res;
|
package res;
|
||||||
|
|
||||||
|
import helper.Tuple;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -9,7 +11,9 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class HttpRequest {
|
public class HttpRequest {
|
||||||
public String sendPostRequest(String urlString, String urlParameters, boolean sendAuth) throws Exception {
|
public static String TOKEN = "";
|
||||||
|
|
||||||
|
public Tuple<Integer, String> sendPostRequest(String urlString, String urlParameters, boolean sendAuth) throws Exception {
|
||||||
byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
|
byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
|
||||||
int postDataLength = postData.length;
|
int postDataLength = postData.length;
|
||||||
|
|
||||||
@ -39,7 +43,7 @@ public class HttpRequest {
|
|||||||
|
|
||||||
if(sendAuth){
|
if(sendAuth){
|
||||||
con.setRequestProperty("Accept", "application/json");
|
con.setRequestProperty("Accept", "application/json");
|
||||||
con.setRequestProperty("Authorization", "Bearer {token}");
|
con.setRequestProperty("Authorization", "Bearer " + TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
|
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
|
||||||
@ -47,22 +51,24 @@ public class HttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int status = con.getResponseCode();
|
int status = con.getResponseCode();
|
||||||
if (status == 200) {
|
|
||||||
BufferedReader in = new BufferedReader(
|
|
||||||
new InputStreamReader(con.getInputStream()));
|
|
||||||
String inputLine;
|
String inputLine;
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
|
BufferedReader in;
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
|
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
} else {
|
||||||
|
in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
|
||||||
|
}
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
content.append(inputLine);
|
content.append(inputLine);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
return content.toString();
|
|
||||||
} else {
|
return new Tuple<>(status, content.toString());
|
||||||
con.disconnect();
|
|
||||||
throw new Exception("Status: " + status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sendGetRequest(String urlString) throws Exception {
|
public String sendGetRequest(String urlString) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user