You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by ql...@apache.org on 2016/09/13 09:41:22 UTC
incubator-unomi git commit: UNOMI-32 remove property if the property
is present in the object with a null value
Repository: incubator-unomi
Updated Branches:
refs/heads/master 9a53c2f48 -> 0bb17729c
UNOMI-32 remove property if the property is present in the object with a null value
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/0bb17729
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/0bb17729
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/0bb17729
Branch: refs/heads/master
Commit: 0bb17729c5dbd461721d8d9487b8b278cda87091
Parents: 9a53c2f
Author: dgaillard <dg...@jahia.com>
Authored: Mon Sep 12 17:55:19 2016 +0200
Committer: dgaillard <dg...@jahia.com>
Committed: Mon Sep 12 17:55:19 2016 +0200
----------------------------------------------------------------------
.../services/services/ProfileServiceImpl.java | 37 +++++++++++---------
1 file changed, 21 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/0bb17729/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
index eaf8d98..71fe2fd 100644
--- a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
@@ -766,35 +766,40 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
return false;
}
- private boolean merge(Map<String,Object> target, Map<String,Object> object) {
+ private boolean merge(Map<String, Object> target, Map<String, Object> object) {
boolean changed = false;
- for (Map.Entry<String, Object> previousEntry : object.entrySet()) {
- if (previousEntry.getValue() != null) {
- if (previousEntry.getValue() instanceof Collection) {
- Collection currentCollection = (Collection) target.get(previousEntry.getKey());
+ for (Map.Entry<String, Object> newEntry : object.entrySet()) {
+ if (newEntry.getValue() != null) {
+ if (newEntry.getValue() instanceof Collection) {
+ Collection currentCollection = (Collection) target.get(newEntry.getKey());
if (currentCollection != null) {
- if (!currentCollection.containsAll((Collection) previousEntry.getValue())) {
- changed |= currentCollection.addAll((Collection) previousEntry.getValue());
+ if (!currentCollection.containsAll((Collection) newEntry.getValue())) {
+ changed |= currentCollection.addAll((Collection) newEntry.getValue());
}
} else {
- target.put(previousEntry.getKey(), previousEntry.getValue());
+ target.put(newEntry.getKey(), newEntry.getValue());
changed = true;
}
- } else if (previousEntry.getValue() instanceof Map) {
- Map<String,Object> currentMap = (Map) target.get(previousEntry.getKey());
+ } else if (newEntry.getValue() instanceof Map) {
+ Map<String,Object> currentMap = (Map) target.get(newEntry.getKey());
if (currentMap == null) {
- target.put(previousEntry.getKey(), previousEntry.getValue());
+ target.put(newEntry.getKey(), newEntry.getValue());
changed = true;
} else {
- changed |= merge(currentMap, (Map) previousEntry.getValue());
+ changed |= merge(currentMap, (Map) newEntry.getValue());
}
- } else if (previousEntry.getValue().getClass().getPackage().getName().equals("java.lang")) {
- if (previousEntry.getValue() != null && !previousEntry.getValue().equals(target.get(previousEntry.getKey()))) {
- target.put(previousEntry.getKey(), previousEntry.getValue());
+ } else if (newEntry.getValue().getClass().getPackage().getName().equals("java.lang")) {
+ if (newEntry.getValue() != null && !newEntry.getValue().equals(target.get(newEntry.getKey()))) {
+ target.put(newEntry.getKey(), newEntry.getValue());
changed = true;
}
} else {
- changed |= merge(target.get(previousEntry.getKey()), previousEntry.getValue());
+ changed |= merge(target.get(newEntry.getKey()), newEntry.getValue());
+ }
+ } else {
+ if (target.containsKey(newEntry.getKey())) {
+ target.remove(newEntry.getKey());
+ changed = true;
}
}
}