\r
private static final String IS_TEAM = "isTeam";\r
private static final String IS_PERSON = "isPerson";\r
- \r
+ private static final String IS_TEAM_OR_PERSON = "isTeamOrPerson";\r
+\r
public BulkEditorMenuPropertyTester(){\r
}\r
/**\r
if(receiver instanceof IStructuredSelection){\r
IStructuredSelection selection = (IStructuredSelection) receiver;\r
Object selectedElement = selection.getFirstElement();\r
+ if (property.equals(IS_TEAM_OR_PERSON) && (selectedElement instanceof Team || selectedElement instanceof Person)){\r
+ return true;\r
+ }\r
if (property.equals(IS_PERSON) && selectedElement instanceof Person){\r
return true;\r
- } \r
+ }\r
if (property.equals(IS_TEAM) && selectedElement instanceof Team){\r
return true;\r
}\r
return false;\r
- \r
+\r
}\r
return false;\r
}\r
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
List<CdmBase> saveCandidates = getEditorInput().getSaveCandidates();
- if (!saveCandidates.isEmpty()){
- CdmStore.getService(saveCandidates.get(0)).merge(saveCandidates, true);
- }
+
dirty.setDirty(false);
getEditorInput().resetSaveCandidates();
getEditorInput().dispose();
*/
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
+import java.util.HashSet;
import java.util.Set;
import javax.inject.Named;
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
AbstractBulkEditorInput input = editor.getEditorInput();
+ Set<CdmBase> mergedCandidates = new HashSet<>();
if(editor.isDirty()){
boolean proceed = MessageDialog.openQuestion(null,
}
// Check whether there are any group annotations
- Set<CdmBase> mergeCandidates = input.getMergeCandidates();
- if (mergeCandidates.size() == 0) {
+ Set<CdmBase> candidatesToMerge = input.getMergeCandidates();
+ if (candidatesToMerge.size() == 0) {
MessageDialog.openWarning(shell,
"No merge candidates", "No objects have been chosen for merging.");
return;
} else if(mergeTarget instanceof Reference){
ref = HibernateProxyHelper.deproxy(mergeTarget, Reference.class);
}
- for (CdmBase item : mergeCandidates) {
+ for (CdmBase item : candidatesToMerge) {
//first check whether entities are mergeable
try{
if (ref != null){
return;
}
input.getModel().remove(item);
+ mergedCandidates.add(item);
+
}
if (teamOrPerson != null){
TeamOrPersonBase<?> teamOrPerson2 = HibernateProxyHelper.deproxy(item, TeamOrPersonBase.class);
return;
}
input.getModel().remove(item);
+ mergedCandidates.add(item);
}
}catch(MergeException e){
-
+ candidatesToMerge.clear();
+ MessageDialog.openWarning(shell,
+ "No merge possible", "A merge is not possible." + e.getLocalizedMessage());
+ return;
}
}
-
+ if (!candidatesToMerge.isEmpty()){
+ input.getMergedEntities().put(mergeTarget, mergedCandidates);
+// mergeCandidates.clear();
+ input.getMergeCandidates().clear();
+ input.setMergeTarget(null);
+ }
editor.setDirty();
editor.refresh();
}
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;
+ }
}
/** {@inheritDoc} */
@Override
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
+
return CdmStore.getSearchManager().findTeamOrPersons(configurator);
}