Browse Source

Matchday Results

master
GAM 4 years ago
parent
commit
ebbffa70e0
36 changed files with 1754 additions and 37 deletions
  1. +414
    -0
      db/db_init.sql
  2. +1
    -1
      frontend/styles/shared-styles.js
  3. +40
    -0
      frontend/views/results/results-view.css
  4. +79
    -0
      package-lock.json
  5. +11
    -3
      package.json
  6. +12
    -0
      pom.xml
  7. +64
    -0
      src/main/java/com/example/application/data/bean/MatchForMatchdayView.java
  8. +77
    -0
      src/main/java/com/example/application/data/entity/Game.java
  9. +66
    -0
      src/main/java/com/example/application/data/entity/GameInfo.java
  10. +78
    -0
      src/main/java/com/example/application/data/entity/Match.java
  11. +72
    -0
      src/main/java/com/example/application/data/entity/Matchday.java
  12. +93
    -0
      src/main/java/com/example/application/data/entity/Player.java
  13. +55
    -0
      src/main/java/com/example/application/data/entity/PlayerInfo.java
  14. +76
    -0
      src/main/java/com/example/application/data/entity/Season.java
  15. +23
    -23
      src/main/java/com/example/application/data/generator/DataGenerator.java
  16. +8
    -0
      src/main/java/com/example/application/data/service/GameInfoRepository.java
  17. +22
    -0
      src/main/java/com/example/application/data/service/GameInfoService.java
  18. +7
    -0
      src/main/java/com/example/application/data/service/GameRepository.java
  19. +22
    -0
      src/main/java/com/example/application/data/service/GameService.java
  20. +8
    -0
      src/main/java/com/example/application/data/service/MatchRepository.java
  21. +50
    -0
      src/main/java/com/example/application/data/service/MatchService.java
  22. +8
    -0
      src/main/java/com/example/application/data/service/MatchdayRepository.java
  23. +31
    -0
      src/main/java/com/example/application/data/service/MatchdayService.java
  24. +8
    -0
      src/main/java/com/example/application/data/service/PlayerInfoRepository.java
  25. +22
    -0
      src/main/java/com/example/application/data/service/PlayerInfoService.java
  26. +8
    -0
      src/main/java/com/example/application/data/service/PlayerRepository.java
  27. +22
    -0
      src/main/java/com/example/application/data/service/PlayerService.java
  28. +8
    -0
      src/main/java/com/example/application/data/service/SeasonRepository.java
  29. +34
    -0
      src/main/java/com/example/application/data/service/SeasonService.java
  30. +32
    -1
      src/main/java/com/example/application/views/about/AboutView.java
  31. +1
    -4
      src/main/java/com/example/application/views/helloworld/HelloWorldView.java
  32. +15
    -5
      src/main/java/com/example/application/views/main/MainView.java
  33. +282
    -0
      src/main/java/com/example/application/views/results/ResultsView.java
  34. BIN
      src/main/resources/META-INF/resources/icons/icon.png
  35. BIN
      src/main/resources/META-INF/resources/images/logo.png
  36. +5
    -0
      src/main/resources/application.properties

+ 414
- 0
db/db_init.sql View File

