working on backend-side translations
This commit is contained in:
@@ -9,6 +9,7 @@ public class Errors {
|
||||
public static final String FAILED_TO_CREATE_TABLE = "failed_to_create_table";
|
||||
public static final String FAILED_TO_DROP_ENTITY = "failed_to_drop_entity";
|
||||
public static final String FAILED_TO_DROP_ENTITY_OF_ENTITY = "failed_to_drop_entity_from_entity";
|
||||
public static final String FAILED_TO_DROP_NOTES = "failed_to_drop_notes";
|
||||
public static final String FAILED_TO_INSERT_PROJECT = "failed_to_insert_project";
|
||||
public static final String FAILED_TO_LIST_ENTITIES = "failed_to_list_entities";
|
||||
public static final String FAILED_TO_LOAD_COMPANY_MEMBERS = "failed_to_load_company_members";
|
||||
@@ -20,6 +21,7 @@ public class Errors {
|
||||
public static final String FAILED_TO_LOAD_ENTITY_BY_ID = "failed_to_load_entity_by_id";
|
||||
public static final String FAILED_TO_LOAD_PROJECT_MEMBERS = "failed_to_load_project_members";
|
||||
public static final String FAILED_TO_LOAD_USER_COMPANIES = "failed_to_load_user_companies";
|
||||
public static final String FAILED_TO_LOAD_USER_SETTINGS = "failed_to_load_user_settings";
|
||||
public static final String FAILED_TO_MOVE = "failed_to_move";
|
||||
public static final String FAILED_TO_READ_LAST_DOCID = "failed_to_read_last_docId";
|
||||
public static final String FAILED_TO_SEARCH_DB = "failed_to_search_db";
|
||||
|
||||
@@ -4,6 +4,8 @@ package de.srsoftware.umbrella.message;
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
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.message.model.Settings.Times;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
@@ -39,8 +41,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} Integer PRIMARY KEY, {2} VARCHAR(255) NOT N
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_SUBMISSIONS,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_SUBMISSIONS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +55,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_SETTINGS,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_SETTINGS).causedBy(e);
|
||||
}
|
||||
|
||||
Integer version = null;
|
||||
@@ -67,11 +67,9 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
version = INITIAL_DB_VERSION;
|
||||
insertInto(TABLE_SETTINGS, KEY, VALUE).values(DB_VERSION,version).execute(db).close();
|
||||
}
|
||||
|
||||
return version;
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,DB_VERSION,TABLE_SETTINGS,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY,DB_VERSION).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +88,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
if (settings != null) return settings;
|
||||
throw new UmbrellaException(500,"No submission settings stored for {0}",user);
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed to read settings for {0} from {1} table",user,TABLE_SUBMISSIONS,e);
|
||||
throw new UmbrellaException(500,"Failed to read settings for {0} from {1} table",user,TABLE_SUBMISSIONS).causedBy(e);
|
||||
throw databaseException(FAILED_TO_LOAD_USER_SETTINGS,user).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +115,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
replaceInto(TABLE_SUBMISSIONS, USER_ID, VALUE).values(user.id(),times).execute(db).close();
|
||||
return settings;
|
||||
} catch (SQLException e) {
|
||||
LOG.log(WARNING,"Failed to store submission data for {0}!",user.name(),e);
|
||||
throw new UmbrellaException(500,"Failed to store submission data for {0}!",user.name()).causedBy(e);
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,"submission data").causedBy(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import static de.srsoftware.tools.jdbc.Condition.like;
|
||||
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.notes.Constants.*;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
@@ -55,8 +56,7 @@ ADD COLUMN entity_id VARCHAR(255);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed to add \"entity_id\" column to table {0}",TABLE_NOTES,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_COLUMN,"(not existing)",ENTITY_ID,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,7 @@ ADD COLUMN module VARCHAR(20);
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed to add \"module\" column to table {0}",TABLE_NOTES,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_COLUMN,"(not existing)",MODULE,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +85,7 @@ SET module = SUBSTR(uri, 1, INSTR(uri, ':') - 1),
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed fill \"module\" and \"entity_id\" columns",e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException("Failed to fill \"{0}\" and \"{1}\" columns",MODULE,ENTITY_ID).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +102,7 @@ CREATE TABLE IF NOT EXISTS notes (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_NOTES,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,8 +121,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_NOTES,e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +133,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
.execute(db);
|
||||
return noteId;
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Failed to delete note {0}",noteId);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,"note",noteId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +144,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
.where(MODULE,equal(module)).where(ENTITY_ID,equal(entityId))
|
||||
.execute(db);
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Failed to delete notes of ({0} {1})",module,entityId);
|
||||
throw databaseException(FAILED_TO_DROP_NOTES,module,entityId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +155,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,"Failed drop \"uri\" column",e);
|
||||
throw new RuntimeException(e);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,"uri","column").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +173,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to search notes");
|
||||
throw databaseException(FAILED_TO_SEARCH_DB,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +190,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load notes");
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +208,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return notes;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load notes");
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,TABLE_NOTES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +221,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
rs.close();
|
||||
return note;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load note {0}",noteId);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"note",noteId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +245,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
}
|
||||
return note;
|
||||
} catch (SQLException e){
|
||||
throw databaseException("Failed to save note: {0}",note.text());
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,"note").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +255,7 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
update(TABLE_NOTES).set(ENTITY_ID).where(MODULE,equal(module)).where(ENTITY_ID,equal(oldId)).prepare(db).apply(newId).close();
|
||||
LOG.log(DEBUG,"Updated note @ {0}.{1} → {0}.{2}",module,oldId,newId);
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to update {0}.{1} → {0}.{2}",module,oldId,newId);
|
||||
throw databaseException("Failed to update {0}.{1} → {0}.{2}",module,oldId,newId).causedBy(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Errors.*;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.translator;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.notFound;
|
||||
import static de.srsoftware.umbrella.core.model.Status.COMPLETE;
|
||||
import static de.srsoftware.umbrella.core.model.Status.OPEN;
|
||||
import static de.srsoftware.umbrella.project.Constants.*;
|
||||
@@ -49,7 +50,7 @@ public class SqliteDb extends BaseDb implements ProjectDb {
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PROJECTS);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PROJECTS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ PRIMARY KEY (project_id, code)
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_CUSTOM_STATES);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_CUSTOM_STATES).causedBy(e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,7 +100,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PROJECT_USERS);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_PROJECT_USERS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
.where(USER_ID,equal(userId))
|
||||
.execute(db);
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY_OF_ENTITY,"member",userId,"project",projectId);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY_OF_ENTITY,"member",userId,"project",projectId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
return result;
|
||||
} catch (SQLException e){
|
||||
throw databaseException(FAILED_TO_LOAD_PROJECT_MEMBERS);
|
||||
throw databaseException(FAILED_TO_LOAD_PROJECT_MEMBERS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
if (rs.next()) project = Project.of(rs);
|
||||
rs.close();
|
||||
|
||||
if (project == null) throw UmbrellaException.notFound("no_project_for_id",projectId);
|
||||
if (project == null) throw notFound("no_project_for_id",projectId);
|
||||
|
||||
rs = select(ALL).from(TABLE_CUSTOM_STATES).where(PROJECT_ID,equal(projectId)).exec(db);
|
||||
var states = project.allowedStates();
|
||||
@@ -152,7 +153,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
return project;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,"project");
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,"project").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +175,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
return projects;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,"items");
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY,"items").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
return projects;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_ITEMS);
|
||||
throw databaseException(FAILED_TO_LIST_ENTITIES,"items").causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
return projects;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_ITEMS);
|
||||
throw databaseException(FAILED_TO_LIST_ENTITIES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +236,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
return new Project(id, prj.name(), prj.description(),prj.status(),prj.companyId().orElse(null),prj.showClosed(),prj.members(),prj.allowedStates());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_INSERT_PROJECT);
|
||||
throw databaseException(FAILED_TO_INSERT_PROJECT).causedBy(e);
|
||||
}
|
||||
} else { // Update
|
||||
try {
|
||||
@@ -257,7 +258,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
}
|
||||
return prj;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY, translator().translate(user.language(),"project"));
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY, translator().translate(user.language(),"project")).causedBy(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -270,7 +271,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
insertInto(TABLE_CUSTOM_STATES,PROJECT_ID,CODE,NAME).values(projectId,newState.code(),newState.name()).execute(db).close();
|
||||
return newState;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_STATE);
|
||||
throw databaseException(FAILED_TO_CREATE_STATE).causedBy(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
"failed_to_create_table": "Failed to create table `{0}`",
|
||||
"failed_to_drop_entity": "Failed to remove {0} {1}",
|
||||
"failed_to_drop_entity_from_entity": "Failed to remove {0} {1} from {2} {3}",
|
||||
"failed_to_drop_notes": "Failed to delete notes of ({0} {1})",
|
||||
"failed_to_insert_project": "Failed to insert project into database",
|
||||
"failed_to_list_entities": "Failed to list {0}",
|
||||
"failed_to_load_companies": "Could not load company {0}",
|
||||
@@ -114,6 +115,7 @@
|
||||
"failed_to_load_entity_by_id": "Failed to load {0} with id = {1}",
|
||||
"failed_to_load_project_members": "Failed to load members of project",
|
||||
"failed_to_load_user_companies": "Failed to load companies for user {0}",
|
||||
"failed_to_load_user_settings": "Failed to load settings for user {0}!",
|
||||
"failed_to_move": "Failed to move {0} to {1}!",
|
||||
"failed_to_read_last_docId": "Failed to read last document id",
|
||||
"failed_to_remove_user_from_company": "Failed to remove user {0} from company {1}",
|
||||
|
||||
Reference in New Issue
Block a user