diff --git a/CommonCore/SQL/src/de/steamwar/sql/Referee.java b/CommonCore/SQL/src/de/steamwar/sql/Referee.java
deleted file mode 100644
index 3f909643..00000000
--- a/CommonCore/SQL/src/de/steamwar/sql/Referee.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2025 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.sql;
-
-import de.steamwar.sql.internal.Field;
-import de.steamwar.sql.internal.SelectStatement;
-import de.steamwar.sql.internal.Statement;
-import de.steamwar.sql.internal.Table;
-import lombok.AllArgsConstructor;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-
-@AllArgsConstructor
-public class Referee {
-
- private static final Table table = new Table<>(Referee.class);
- private static final SelectStatement byEvent = table.selectFields("eventID");
-
- private static final Statement insert = table.insertAll();
- private static final Statement delete = table.delete("eventReferee");
-
- public static void add(int eventID, int userID) {
- insert.update(eventID, userID);
- }
-
- public static void remove(int eventID, int userID) {
- delete.update(eventID, userID);
- }
-
- public static Set get(int eventID) {
- return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet());
- }
-
- @Field(keys = {"eventReferee"})
- private final int eventID;
- @Field(keys = {"eventReferee"})
- private final int userID;
-}
diff --git a/CommonCore/SQL/src/de/steamwar/sql/Referee.kt b/CommonCore/SQL/src/de/steamwar/sql/Referee.kt
new file mode 100644
index 00000000..e5df5bdd
--- /dev/null
+++ b/CommonCore/SQL/src/de/steamwar/sql/Referee.kt
@@ -0,0 +1,67 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.sql
+
+import de.steamwar.sql.internal.useDb
+import org.jetbrains.exposed.v1.core.and
+import org.jetbrains.exposed.v1.core.dao.id.CompositeID
+import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
+import org.jetbrains.exposed.v1.core.dao.id.EntityID
+import org.jetbrains.exposed.v1.core.eq
+import org.jetbrains.exposed.v1.dao.CompositeEntity
+import org.jetbrains.exposed.v1.dao.CompositeEntityClass
+import org.jetbrains.exposed.v1.jdbc.select
+
+object RefereeTable: CompositeIdTable("Referee") {
+ val eventId = reference("EventId", EventTable)
+ val userId = reference("UserId", SteamwarUserTable)
+
+ override val primaryKey = PrimaryKey(eventId, userId)
+
+ init {
+ addIdColumn(eventId)
+ addIdColumn(userId)
+ }
+}
+
+class Referee(id: EntityID): CompositeEntity(id) {
+ companion object: CompositeEntityClass(RefereeTable) {
+ @JvmStatic
+ fun add(eventId: Int, userId: Int) = useDb {
+ new {
+ this.eventID = eventId
+ this.userID = userId
+ }
+ }
+
+ @JvmStatic
+ fun remove(eventId: Int, userId: Int) = useDb {
+ find { (RefereeTable.eventId eq eventId) and (RefereeTable.userId eq userId) }.firstOrNull()?.delete()
+ }
+
+ @JvmStatic
+ fun get(event: Int) = useDb {
+ find { RefereeTable.eventId eq event }.map { it.userID }.toSet()
+ }
+ }
+
+ var eventID by RefereeTable.eventId.transform({ EntityID(it, EventTable) }, { it.value })
+ var userID by RefereeTable.userId.transform({ EntityID(it, SteamwarUserTable) }, { it.value })
+}
\ No newline at end of file
diff --git a/CommonCore/SQL/src/de/steamwar/sql/SWException.java b/CommonCore/SQL/src/de/steamwar/sql/SWException.java
deleted file mode 100644
index 945743f7..00000000
--- a/CommonCore/SQL/src/de/steamwar/sql/SWException.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2025 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.sql;
-
-import de.steamwar.sql.internal.Field;
-import de.steamwar.sql.internal.Statement;
-import de.steamwar.sql.internal.Table;
-import lombok.AllArgsConstructor;
-
-import java.io.File;
-import java.sql.Timestamp;
-
-@AllArgsConstructor
-public class SWException {
-
- public static void init() {
- // force class initialialisation
- }
-
- private static final String CWD = System.getProperty("user.dir");
- private static final String SERVER_NAME = new File(CWD).getName();
-
- private static final Table table = new Table<>(SWException.class, "Exception");
- private static final Statement insert = table.insertFields(true, "server", "message", "stacktrace");
-
- @Field(keys = {Table.PRIMARY}, autoincrement = true)
- private final int id;
- @Field(def = "CURRENT_TIMESTAMP")
- private final Timestamp time;
- @Field
- private final String server;
- @Field
- private final String message;
- @Field
- private final String stacktrace;
-
- public static void log(String message, String stacktrace){
- insert.update(SERVER_NAME, generateMessage(message), stacktrace);
- }
-
- public static int logGetId(String message, String stacktrace) {
- return insert.insertGetKey(SERVER_NAME, generateMessage(message), stacktrace);
- }
-
- private static String generateMessage(String message) {
- StringBuilder msgBuilder = new StringBuilder(message);
- SQLWrapper.impl.additionalExceptionMetadata(msgBuilder);
- msgBuilder.append("\nCWD: ").append(CWD);
- return msgBuilder.toString();
- }
-}
diff --git a/CommonCore/SQL/src/de/steamwar/sql/SWException.kt b/CommonCore/SQL/src/de/steamwar/sql/SWException.kt
new file mode 100644
index 00000000..7c5dc33c
--- /dev/null
+++ b/CommonCore/SQL/src/de/steamwar/sql/SWException.kt
@@ -0,0 +1,69 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.sql
+
+import de.steamwar.sql.internal.useDb
+import org.jetbrains.exposed.v1.core.dao.id.IntIdTable
+import org.jetbrains.exposed.v1.javatime.timestamp
+import org.jetbrains.exposed.v1.jdbc.insert
+import org.jetbrains.exposed.v1.jdbc.insertAndGetId
+import java.io.File
+import java.time.Instant
+
+object ExceptionTable: IntIdTable("Exception") {
+ val time = timestamp("Time").default(Instant.now())
+ val server = text("Server")
+ val message = text("Message")
+ val stackTrace = text("StackTrace")
+}
+
+class SWException {
+ companion object {
+ val cwd = System.getProperty("user.dir")
+ val serverName = File(cwd).name
+
+ @JvmStatic
+ fun log(message: String, stacktrace: String) = useDb {
+ ExceptionTable.insert {
+ it[ExceptionTable.server] = serverName
+ it[ExceptionTable.message] = generateMessage(message)
+ it[ExceptionTable.stackTrace] = stacktrace
+ }
+
+ Unit
+ }
+
+ @JvmStatic
+ fun logGetId(message: String, stacktrace: String) = useDb {
+ ExceptionTable.insertAndGetId {
+ it[ExceptionTable.server] = serverName
+ it[ExceptionTable.message] = generateMessage(message)
+ it[ExceptionTable.stackTrace] = stacktrace
+ }.value
+ }
+
+ fun generateMessage(message: String): String {
+ val msgBuilder = StringBuilder(message)
+ SQLWrapper.impl.additionalExceptionMetadata(msgBuilder)
+ msgBuilder.append("\nCWD: ").append(cwd)
+ return msgBuilder.toString()
+ }
+ }
+}
\ No newline at end of file
diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchemElo.java b/CommonCore/SQL/src/de/steamwar/sql/SchemElo.java
deleted file mode 100644
index 0a8641b0..00000000
--- a/CommonCore/SQL/src/de/steamwar/sql/SchemElo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2025 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.sql;
-
-import de.steamwar.sql.internal.Field;
-import de.steamwar.sql.internal.SelectStatement;
-import de.steamwar.sql.internal.Statement;
-import de.steamwar.sql.internal.Table;
-import lombok.AllArgsConstructor;
-
-@AllArgsConstructor
-public class SchemElo {
- private static final int ELO_DEFAULT = 1000;
-
- private static final Table table = new Table<>(SchemElo.class);
- private static final SelectStatement select = table.select(Table.PRIMARY);
- private static final Statement setElo = table.insertAll();
-
- public static int getElo(SchematicNode node, int season) {
- SchemElo elo = select.select(node, season);
- return elo != null ? elo.elo : 0;
- }
-
- public static int getCurrentElo(int schemID) {
- SchemElo elo = select.select(schemID, Season.getSeason());
- return elo != null ? elo.elo : ELO_DEFAULT;
- }
-
- public static void setElo(int schemID, int elo) {
- setElo.update(schemID, elo, Season.getSeason());
- }
-
- @Field(keys = {Table.PRIMARY})
- private final int schemId;
- @Field
- private final int elo;
- @Field(keys = {Table.PRIMARY})
- private final int season;
-}
diff --git a/CommonCore/SQL/src/de/steamwar/sql/SchemElo.kt b/CommonCore/SQL/src/de/steamwar/sql/SchemElo.kt
new file mode 100644
index 00000000..fc07f8f4
--- /dev/null
+++ b/CommonCore/SQL/src/de/steamwar/sql/SchemElo.kt
@@ -0,0 +1,75 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2025 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.sql
+
+import de.steamwar.sql.internal.useDb
+import org.jetbrains.exposed.v1.core.and
+import org.jetbrains.exposed.v1.core.dao.id.CompositeID
+import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
+import org.jetbrains.exposed.v1.core.dao.id.EntityID
+import org.jetbrains.exposed.v1.core.dao.id.IdTable
+import org.jetbrains.exposed.v1.core.eq
+import org.jetbrains.exposed.v1.dao.CompositeEntity
+import org.jetbrains.exposed.v1.dao.CompositeEntityClass
+import org.jetbrains.exposed.v1.jdbc.insertIgnore
+
+object SchemEloTable: CompositeIdTable("SchemElo") {
+ val schemId = reference("SchemId", SchematicNodeTable)
+ val season = integer("Season").entityId()
+ val elo = integer("Elo")
+
+ override val primaryKey = PrimaryKey(schemId, season)
+
+ init {
+ addIdColumn(schemId)
+ }
+}
+
+class SchemElo(id: EntityID): CompositeEntity(id) {
+ companion object: CompositeEntityClass(SchemEloTable) {
+ @JvmStatic
+ fun getElo(node: SchematicNode, season: Int, defaultElo: Int = 0) = useDb {
+ find { (SchemEloTable.schemId eq node.id) and (SchemEloTable.season eq season) }.firstOrNull()?.elo ?: defaultElo
+ }
+
+ @JvmStatic
+ fun getCurrentElo(schemId: Int) = getElo(SchematicNode.byId(schemId)!!, Season.getSeason())
+
+ @JvmStatic
+ fun setElo(node: Int, elo: Int) = useDb {
+ findByIdAndUpdate(CompositeID {
+ it[SchemEloTable.schemId] = node
+ it[SchemEloTable.season] = Season.getSeason()
+ }) {
+ it.elo = elo
+ } ?: SchemEloTable.insertIgnore {
+ it[SchemEloTable.schemId] = node
+ it[SchemEloTable.season] = Season.getSeason()
+ it[SchemEloTable.elo] = elo
+ }
+
+ return@useDb
+ }
+ }
+
+ var node by SchemEloTable.schemId
+ var season by SchemEloTable.season
+ var elo by SchemEloTable.elo
+}
\ No newline at end of file
diff --git a/CommonCore/SQL/src/de/steamwar/sql/Script.java b/CommonCore/SQL/src/de/steamwar/sql/Script.java
deleted file mode 100644
index 1a5ccd25..00000000
--- a/CommonCore/SQL/src/de/steamwar/sql/Script.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2025 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.sql;
-
-import de.steamwar.sql.internal.Field;
-import de.steamwar.sql.internal.SelectStatement;
-import de.steamwar.sql.internal.Statement;
-import de.steamwar.sql.internal.Table;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.List;
-
-@AllArgsConstructor
-@Getter
-public class Script {
-
- private static final Table