@ -0,0 +1,414 @@
-- Database: chessleague
-- DROP DATABASE chessleague;
-- CREATE DATABASE chessleague
-- WITH
-- OWNER = postgres
-- ENCODING = 'UTF8'
-- LC_COLLATE = 'German_Germany.1252'
-- LC_CTYPE = 'German_Germany.1252'
-- TABLESPACE = pg_default
-- CONNECTION LIMIT = -1;
DROP TABLE IF EXISTS "player" CASCADE;
DROP TABLE IF EXISTS "player_info" CASCADE;
DROP TABLE IF EXISTS "game" CASCADE;
DROP TABLE IF EXISTS "game_info" CASCADE;
DROP TABLE IF EXISTS "match" CASCADE;
DROP TABLE IF EXISTS "matchday" CASCADE;
DROP TABLE IF EXISTS "season" CASCADE;
CREATE TABLE "player" (
"id" SERIAL PRIMARY KEY,
"name" varchar NOT NULL,
"nickname" varchar NOT NULL,
"info" int UNIQUE
);
CREATE TABLE "player_info" (
"id" SERIAL PRIMARY KEY,
"url" varchar
);
CREATE TABLE "game" (
"id" SERIAL PRIMARY KEY,
"match" int NOT NULL,
"player1_is_white" boolean NOT NULL,
"result" int NOT NULL,
"info" int UNIQUE
);
CREATE TABLE "game_info" (
"id" SERIAL PRIMARY KEY,
"format" int,
"url" varchar
);
CREATE TABLE "match" (
"id" SERIAL PRIMARY KEY,
"player1" int NOT NULL,
"player2" int NOT NULL,
"matchday" int NOT NULL
);
CREATE TABLE "matchday" (
"id" SERIAL PRIMARY KEY,
"number" int NOT NULL,
"season" int NOT NULL
);
CREATE TABLE "season" (
"id" SERIAL PRIMARY KEY,
"year_start" int NOT NULL,
"year_end" int NOT NULL
);
ALTER TABLE "player" ADD FOREIGN KEY ("info") REFERENCES "player_info" ("id");
ALTER TABLE "game" ADD FOREIGN KEY ("match") REFERENCES "match" ("id");
ALTER TABLE "game" ADD FOREIGN KEY ("info") REFERENCES "game_info" ("id");
ALTER TABLE "match" ADD FOREIGN KEY ("player1") REFERENCES "player" ("id");
ALTER TABLE "match" ADD FOREIGN KEY ("player2") REFERENCES "player" ("id");
ALTER TABLE "match" ADD FOREIGN KEY ("matchday") REFERENCES "matchday" ("id");
ALTER TABLE "matchday" ADD FOREIGN KEY ("season") REFERENCES "season" ("id");
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/aprilem262');
INSERT INTO "player" (name, nickname, info) VALUES ('Sophia', 'aprilem262', (SELECT id from player_info WHERE url='https://www.chess.com/member/aprilem262') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/friedox');
INSERT INTO "player" (name, nickname, info) VALUES ('Friedi', 'friedox', (SELECT id from player_info WHERE url='https://www.chess.com/member/friedox') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/internity');
INSERT INTO "player" (name, nickname, info) VALUES ('Albert', 'internity', (SELECT id from player_info WHERE url='https://www.chess.com/member/internity') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/kevske');
INSERT INTO "player" (name, nickname, info) VALUES ('Kevin', 'kevske', (SELECT id from player_info WHERE url='https://www.chess.com/member/kevske') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/kochi291');
INSERT INTO "player" (name, nickname, info) VALUES ('Marcel', 'Kochi291', (SELECT id from player_info WHERE url='https://www.chess.com/member/kochi291') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/ladyanne26');
INSERT INTO "player" (name, nickname, info) VALUES ('Anne', 'LadyAnne26', (SELECT id from player_info WHERE url='https://www.chess.com/member/ladyanne26') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/lakes0');
INSERT INTO "player" (name, nickname, info) VALUES ('Florian', 'Lakes0', (SELECT id from player_info WHERE url='https://www.chess.com/member/lakes0') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/maddingladi');
INSERT INTO "player" (name, nickname, info) VALUES ('Maddin', 'maddingladi', (SELECT id from player_info WHERE url='https://www.chess.com/member/maddingladi') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/magnus_brother');
INSERT INTO "player" (name, nickname, info) VALUES ('Tariq', 'Magnus_brother', (SELECT id from player_info WHERE url='https://www.chess.com/member/magnus_brother') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/mama-lolo');
INSERT INTO "player" (name, nickname, info) VALUES ('Malte', 'Mama-Lolo', (SELECT id from player_info WHERE url='https://www.chess.com/member/mama-lolo') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/marcriedlsperger');
INSERT INTO "player" (name, nickname, info) VALUES ('Marc', 'marcriedlsperger', (SELECT id from player_info WHERE url='https://www.chess.com/member/marcriedlsperger') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/mistmade03');
INSERT INTO "player" (name, nickname, info) VALUES ('Florian', 'Mistmade03', (SELECT id from player_info WHERE url='https://www.chess.com/member/mistmade03') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/moryzzle');
INSERT INTO "player" (name, nickname, info) VALUES ('Moritz', 'Moryzzle', (SELECT id from player_info WHERE url='https://www.chess.com/member/moryzzle') );
INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/pandroit');
INSERT INTO "player" (name, nickname, info) VALUES ('Peter', 'pandroit', (SELECT id from player_info WHERE url='https://www.chess.com/member/pandroit') );
INSERT INTO "season" (year_start, year_end) VALUES (2020, 2020);
INSERT INTO "matchday" (number, season) VALUES (1, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 1, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 8, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 4, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 3, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 6, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 9, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 7, 1);
INSERT INTO "matchday" (number, season) VALUES (2, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 11, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 12, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 8, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 4, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 3, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 6, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 9, 2);
INSERT INTO "matchday" (number, season) VALUES (3, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 1, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 11, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 12, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 8, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 4, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 3, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 6, 3);
INSERT INTO "matchday" (number, season) VALUES (4, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 5, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 10, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 11, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 12, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 8, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 4, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 3, 4);
INSERT INTO "matchday" (number, season) VALUES (5, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 1, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 5, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 10, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 11, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 12, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 8, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 4, 5);
INSERT INTO "matchday" (number, season) VALUES (6, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 2, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 13, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 5, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 10, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 11, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 12, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 8, 6);
INSERT INTO "matchday" (number, season) VALUES (7, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 1, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 2, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 13, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 5, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 10, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 11, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 12, 7);
INSERT INTO "matchday" (number, season) VALUES (8, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 7, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 14, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 2, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 13, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 5, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 10, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 11, 8);
INSERT INTO "matchday" (number, season) VALUES (9, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 1, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 7, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 14, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 2, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 13, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 5, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 10, 9);
INSERT INTO "matchday" (number, season) VALUES (10, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 6, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 9, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 7, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 14, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 2, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 13, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 5, 10);
INSERT INTO "matchday" (number, season) VALUES (11, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 1, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 6, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 9, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 7, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 14, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 2, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 13, 11);
INSERT INTO "matchday" (number, season) VALUES (12, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 4, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 3, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 6, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 9, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 7, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 14, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 2, 12);
INSERT INTO "matchday" (number, season) VALUES (13, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 1, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 4, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 3, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 6, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 9, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 7, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 14, 13);
INSERT INTO "matchday" (number, season) VALUES (14, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 12, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 11, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 10, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 5, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 13, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 2, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 14, 14);
INSERT INTO "matchday" (number, season) VALUES (15, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 1, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 10, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 5, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 13, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 2, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 14, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 7, 15);
INSERT INTO "matchday" (number, season) VALUES (16, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 10, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 5, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 13, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 2, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 14, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 7, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 9, 16);
INSERT INTO "matchday" (number, season) VALUES (17, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 1, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 13, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 2, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 14, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 7, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 9, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 6, 17);
INSERT INTO "matchday" (number, season) VALUES (18, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 13, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 2, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 14, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 7, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 9, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 6, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 3, 18);
INSERT INTO "matchday" (number, season) VALUES (19, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 1, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 14, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 7, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 9, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 6, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 3, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 4, 19);
INSERT INTO "matchday" (number, season) VALUES (20, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 14, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 7, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 9, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 6, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 3, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 4, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 8, 20);
INSERT INTO "matchday" (number, season) VALUES (21, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 1, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 9, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 6, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 3, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 4, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 8, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 12, 21);
INSERT INTO "matchday" (number, season) VALUES (22, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 9, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 6, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 3, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 4, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 8, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 12, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 11, 22);
INSERT INTO "matchday" (number, season) VALUES (23, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 1, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 3, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 4, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 8, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 12, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 11, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 10, 23);
INSERT INTO "matchday" (number, season) VALUES (24, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 3, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 4, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 8, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 12, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 11, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 10, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 5, 24);
INSERT INTO "matchday" (number, season) VALUES (25, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 1, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 8, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 12, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 11, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 10, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 5, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 13, 25);
INSERT INTO "matchday" (number, season) VALUES (26, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 8, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 12, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 11, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 10, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 5, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 13, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 2, 26);
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8722014513');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8722014513'));
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8723231941');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8723231941'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8724907847');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8724907847'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8725036665');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725036665'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8725614379');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725614379'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8726184583');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8726184583'));
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8616485043');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8616485043'));
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618149677');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618149677'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8702757001');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8702757001'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8705204521');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705204521'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8705796221');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705796221'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8706438057');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8706438057'));
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8617630129');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8617630129'));
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618225533');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618225533'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619306585');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619306585'));
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619471075');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619471075'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620078695');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620078695'));
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620568591');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620568591'));

+ 1
- 1
frontend/styles/shared-styles.js View File

