working on backend-side translations
This commit is contained in:
@@ -12,8 +12,7 @@ import static de.srsoftware.umbrella.core.Constants.COMPANY;
|
||||
import static de.srsoftware.umbrella.core.Errors.*;
|
||||
import static de.srsoftware.umbrella.core.Field.*;
|
||||
import static de.srsoftware.umbrella.core.Field.COMPANY_ID;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.company.api.CompanyDb;
|
||||
@@ -68,7 +67,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_COMPANIES);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_COMPANIES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_COMPANIES);
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_COMPANIES).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +91,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
.execute(db)
|
||||
.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_ASSIGN_USER_TO_COMPANY);
|
||||
throw databaseException(FAILED_TO_ASSIGN_USER_TO_COMPANY).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +102,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
delete().from(TABLE_COMPANIES).where(ID,equal(companyId)).execute(db);
|
||||
return companyId;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,"company",companyId);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY,"company",companyId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +111,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
try {
|
||||
delete().from(TABLE_COMPANIES_USERS).where(COMPANY_ID,equal(companyId)).where(USER_ID,equal(userId)).execute(db);
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY_OF_ENTITY,"user",userId,"company",companyId);
|
||||
throw databaseException(FAILED_TO_DROP_ENTITY_OF_ENTITY,"user",userId,"company",companyId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
rs.close();
|
||||
return ids;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_COMPANY_MEMBERS,companyId);
|
||||
throw databaseException(FAILED_TO_LOAD_COMPANY_MEMBERS,companyId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
var next = last+1;
|
||||
return prefix+next; // TODO: currently not taking growing number lengths into account, this should be resolved!
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_CUSTOMER_NUM_SETTINGS,companyId);
|
||||
throw databaseException(FAILED_TO_LOAD_CUSTOMER_NUM_SETTINGS,companyId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +162,8 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
}
|
||||
rs.close();
|
||||
return companies;
|
||||
} catch (SQLException ex){
|
||||
throw databaseException(FAILED_TO_SEARCH_DB, ModuleRegistry.translator().translate(user.language(),COMPANY));
|
||||
} catch (SQLException e){
|
||||
throw databaseException(FAILED_TO_SEARCH_DB, ModuleRegistry.translator().translate(user.language(),COMPANY)).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
rs.close();
|
||||
return companies;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_USER_COMPANIES,userId);
|
||||
throw databaseException(FAILED_TO_LOAD_USER_COMPANIES,userId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,10 +190,10 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
Company company = null;
|
||||
if (rs.next()) company = Company.of(rs);
|
||||
rs.close();
|
||||
if (company == null) throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"company",companyId);
|
||||
if (company == null) throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID,"company",companyId);
|
||||
return company;
|
||||
} catch (SQLException e){
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"company",companyId);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,"company",companyId).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +225,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
return company;
|
||||
}
|
||||
} catch (SQLException e){
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,company.name());
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,company.name()).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ CREATE TABLE IF NOT EXISTS "companies" (
|
||||
try {
|
||||
update(TABLE_COMPANIES).set(LAST_CUSTOMER_NUMBER,CUSTOMER_NUMBER_PREFIX).where(ID,equal(companyId)).prepare(db).apply(number,prefix).close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY, LAST_CUSTOMER_NUMBER);
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY, LAST_CUSTOMER_NUMBER).causedBy(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user