implemented creating new stock items
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -90,6 +90,7 @@ public class DbLocation extends Location {
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
var map = super.toMap();
|
||||
if (description == null) description = "";
|
||||
map.put(OWNER,owner.toMap());
|
||||
map.put(NAME,name);
|
||||
map.put(DESCRIPTION,Map.of(SOURCE,description,RENDERED,markdown(description)));
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Item implements Mappable {
|
||||
private Collection<Property> properties;
|
||||
private Set<String> dirtyFields = new HashSet<>();
|
||||
|
||||
private Item(long id, Owner owner, long ownerNumber, Location location, String code, String name) {
|
||||
public Item(long id, Owner owner, long ownerNumber, Location location, String code, String name) {
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
this.ownerNumber = ownerNumber;
|
||||
@@ -45,6 +45,11 @@ public class Item implements Mappable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Item id(long newVal) {
|
||||
id = newVal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Location location(){
|
||||
return location;
|
||||
}
|
||||
@@ -73,6 +78,10 @@ public class Item implements Mappable {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public long ownerNumber(){
|
||||
return ownerNumber;
|
||||
}
|
||||
|
||||
public Item patch(JSONObject json) {
|
||||
for (var field : json.keySet()){
|
||||
var known = true;
|
||||
@@ -103,6 +112,7 @@ public class Item implements Mappable {
|
||||
map.put(LOCATION,location.toMap());
|
||||
map.put(CODE,code);
|
||||
map.put(NAME,name);
|
||||
map.put(OWNER_NUMBER,ownerNumber);
|
||||
if (properties != null) map.put(PROPERTIES,properties.stream().map(Property::toMap).toList());
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user