working on loading items for location

This commit is contained in:
2025-10-13 21:57:50 +02:00
parent 26d2f7c1f4
commit 6e9a2b6aca
10 changed files with 152 additions and 9 deletions

View File

@@ -9,6 +9,9 @@ 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";
@@ -117,6 +120,7 @@ public class Constants {
public static final String LANGUAGE = "language";
public static final String LAST_CUSTOMER_NUMBER = "last_customer_number";
public static final String LIMIT = "limit";
public static final String LOCATION = "location";
public static final String LOCATION_ID = "location_id";
public static final String LOGIN = "login";
@@ -144,7 +148,10 @@ public class Constants {
public static final String PRIORITY = "priority";
public static final String PROJECT = "project";
public static final String PROJECT_ID = "project_id";
public static final String PROPERTIES = "properties";
public static final String QUANTITY = "quantity";
public static final String RECEIVERS = "receivers";
public static final String REDIRECT = "redirect";
public static final String RENDERED = "rendered";

View File

@@ -1,12 +1,53 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import java.util.Collection;
import de.srsoftware.tools.Mappable;
public class Item {
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import static de.srsoftware.umbrella.core.Constants.*;
public class Item implements Mappable {
private long id;
private String code;
private boolean physical;
private Mappable owner;
private String code, name;
private Location location;
private Collection<Property> properties;
private Item(Mappable owner, long id, Location location, String code, String name) {
this.owner = owner;
this.id = id;
this.location = location;
this.code = code;
this.name = name;
this.properties = new HashSet<>();
}
public static Item of(ResultSet rs, Mappable owner, Location location) throws SQLException {
var id = rs.getLong(ID);
var code = rs.getString(CODE);
var name = rs.getString(NAME);
return new Item(owner, id, location, code, name);
}
@Override
public Map<String, Object> toMap() {
return Map.of(
OWNER, owner.toMap(),
ID, id,
LOCATION, location.toMap(),
CODE, code,
NAME, name,
PROPERTIES, properties.stream().map(Property::toMap).toList()
);
}
@Override
public String toString() {
return name;
}
}

View File

@@ -64,4 +64,9 @@ public class Location implements Mappable {
NAME,name,
DESCRIPTION,description);
}
@Override
public String toString() {
return name;
}
}

View File

@@ -1,10 +1,27 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
public class Property {
import de.srsoftware.tools.Mappable;
import java.util.Map;
import static de.srsoftware.umbrella.core.Constants.*;
public class Property implements Mappable {
long id;
String name;
Object value;
String unit;
String quantity;
@Override
public Map<String, Object> toMap() {
return Map.of(
ID, id,
NAME, name,
VALUE, value,
UNIT, unit,
QUANTITY, quantity
);
}
}