@ -7,7 +7,7 @@ $_documentContainer.innerHTML = `
<custom-style> <custom-style>
<style include='lumo-badge'> <style include='lumo-badge'>
html { html {
--lumo-font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif;
--lumo-font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
} }
[theme~="dark"] { [theme~="dark"] {


+ 40
- 0
frontend/views/results/results-view.css View File

@ -0,0 +1,40 @@
.about-view {
display: block;
}
.column_header {
font-weight: bold;
font-size: large;
}
.big_header {
font-weight: bolder;
font-size: x-large;
}
.matchday_grid {
--_lumo-grid-border-width: 0;
}
/*.inner_matchday_layout {*/
/* background-color: white;*/
/*}*/
/*.inner_matchday_layout > th {*/
/* background-color: white;*/
/*}*/
/*:host {*/
/* background-color: white;*/
/*}*/
/*[part~="cell"].matchday_grid {*/
/* background-color: white;*/
/*}*/
/*.matchday_grid .v-grid-cell {*/
/*}*/
/*.matchday_grid .v-grid-tablewrapper{*/
/* border: none;*/
/*}*/

+ 79
- 0
package-lock.json View File

@ -1410,6 +1410,11 @@
"@webcomponents/shadycss": "^1.8.0" "@webcomponents/shadycss": "^1.8.0"
} }
}, },
"@types/geojson": {
"version": "7946.0.7",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz",
"integrity": "sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ=="
},
"@types/glob": { "@types/glob": {
"version": "7.1.3", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz",
@ -1426,6 +1431,14 @@
"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==",
"dev": true "dev": true
}, },
"@types/leaflet": {
"version": "1.5.23",
"resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.5.23.tgz",
"integrity": "sha512-S/xpuwjZuwYMP+4ZzQ10PX0Jy+0XmwPeojtjqhbca9UXaINdoru91Qm/DUUXyh4qYm3CP6Vher06l/UcA9tUKQ==",
"requires": {
"@types/geojson": "*"
}
},
"@types/minimatch": { "@types/minimatch": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
@ -1464,6 +1477,23 @@
"@vaadin/vaadin-themable-mixin": "^1.6.1" "@vaadin/vaadin-themable-mixin": "^1.6.1"
} }
}, },
"@vaadin/vaadin-avatar": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@vaadin/vaadin-avatar/-/vaadin-avatar-1.0.0.tgz",
"integrity": "sha512-+RpyW7dPYFX581csOTek3q4QhWiJl8WGF6X0gw4vKelaOJbcPztTYoLmcRVP4lC95L+1NWYjyUvrB21FgvGndg==",
"requires": {
"@polymer/iron-a11y-announcer": "^3.0.0",
"@polymer/iron-resizable-behavior": "^3.0.0",
"@polymer/polymer": "^3.0.0",
"@vaadin/vaadin-element-mixin": "^2.3.2",
"@vaadin/vaadin-item": "^2.2.0",
"@vaadin/vaadin-list-box": "^1.3.0",
"@vaadin/vaadin-lumo-styles": "^1.6.0",
"@vaadin/vaadin-material-styles": "^1.3.2",
"@vaadin/vaadin-overlay": "^3.4.1",
"@vaadin/vaadin-themable-mixin": "^1.6.1"
}
},
"@vaadin/vaadin-board": { "@vaadin/vaadin-board": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/@vaadin/vaadin-board/-/vaadin-board-2.2.0.tgz", "resolved": "https://registry.npmjs.org/@vaadin/vaadin-board/-/vaadin-board-2.2.0.tgz",
@ -4362,6 +4392,21 @@
"integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw==", "integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw==",
"dev": true "dev": true
}, },
"cdigit": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/cdigit/-/cdigit-2.5.6.tgz",
"integrity": "sha512-vWobMCPvyrlifhkVAgLhmRApM33OsvoWDhrNaAiwzZcWpzQfT0H3a+rxSZlCv3IyyjxwJHEQbExoJAQUSKvyRA==",
"requires": {
"commander": "^6.0.0"
},
"dependencies": {
"commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
}
}
},
"chalk": { "chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@ -4373,6 +4418,11 @@
"supports-color": "^5.3.0" "supports-color": "^5.3.0"
} }
}, },
"chance": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/chance/-/chance-1.1.7.tgz",
"integrity": "sha512-bua/2cZEfzS6qPm0vi3JEvGNbriDLcMj9lKxCQOjUcCJRcyjA7umP0zZm6bKWWlBN04vA0L99QGH/CZQawr0eg=="
},
"chokidar": { "chokidar": {
"version": "3.5.1", "version": "3.5.1",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz",
@ -6691,6 +6741,11 @@
} }
} }
}, },
"is-docker": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz",
"integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw=="
},
"is-extendable": { "is-extendable": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
@ -6880,6 +6935,11 @@
"invert-kv": "^2.0.0" "invert-kv": "^2.0.0"
} }
}, },
"leaflet": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.7.1.tgz",
"integrity": "sha512-/xwPEBidtg69Q3HlqPdU3DnrXQOvQU/CCHA1tcDQVzOwm91YMYaILjNp7L4Eaw5Z4sOYdbBz6koWyibppd8Zqw=="
},
"lit-element": { "lit-element": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/lit-element/-/lit-element-2.4.0.tgz", "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-2.4.0.tgz",
@ -7615,6 +7675,25 @@
"wrappy": "1" "wrappy": "1"
} }
}, },
"open": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz",
"integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==",
"requires": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"
},
"dependencies": {
"is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"requires": {
"is-docker": "^2.0.0"
}
}
}
},
"opn": { "opn": {
"version": "5.5.0", "version": "5.5.0",
"resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz",


+ 11
- 3
package.json View File

@ -46,7 +46,11 @@
"@vaadin/vaadin-tabs": "3.2.0", "@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-lumo-styles": "1.6.0", "@vaadin/vaadin-lumo-styles": "1.6.0",
"@vaadin/vaadin-material-styles": "1.3.2", "@vaadin/vaadin-material-styles": "1.3.2",
"@vaadin/vaadin-rich-text-editor": "1.3.0"
"@vaadin/vaadin-rich-text-editor": "1.3.0",
"cdigit": "2.5.6",
"chance": "1.1.7",
"@vaadin/vaadin-avatar": "1.0.0",
"open": "^7.2.1"
}, },
"devDependencies": { "devDependencies": {
"webpack-babel-multi-target-plugin": "2.3.3", "webpack-babel-multi-target-plugin": "2.3.3",
@ -59,7 +63,7 @@
"webpack-merge": "4.2.2", "webpack-merge": "4.2.2",
"webpack-dev-server": "3.11.0" "webpack-dev-server": "3.11.0"
}, },
"hash": "81077bf7aa0e1c9065dd7e9ca4953a7e706e0df572c3312c0a71a8a737a7af44"
"hash": "922cd90376cedcde9242327df36d06db3494f125b2e11465002bb39b2ca78988"
}, },
"dependencies": { "dependencies": {
"lit-element": "^2.2.1", "lit-element": "^2.2.1",
@ -107,7 +111,11 @@
"@vaadin/vaadin-material-styles": "1.3.2", "@vaadin/vaadin-material-styles": "1.3.2",
"@vaadin/vaadin-rich-text-editor": "1.3.0", "@vaadin/vaadin-rich-text-editor": "1.3.0",
"leaflet": "^1.7.1", "leaflet": "^1.7.1",
"@types/leaflet": "^1.5.23"
"@types/leaflet": "^1.5.23",
"cdigit": "2.5.6",
"chance": "1.1.7",
"@vaadin/vaadin-avatar": "1.0.0",
"open": "^7.2.1"
}, },
"devDependencies": { "devDependencies": {
"webpack-babel-multi-target-plugin": "2.3.3", "webpack-babel-multi-target-plugin": "2.3.3",


+ 12
- 0
pom.xml View File

@ -126,11 +126,23 @@
<version>3.0.0</version> <version>3.0.0</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.hibernate</groupId>-->
<!-- <artifactId>hibernate-core</artifactId>-->
<!-- <version>5.4.29.Final</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.19.jre7</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>


+ 64
- 0
src/main/java/com/example/application/data/bean/MatchForMatchdayView.java View File

@ -0,0 +1,64 @@
package com.example.application.data.bean;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Match;
import com.example.application.data.entity.Matchday;
import com.example.application.data.entity.Player;
import java.util.Collection;
public class MatchForMatchdayView {
private Match match;
private Player player1;
private Player player2;
private Integer score1;
private Integer score2;
public MatchForMatchdayView(Match match, Player player1, Player player2, Integer score1, Integer score2) {
this.match = match;
this.player1 = player1;
this.player2 = player2;
this.score1 = score1;
this.score2 = score2;
}
public Match getMatch() {
return match;
}
public void setMatch(Match match) {
this.match = match;
}
public Player getPlayer1() {
return player1;
}
public void setPlayer1(Player player1) {
this.player1 = player1;
}
public Player getPlayer2() {
return player2;
}
public void setPlayer2(Player player2) {
this.player2 = player2;
}
public Integer getScore1() {
return score1;
}
public void setScore1(Integer score1) {
this.score1 = score1;
}
public Integer getScore2() {
return score2;
}
public void setScore2(Integer score2) {
this.score2 = score2;
}
}

+ 77
- 0
src/main/java/com/example/application/data/entity/Game.java View File

@ -0,0 +1,77 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "game", schema = "public", catalog = "chessleague")
public class Game {
private Integer id;
private Boolean player1IsWhite;
private Integer result;
private Match match;
private GameInfo gameInfo;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "player1_is_white", nullable = false)
public Boolean getPlayer1IsWhite() {
return player1IsWhite;
}
public void setPlayer1IsWhite(Boolean player1IsWhite) {
this.player1IsWhite = player1IsWhite;
}
@Basic
@Column(name = "result", nullable = false)
public Integer getResult() {
return result;
}
public void setResult(Integer result) {
this.result = result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Game that = (Game) o;
return Objects.equals(id, that.id) && Objects.equals(player1IsWhite, that.player1IsWhite) && Objects.equals(result, that.result);
}
@Override
public int hashCode() {
return Objects.hash(id, player1IsWhite, result);
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "match", referencedColumnName = "id", nullable = false)
public Match getMatch() {
return match;
}
public void setMatch(Match match) {
this.match = match;
}
@OneToOne
@JoinColumn(name = "info", referencedColumnName = "id")
public GameInfo getGameInfo() {
return gameInfo;
}
public void setGameInfo(GameInfo gameInfo) {
this.gameInfo = gameInfo;
}
}

+ 66
- 0
src/main/java/com/example/application/data/entity/GameInfo.java View File

@ -0,0 +1,66 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "game_info", schema = "public", catalog = "chessleague")
public class GameInfo {
private Integer id;
private String url;
private Game game;
private Integer format;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "url", length = -1)
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Basic
@Column(name = "format", nullable = false)
public Integer getFormat() {
return format;
}
public void setFormat(Integer format) {
this.format = format;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GameInfo that = (GameInfo) o;
return Objects.equals(id, that.id) && Objects.equals(url, that.url) && Objects.equals(format, that.format);
}
@Override
public int hashCode() {
return Objects.hash(id, url, format);
}
@OneToOne(mappedBy = "gameInfo")
public Game getGame() {
return game;
}
public void setGame(Game game) {
this.game = game;
}
}

+ 78
- 0
src/main/java/com/example/application/data/entity/Match.java View File

@ -0,0 +1,78 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;
@Entity
@Table(name = "match", schema = "public", catalog = "chessleague")
public class Match {
private Integer id;
private Collection<Game> games;
private Player player1;
private Player player2;
private Matchday matchday;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Match that = (Match) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@OneToMany(mappedBy = "match", fetch = FetchType.EAGER)
public Collection<Game> getGames() {
return games;
}
public void setGames(Collection<Game> games) {
this.games = games;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "player1", referencedColumnName = "id", nullable = false)
public Player getPlayer1() {
return player1;
}
public void setPlayer1(Player player1) {
this.player1 = player1;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "player2", referencedColumnName = "id", nullable = false)
public Player getPlayer2() {
return player2;
}
public void setPlayer2(Player player2) {
this.player2 = player2;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "matchday", referencedColumnName = "id", nullable = false)
public Matchday getMatchday() {
return matchday;
}
public void setMatchday(Matchday matchday) {
this.matchday = matchday;
}
}

+ 72
- 0
src/main/java/com/example/application/data/entity/Matchday.java View File

@ -0,0 +1,72 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;
@Entity
@Table(name = "matchday", schema = "public", catalog = "chessleague")
public class Matchday {
private Integer id;
private Integer number;
private Collection<Match> matches;
private Season season;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "number", nullable = false)
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Matchday that = (Matchday) o;
return Objects.equals(id, that.id) && Objects.equals(number, that.number);
}
@Override
public int hashCode() {
return Objects.hash(id, number);
}
@OneToMany(mappedBy = "matchday")
public Collection<Match> getMatches() {
return matches;
}
public void setMatches(Collection<Match> matches) {
this.matches = matches;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "season", referencedColumnName = "id", nullable = false)
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
@Override
public String toString() {
return number.toString();
}
}

+ 93
- 0
src/main/java/com/example/application/data/entity/Player.java View File

@ -0,0 +1,93 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;
@Entity
@Table(name = "player", schema = "public", catalog = "chessleague")
public class Player {
private Integer id;
private String name;
private String nickname;
private Collection<Match> matchesAsPlayer1;
private Collection<Match> matchesAsPlayer2;
private PlayerInfo playerInfo;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "name", nullable = false, length = -1)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Basic
@Column(name = "nickname", nullable = false, length = -1)
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Player that = (Player) o;
return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(nickname, that.nickname);
}
@Override
public int hashCode() {
return Objects.hash(id, name, nickname);
}
@OneToMany(mappedBy = "player1")
public Collection<Match> getMatchesAsPlayer1() {
return matchesAsPlayer1;
}
public void setMatchesAsPlayer1(Collection<Match> matchesAsPlayer1) {
this.matchesAsPlayer1 = matchesAsPlayer1;
}
@OneToMany(mappedBy = "player2")
public Collection<Match> getMatchesAsPlayer2() {
return matchesAsPlayer2;
}
public void setMatchesAsPlayer2(Collection<Match> matchesAsPlayer2) {
this.matchesAsPlayer2 = matchesAsPlayer2;
}
@OneToOne
@JoinColumn(name = "info", referencedColumnName = "id")
public PlayerInfo getPlayerInfo() {
return playerInfo;
}
public void setPlayerInfo(PlayerInfo playerInfo) {
this.playerInfo = playerInfo;
}
@Override
public String toString() {
return name + " (" + nickname + ")";
}
}

+ 55
- 0
src/main/java/com/example/application/data/entity/PlayerInfo.java View File

@ -0,0 +1,55 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "player_info", schema = "public", catalog = "chessleague")
public class PlayerInfo {
private Integer id;
private String url;
private Player player;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "url", length = -1)
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PlayerInfo that = (PlayerInfo) o;
return Objects.equals(id, that.id) && Objects.equals(url, that.url);
}
@Override
public int hashCode() {
return Objects.hash(id, url);
}
@OneToOne(mappedBy = "playerInfo")
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
}

+ 76
- 0
src/main/java/com/example/application/data/entity/Season.java View File

@ -0,0 +1,76 @@
package com.example.application.data.entity;
import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;
@Entity
@Table(name = "season", schema = "public", catalog = "chessleague")
public class Season {
private Integer id;
private Integer yearStart;
private Integer yearEnd;
private Collection<Matchday> matchdays;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Basic
@Column(name = "year_start", nullable = false)
public Integer getYearStart() {
return yearStart;
}
public void setYearStart(Integer yearStart) {
this.yearStart = yearStart;
}
@Basic
@Column(name = "year_end", nullable = false)
public Integer getYearEnd() {
return yearEnd;
}
public void setYearEnd(Integer yearEnd) {
this.yearEnd = yearEnd;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Season that = (Season) o;
return Objects.equals(id, that.id) && Objects.equals(yearStart, that.yearStart) && Objects.equals(yearEnd, that.yearEnd);
}
@Override
public int hashCode() {
return Objects.hash(id, yearStart, yearEnd);
}
@OneToMany(mappedBy = "season")
public Collection<Matchday> getMatchdays() {
return matchdays;
}
public void setMatchdays(Collection<Matchday> matchdays) {
this.matchdays = matchdays;
}
@Override
public String toString() {
String s = yearStart.toString();
if (!yearEnd.equals(yearStart)) {
s += "/" + yearEnd.toString();
}
return s;
}
}

+ 23
- 23
src/main/java/com/example/application/data/generator/DataGenerator.java View File

@ -20,29 +20,29 @@ public class DataGenerator {
@Bean @Bean
public CommandLineRunner loadData(SamplePersonRepository samplePersonRepository) { public CommandLineRunner loadData(SamplePersonRepository samplePersonRepository) {
return args -> { return args -> {
Logger logger = LoggerFactory.getLogger(getClass());
if (samplePersonRepository.count() != 0L) {
logger.info("Using existing database");
return;
}
int seed = 123;
logger.info("Generating demo data");
logger.info("... generating 100 Sample Person entities...");
ExampleDataGenerator<SamplePerson> samplePersonRepositoryGenerator = new ExampleDataGenerator<>(
SamplePerson.class, LocalDateTime.of(2021, 2, 26, 0, 0, 0));
samplePersonRepositoryGenerator.setData(SamplePerson::setId, DataType.ID);
samplePersonRepositoryGenerator.setData(SamplePerson::setFirstName, DataType.FIRST_NAME);
samplePersonRepositoryGenerator.setData(SamplePerson::setLastName, DataType.LAST_NAME);
samplePersonRepositoryGenerator.setData(SamplePerson::setEmail, DataType.EMAIL);
samplePersonRepositoryGenerator.setData(SamplePerson::setPhone, DataType.PHONE_NUMBER);
samplePersonRepositoryGenerator.setData(SamplePerson::setDateOfBirth, DataType.DATE_OF_BIRTH);
samplePersonRepositoryGenerator.setData(SamplePerson::setOccupation, DataType.OCCUPATION);
samplePersonRepositoryGenerator.setData(SamplePerson::setImportant, DataType.BOOLEAN_10_90);
samplePersonRepository.saveAll(samplePersonRepositoryGenerator.create(100, seed));
logger.info("Generated demo data");
// Logger logger = LoggerFactory.getLogger(getClass());
// if (samplePersonRepository.count() != 0L) {
// logger.info("Using existing database");
// return;
// }
// int seed = 123;
//
// logger.info("Generating demo data");
//
// logger.info("... generating 100 Sample Person entities...");
// ExampleDataGenerator<SamplePerson> samplePersonRepositoryGenerator = new ExampleDataGenerator<>(
// SamplePerson.class, LocalDateTime.of(2021, 2, 26, 0, 0, 0));
// samplePersonRepositoryGenerator.setData(SamplePerson::setId, DataType.ID);
// samplePersonRepositoryGenerator.setData(SamplePerson::setFirstName, DataType.FIRST_NAME);
// samplePersonRepositoryGenerator.setData(SamplePerson::setLastName, DataType.LAST_NAME);
// samplePersonRepositoryGenerator.setData(SamplePerson::setEmail, DataType.EMAIL);
// samplePersonRepositoryGenerator.setData(SamplePerson::setPhone, DataType.PHONE_NUMBER);
// samplePersonRepositoryGenerator.setData(SamplePerson::setDateOfBirth, DataType.DATE_OF_BIRTH);
// samplePersonRepositoryGenerator.setData(SamplePerson::setOccupation, DataType.OCCUPATION);
// samplePersonRepositoryGenerator.setData(SamplePerson::setImportant, DataType.BOOLEAN_10_90);
// samplePersonRepository.saveAll(samplePersonRepositoryGenerator.create(100, seed));
//
// logger.info("Generated demo data");
}; };
} }

+ 8
- 0
src/main/java/com/example/application/data/service/GameInfoRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.GameInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface GameInfoRepository extends JpaRepository<GameInfo, Integer> {
}

+ 22
- 0
src/main/java/com/example/application/data/service/GameInfoService.java View File

@ -0,0 +1,22 @@
package com.example.application.data.service;
import com.example.application.data.entity.GameInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
@Service
public class GameInfoService extends CrudService<GameInfo, Integer> {
private final GameInfoRepository repository;
public GameInfoService(@Autowired GameInfoRepository repository) {
this.repository = repository;
}
@Override
protected GameInfoRepository getRepository() {
return repository;
}
}

+ 7
- 0
src/main/java/com/example/application/data/service/GameRepository.java View File

@ -0,0 +1,7 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import org.springframework.data.jpa.repository.JpaRepository;
public interface GameRepository extends JpaRepository<Game, Integer> {
}

+ 22
- 0
src/main/java/com/example/application/data/service/GameService.java View File

@ -0,0 +1,22 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
@Service
public class GameService extends CrudService<Game, Integer> {
private final GameRepository repository;
public GameService(@Autowired GameRepository repository) {
this.repository = repository;
}
@Override
protected GameRepository getRepository() {
return repository;
}
}

+ 8
- 0
src/main/java/com/example/application/data/service/MatchRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Match;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MatchRepository extends JpaRepository<Match, Integer> {
}

+ 50
- 0
src/main/java/com/example/application/data/service/MatchService.java View File

@ -0,0 +1,50 @@
package com.example.application.data.service;
import com.example.application.data.bean.MatchForMatchdayView;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Match;
import com.example.application.data.entity.Matchday;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class MatchService extends CrudService<Match, Integer> {
private final MatchRepository repository;
public MatchService(@Autowired MatchRepository repository) {
this.repository = repository;
}
@Override
protected MatchRepository getRepository() {
return repository;
}
public List<MatchForMatchdayView> getMatchesForMatchdayView(Matchday matchday) {
return repository.findAll().stream()
.filter(match -> match.getMatchday().equals(matchday))
.map(match -> new MatchForMatchdayView(match, match.getPlayer1(), match.getPlayer2(), getScore1(match), getScore2(match)))
.collect(Collectors.toList());
}
private static Integer getScore1(Match match) {
int score = 0;
for (Game game : match.getGames()) {
score += ((game.getPlayer1IsWhite() ? game.getResult() : -game.getResult()) + 1) / 2;
}
return score;
}
private static Integer getScore2(Match match) {
int score = 0;
for (Game game : match.getGames()) {
score += ((game.getPlayer1IsWhite() ? -game.getResult() : game.getResult()) + 1) / 2;
}
return score;
}
}

+ 8
- 0
src/main/java/com/example/application/data/service/MatchdayRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Matchday;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MatchdayRepository extends JpaRepository<Matchday, Integer> {
}

+ 31
- 0
src/main/java/com/example/application/data/service/MatchdayService.java View File

@ -0,0 +1,31 @@
package com.example.application.data.service;
import com.example.application.data.entity.Matchday;
import com.example.application.data.entity.Season;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class MatchdayService extends CrudService<Matchday, Integer> {
private final MatchdayRepository repository;
public MatchdayService(@Autowired MatchdayRepository repository) {
this.repository = repository;
}
@Override
protected MatchdayRepository getRepository() {
return repository;
}
public List<Matchday> getMatchdaysForSeason(Season season) {
return repository.findAll().stream()
.filter(matchday -> matchday.getSeason().equals(season))
.collect(Collectors.toList());
}
}

+ 8
- 0
src/main/java/com/example/application/data/service/PlayerInfoRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.PlayerInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PlayerInfoRepository extends JpaRepository<PlayerInfo, Integer> {
}

+ 22
- 0
src/main/java/com/example/application/data/service/PlayerInfoService.java View File

@ -0,0 +1,22 @@
package com.example.application.data.service;
import com.example.application.data.entity.PlayerInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
@Service
public class PlayerInfoService extends CrudService<PlayerInfo, Integer> {
private final PlayerInfoRepository repository;
public PlayerInfoService(@Autowired PlayerInfoRepository repository) {
this.repository = repository;
}
@Override
protected PlayerInfoRepository getRepository() {
return repository;
}
}

+ 8
- 0
src/main/java/com/example/application/data/service/PlayerRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Player;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PlayerRepository extends JpaRepository<Player, Integer> {
}

+ 22
- 0
src/main/java/com/example/application/data/service/PlayerService.java View File

@ -0,0 +1,22 @@
package com.example.application.data.service;
import com.example.application.data.entity.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
@Service
public class PlayerService extends CrudService<Player, Integer> {
private final PlayerRepository repository;
public PlayerService(@Autowired PlayerRepository repository) {
this.repository = repository;
}
@Override
protected PlayerRepository getRepository() {
return repository;
}
}

+ 8
- 0
src/main/java/com/example/application/data/service/SeasonRepository.java View File

@ -0,0 +1,8 @@
package com.example.application.data.service;
import com.example.application.data.entity.Game;
import com.example.application.data.entity.Season;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SeasonRepository extends JpaRepository<Season, Integer> {
}

+ 34
- 0
src/main/java/com/example/application/data/service/SeasonService.java View File

@ -0,0 +1,34 @@
package com.example.application.data.service;
import com.example.application.data.entity.Season;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.vaadin.artur.helpers.CrudService;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SeasonService extends CrudService<Season, Integer> {
private final SeasonRepository repository;
public SeasonService(@Autowired SeasonRepository repository) {
this.repository = repository;
}
@Override
protected SeasonRepository getRepository() {
return repository;
}
public List<Season> getAllSeasonsSorted() {
return repository.findAll().stream()
.sorted(Comparator.comparingInt(Season::getYearEnd))
.sorted(Comparator.comparingInt(Season::getYearStart))
.collect(Collectors.toList());
}
}

+ 32
- 1
src/main/java/com/example/application/views/about/AboutView.java View File

@ -1,5 +1,7 @@
package com.example.application.views.about; package com.example.application.views.about;
import com.example.application.data.entity.*;
import com.example.application.data.service.GameService;
import com.vaadin.flow.component.Text; import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Div;
@ -12,7 +14,36 @@ import com.example.application.views.main.MainView;
@PageTitle("About") @PageTitle("About")
public class AboutView extends Div { public class AboutView extends Div {
public AboutView() {
public AboutView(GameService gameService) {
// Player player1 = new Player();
// player1.setName("Martin");
// player1.setNickname("maddingladi");
//
// Player player2 = new Player();
// player2.setName("Marcel");
// player2.setNickname("Kochi");
//
// Season season = new Season();
// season.setYearStart(2020);
// season.setYearEnd(2020);
//
// Matchday matchday = new Matchday();
// matchday.setNumber(1);
// matchday.setSeason(season);
//
// Match match = new Match();
// match.setMatchday(matchday);
// match.setPlayer1(player1);
// match.setPlayer2(player2);
//
// Game game = new Game();
// game.setMatch(match);
// game.setFormat(10);
// game.setPlayer1IsWhite(true);
// game.setResult(1);
//
// gameService.update(game);
addClassName("about-view"); addClassName("about-view");
add(new Text("Content placeholder")); add(new Text("Content placeholder"));
} }


+ 1
- 4
src/main/java/com/example/application/views/helloworld/HelloWorldView.java View File

@ -13,7 +13,6 @@ import com.vaadin.flow.router.RouteAlias;
@CssImport("./views/helloworld/hello-world-view.css") @CssImport("./views/helloworld/hello-world-view.css")
@Route(value = "hello", layout = MainView.class) @Route(value = "hello", layout = MainView.class)
@RouteAlias(value = "", layout = MainView.class)
@PageTitle("Hello World") @PageTitle("Hello World")
public class HelloWorldView extends HorizontalLayout { public class HelloWorldView extends HorizontalLayout {
@ -26,9 +25,7 @@ public class HelloWorldView extends HorizontalLayout {
sayHello = new Button("Say hello"); sayHello = new Button("Say hello");
add(name, sayHello); add(name, sayHello);
setVerticalComponentAlignment(Alignment.END, name, sayHello); setVerticalComponentAlignment(Alignment.END, name, sayHello);
sayHello.addClickListener(e -> {
Notification.show("Hello " + name.getValue());
});
sayHello.addClickListener(e -> Notification.show("Hello " + name.getValue()));
} }
} }

+ 15
- 5
src/main/java/com/example/application/views/main/MainView.java View File

@ -2,6 +2,7 @@ package com.example.application.views.main;
import java.util.Optional; import java.util.Optional;
import com.example.application.views.results.ResultsView;
import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentUtil; import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.applayout.AppLayout; import com.vaadin.flow.component.applayout.AppLayout;
@ -35,7 +36,10 @@ import com.vaadin.flow.theme.lumo.Lumo;
* The main view is a top-level placeholder for other views. * The main view is a top-level placeholder for other views.
*/ */
@CssImport("./views/main/main-view.css") @CssImport("./views/main/main-view.css")
@PWA(name = "Schachliga DeLuxe", shortName = "Schachliga DeLuxe", enableInstallPrompt = false)
@PWA(name = "Schachliga DeLuxe",
shortName = "Schachliga DeLuxe",
iconPath = "images/logo.png",
enableInstallPrompt = false)
@JsModule("./styles/shared-styles.js") @JsModule("./styles/shared-styles.js")
@Theme(value = Lumo.class, variant = Lumo.DARK) @Theme(value = Lumo.class, variant = Lumo.DARK)
public class MainView extends AppLayout { public class MainView extends AppLayout {
@ -90,10 +94,16 @@ public class MainView extends AppLayout {
} }
private Component[] createMenuItems() { private Component[] createMenuItems() {
return new Tab[]{createTab("Hello World", HelloWorldView.class), createTab("About", AboutView.class),
createTab("Card List", CardListView.class), createTab("Master-Detail", MasterDetailView.class),
createTab("Person Form", PersonFormView.class), createTab("Address Form", AddressFormView.class),
createTab("Credit Card Form", CreditCardFormView.class), createTab("Map", MapView.class)};
return new Tab[]{
// createTab("Hello World", HelloWorldView.class),
// createTab("About", AboutView.class),
// createTab("Card List", CardListView.class),
// createTab("Master-Detail", MasterDetailView.class),
// createTab("Person Form", PersonFormView.class),
// createTab("Address Form", AddressFormView.class),
// createTab("Credit Card Form", CreditCardFormView.class),
// createTab("Map", MapView.class),
createTab("Results", ResultsView.class)};
} }
private static Tab createTab(String text, Class<? extends Component> navigationTarget) { private static Tab createTab(String text, Class<? extends Component> navigationTarget) {


+ 282
- 0
src/main/java/com/example/application/views/results/ResultsView.java View File

@ -0,0 +1,282 @@
package com.example.application.views.results;
import com.example.application.data.bean.MatchForMatchdayView;
import com.example.application.data.entity.Matchday;
import com.example.application.data.entity.Player;
import com.example.application.data.entity.Season;
import com.example.application.data.service.MatchService;
import com.example.application.data.service.MatchdayService;
import com.example.application.data.service.SeasonService;
import com.example.application.views.main.MainView;
import com.vaadin.flow.component.*;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.grid.ColumnTextAlign;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.select.Select;
import com.vaadin.flow.function.ValueProvider;
import com.vaadin.flow.router.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.ArrayList;
import java.util.List;
@CssImport("./views/results/results-view.css")
@Route(value = "results", layout = MainView.class)
@RouteAlias(value = "", layout = MainView.class)
@PageTitle("Results")
public class ResultsView extends Div implements HasUrlParameter<String> {
private final SeasonService seasonService;
private final MatchdayService matchdayService;
private final MatchService matchService;
private String seasonParam;
private String matchdayParam;
private final Label invalidUrlLabel = new Label();
private final Label matchdayViewHeader = new Label();
private final VerticalLayout outer = new VerticalLayout();
private final HorizontalLayout selectionLayout = new HorizontalLayout();
private final HorizontalLayout outerMatchdaylayout = new HorizontalLayout();
private final VerticalLayout innerMatchdayLayout = new VerticalLayout();
private final List<Season> seasonList = new ArrayList<>();
private final Select<Season> seasonSelect = new Select<>();
private final List<Matchday> matchdayList = new ArrayList<>();
private final Select<Matchday> matchdaySelect = new Select<>();
private final Button prevButton = new Button(new Icon(VaadinIcon.ARROW_LEFT));
private final Button nextButton = new Button(new Icon(VaadinIcon.ARROW_RIGHT));
private final Grid<MatchForMatchdayView> grid = new Grid<>();
public ResultsView(@Autowired SeasonService seasonService, @Autowired MatchdayService matchdayService, @Autowired MatchService matchService) {
this.seasonService = seasonService;
this.matchdayService = matchdayService;
this.matchService = matchService;
addClassName("results-view");
configureOuterLayout();
configureSelectionLayout();
configureMatchdayViewLayout();
}
private void configureOuterLayout() {
add(outer);
outer.setAlignItems(FlexComponent.Alignment.CENTER);
}
private void configureSelectionLayout() {
// pretty looks
selectionLayout.setWidthFull();
selectionLayout.setAlignItems(FlexComponent.Alignment.CENTER);
selectionLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
selectionLayout.add(new Label("Season:"), seasonSelect, new Label("Matchday:"), matchdaySelect);
seasonSelect.addValueChangeListener(seasonSelectValueChangeListener());
matchdaySelect.addValueChangeListener(matchdaySelectValueChangeListener());
// provide data
fillSeasonSelectWithData();
}
private HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Select<Matchday>, Matchday>> matchdaySelectValueChangeListener() {
return matchdayChangeEvent -> getUI().ifPresent(ui -> {
Season season = seasonSelect.getValue();
Matchday matchday = matchdayChangeEvent.getValue();
if (season != null && matchday != null) {
String seasonParam = season.toString();
String matchdayParam = matchday.toString();
navigate(ui, seasonParam, matchdayParam);
}
});
}
private HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<Select<Season>, Season>> seasonSelectValueChangeListener() {
return seasonChangeEvent -> getUI().ifPresent(ui -> {
Season newSeason = seasonChangeEvent.getValue();
if (newSeason != null) {
String seasonParam = newSeason.toString();
String matchdayParam = null;
Matchday matchdayInNewSeason = null;
Matchday matchdayInOldSeason = matchdaySelect.getValue();
if (matchdayInOldSeason != null) {
matchdayParam = matchdayInOldSeason.toString();
matchdayInNewSeason = getMatchdayFromParam(matchdayParam, newSeason);
}
matchdayParam = matchdayInNewSeason == null ? "1" : matchdayParam;
navigate(ui, seasonParam, matchdayParam);
}
});
}
private void fillSeasonSelectWithData() {
seasonList.clear();
seasonList.addAll(seasonService.getAllSeasonsSorted());
seasonSelect.setItems(seasonList);
}
private void fillMatchdaySelectWithData() {
matchdayList.clear();
matchdayList.addAll(matchdayService.getMatchdaysForSeason(seasonSelect.getValue()));
matchdaySelect.setItems(matchdayList);
}
private void configureMatchdayViewLayout() {
outerMatchdaylayout.add(prevButton, innerMatchdayLayout, nextButton);
matchdayViewHeader.addClassName("big_header");
innerMatchdayLayout.setPadding(false);
innerMatchdayLayout.add(matchdayViewHeader, grid);
innerMatchdayLayout.setAlignItems(FlexComponent.Alignment.CENTER);
innerMatchdayLayout.addClassName("inner_matchday_layout");
Label headerPlayer1 = new Label("Player 1");
headerPlayer1.addClassName("column_header");
Label headerPlayer2 = new Label("Player 2");
headerPlayer2.addClassName("column_header");
Label headerResult = new Label("Result");
headerResult.addClassName("column_header");
grid.addColumn((ValueProvider<MatchForMatchdayView, Player>) MatchForMatchdayView::getPlayer1)
.setHeader(headerPlayer1)
.setTextAlign(ColumnTextAlign.CENTER)
.setWidth("13em");
grid.addColumn((ValueProvider<MatchForMatchdayView, String>) match -> "vs.")
.setHeader("vs.")
.setTextAlign(ColumnTextAlign.CENTER)
.setWidth("3em");
grid.addColumn((ValueProvider<MatchForMatchdayView, Player>) MatchForMatchdayView::getPlayer2)
.setHeader(headerPlayer2)
.setTextAlign(ColumnTextAlign.CENTER)
.setWidth("13em");
grid.addColumn((ValueProvider<MatchForMatchdayView, String>) match -> {
String result = match.getScore1().toString() + " : " + match.getScore2().toString();
return result.equals("0 : 0") ? "" : result;
})
.setHeader(headerResult)
.setTextAlign(ColumnTextAlign.CENTER)
.setWidth("6em");
grid.setWidth("36em");
grid.setHeightByRows(true);
grid.addClassName("matchday_grid");
}
private String getPrevMatchdayParam() {
return String.valueOf(Integer.parseInt(matchdayParam) - 1);
}
private String getNextMatchdayParam() {
return String.valueOf(Integer.parseInt(matchdayParam) + 1);
}
private boolean isMatchDayParamValid(@NonNull String matchdayParam) {
return matchdayList.stream().anyMatch(matchday -> matchdayParam.equals(matchday.toString()));
}
private ComponentEventListener<ClickEvent<Button>> getButtonClickListener(Button button, String matchdayParam) {
return buttonClickEvent -> getUI().ifPresent(ui -> navigate(ui, seasonParam, matchdayParam));
}
private void navigate(UI ui, String seasonParam, String matchdayParam) {
ui.navigate(String.format("results/%s/%s/", seasonParam, matchdayParam));
}
private void configureMatchdayView() {
matchdayViewHeader.setText(String.format("Matchday %s", matchdaySelect.getValue().toString()));
grid.setItems(matchService.getMatchesForMatchdayView(matchdaySelect.getValue()));
}
@Override
public void setParameter(BeforeEvent beforeEvent, @WildcardParameter String param) {
outer.removeAll();
if (!param.matches("^[0-9]*/[0-9]*/?$")) {
invalidUrlLabel.setText("Invalid URL! Please provide params in the form season/matchday/");
outer.add(invalidUrlLabel);
return;
}
String[] params = param.split("/");
seasonParam = params[0];
matchdayParam = params[1];
Season season = getSeasonFromParam(seasonParam);
if (season == null) {
invalidUrlLabel.setText(String.format("Invalid URL! Season \"%s\" does not exist in the database!", seasonParam));
outer.add(invalidUrlLabel);
return;
}
seasonSelect.setValue(season);
fillMatchdaySelectWithData();
Matchday matchday = getMatchdayFromParam(matchdayParam);
if (matchday == null) {
invalidUrlLabel.setText(String.format("Invalid URL! Matchday \"%s\" in Season \"%s\" does not exist in the database!", matchdayParam, seasonParam));
outer.add(invalidUrlLabel);
return;
}
matchdaySelect.setValue(matchday);
configureMatchdayView();
outer.add(selectionLayout);
outer.add(outerMatchdaylayout);
configureButtons();
}
private void configureButtons() {
prevButton.setEnabled(isMatchDayParamValid(getPrevMatchdayParam()));
prevButton.addClickListener(getButtonClickListener(prevButton, getPrevMatchdayParam()));
nextButton.setEnabled(isMatchDayParamValid(getNextMatchdayParam()));
nextButton.addClickListener(getButtonClickListener(nextButton, getNextMatchdayParam()));
}
@Nullable
private Season getSeasonFromParam(@NonNull String seasonParam) {
for (Season season : seasonList) {
if (seasonParam.equals(season.toString())) {
return season;
}
}
return null;
}
@Nullable
private Matchday getMatchdayFromParam(@NonNull String matchdayParam) {
return getMatchdayFromParam(matchdayParam, null);
}
@Nullable
private Matchday getMatchdayFromParam(@NonNull String matchdayParam, @Nullable Season season) {
List<Matchday> matchdayList = season == null ? this.matchdayList : matchdayService.getMatchdaysForSeason(season);
for (Matchday matchday : matchdayList) {
if (matchdayParam.equals(matchday.toString())) {
return matchday;
}
}
return null;
}
}

BIN
src/main/resources/META-INF/resources/icons/icon.png View File

Before After
Width: 512  |  Height: 512  |  Size: 16 KiB

BIN
src/main/resources/META-INF/resources/images/logo.png View File

Before After
Width: 225  |  Height: 225  |  Size: 16 KiB Width: 1100  |  Height: 1100  |  Size: 13 KiB

+ 5
- 0
src/main/resources/application.properties View File

@ -6,3 +6,8 @@ logging.level.org.atmosphere = warn
# To improve the performance during development. # To improve the performance during development.
# For more information https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#special-configuration-parameters # For more information https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#special-configuration-parameters
# vaadin.whitelisted-packages= org/vaadin/example # vaadin.whitelisted-packages= org/vaadin/example
spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/chessleague
spring.datasource.username=postgres
spring.datasource.password=postgres

Loading…
Cancel
Save