implemented moving of items

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-20 22:25:47 +02:00
parent b1517edc31
commit 715d2b0f31
5 changed files with 75 additions and 26 deletions

View File

@@ -77,6 +77,11 @@ public class Company implements Mappable, Owner {
return decimalSeparator;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Company c && c.id == id;
}
public String email() {
return email;
}

View File

@@ -28,6 +28,11 @@ public class Item implements Mappable {
this.properties = new HashSet<>();
}
public Item clear() {
dirtyFields.clear();
return this;
}
public String code(){
return code;
}
@@ -44,6 +49,12 @@ public class Item implements Mappable {
return location;
}
public Item location(Location newVal) {
location = newVal;
dirtyFields.add(LOCATION);
return this;
}
public String name(){
return name;
}
@@ -62,6 +73,24 @@ public class Item implements Mappable {
return owner;
}
public Item patch(JSONObject json) {
for (var field : json.keySet()){
var known = true;
switch (field) {
case CODE:
code = json.getString(field);
break;
case NAME:
name = json.getString(field);
break;
default:
known = false;
}
if (known) dirtyFields.add(field);
}
return this;
}
public Collection<Property> properties() {
return properties;
}
@@ -82,27 +111,4 @@ public class Item implements Mappable {
public String toString() {
return name;
}
public Item patch(JSONObject json) {
for (var field : json.keySet()){
var known = true;
switch (field) {
case CODE:
code = json.getString(field);
break;
case NAME:
name = json.getString(field);
break;
default:
known = false;
}
if (known) dirtyFields.add(field);
}
return this;
}
public Item clear() {
dirtyFields.clear();
return this;
}
}