private List<T> saveCandidates = new ArrayList<>();
- private Set<T> mergeCandidates = new HashSet<>();
- private T mergeTarget = null;
+ private Set<T> markedMergeCandidates = new HashSet<>();
+ private T markedMergeTarget = null;
+
+ private HashMap<T, Set<T>> mergedEntities = new HashMap<>();
private IEntityCreator<T> entityCreator;
private final ConversationHolder conversation;
protected abstract T loadEntity(UUID entityUuid);
public void setMergeTarget(T t){
- mergeTarget = t;
+ markedMergeTarget = t;
}
public Set<T> getMergeCandidates() {
- return mergeCandidates;
+ return markedMergeCandidates;
}
public T getMergeTarget() {
- return mergeTarget;
+ return markedMergeTarget;
}
public void removeMergeTarget(){
- mergeTarget = null;
+ markedMergeTarget = null;
}
public void addMergeCandidate(T t){
- mergeCandidates.add(t);
+ markedMergeCandidates.add(t);
}
public void removeMergeCandidate(T t){
- mergeCandidates.remove(t);
+ markedMergeCandidates.remove(t);
}
public void addToDelete(T t, DeleteConfiguratorBase config) {
}
}
toDelete.clear();
+ if (!saveCandidates.isEmpty()){
+ CdmStore.getService(saveCandidates.get(0)).merge(saveCandidates, true);
+ }
if(resetMerge){
//merge entities
- for(T mergeCandidate:mergeCandidates){
- merge(mergeCandidate, mergeTarget);
+ for(T mergeTarget:mergedEntities.keySet()){
+ for (T mergeCandidate: mergedEntities.get(mergeTarget)){
+ merge(mergeCandidate, mergeTarget);
+ }
}
- mergeCandidates.clear();
- mergeTarget = null;
+ mergedEntities.clear();
+
}
}
this.saveCandidates.clear();
}
+
+ public HashMap<T, Set<T>> getMergedEntities() {
+ return mergedEntities;
+ }
+
+ public void setMergedEntities(HashMap<T, Set<T>> mergedEntities) {
+ this.mergedEntities = mergedEntities;
+ }
}