refactored location patching
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user