Target attributes update: Allow null values
Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com>
This commit is contained in:
@@ -672,12 +672,12 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
case REPLACE:
|
case REPLACE:
|
||||||
// clear the attributes before adding the new attributes
|
// clear the attributes before adding the new attributes
|
||||||
controllerAttributes.clear();
|
controllerAttributes.clear();
|
||||||
copyNonNull(data, controllerAttributes);
|
copy(data, controllerAttributes);
|
||||||
target.setRequestControllerAttributes(false);
|
target.setRequestControllerAttributes(false);
|
||||||
break;
|
break;
|
||||||
case MERGE:
|
case MERGE:
|
||||||
// just merge the attributes in
|
// just merge the attributes in
|
||||||
copyNonNull(data, controllerAttributes);
|
copy(data, controllerAttributes);
|
||||||
target.setRequestControllerAttributes(false);
|
target.setRequestControllerAttributes(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -689,11 +689,17 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
return targetRepository.save(target);
|
return targetRepository.save(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyNonNull(final Map<String, String> src, final Map<String, String> trg) {
|
private static void copy(final Map<String, String> src, final Map<String, String> trg) {
|
||||||
if (src == null || src.isEmpty()) {
|
if (src == null || src.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
src.entrySet().stream().filter(e -> e.getValue() != null).forEach(e -> trg.put(e.getKey(), e.getValue()));
|
src.entrySet().stream().forEach(e -> {
|
||||||
|
if (e.getValue() != null) {
|
||||||
|
trg.put(e.getKey(), e.getValue());
|
||||||
|
} else {
|
||||||
|
trg.remove(e.getKey());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTargetAttributesQuota(final JpaTarget target) {
|
private void assertTargetAttributesQuota(final JpaTarget target) {
|
||||||
|
|||||||
Reference in New Issue
Block a user