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();
|
||||||
controllerAttributes.putAll(data);
|
copyNonNull(data, controllerAttributes);
|
||||||
target.setRequestControllerAttributes(false);
|
target.setRequestControllerAttributes(false);
|
||||||
break;
|
break;
|
||||||
case MERGE:
|
case MERGE:
|
||||||
// just merge the attributes in
|
// just merge the attributes in
|
||||||
controllerAttributes.putAll(data);
|
copyNonNull(data, controllerAttributes);
|
||||||
target.setRequestControllerAttributes(false);
|
target.setRequestControllerAttributes(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -689,6 +689,13 @@ 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) {
|
||||||
|
if (src == null || src.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
src.entrySet().stream().filter(e -> e.getValue() != null).forEach(e -> trg.put(e.getKey(), e.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
private void assertTargetAttributesQuota(final JpaTarget target) {
|
private void assertTargetAttributesQuota(final JpaTarget target) {
|
||||||
final int limit = quotaManagement.getMaxAttributeEntriesPerTarget();
|
final int limit = quotaManagement.getMaxAttributeEntriesPerTarget();
|
||||||
QuotaHelper.assertAssignmentQuota(target.getId(), target.getControllerAttributes().size(), limit, "Attribute",
|
QuotaHelper.assertAssignmentQuota(target.getId(), target.getControllerAttributes().size(), limit, "Attribute",
|
||||||
|
|||||||
Reference in New Issue
Block a user