BGBM BDI Projects
/
taxeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2864959
)
improve deduplication handling and saving in bulkeditor
author
Katja Luther
<k.luther@bgbm.org>
Thu, 22 Mar 2018 10:04:07 +0000
(11:04 +0100)
committer
Katja Luther
<k.luther@bgbm.org>
Thu, 22 Mar 2018 10:07:24 +0000
(11:07 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorMenuPropertyTester.java
patch
|
blob
|
history
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
patch
|
blob
|
history
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java
patch
|
blob
|
history
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
patch
|
blob
|
history
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
patch
|
blob
|
history
diff --git
a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorMenuPropertyTester.java
b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorMenuPropertyTester.java
index f8e4aaeaff8613214e84abcd534a40b3f4c34d8a..abfd07293dbe2e3cb6f7a103ae08fe101aae5aea 100644
(file)
--- a/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorMenuPropertyTester.java
+++ b/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorMenuPropertyTester.java
@@
-24,7
+24,8
@@
public class BulkEditorMenuPropertyTester extends PropertyTester {
\r
private static final String IS_TEAM = "isTeam";
\r
private static final String IS_PERSON = "isPerson";
\r
\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
public BulkEditorMenuPropertyTester(){
\r
}
\r
/**
\r
@@
-36,14
+37,17
@@
public class BulkEditorMenuPropertyTester extends PropertyTester {
if(receiver instanceof IStructuredSelection){
\r
IStructuredSelection selection = (IStructuredSelection) receiver;
\r
Object selectedElement = selection.getFirstElement();
\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
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
if (property.equals(IS_TEAM) && selectedElement instanceof Team){
\r
return true;
\r
}
\r
return false;
\r
-
\r
+
\r
}
\r
return false;
\r
}
\r
}
\r
return false;
\r
}
\r
diff --git
a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
index 39825ea0bc92800c90c2d427175038fdd24742c6..60838b9eb3addbd6c0acdc68128b94eac2e546d0 100644
(file)
--- a/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
+++ b/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
@@
-67,7
+67,6
@@
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
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;
/**
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
@@
-260,9
+259,7
@@
public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
List<CdmBase> saveCandidates = getEditorInput().getSaveCandidates();
List<CdmBase> saveCandidates = getEditorInput().getSaveCandidates();
- if (!saveCandidates.isEmpty()){
- CdmStore.getService(saveCandidates.get(0)).merge(saveCandidates, true);
- }
+
dirty.setDirty(false);
getEditorInput().resetSaveCandidates();
getEditorInput().dispose();
dirty.setDirty(false);
getEditorInput().resetSaveCandidates();
getEditorInput().dispose();
diff --git
a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java
b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java
index ec655a611d47aa5377f3ae0af9d8d806a04edf10..ec025e6cbc8c3986bd2c3bd62b1023cdb1c7cb3f 100644
(file)
--- a/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java
+++ b/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java
@@
-8,6
+8,7
@@
*/
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
*/
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
+import java.util.HashSet;
import java.util.Set;
import javax.inject.Named;
import java.util.Set;
import javax.inject.Named;
@@
-48,6
+49,7
@@
public class MergeGroupHandlerE4 {
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
AbstractBulkEditorInput input = editor.getEditorInput();
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
AbstractBulkEditorInput input = editor.getEditorInput();
+ Set<CdmBase> mergedCandidates = new HashSet<>();
if(editor.isDirty()){
boolean proceed = MessageDialog.openQuestion(null,
if(editor.isDirty()){
boolean proceed = MessageDialog.openQuestion(null,
@@
-63,8
+65,8
@@
public class MergeGroupHandlerE4 {
}
// Check whether there are any group annotations
}
// 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;
MessageDialog.openWarning(shell,
"No merge candidates", "No objects have been chosen for merging.");
return;
@@
-85,7
+87,7
@@
public class MergeGroupHandlerE4 {
} else if(mergeTarget instanceof Reference){
ref = HibernateProxyHelper.deproxy(mergeTarget, Reference.class);
}
} 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){
//first check whether entities are mergeable
try{
if (ref != null){
@@
-97,6
+99,8
@@
public class MergeGroupHandlerE4 {
return;
}
input.getModel().remove(item);
return;
}
input.getModel().remove(item);
+ mergedCandidates.add(item);
+
}
if (teamOrPerson != null){
TeamOrPersonBase<?> teamOrPerson2 = HibernateProxyHelper.deproxy(item, TeamOrPersonBase.class);
}
if (teamOrPerson != null){
TeamOrPersonBase<?> teamOrPerson2 = HibernateProxyHelper.deproxy(item, TeamOrPersonBase.class);
@@
-107,12
+111,21
@@
public class MergeGroupHandlerE4 {
return;
}
input.getModel().remove(item);
return;
}
input.getModel().remove(item);
+ mergedCandidates.add(item);
}
}catch(MergeException e){
}
}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();
}
editor.setDirty();
editor.refresh();
}
diff --git
a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
index bb383be7f65a2a60521f086da8ccd2bee316ef79..a26da3ad3d08d4d9801003b933ae283de80d7ea6 100644
(file)
--- a/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
+++ b/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
@@
-57,8
+57,10
@@
public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEnti
private List<T> saveCandidates = new ArrayList<>();
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;
private IEntityCreator<T> entityCreator;
private final ConversationHolder conversation;
@@
-91,27
+93,27
@@
public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEnti
protected abstract T loadEntity(UUID entityUuid);
public void setMergeTarget(T t){
protected abstract T loadEntity(UUID entityUuid);
public void setMergeTarget(T t){
- mergeTarget = t;
+ m
arkedM
ergeTarget = t;
}
public Set<T> getMergeCandidates() {
}
public Set<T> getMergeCandidates() {
- return mergeCandidates;
+ return m
arkedM
ergeCandidates;
}
public T getMergeTarget() {
}
public T getMergeTarget() {
- return mergeTarget;
+ return m
arkedM
ergeTarget;
}
public void removeMergeTarget(){
}
public void removeMergeTarget(){
- mergeTarget = null;
+ m
arkedM
ergeTarget = null;
}
public void addMergeCandidate(T t){
}
public void addMergeCandidate(T t){
- mergeCandidates.add(t);
+ m
arkedM
ergeCandidates.add(t);
}
public void removeMergeCandidate(T t){
}
public void removeMergeCandidate(T t){
- mergeCandidates.remove(t);
+ m
arkedM
ergeCandidates.remove(t);
}
public void addToDelete(T t, DeleteConfiguratorBase config) {
}
public void addToDelete(T t, DeleteConfiguratorBase config) {
@@
-198,13
+200,18
@@
public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEnti
}
}
toDelete.clear();
}
}
toDelete.clear();
+ if (!saveCandidates.isEmpty()){
+ CdmStore.getService(saveCandidates.get(0)).merge(saveCandidates, true);
+ }
if(resetMerge){
//merge entities
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);
+ }
}
}
- merge
Candidat
es.clear();
- mergeTarget = null;
+ merge
dEntiti
es.clear();
+
}
}
}
}
@@
-299,4
+306,12
@@
public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEnti
this.saveCandidates.clear();
}
this.saveCandidates.clear();
}
+
+ public HashMap<T, Set<T>> getMergedEntities() {
+ return mergedEntities;
+ }
+
+ public void setMergedEntities(HashMap<T, Set<T>> mergedEntities) {
+ this.mergedEntities = mergedEntities;
+ }
}
}
diff --git
a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
index 1c5f1405631755baca8d7eedd7970c8d1f55980c..7bdcf41cd0301d25ce6fc3ed2e025101627625ff 100644
(file)
--- a/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
+++ b/
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
@@
-105,6
+105,7
@@
public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
/** {@inheritDoc} */
@Override
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
/** {@inheritDoc} */
@Override
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
+
return CdmStore.getSearchManager().findTeamOrPersons(configurator);
}
return CdmStore.getSearchManager().findTeamOrPersons(configurator);
}