diff --git a/pom.xml b/pom.xml
index 8a728ed..aacfdfd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,15 +32,10 @@
vaadin-spring-boot-starter
-
- com.h2database
- h2
- runtime
+ org.mariadb.jdbc
+ mariadb-java-client
+ 3.5.1
org.springframework.boot
diff --git a/src/main/frontend/index.html b/src/main/frontend/index.html
new file mode 100644
index 0000000..d36e593
--- /dev/null
+++ b/src/main/frontend/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/frontend/themes/my-theme/styles.css b/src/main/frontend/themes/my-theme/styles.css
new file mode 100644
index 0000000..7402663
--- /dev/null
+++ b/src/main/frontend/themes/my-theme/styles.css
@@ -0,0 +1,19 @@
+/*
+ CSS styling examples for the Vaadin app.
+
+ Visit https://vaadin.com/docs/styling/application-theme/ for more information.
+*/
+
+/* Example: CSS class name to center align the content . */
+.centered-content {
+ margin: 0 auto;
+ max-width: 250px;
+}
+
+/* Example: the style is applied only to the textfields which have the `bordered` class name. */
+vaadin-text-field.bordered::part(input-field) {
+ box-shadow: inset 0 0 0 1px var(--lumo-contrast-30pct);
+ background-color: var(--lumo-base-color);
+}
+
+
diff --git a/src/main/frontend/themes/my-theme/theme.json b/src/main/frontend/themes/my-theme/theme.json
new file mode 100644
index 0000000..b007ffd
--- /dev/null
+++ b/src/main/frontend/themes/my-theme/theme.json
@@ -0,0 +1,3 @@
+{
+ "lumoImports" : [ "typography", "color", "spacing", "badge", "utility" ]
+}
diff --git a/src/main/java/org/kickerelo/kickerelo/MainView.java b/src/main/java/org/kickerelo/kickerelo/MainView.java
index bf52851..b9d0570 100644
--- a/src/main/java/org/kickerelo/kickerelo/MainView.java
+++ b/src/main/java/org/kickerelo/kickerelo/MainView.java
@@ -57,8 +57,15 @@ public class MainView extends VerticalLayout {
loserGoals.setValue(0);
loserGoals.setStepButtonsVisible(true);
- Button saveButton = new Button("Speichern", e ->
- eloService.enterResult1vs1(winnerSelect.getValue(), loserSelect.getValue(), loserGoals.getValue().shortValue()));
+ Button saveButton = new Button("Speichern", e -> {
+ try {
+ eloService.enterResult1vs1(winnerSelect.getValue(), loserSelect.getValue(), loserGoals.getValue().shortValue());
+ Notification.show("Gespeichert").addThemeVariants(NotificationVariant.LUMO_SUCCESS);
+ } catch (NoSuchPlayerException err) {
+ Notification.show("Konnte nicht gespeichert werden").addThemeVariants(NotificationVariant.LUMO_ERROR);
+ }
+ });
+
// Use custom CSS classes to apply styling. This is defined in
diff --git a/src/main/java/org/kickerelo/kickerelo/data/Ergebnis1vs1.java b/src/main/java/org/kickerelo/kickerelo/data/Ergebnis1vs1.java
index 28e0c91..80e0dd2 100644
--- a/src/main/java/org/kickerelo/kickerelo/data/Ergebnis1vs1.java
+++ b/src/main/java/org/kickerelo/kickerelo/data/Ergebnis1vs1.java
@@ -1,27 +1,30 @@
package org.kickerelo.kickerelo.data;
import jakarta.persistence.*;
+import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
public class Ergebnis1vs1 {
@Id
- @Column(name = "ID")
+ @Column(name = "ID", unique = true, nullable = false)
+ @GeneratedValue
private long id;
@ManyToOne
- @JoinColumn(name = "GEWINNER")
+ @JoinColumn(name = "GEWINNER", nullable = false)
private Spieler gewinner;
@ManyToOne
- @JoinColumn(name = "VERLIERER")
+ @JoinColumn(name = "VERLIERER", nullable = false)
private Spieler verlierer;
- @Column(name = "TORE_VERLIERER")
+ @Column(name = "TORE_VERLIERER", nullable = false)
private short toreVerlierer;
- @Column(name = "ZEITPUNKT")
+ @Column(name = "ZEITPUNKT", updatable = false)
+ @CreationTimestamp
private LocalDateTime timestamp;
public Ergebnis1vs1() {
diff --git a/src/main/java/org/kickerelo/kickerelo/data/Ergebnis2vs2.java b/src/main/java/org/kickerelo/kickerelo/data/Ergebnis2vs2.java
index 75f3d53..a8c035a 100644
--- a/src/main/java/org/kickerelo/kickerelo/data/Ergebnis2vs2.java
+++ b/src/main/java/org/kickerelo/kickerelo/data/Ergebnis2vs2.java
@@ -1,35 +1,38 @@
package org.kickerelo.kickerelo.data;
import jakarta.persistence.*;
+import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
public class Ergebnis2vs2 {
@Id
- @Column(name = "ID")
+ @Column(name = "ID", unique = true, nullable = false)
+ @GeneratedValue
private long id;
@ManyToOne
- @JoinColumn(name = "GEWINNER_VORN")
+ @JoinColumn(name = "GEWINNER_VORN", nullable = false)
private Spieler gewinnerVorn;
@ManyToOne
- @JoinColumn(name = "GEWINNER_HINTEN")
+ @JoinColumn(name = "GEWINNER_HINTEN", nullable = false)
private Spieler gewinnerHinten;
@ManyToOne
- @JoinColumn(name = "VERLIERER_VORN")
+ @JoinColumn(name = "VERLIERER_VORN", nullable = false)
private Spieler verliererVorn;
@ManyToOne
- @JoinColumn(name = "VERLIERER_HINTEN")
+ @JoinColumn(name = "VERLIERER_HINTEN", nullable = false)
private Spieler verliererHinten;
- @Column(name = "TORE_VERLIERER")
+ @Column(name = "TORE_VERLIERER", nullable = false)
private short toreVerlierer;
- @Column(name = "ZEITPUNKT")
+ @Column(name = "ZEITPUNKT", nullable = false, updatable = false)
+ @CreationTimestamp
private LocalDateTime timestamp;
public Ergebnis2vs2() {
diff --git a/src/main/java/org/kickerelo/kickerelo/data/Spieler.java b/src/main/java/org/kickerelo/kickerelo/data/Spieler.java
index d4946f0..a0f64b1 100644
--- a/src/main/java/org/kickerelo/kickerelo/data/Spieler.java
+++ b/src/main/java/org/kickerelo/kickerelo/data/Spieler.java
@@ -16,6 +16,9 @@ public class Spieler {
@Column(name = "ELO", nullable = false)
private float elo;
+ @Column(name = "ELO_ALT")
+ private float elo_alt;
+
public Spieler() {
}
@@ -42,4 +45,12 @@ public class Spieler {
public void setElo(float elo) {
this.elo = elo;
}
+
+ public float getElo_alt() {
+ return elo_alt;
+ }
+
+ public void setElo_alt(float elo_alt) {
+ this.elo_alt = elo_alt;
+ }
}
diff --git a/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql b/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql
new file mode 100644
index 0000000..771b9d4
--- /dev/null
+++ b/src/main/java/org/kickerelo/kickerelo/data/update-schema.sql
@@ -0,0 +1,57 @@
+CREATE SEQUENCE ergebnis1vs1_seq INCREMENT BY 50 START WITH 1;
+
+CREATE SEQUENCE ergebnis2vs2_seq INCREMENT BY 50 START WITH 1;
+
+CREATE SEQUENCE spieler_seq INCREMENT BY 50 START WITH 1;
+
+CREATE TABLE ergebnis1vs1
+(
+ id BIGINT NOT NULL,
+ gewinner INT NOT NULL,
+ verlierer INT NOT NULL,
+ tore_verlierer SMALLINT NOT NULL,
+ zeitpunkt datetime NULL,
+ CONSTRAINT pk_ergebnis1vs1 PRIMARY KEY (id)
+);
+
+CREATE TABLE ergebnis2vs2
+(
+ id BIGINT NOT NULL,
+ gewinner_vorn INT NOT NULL,
+ gewinner_hinten INT NOT NULL,
+ verlierer_vorn INT NOT NULL,
+ verlierer_hinten INT NOT NULL,
+ tore_verlierer SMALLINT NOT NULL,
+ zeitpunkt datetime NOT NULL,
+ CONSTRAINT pk_ergebnis2vs2 PRIMARY KEY (id)
+);
+
+CREATE TABLE spieler
+(
+ id INT NOT NULL,
+ name VARCHAR(255) NOT NULL,
+ elo FLOAT NOT NULL,
+ elo_alt FLOAT NULL,
+ CONSTRAINT pk_spieler PRIMARY KEY (id)
+);
+
+ALTER TABLE spieler
+ ADD CONSTRAINT uc_spieler_name UNIQUE (name);
+
+ALTER TABLE ergebnis1vs1
+ ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_GEWINNER FOREIGN KEY (gewinner) REFERENCES spieler (id);
+
+ALTER TABLE ergebnis1vs1
+ ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_VERLIERER FOREIGN KEY (verlierer) REFERENCES spieler (id);
+
+ALTER TABLE ergebnis2vs2
+ ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_HINTEN FOREIGN KEY (gewinner_hinten) REFERENCES spieler (id);
+
+ALTER TABLE ergebnis2vs2
+ ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_VORN FOREIGN KEY (gewinner_vorn) REFERENCES spieler (id);
+
+ALTER TABLE ergebnis2vs2
+ ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_HINTEN FOREIGN KEY (verlierer_hinten) REFERENCES spieler (id);
+
+ALTER TABLE ergebnis2vs2
+ ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_VORN FOREIGN KEY (verlierer_vorn) REFERENCES spieler (id);
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 38b2b4d..743bb0a 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -4,3 +4,12 @@ spring.mustache.check-template-location = false
# Launch the default browser when starting the application in development mode
vaadin.launch-browser=true
+
+spring.datasource.url=jdbc:mariadb://localhost:3306/kickerelo
+spring.datasource.username=
+spring.datasource.password=
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.jpa.hibernate.ddl-auto=validate
+spring.jpa.show-sql=true
+spring.jpa.format-sql=true
+spring.jpa.open-in-view=false
\ No newline at end of file