working on backend-side translations
This commit is contained in:
@@ -14,7 +14,6 @@ import static java.text.MessageFormat.format;
|
|||||||
import static java.time.ZoneOffset.UTC;
|
import static java.time.ZoneOffset.UTC;
|
||||||
|
|
||||||
import de.srsoftware.umbrella.core.BaseDb;
|
import de.srsoftware.umbrella.core.BaseDb;
|
||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
|
||||||
import de.srsoftware.umbrella.core.model.Bookmark;
|
import de.srsoftware.umbrella.core.model.Bookmark;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
|
|||||||
rs.close();
|
rs.close();
|
||||||
return contacts;
|
return contacts;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(FAILED_TO_LOAD_CONTACTS_OF_USER,userId).causedBy(e);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"contacts",userId).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class SqliteDb extends BaseDb implements ContactDb{
|
|||||||
if (contact != null) return contact;
|
if (contact != null) return contact;
|
||||||
throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID, "contact", contactId);
|
throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID, "contact", contactId);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(FAILED_TO_LOAD_CONTACTS_OF_USER,userId).causedBy(e);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"contacts",userId).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
package de.srsoftware.umbrella.core;
|
package de.srsoftware.umbrella.core;
|
||||||
|
|
||||||
public class Errors {
|
public class Errors {
|
||||||
|
public static final String FAILED_TO_ADD_COLUMN = "failed_to_add_column";
|
||||||
|
public static final String FAILED_TO_ADD_PROPERTY_TO_ITEM = "failed_to_add_prop_to_item";
|
||||||
public static final String FAILED_TO_ASSIGN_USER_TO_COMPANY = "failed_to_assign_user_to_company";
|
public static final String FAILED_TO_ASSIGN_USER_TO_COMPANY = "failed_to_assign_user_to_company";
|
||||||
public static final String FAILED_TO_ASSIGN_CONTACT_TO_USER = "failed_to_assign_contact_to_user";
|
public static final String FAILED_TO_ASSIGN_CONTACT_TO_USER = "failed_to_assign_contact_to_user";
|
||||||
public static final String FAILED_TO_CHECK_FILE_PERMISSIONS = "failed_to_check_file_permissions";
|
public static final String FAILED_TO_CHECK_FILE_PERMISSIONS = "failed_to_check_file_permissions";
|
||||||
@@ -12,8 +14,9 @@ public class Errors {
|
|||||||
public static final String FAILED_TO_DROP_NOTES = "failed_to_drop_notes";
|
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_INSERT_PROJECT = "failed_to_insert_project";
|
||||||
public static final String FAILED_TO_LIST_ENTITIES = "failed_to_list_entities";
|
public static final String FAILED_TO_LIST_ENTITIES = "failed_to_list_entities";
|
||||||
|
public static final String FAILED_TO_LOAD_CHILD_LOCATIONS = "failed_to_load_child_locations";
|
||||||
public static final String FAILED_TO_LOAD_COMPANY_MEMBERS = "failed_to_load_company_members";
|
public static final String FAILED_TO_LOAD_COMPANY_MEMBERS = "failed_to_load_company_members";
|
||||||
public static final String FAILED_TO_LOAD_CONTACTS_OF_USER = "failed_to_load_contacts_of_user";
|
public static final String FAILED_TO_LOAD_ENTITIES_OF_OWNER = "failed_to_load_entities_of_owner";
|
||||||
public static final String FAILED_TO_LOAD_CUSTOMER_NUM_SETTINGS = "failed_to_load_customer_number_settings";
|
public static final String FAILED_TO_LOAD_CUSTOMER_NUM_SETTINGS = "failed_to_load_customer_number_settings";
|
||||||
public static final String FAILED_TO_LOAD_CUSTOMER_PRICE = "failed_to_load_customer_price";
|
public static final String FAILED_TO_LOAD_CUSTOMER_PRICE = "failed_to_load_customer_price";
|
||||||
public static final String FAILED_TO_LOAD_CUSTOMER_SETTINGS = "failed_to_load_customer_settings";
|
public static final String FAILED_TO_LOAD_CUSTOMER_SETTINGS = "failed_to_load_customer_settings";
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import static de.srsoftware.umbrella.core.Constants.*;
|
|||||||
import static de.srsoftware.umbrella.core.Errors.*;
|
import static de.srsoftware.umbrella.core.Errors.*;
|
||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||||
import static de.srsoftware.umbrella.message.model.Settings.Times;
|
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;
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import static java.time.ZoneOffset.UTC;
|
|||||||
|
|
||||||
import de.srsoftware.tools.jdbc.Query;
|
import de.srsoftware.tools.jdbc.Query;
|
||||||
import de.srsoftware.umbrella.core.BaseDb;
|
import de.srsoftware.umbrella.core.BaseDb;
|
||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
|
||||||
import de.srsoftware.umbrella.core.model.Note;
|
import de.srsoftware.umbrella.core.model.Note;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import java.util.Map;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class SqliteDb extends BaseDb implements ProjectDb {
|
public class SqliteDb extends BaseDb implements ProjectDb {
|
||||||
private static final System.Logger LOG = System.getLogger("ProjectDb");
|
|
||||||
private static final int INITIAL_DB_VERSION = 1;
|
|
||||||
|
|
||||||
public SqliteDb(Connection connection) {
|
public SqliteDb(Connection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import static de.srsoftware.tools.jdbc.Condition.like;
|
|||||||
import static de.srsoftware.tools.jdbc.Query.*;
|
import static de.srsoftware.tools.jdbc.Query.*;
|
||||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||||
import static de.srsoftware.umbrella.core.Constants.*;
|
import static de.srsoftware.umbrella.core.Constants.*;
|
||||||
|
import static de.srsoftware.umbrella.core.Errors.*;
|
||||||
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService;
|
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService;
|
||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||||
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.notFound;
|
||||||
import static de.srsoftware.umbrella.stock.Constants.*;
|
import static de.srsoftware.umbrella.stock.Constants.*;
|
||||||
import static java.lang.System.Logger.Level.*;
|
import static java.lang.System.Logger.Level.*;
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
@@ -17,7 +19,6 @@ import static java.text.MessageFormat.format;
|
|||||||
import de.srsoftware.tools.jdbc.Query;
|
import de.srsoftware.tools.jdbc.Query;
|
||||||
import de.srsoftware.umbrella.core.BaseDb;
|
import de.srsoftware.umbrella.core.BaseDb;
|
||||||
import de.srsoftware.umbrella.core.api.Owner;
|
import de.srsoftware.umbrella.core.api.Owner;
|
||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
|
||||||
import de.srsoftware.umbrella.core.model.*;
|
import de.srsoftware.umbrella.core.model.*;
|
||||||
import de.srsoftware.umbrella.core.model.Location;
|
import de.srsoftware.umbrella.core.model.Location;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -51,12 +52,12 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
Long propertyId = null;
|
Long propertyId = null;
|
||||||
if (rs.next()) propertyId = rs.getLong(1);
|
if (rs.next()) propertyId = rs.getLong(1);
|
||||||
rs.close();
|
rs.close();
|
||||||
if (propertyId == null || propertyId == 0) throw databaseException("Failed to create new property {0} in DB",name);
|
if (propertyId == null || propertyId == 0) throw databaseException(FAILED_TO_STORE_ENTITY,"property");
|
||||||
insertInto(TABLE_ITEM_PROPERTIES,ITEM_ID,PROPERTY_ID,VALUE).values(itemId,propertyId,value).execute(db).close();
|
insertInto(TABLE_ITEM_PROPERTIES,ITEM_ID,PROPERTY_ID,VALUE).values(itemId,propertyId,value).execute(db).close();
|
||||||
db.setAutoCommit(true);
|
db.setAutoCommit(true);
|
||||||
return new Property(propertyId,name,value,unit);
|
return new Property(propertyId,name,value,unit);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to create new property {0} in DB",name);
|
throw databaseException(FAILED_TO_STORE_ENTITY,"property").causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
sql = format(sql,TABLE_ITEMS,DESCRIPTION);
|
sql = format(sql,TABLE_ITEMS,DESCRIPTION);
|
||||||
db.prepareStatement(sql).execute();
|
db.prepareStatement(sql).execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("failed to create {0} column in {1} table!",DESCRIPTION,TABLE_ITEMS);
|
throw databaseException(FAILED_TO_ADD_COLUMN,DESCRIPTION,TABLE_ITEMS).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
sql = format(sql, TABLE_ITEMS, ID, CODE, NAME, LOCATION_ID);
|
sql = format(sql, TABLE_ITEMS, ID, CODE, NAME, LOCATION_ID);
|
||||||
db.prepareStatement(sql).execute();
|
db.prepareStatement(sql).execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_ITEMS);
|
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_ITEMS).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
sql = format(sql, TABLE_ITEM_PROPERTIES, ITEM_ID, PROPERTY_ID,VALUE);
|
sql = format(sql, TABLE_ITEM_PROPERTIES, ITEM_ID, PROPERTY_ID,VALUE);
|
||||||
db.prepareStatement(sql).execute();
|
db.prepareStatement(sql).execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_ITEM_PROPERTIES);
|
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_ITEM_PROPERTIES).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
sql = format(sql, TABLE_LOCATIONS, ID, LOCATION_ID, NAME, DESCRIPTION);
|
sql = format(sql, TABLE_LOCATIONS, ID, LOCATION_ID, NAME, DESCRIPTION);
|
||||||
db.prepareStatement(sql).execute();
|
db.prepareStatement(sql).execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_LOCATIONS);
|
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_LOCATIONS).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
sql = format(sql, TABLE_PROPERTIES, ID, NAME, TYPE, UNIT);
|
sql = format(sql, TABLE_PROPERTIES, ID, NAME, TYPE, UNIT);
|
||||||
db.prepareStatement(sql).execute();
|
db.prepareStatement(sql).execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_PROPERTIES);
|
throw databaseException(ERROR_FAILED_CREATE_TABLE,TABLE_PROPERTIES).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
Query.delete().from(TABLE_LOCATIONS).where(ID,equal(location.id())).execute(db);
|
Query.delete().from(TABLE_LOCATIONS).where(ID,equal(location.id())).execute(db);
|
||||||
return location;
|
return location;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to delete \"{0}\"",location.name());
|
throw databaseException(FAILED_TO_DROP_ENTITY,location.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
try {
|
try {
|
||||||
db.prepareStatement("DROP TABLE IF EXISTS tokens").execute();
|
db.prepareStatement("DROP TABLE IF EXISTS tokens").execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to drop table tokens!");
|
throw databaseException(FAILED_TO_DROP_ENTITY,"table tokens").causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +211,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return items;
|
return items;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new UmbrellaException("Failed to load items from database");
|
throw databaseException(FAILED_TO_LIST_ENTITIES,ITEMS).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load child locations for {0}",parentId);
|
throw databaseException(FAILED_TO_LOAD_CHILD_LOCATIONS,parentId).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +237,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load locations for user {0}",company.name());
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"locations",company.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +252,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
for (var item : list) loadProperties(item);
|
for (var item : list) loadProperties(item);
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load items at {0}",location);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,ITEMS,location).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
for (var item : list) loadProperties(item);
|
for (var item : list) loadProperties(item);
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load items of {0}",company);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,ITEMS,company).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +280,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return item;
|
return item;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load properties of {0}",item.name());
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,PROPERTIES,item.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,9 +303,10 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
if (rs.next()) result = Item.of(rs);
|
if (rs.next()) result = Item.of(rs);
|
||||||
rs.close();
|
rs.close();
|
||||||
if (result != null) return result;
|
if (result != null) return result;
|
||||||
} catch (SQLException ignored) {
|
throw notFound(FAILED_TO_LOAD_ENTITY,ITEM);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw databaseException(FAILED_TO_LOAD_ENTITY,ITEM).causedBy(e);
|
||||||
}
|
}
|
||||||
throw databaseException("Failed to load item");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbLocation loadLocation(long locationId) {
|
public DbLocation loadLocation(long locationId) {
|
||||||
@@ -314,9 +316,9 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
if (rs.next()) loc = DbLocation.of(rs);
|
if (rs.next()) loc = DbLocation.of(rs);
|
||||||
rs.close();
|
rs.close();
|
||||||
if (loc != null) return loc;
|
if (loc != null) return loc;
|
||||||
throw databaseException("Failed to load location with id = {0}",locationId);
|
throw notFound(FAILED_TO_LOAD_ENTITY_BY_ID,LOCATION,locationId);
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load location with id = {0}",locationId);
|
throw databaseException(FAILED_TO_LOAD_ENTITY_BY_ID,LOCATION,locationId).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +331,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load properties!");
|
throw databaseException(FAILED_TO_LOAD_ENTITY,PROPERTIES).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +344,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return list;
|
return list;
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load locations for user {0}",user.name());
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,LOCATIONS,user.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +356,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
rs.close();
|
rs.close();
|
||||||
return number +1L;
|
return number +1L;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to read last item number for {0}",owner);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"last item number",owner).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +379,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
location = parent;
|
location = parent;
|
||||||
}
|
}
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to load path to location {0}",target);
|
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"path",target).causedBy(e);
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@@ -408,10 +410,10 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
long id = 0;
|
long id = 0;
|
||||||
if (rs.next()) id = rs.getLong(1);
|
if (rs.next()) id = rs.getLong(1);
|
||||||
rs.close();
|
rs.close();
|
||||||
if (id == 0) throw databaseException("Failed to save new location ({0})",location.name());
|
if (id == 0) throw databaseException(FAILED_TO_STORE_ENTITY,location.name());
|
||||||
return location.id(id);
|
return location.id(id);
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to save new location ({0})",location.name());
|
throw databaseException(FAILED_TO_STORE_ENTITY,location.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -423,7 +425,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
.close();
|
.close();
|
||||||
return location.clear();
|
return location.clear();
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Updating location \"{0}\" not implemented",location.name());
|
throw databaseException(FAILED_TO_UPDATE_ENTITY,location.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,7 +441,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
if (rs.next()) item.id(rs.getLong(1)).ownerNumber(number);
|
if (rs.next()) item.id(rs.getLong(1)).ownerNumber(number);
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to save new item to database!");
|
throw databaseException(FAILED_TO_STORE_ENTITY,item.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
} else if (item.isDirty()) {
|
} else if (item.isDirty()) {
|
||||||
try {
|
try {
|
||||||
@@ -458,7 +460,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
}
|
}
|
||||||
item.clear();
|
item.clear();
|
||||||
} catch (SQLException e){
|
} catch (SQLException e){
|
||||||
throw databaseException("Failed to update item {0}",item.name());
|
throw databaseException(FAILED_TO_UPDATE_ENTITY,item.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveProperties(item);
|
saveProperties(item);
|
||||||
@@ -468,9 +470,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
|
|
||||||
private void saveProperties(Item item){
|
private void saveProperties(Item item){
|
||||||
var saved = new ArrayList<Property>();
|
var saved = new ArrayList<Property>();
|
||||||
for (var property : item.properties()) {
|
for (var property : item.properties()) saved.add(saveProperty(item, property));
|
||||||
saved.add(saveProperty(item, property));
|
|
||||||
}
|
|
||||||
item.properties().clear();
|
item.properties().clear();
|
||||||
item.properties().addAll(saved);
|
item.properties().addAll(saved);
|
||||||
}
|
}
|
||||||
@@ -478,15 +478,12 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
private Property saveProperty(Item item, Property property) {
|
private Property saveProperty(Item item, Property property) {
|
||||||
Long propId = property.id();
|
Long propId = property.id();
|
||||||
if (is0(propId)) {
|
if (is0(propId)) {
|
||||||
LOG.log(DEBUG,"Saving new property {0}",property);
|
|
||||||
try {
|
try {
|
||||||
var rs = select(ID).from(TABLE_PROPERTIES).where(NAME,equal(property.name())).where(UNIT,equal(property.unit())).exec(db);
|
var rs = select(ID).from(TABLE_PROPERTIES).where(NAME,equal(property.name())).where(UNIT,equal(property.unit())).exec(db);
|
||||||
if (rs.next()) {
|
if (rs.next()) propId = rs.getLong(1);
|
||||||
propId = rs.getLong(1);
|
|
||||||
}
|
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to load property \"{}\"!",property.name());
|
throw databaseException(FAILED_TO_LOAD_ENTITY,property.name()).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is0(propId)) return addNewProperty(item.id(), property.name(), property.value(), property.unit());
|
if (is0(propId)) return addNewProperty(item.id(), property.name(), property.value(), property.unit());
|
||||||
@@ -500,7 +497,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
var rs = select(ALL).from(TABLE_PROPERTIES).where(ID,equal(existingPropId)).exec(db);
|
var rs = select(ALL).from(TABLE_PROPERTIES).where(ID,equal(existingPropId)).exec(db);
|
||||||
if (rs.next()) prop = Property.of(rs);
|
if (rs.next()) prop = Property.of(rs);
|
||||||
rs.close();
|
rs.close();
|
||||||
if (prop == null) throw databaseException("Failed to load property {0} for item {1}",existingPropId,itemId);
|
if (prop == null) throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER,"property "+existingPropId,"item "+itemId);
|
||||||
if ("".equals(value)){
|
if ("".equals(value)){
|
||||||
Query.delete().from(TABLE_ITEM_PROPERTIES).where(ITEM_ID,equal(itemId)).where(PROPERTY_ID,equal(existingPropId)).execute(db);
|
Query.delete().from(TABLE_ITEM_PROPERTIES).where(ITEM_ID,equal(itemId)).where(PROPERTY_ID,equal(existingPropId)).execute(db);
|
||||||
} else {
|
} else {
|
||||||
@@ -508,7 +505,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
}
|
}
|
||||||
return prop.value(value);
|
return prop.value(value);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw databaseException("Failed to add new property to item {0}",itemId);
|
throw databaseException(FAILED_TO_ADD_PROPERTY_TO_ITEM,itemId).causedBy(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,8 @@
|
|||||||
|
|
||||||
"failed": "fehlgeschlagen",
|
"failed": "fehlgeschlagen",
|
||||||
"failed_login_attempts" : "Account nach {attempts} fehlgeschlagenen Logins gesperrt bis {release_time}",
|
"failed_login_attempts" : "Account nach {attempts} fehlgeschlagenen Logins gesperrt bis {release_time}",
|
||||||
|
"failed_to_add_column": "Failed to add {0} column to {1} table",
|
||||||
|
"failed_to_add_prop_to_item": "Failed to add new property to item {0}",
|
||||||
"failed_to_assign_contact_to_user": "Failed to assign contact {0} to user {1]",
|
"failed_to_assign_contact_to_user": "Failed to assign contact {0} to user {1]",
|
||||||
"failed_to_assign_user_to_company": "Failed to assign user {0} to company {1}",
|
"failed_to_assign_user_to_company": "Failed to assign user {0} to company {1}",
|
||||||
"failed_to_check_file_permissions": "Failed to check file permissions!",
|
"failed_to_check_file_permissions": "Failed to check file permissions!",
|
||||||
@@ -105,9 +107,10 @@
|
|||||||
"failed_to_drop_notes": "Failed to delete notes of ({0} {1})",
|
"failed_to_drop_notes": "Failed to delete notes of ({0} {1})",
|
||||||
"failed_to_insert_project": "Failed to insert project into database",
|
"failed_to_insert_project": "Failed to insert project into database",
|
||||||
"failed_to_list_entities": "Failed to list {0}",
|
"failed_to_list_entities": "Failed to list {0}",
|
||||||
|
"failed_to_load_child_locations": "Failed to load child locations for {0}",
|
||||||
"failed_to_load_companies": "Could not load company {0}",
|
"failed_to_load_companies": "Could not load company {0}",
|
||||||
"failed_to_load_company_members": "Failed to load members of company {0}",
|
"failed_to_load_company_members": "Failed to load members of company {0}",
|
||||||
"failed_to_load_contacts_of_user": "Failed to load contacts of user {0}",
|
"failed_to_load_entities_of_owner": "Failed to load {0} of {1}",
|
||||||
"failed_to_load_customer_number_settings": "Failed to load customer number settings for company {0}",
|
"failed_to_load_customer_number_settings": "Failed to load customer number settings for company {0}",
|
||||||
"failed_to_load_customer_price": "Failed to load customer price (company: {0}, customer: {1}, item: {2})",
|
"failed_to_load_customer_price": "Failed to load customer price (company: {0}, customer: {1}, item: {2})",
|
||||||
"failed_to_load_customer_settings": "Failed to load customer settings (company: {0}, document type: {1})",
|
"failed_to_load_customer_settings": "Failed to load customer settings (company: {0}, document type: {1})",
|
||||||
|
|||||||
Reference in New Issue
Block a user