working on backend-side translations

This commit is contained in:
2025-12-15 22:07:26 +01:00
parent a275b5065d
commit c7b5b11f4c
9 changed files with 86 additions and 119 deletions

View File

@@ -5,10 +5,10 @@ import static de.srsoftware.tools.jdbc.Condition.*;
import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Errors.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
import static de.srsoftware.umbrella.core.model.Time.State.Complete;
import static de.srsoftware.umbrella.time.Constants.*;
import static java.lang.System.Logger.Level.ERROR;
import static java.text.MessageFormat.format;
import de.srsoftware.tools.jdbc.Query;
@@ -50,8 +50,7 @@ CREATE TABLE IF NOT EXISTS {0} (
stmt.execute();
stmt.close();
} catch (SQLException e) {
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_TASK_TIMES, e);
throw new RuntimeException(e);
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_TASK_TIMES).causedBy(e);
}
}
@@ -72,8 +71,7 @@ CREATE TABLE IF NOT EXISTS {0} (
stmt.execute();
stmt.close();
} catch (SQLException e) {
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_TIMES, e);
throw new RuntimeException(e);
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_TIMES).causedBy(e);
}
}
@@ -86,7 +84,7 @@ CREATE TABLE IF NOT EXISTS {0} (
db.setAutoCommit(false);
return timeId;
} catch (SQLException e) {
throw databaseException("Failed to delete time with id = {0}",timeId);
throw databaseException(FAILED_TO_DROP_ENTITY,"time "+timeId).causedBy(e);
}
}
@@ -108,7 +106,7 @@ CREATE TABLE IF NOT EXISTS {0} (
rs.close();
return times;
} catch (Exception e) {
throw new UmbrellaException("Failed to search for times");
throw databaseException(FAILED_TO_SEARCH_DB,TABLE_TIMES).causedBy(e);
}
}
@@ -135,8 +133,7 @@ CREATE TABLE IF NOT EXISTS {0} (
rs.close();
return times;
} catch (Exception e) {
throw new UmbrellaException("Failed to load times for task list");
throw databaseException(FAILED_TO_LIST_ENTITIES,TIMES).causedBy(e);
}
}
@@ -160,7 +157,7 @@ CREATE TABLE IF NOT EXISTS {0} (
rs.close();
return times;
} catch (SQLException e) {
throw new UmbrellaException("Failed to load times for task list");
throw databaseException(FAILED_TO_LIST_ENTITIES,TIMES).causedBy(e);
}
}
@@ -178,7 +175,7 @@ CREATE TABLE IF NOT EXISTS {0} (
if (time == null) throw UmbrellaException.notFound("No time found with id = {0}",timeId);
return time;
} catch (SQLException e) {
throw new UmbrellaException("Failed to load times for task list");
throw databaseException(FAILED_TO_LIST_ENTITIES,TIMES).causedBy(e);
}
}
@@ -202,8 +199,7 @@ CREATE TABLE IF NOT EXISTS {0} (
query.execute(db).close();
return track;
} catch (SQLException e){
LOG.log(ERROR,"Failed to write time to DB",e);
throw databaseException("Failed to write time to DB");
throw databaseException(FAILED_TO_STORE_ENTITY,"time").causedBy(e);
}
}
@@ -217,7 +213,7 @@ CREATE TABLE IF NOT EXISTS {0} (
.apply(timeState.code())
.close();
} catch (SQLException e) {
throw databaseException("Failed to update state of several times");
throw databaseException(FAILED_TO_UPDATE_ENTITY,TIMES).causedBy(e);
}
}
}