preparing to delete locations
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -276,6 +276,26 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
db.prepareStatement(format("ALTER TABLE {0} RENAME TO {1}","locations_temp",TABLE_LOCATIONS)).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location save(DbLocation location) {
|
||||
if (location.id() == 0) { // new location
|
||||
try {
|
||||
var rs = insertInto(TABLE_LOCATIONS,OWNER,PARENT_LOCATION_ID,NAME,DESCRIPTION)
|
||||
.values(location.owner().dbCode(),location.parent(),location.name(),null)
|
||||
.execute(db).getGeneratedKeys();
|
||||
long id = 0;
|
||||
if (rs.next()) id = rs.getLong(1);
|
||||
rs.close();
|
||||
if (id == 0) throw databaseException("Failed to save new location ({0})",location.name());
|
||||
return location.id(id);
|
||||
} catch (SQLException e){
|
||||
throw databaseException("Failed to save new location ({0})",location.name());
|
||||
}
|
||||
} else {
|
||||
throw databaseException("Updating locations not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item save(Item item) {
|
||||
if (item.id() == 0){ // TODO
|
||||
|
||||
@@ -6,14 +6,15 @@ import de.srsoftware.umbrella.core.model.Location;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface StockDb {
|
||||
Property addNewProperty(long itemId, String name, Object value, String unit);
|
||||
Property addNewProperty(long itemId, String name, Object value, String unit);
|
||||
Collection<DbLocation> listChildLocations(long parentId);
|
||||
Collection<DbLocation> listCompanyLocations(Company company);
|
||||
Collection<Item> listItemsAt(Location location);
|
||||
Collection<Property> listProperties();
|
||||
Collection<Item> listItemsAt(Location location);
|
||||
Collection<Property> listProperties();
|
||||
Collection<DbLocation> listUserLocations(UmbrellaUser userId);
|
||||
Item loadItem(long id);
|
||||
Item loadItem(long id);
|
||||
DbLocation loadLocation(long locationId);
|
||||
Item save(Item item);
|
||||
Property setProperty(long itemId, long existingPropId, Object value);
|
||||
Location save(DbLocation location);
|
||||
Item save(Item item);
|
||||
Property setProperty(long itemId, long existingPropId, Object value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user