refactored location patching

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-22 22:45:14 +02:00
parent eafa7a5b5f
commit 8bf0790fca
3 changed files with 42 additions and 22 deletions

View File

@@ -4,6 +4,8 @@ package de.srsoftware.umbrella.core.model;
import static de.srsoftware.umbrella.core.Constants.*;
import de.srsoftware.umbrella.core.api.Owner;
import org.json.JSONObject;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
@@ -59,9 +61,24 @@ public class DbLocation extends Location {
return parentLocationId;
}
public DbLocation parent(DbLocation newParent) {
parentLocationId = newParent.id();
dirtyFields.add(PARENT_LOCATION_ID);
public DbLocation patch(JSONObject json) {
for (var field : json.keySet()){
boolean known = true;
switch (field) {
case PARENT_LOCATION_ID:
parentLocationId = json.getLong(field);
break;
case NAME:
name = json.getString(NAME);
break;
case DESCRIPTION:
description = json.getString(DESCRIPTION);
break;
default:
known = false;
}
if (known) dirtyFields.add(field);
}
return this;
}