Fixed event/add endpoint
This commit is contained in:
parent
78505097db
commit
2269f05f52
@ -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
|
||||||
);
|
);
|
||||||
|
@ -4,9 +4,11 @@ import com.sun.jdi.event.StepEvent;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
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;
|
||||||
@ -95,17 +97,19 @@ public class Event {
|
|||||||
int priority,
|
int priority,
|
||||||
boolean isFullDay,
|
boolean isFullDay,
|
||||||
boolean isPrivate,
|
boolean isPrivate,
|
||||||
String start,
|
LocalTime start,
|
||||||
String end,
|
LocalTime end,
|
||||||
LocalDateTime date,
|
LocalDateTime date,
|
||||||
int ownerId
|
int ownerId
|
||||||
) throws IllegalArgumentException{
|
) throws IllegalArgumentException {
|
||||||
if(name.length() < 3){
|
|
||||||
|
System.out.println("Create Event");
|
||||||
|
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.");
|
||||||
}
|
}
|
||||||
Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$.:,;_<>()-]*");
|
Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$.:,;_<>()-]*");
|
||||||
Matcher matcher = pattern.matcher(name);
|
Matcher matcher = pattern.matcher(name);
|
||||||
if(!matcher.matches()){
|
if (!matcher.matches()) {
|
||||||
System.out.println(name);
|
System.out.println(name);
|
||||||
|
|
||||||
byte[] bytes = name.getBytes(StandardCharsets.UTF_16);
|
byte[] bytes = name.getBytes(StandardCharsets.UTF_16);
|
||||||
@ -114,25 +118,25 @@ public class Event {
|
|||||||
System.out.println(utf8EncodedString);
|
System.out.println(utf8EncodedString);
|
||||||
|
|
||||||
for (char c : (name).toCharArray()) {
|
for (char c : (name).toCharArray()) {
|
||||||
System.out.print(c + " " + (int)c + ", ");
|
System.out.print(c + " " + (int) c + ", ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
for (char c : (name).toCharArray()) {
|
for (char c : (name).toCharArray()) {
|
||||||
System.out.print(c + " " + (int)c + ", ");
|
System.out.print(c + " " + (int) c + ", ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
for (char c : ("TäöüÄÖÜ").toCharArray()) {
|
for (char c : ("TäöüÄÖÜ").toCharArray()) {
|
||||||
System.out.print(c + " " + (int)c + ", ");
|
System.out.print(c + " " + (int) c + ", ");
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$.:,;_ <>()-");
|
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$.:,;_ <>()-");
|
||||||
}
|
}
|
||||||
if(priority < 0){
|
if (priority < 0) {
|
||||||
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen.");
|
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen.");
|
||||||
}
|
}
|
||||||
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||||
if(Duration.between(today, date).isNegative()){
|
if (Duration.between(today, date).isNegative()) {
|
||||||
throw new IllegalArgumentException("Das Datum muss in der Zukunft liegen.");
|
throw new IllegalArgumentException("Das Datum muss in der Zukunft liegen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,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;
|
||||||
}
|
}
|
||||||
@ -242,12 +246,12 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertToASCII(String s){
|
private String convertToASCII(String s) {
|
||||||
byte[] germanBytes = s.getBytes();
|
byte[] germanBytes = s.getBytes();
|
||||||
return new String(germanBytes, StandardCharsets.US_ASCII);
|
return new String(germanBytes, StandardCharsets.US_ASCII);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user