working on transformation of stock tables

This commit is contained in:
2025-10-13 14:52:15 +02:00
parent dabacd3d00
commit b361731cab
4 changed files with 147 additions and 55 deletions

View File

@@ -8,6 +8,7 @@ public class Constants {
private Constants(){}
public static final String ADDRESS = "address";
public static final String ALLOWED_STATES = "allowed_states";
public static final String ATTACHMENTS = "attachments";

View File

@@ -8,8 +8,8 @@ import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
public class Location {
long owner;
boolean ownerIsCompany = false;
private long owner;
private boolean ownerIsCompany = false;
private long id;
private Long parentLocationId;
private String name;
@@ -25,36 +25,29 @@ public class Location {
this.description = description;
}
public final long id(){
return id;
}
public String description() {
return description;
}
public String name() {
return name;
}
public static Location of(ResultSet rs){
return null;
}
public static Location ofLegacy(ResultSet rs) throws SQLException {
var id = rs.getString(ID);
var parent = rs.getString(LOCATION_ID);
var name = rs.getString(NAME);
var description = rs.getString(DESCRIPTION);
var ownerIsCompany = false;
var parts = id.split(":");
if (parts.length != 3) throw databaseException("Legacy id expected to be of format ss:dd:ss, encountered {0}",id);
switch (parts[0]){
case "company":
ownerIsCompany = true; break;
case "user":
break;
case null, default:
throw databaseException("Legacy id expected to start with 'company' or 'user', encountered {0}",id);
}
var owner = 0L;
try {
owner = Long.parseLong(parts[1]);
} catch (NumberFormatException nfe){
throw databaseException("Legacy id expected to be of format ss:dd:ss, encountered {0}",id);
}
Long parentLocationId = null;
if (parent != null){
// TODO
}
return new Location(owner, ownerIsCompany, id, parentLocationId, name, description);
public long ownerCoded(){
return ownerIsCompany ? -owner : owner;
}
public Long parent(){
return parentLocationId;
}
}