5
0
mirror of https://github.com/AJMicke/KickerELO.git synced 2026-03-11 13:31:02 +01:00

Working entry of results

This commit is contained in:
Anton Micke
2025-02-05 23:11:48 +01:00
parent ee2c9687a4
commit 9d3faf61c9
10 changed files with 152 additions and 22 deletions

11
pom.xml
View File

@@ -32,15 +32,10 @@
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.13.1.1</version>
</dependency>-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<!--
This file is auto-generated by Vaadin.
-->
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body, #outlet {
height: 100vh;
width: 100%;
margin: 0;
}
</style>
<!-- index.ts is included here automatically (either by the dev server or during the build) -->
</head>
<body>
<!-- This outlet div is where the views are rendered -->
<div id="outlet"></div>
</body>
</html>

View File

@@ -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);
}

View File

@@ -0,0 +1,3 @@
{
"lumoImports" : [ "typography", "color", "spacing", "badge", "utility" ]
}

View File

@@ -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

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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