Revision fd7d64e9
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
125 | 125 |
|
126 | 126 |
@Persist |
127 | 127 |
public void save() { |
128 |
//FIXME E4 do the potential merging of groups
|
|
128 |
input.saveModel();
|
|
129 | 129 |
|
130 | 130 |
// commit the conversation and start a new transaction immediately |
131 | 131 |
conversation.commit(true); |
... | ... | |
138 | 138 |
} |
139 | 139 |
} |
140 | 140 |
dirty.setDirty(false); |
141 |
viewer.refresh(); |
|
142 |
|
|
141 | 143 |
} |
142 | 144 |
|
143 | 145 |
/** {@inheritDoc} */ |
... | ... | |
190 | 192 |
return input; |
191 | 193 |
} |
192 | 194 |
|
193 |
public void removeAllAnnotations(){ |
|
194 |
input.removeMergeTarget(); |
|
195 |
input.removeMergeCandidates(); |
|
196 |
} |
|
197 |
|
|
198 | 195 |
/** |
199 | 196 |
* {@inheritDoc} |
200 | 197 |
*/ |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/DeleteHandlerE4.java | ||
---|---|---|
86 | 86 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
87 | 87 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) { |
88 | 88 |
|
89 |
boolean delete = MessageDialog.openQuestion(null, |
|
90 |
"Really delete", "Do you really want to delete the selected element?"); |
|
91 |
if (!delete) { |
|
92 |
return ; |
|
93 |
} |
|
94 |
|
|
95 | 89 |
BulkEditorE4 editor= (BulkEditorE4) activePart.getObject(); |
96 | 90 |
|
97 | 91 |
DeleteConfiguratorBase config = null; |
... | ... | |
238 | 232 |
} |
239 | 233 |
} |
240 | 234 |
if (result.isOk() ){ |
241 |
result.includeResult(CdmStore.getService(object).delete(object.getUuid()));
|
|
235 |
editor.getEditorInput().addToDelete(object, config);
|
|
242 | 236 |
editor.getEditorInput().getModel().remove(object); |
243 | 237 |
editor.refresh(true); |
238 |
editor.setDirty(); |
|
244 | 239 |
|
245 | 240 |
if(result.getUpdatedObjects().size() != 0 || !result.getExceptions().isEmpty()){ |
246 | 241 |
List<String> messages = new ArrayList<String>(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
29 | 29 |
|
30 | 30 |
/** |
31 |
* |
|
31 |
* Note: This merging is persisted only when saved. This handler only checks |
|
32 |
* if merging is possible and removes only the list items but <b>not</b> the |
|
33 |
* CDM entitites |
|
32 | 34 |
* @author pplitzner |
33 | 35 |
* @date 11.09.2017 |
34 | 36 |
* |
... | ... | |
43 | 45 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
44 | 46 |
AbstractBulkEditorInput input = editor.getEditorInput(); |
45 | 47 |
|
48 |
if(editor.isDirty()){ |
|
49 |
boolean proceed = MessageDialog.openQuestion(null, |
|
50 |
"Save changes", "You have made changes that must be saved before this query can be executed. Would you like to proceed?"); |
|
51 |
if (proceed) { |
|
52 |
editor.save(); |
|
53 |
} else { |
|
54 |
return ; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
46 | 58 |
// Check whether there are any group annotations |
47 | 59 |
List<CdmBase> mergeCandidates = input.getMergeCandidates(); |
48 | 60 |
if (mergeCandidates.size() == 0) { |
... | ... | |
92 | 104 |
}catch(MergeException e){ |
93 | 105 |
|
94 | 106 |
} |
95 |
// ((BulkEditor) editor).removeAnnotatedLine(item); |
|
96 |
// |
|
97 |
// // Mark entity container for merging with target entity |
|
98 |
// ((IEntityContainer) item).markAsMerged(targetEntity); |
|
99 |
// logger.info("Merging " + item + " with " + targetAnnotation); |
|
100 |
// |
|
101 |
// // Remove annotation from model |
|
102 |
// model.removeAnnotation(item); |
|
103 |
// } |
|
104 |
// |
|
105 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_CANDIDATE); |
|
106 |
// model.removeTypeFromAllAnnotations(IBulkEditorConstants.TYPE_MERGE_TARGET); |
|
107 | 107 |
} |
108 | 108 |
editor.setDirty(); |
109 | 109 |
editor.refresh(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Collections; |
13 | 13 |
import java.util.Comparator; |
14 |
import java.util.HashMap; |
|
14 | 15 |
import java.util.List; |
15 | 16 |
import java.util.Map; |
17 |
import java.util.Map.Entry; |
|
16 | 18 |
import java.util.UUID; |
17 | 19 |
|
18 | 20 |
import org.eclipse.jface.resource.ImageDescriptor; |
... | ... | |
20 | 22 |
import org.eclipse.ui.IPersistableElement; |
21 | 23 |
|
22 | 24 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
25 |
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; |
|
23 | 26 |
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; |
27 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
|
24 | 28 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
25 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 | 30 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
... | ... | |
51 | 55 |
|
52 | 56 |
private List<T> model = new ArrayList<>(); |
53 | 57 |
|
58 |
private Map<T, DeleteConfiguratorBase> toDelete = new HashMap<>(); |
|
59 |
|
|
54 | 60 |
private List<T> mergeCandidates = new ArrayList<>(); |
55 | 61 |
private T mergeTarget = null; |
56 | 62 |
|
... | ... | |
106 | 112 |
mergeCandidates.remove(t); |
107 | 113 |
} |
108 | 114 |
|
109 |
public void removeMergeCandidates() {
|
|
110 |
mergeCandidates = new ArrayList<>();
|
|
115 |
public void addToDelete(T t, DeleteConfiguratorBase config) {
|
|
116 |
toDelete.put(t, config);
|
|
111 | 117 |
} |
112 | 118 |
|
113 | 119 |
private void setEntityUuid(UUID entityUuid){ |
... | ... | |
198 | 204 |
return true; |
199 | 205 |
} |
200 | 206 |
|
207 |
public void saveModel(){ |
|
208 |
//delete entities |
|
209 |
for(Entry<T, DeleteConfiguratorBase> entry:toDelete.entrySet()){ |
|
210 |
try { |
|
211 |
delete(entry.getKey(), entry.getValue()); |
|
212 |
} catch (ReferencedObjectUndeletableException e) { |
|
213 |
e.printStackTrace(); |
|
214 |
} |
|
215 |
} |
|
216 |
toDelete.clear(); |
|
217 |
//merge entities |
|
218 |
for(T mergeCandidate:mergeCandidates){ |
|
219 |
merge(mergeCandidate, mergeTarget); |
|
220 |
} |
|
221 |
mergeCandidates.clear(); |
|
222 |
mergeTarget = null; |
|
223 |
} |
|
224 |
|
|
201 | 225 |
|
202 | 226 |
/** {@inheritDoc} */ |
203 | 227 |
@Override |
Also available in: Unified diff
ref #6932 Refactor merge and delete handler