Project

General

Profile

« Previous | Next » 

Revision 7dce04a4

Added by Katja Luther over 7 years ago

fix #5692: adapt delete algorithm to annotatedLineEditor mechanisms

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
26 26
import org.eclipse.ui.texteditor.AbstractDocumentProvider;
27 27

  
28 28
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
29
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
30
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
29 31
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
30 32
import eu.etaxonomy.taxeditor.model.MessagingUtils;
31 33

  
......
274 276
				}
275 277
				if (annotation.isMarkedAsMerged()) {
276 278
					persistenceService.merge(annotation.getEntity(), annotation.getMergeTarget()); //  merge
277
				} else {
279
				} if (annotation.isMarkedAsDeleted()) {
280
					try {
281
						persistenceService.delete(annotation.getEntity(), annotation.getDeleteConfigurator());
282
					} catch (ReferencedObjectUndeletableException e) {
283
						// TODO Auto-generated catch block
284
						e.printStackTrace();
285
					} //  merge
286
				}
287
				
288
				else {
278 289
					// TODO clarify w AM whether this needs to be executed on merged objects
279 290
					//persistenceService.delete(annotation.getEntity()); // delete
280 291
				}
......
378 389
			int length = position.getLength();
379 390

  
380 391
			Object entity = annotation.getEntity();
381
			annotation.markAsDeleted();
392
			//annotation.markAsDeleted(configurator);
382 393
			model.removeAnnotation(annotation);
383

  
394
			
384 395
			// Immediately followed by a delimiter?
385 396
			int annotationEnd = offset + length;
386 397
			try {
......
392 403
			}
393 404

  
394 405
			try {
406
				
395 407
				document.replace(offset, length, "");
408
				
396 409
			} catch (BadLocationException e) {
397 410
				MessagingUtils.error(getClass(), "Problems removing annotated line", e);
398 411
			}
......
411 424
			updateLineFromAnnotation(annotation);
412 425
		}
413 426
	}
427
	
428
	
414 429
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
235 235
     */
236 236
    public void removeAnnotatedLine(LineAnnotation annotation) {
237 237
        ((AnnotatedLineDocumentProvider) getDocumentProvider()).removeAnnotatedLine(annotation);
238
        
238 239
    }
239 240

  
240 241
    /* (non-Javadoc)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/IEntityPersistenceService.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.annotatedlineeditor;
12 12

  
13
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
13 14
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
14 15

  
15 16

  
......
57 58
	 * @return a boolean.
58 59
	 * @throws ReferencedObjectUndeletableException
59 60
	 */
60
	boolean delete(T entity) throws ReferencedObjectUndeletableException;
61
	boolean delete(T entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException;
61 62
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/LineAnnotation.java
14 14
import org.apache.log4j.Logger;
15 15
import org.eclipse.jface.text.source.Annotation;
16 16

  
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
18
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
19

  
17 20
/**
18 21
 * An <code>Annotation</code> which spans an entire line and holds an object associated
19 22
 * with the line in an <code>IEntityContainer</code>.
......
37 40
	private boolean markedAsMerged;
38 41
	private boolean markedAsNew;
39 42
	private T mergeTarget;
43
	private DeleteConfiguratorBase configurator= null;
40 44

  
41 45

  
42 46
	/**
......
184 188
			lineDisplayStrategy.setStatusMessage(entity + " deleted.", entity);
185 189
		}
186 190
	}
187

  
191
	 public void markAsDeleted(DeleteConfiguratorBase config) {
192
			super.markDeleted(true);
193
			this.configurator = config;
194
			if (!isMarkedAsMerged()) {
195
				lineDisplayStrategy.setStatusMessage(entity + " deleted.", entity);
196
			}
197
		}
188 198
	/* (non-Javadoc)
189 199
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsMerged(eu.etaxonomy.cdm.model.common.CdmBase)
190 200
	 */
......
248 258
    public void setEntity(Object entity) {
249 259
        this.entity = (T) entity;
250 260
    }
261

  
262
	public DeleteConfiguratorBase getDeleteConfigurator() {
263
		return this.configurator;
264
	}
265

  
266
	public void setDeleteConfigurator(DeleteConfiguratorBase config) {
267
		this.configurator = config;
268
		
269
	}
251 270
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
74 74
	private boolean isDirty;
75 75

  
76 76
    private IUndoContext undoContext;
77
    
78
    private BulkEditorQuery lastQuery;
79
    
80
	/**
81
	 * @return the lastQuery
82
	 */
83
	public BulkEditorQuery getLastQuery() {
84
		return lastQuery;
85
	}
77 86

  
78 87
	public BulkEditor() {
79 88
		super(CdmStore.createConversation());
......
185 194
		searchBar.setFocus();
186 195
	}
187 196

  
197
	/**
198
	 * @return the searchBar
199
	 */
200
	public BulkEditorSearch getSearchBar() {
201
		return searchBar;
202
	}
203

  
188 204
	private void displayWarningDialog() {
189 205
		IPreferenceStore prefs = PreferencesUtil.getPreferenceStore();
190 206
		if (!prefs.getBoolean(IPreferenceKeys.HIDE_BULKEDITOR_INFO)) {
......
247 263
	    isDirty = true;
248 264
	    firePropertyChange(PROP_DIRTY);
249 265
	}
250

  
251
	@Override
266
	
267
	
268
   	@Override
252 269
	public void doSave(IProgressMonitor progressMonitor) {
253 270
	    isDirty = false;
254 271

  
......
286 303
					return;
287 304
				}
288 305
			}
289
			conversation.clear();
290
			conversation.commit(true);
306
			//conversation.clear();
307
			//conversation.commit(true);
291 308

  
292 309
			getEditorInput().dispose();
293 310
			getEditorInput().bind();
294 311
			getEditorInput().performSearch(query);
295

  
312
			this.lastQuery = query;	
313
			this.lastQuery.getSearchConfigurator().setCheckResult(false);
296 314
			refresh();
297 315

  
298 316
			selectFirstItem();
......
336 354
    public IUndoContext getUndoContext() {
337 355
        return undoContext;
338 356
    }
357

  
358
	public void setDirty(boolean isDirty) {
359
		this.isDirty = isDirty;
360
	}
339 361
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java
11 11
package eu.etaxonomy.taxeditor.bulkeditor.handler;
12 12

  
13 13
import java.util.ArrayList;
14
import java.util.Iterator;
14 15
import java.util.List;
15 16

  
16 17
import org.eclipse.core.commands.AbstractHandler;
17 18
import org.eclipse.core.commands.ExecutionEvent;
18 19
import org.eclipse.core.commands.ExecutionException;
20
import org.eclipse.core.commands.common.NotDefinedException;
21
import org.eclipse.core.runtime.IStatus;
19 22
import org.eclipse.core.runtime.Status;
20 23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.text.TextSelection;
21 25
import org.eclipse.jface.viewers.ISelection;
22 26
import org.eclipse.jface.viewers.IStructuredSelection;
23 27
import org.eclipse.ui.IEditorInput;
......
30 34
import eu.etaxonomy.cdm.api.service.IAgentService;
31 35
import eu.etaxonomy.cdm.api.service.IGroupService;
32 36
import eu.etaxonomy.cdm.api.service.IMediaService;
33
import eu.etaxonomy.cdm.api.service.INameService;
34 37
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
35 38
import eu.etaxonomy.cdm.api.service.IReferenceService;
36
import eu.etaxonomy.cdm.api.service.ITaxonService;
37 39
import eu.etaxonomy.cdm.api.service.IUserService;
40
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
41
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
38 42
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
39 43
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
40 44
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
45
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
41 46
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
42 47
import eu.etaxonomy.cdm.model.common.Group;
43 48
import eu.etaxonomy.cdm.model.common.User;
......
52 57
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
53 58
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
54 59
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
60
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
61
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
55 62
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
63
import eu.etaxonomy.taxeditor.bulkeditor.operation.DeleteTaxonBaseOperation;
64
import eu.etaxonomy.taxeditor.bulkeditor.operation.DeleteTaxonNameOperation;
65
import eu.etaxonomy.taxeditor.model.AbstractUtility;
56 66
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
57 67
import eu.etaxonomy.taxeditor.model.MessagingUtils;
68
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
69
import eu.etaxonomy.taxeditor.operation.CdmDeleteOperation;
70
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
58 71
import eu.etaxonomy.taxeditor.store.CdmStore;
59 72
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
60 73

  
......
66 79
 */
67 80
public class DeleteHandler extends AbstractHandler {
68 81

  
82
	
83
	
69 84
	/* (non-Javadoc)
70 85
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
71 86
	 */
72 87
	@Override
73 88
	public Object execute(ExecutionEvent event) throws ExecutionException {
74 89

  
75
		ISelection selection = HandlerUtil.getCurrentSelection(event);
76

  
90
		
91
		TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
77 92
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
78 93

  
79 94
		IEditorInput input = editor.getEditorInput();
......
89 104
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
90 105

  
91 106
			IEntityPersistenceService persistenceService = (IEntityPersistenceService) input;
92

  
93

  
107
			
94 108
			for(Object object : structuredSelection.toList()){
95 109

  
96 110
				LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object);
......
104 118
					if (object instanceof SpecimenOrObservationBase){
105 119
						IOccurrenceService service = controller.getOccurrenceService();
106 120
						if (object != null){
107
							result = service.delete(((SpecimenOrObservationBase) object).getUuid());
121
							result = service.isDeletable(((SpecimenOrObservationBase) object), null);
108 122
							errorMessage = "The specimen or observation ";
123
							if (model != null) {
124
								Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
125
								while (iter.hasNext()) {
126
									Object next = iter.next();
127
									if (next instanceof LineAnnotation) {
128
										if (result.isOk()){
129
											((LineAnnotation)next).markAsDeleted(null);
130
										}
131
										
132
									}
133
								}
134
							}
109 135
						}
110 136
					} else if (object instanceof Reference){
111 137
						IReferenceService service = controller.getReferenceService();
112 138
						if (object != null){
113
							result = service.delete(((Reference) object).getUuid());
139
							result = service.isDeletable((Reference)object, null);
114 140
							errorMessage = "The reference ";
115 141
						}
142
						if (model != null) {
143
							Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
144
							while (iter.hasNext()) {
145
								Object next = iter.next();
146
								if (next instanceof LineAnnotation) {
147
									if (result.isOk()){
148
										((LineAnnotation)next).markAsDeleted(null);
149
									}
150
									
151
								}
152
							}
153
						}
116 154

  
117 155
					} else if (object instanceof Group){
118
						IGroupService service = controller.getGroupService();
119
						if (object != null){
120
							result = service.delete(((Group) object).getUuid());
121
							errorMessage = "The group ";
156
						if (model != null) {
157
							Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
158
							while (iter.hasNext()) {
159
								Object next = iter.next();
160
								if (next instanceof LineAnnotation) {
161
									if (result.isOk()){
162
										((LineAnnotation)next).markAsDeleted(null);
163
									}
164
									
165
								}
166
							}
122 167
						}
168
						
169
//						IGroupService service = controller.getGroupService();
170
//						if (object != null){
171
//							result = service.delete(((Group) object).getUuid());
172
//							errorMessage = "The group ";
173
//						}
123 174
					}else if (object instanceof User){
124
						IUserService service = controller.getUserService();
125
						if (object != null){
126
							result = service.delete(((User) object).getUuid());
127
							errorMessage = "The user ";
175
						if (model != null) {
176
							Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
177
							while (iter.hasNext()) {
178
								Object next = iter.next();
179
								if (next instanceof LineAnnotation) {
180
									if (result.isOk()){
181
										((LineAnnotation)next).markAsDeleted(null);
182
									}
183
									
184
								}
185
							}
128 186
						}
187
						
188
//						IUserService service = controller.getUserService();
189
//						if (object != null){
190
//							result = service.delete(((User) object).getUuid());
191
//							errorMessage = "The user ";
192
//						}
129 193
					} else if (object instanceof TaxonNameBase){
130
						INameService service = controller.getNameService();
194
						TaxonNameBase name = HibernateProxyHelper.deproxy(object, TaxonNameBase.class);
195
						
196
						
131 197
						if (object != null){
132 198
							NameDeletionConfigurator config = new NameDeletionConfigurator();
133 199

  
134
							DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the name?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
200
							DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the name?\nThis operation is irreversible!", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
135 201
							int result_dialog= dialog.open();
136 202
							if (result_dialog != Status.OK){
137 203
								return null;
138 204
							}
139
							result = service.delete(((TaxonNameBase) object).getUuid(), config);
205
							
206
							//operation = new DeleteTaxonNameOperation(commandName,((BulkEditor) editor).getUndoContext() , name, config, (BulkEditor)editor);
140 207
							errorMessage = "The name ";
208
							
209
							if (model != null) {
210
								Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
211
								while (iter.hasNext()) {
212
									Object next = iter.next();
213
									if (next instanceof LineAnnotation) {
214
										result = controller.getNameService().isDeletable(name, config);
215
										if (result.isOk()){
216
											((LineAnnotation)next).markAsDeleted(config);
217
										}
218
										
219
									}
220
								}
221
							}
141 222
						}
142 223
					} else if (object instanceof TaxonBase){
143
						ITaxonService service = controller.getTaxonService();
144
						if (object != null){
145
							if (object instanceof Taxon){
146
							    TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
147
								config.setDeleteInAllClassifications(true);
148
								DeleteConfiguratorDialog dialog;
149
								if (((Taxon)object).getTaxonNodes().isEmpty()){
150
								    dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the taxon?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
151
								    int result_dialog= dialog.open();
152
	                                if (result_dialog != Status.OK){
153
	                                    return null;
154
	                                }
155
	                                result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null);
156
	                                errorMessage = "The taxon ";
157
								} else{
158
								    MessagingUtils.messageDialog("Delete not possible", getClass(), "The taxon can not be deleted in bulk editor. It is used in a classification.", null);
159
								    return null;
224
						
225
						// synonym
226
						if(object instanceof Synonym){
227
							Synonym synonym = HibernateProxyHelper.deproxy(object, Synonym.class);
228
							SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
229
							errorMessage = "The synonym ";
230
							DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the synonym?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
231
                            int result_dialog= dialog.open();
232
                            if (result_dialog != Status.OK){
233
                                 return null;
234
                            }
235
							//operation = new DeleteTaxonBaseOperation(commandName,((BulkEditor) editor).getUndoContext() , synonym, config, (BulkEditor)editor);
236
							if (model != null) {
237
								Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
238
								while (iter.hasNext()) {
239
									Object next = iter.next();
240
									if (next instanceof LineAnnotation) {
241
										result = controller.getTaxonService().isDeletable(synonym, config);
242
										if (result.isOk()){
243
											((LineAnnotation)next).markAsDeleted(config);
244
										}
245
										
246
									}
247
								}
248
							}
249
						}
250
						
251
						else if(object instanceof Taxon ){
252
							Taxon  taxon = HibernateProxyHelper.deproxy(object, Taxon.class);
253
							if (((Taxon)object).getTaxonNodes().isEmpty()){
254
							   
255
                                errorMessage = "The taxon ";
256
							} else{
257
							    MessagingUtils.messageDialog("Delete not possible", getClass(), "The taxon can not be deleted in bulk editor. It is used in a classification.", null);
258
							    return null;
259
							}
260
							TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
261
							config.setDeleteInAllClassifications(true);
262
							DeleteConfiguratorDialog dialog;
263
						    dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the taxon?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
264
							int result_dialog= dialog.open();
265
                            if (result_dialog != Status.OK){
266
                                 return null;
267
                            }
268
                            //operation = new DeleteTaxonBaseOperation(commandName, ((BulkEditor) editor).getUndoContext(), taxon, config, (BulkEditor)editor);
269
                            if (model != null) {
270
								Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
271
								while (iter.hasNext()) {
272
									Object next = iter.next();
273
									if (next instanceof LineAnnotation) {
274
										result = controller.getTaxonService().isDeletable(taxon, config);
275
										if (result.isOk()){
276
											((LineAnnotation)next).markAsDeleted(config);
277
										}
278
										
279
									}
160 280
								}
161

  
162
							}else{
163
								SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
164
								DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the synonym?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
165
                                int result_dialog= dialog.open();
166
                                if (result_dialog != Status.OK){
167
                                     return null;
168
                                }
169
								result = service.deleteSynonym(((Synonym)object).getUuid(), config);
170
								errorMessage = "The synonym ";
171 281
							}
172 282
						}
283
							
284
						
285
//						ITaxonService service = controller.getTaxonService();
286
//						if (object != null){
287
//							if (object instanceof Taxon){
288
//							    TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
289
//								config.setDeleteInAllClassifications(true);
290
//								DeleteConfiguratorDialog dialog;
291
//								if (((Taxon)object).getTaxonNodes().isEmpty()){
292
//								    dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the taxon?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
293
//								    int result_dialog= dialog.open();
294
//	                                if (result_dialog != Status.OK){
295
//	                                    return null;
296
//	                                }
297
//	                                result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null);
298
//	                                errorMessage = "The taxon ";
299
//								} else{
300
//								    MessagingUtils.messageDialog("Delete not possible", getClass(), "The taxon can not be deleted in bulk editor. It is used in a classification.", null);
301
//								    return null;
302
//								}
303
//
304
//							}else{
305
//								SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
306
//								DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the synonym?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
307
//                                int result_dialog= dialog.open();
308
//                                if (result_dialog != Status.OK){
309
//                                     return null;
310
//                                }
311
//								result = service.deleteSynonym(((Synonym)object).getUuid(), config);
312
//								errorMessage = "The synonym ";
313
//							}
314
//						}
173 315
					} else if (object instanceof TeamOrPersonBase){
174
						IAgentService service = controller.getAgentService();
316
						
317
						  if (model != null) {
318
								Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
319
								while (iter.hasNext()) {
320
									Object next = iter.next();
321
									if (next instanceof LineAnnotation) {
322
										
323
										result = controller.getAgentService().isDeletable((TeamOrPersonBase) object, null);
324
										if (result.isOk()){
325
											((LineAnnotation)next).markAsDeleted(null);
326
										}
327
										
328
									}
329
								}
330
							}
331
						//IAgentService service = controller.getAgentService();
175 332
						//TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid());
176
						result = service.delete(((TeamOrPersonBase)object).getUuid());
333
					//result = service.delete(((TeamOrPersonBase)object).getUuid());
177 334
						errorMessage = "The team or person ";
178 335
					} else if (object instanceof Media){
336
						MediaDeletionConfigurator config = new MediaDeletionConfigurator();
337
						
338
						DeleteConfiguratorDialog dialog;
339
					    dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the media?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
340
						int result_dialog= dialog.open();
341
                        if (result_dialog != Status.OK){
342
                             return null;
343
                        }
179 344
                        IMediaService service = controller.getMediaService();
180 345
                        //TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid());
181
                        result = service.delete(((Media)object).getUuid(), null);
346
                       
182 347
                        errorMessage = "The media ";
348
                        
349
                        if (model != null) {
350
							Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
351
							while (iter.hasNext()) {
352
								Object next = iter.next();
353
								if (next instanceof LineAnnotation) {
354
									 result = service.isDeletable(((Media)object), config);
355
									if (result.isOk()){
356
										((LineAnnotation)next).markAsDeleted(null);
357
									}
358
									
359
								}
360
							}
361
						}
183 362
                    }
184 363

  
185 364
				} catch (Exception e){
......
199 378
						MessagingUtils.messageDialog("Delete not possible", getClass(), "The object could not be deleted. An exception occured.", null);
200 379
					}
201 380
				}
381
				
382
				
202 383
				if (result.isOk() ){
384
					
203 385
					((BulkEditor) editor).removeAnnotatedLine(annotation);
386
									
204 387
					if(result.getUpdatedObjects().size() != 0 || !result.getExceptions().isEmpty()){
205 388
					    List<String> messages = new ArrayList<String>();
206 389
                        int i = result.getExceptions().size();
207 390
                        for (Exception e:result.getExceptions()){
208 391
                            messages.add(e.getMessage());
209 392
                        }
210
					    errorMessage += "was deleted but related object(s) could not be deleted. ";
393
					    errorMessage += "can be deleted but related object(s) could not be deleted. ";
211 394
					    //MessagingUtils.errorDialog("test", getClass(), "message", TaxeditorBulkeditorPlugin.PLUGIN_ID, result.getExceptions().iterator().next(),true);
212 395
					    DeleteResultMessagingUtils.messageDialogWithDetails(result, errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID);
213 396
					}
......
221 404
		return null;
222 405
	}
223 406

  
407
	
224 408
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
14 14
import java.util.UUID;
15 15

  
16 16
import eu.etaxonomy.cdm.api.service.IAgentService;
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
17 18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
18 19
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
19 20
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
155 156
	}
156 157

  
157 158
	@Override
158
	public boolean delete(TeamOrPersonBase entity)
159
	public boolean delete(TeamOrPersonBase entity, DeleteConfiguratorBase config)
159 160
			throws ReferencedObjectUndeletableException {
160
		// TODO Auto-generated method stub
161
		return false;
161
		return CdmStore.getService(IAgentService.class).delete(entity.getUuid()) != null;
162 162
	}
163 163

  
164 164
    /* (non-Javadoc)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.IAgentService;
18 18
import eu.etaxonomy.cdm.api.service.IGroupService;
19
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
19 20
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
20 21
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
21 22
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
74 75
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
75 76
	 */
76 77
	@Override
77
	public boolean delete(Group entity) throws ReferencedObjectUndeletableException {
78
		return CdmStore.getService(IGroupService.class).delete(entity) != null;
78
	public boolean delete(Group entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
79
		return CdmStore.getService(IGroupService.class).delete(entity.getUuid()) != null;
79 80
	}
80 81

  
81 82
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/MediaEditorInput.java
14 14
import java.util.UUID;
15 15

  
16 16
import eu.etaxonomy.cdm.api.service.IMediaService;
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
17 18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
18 20
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
19 21
import eu.etaxonomy.cdm.model.media.Media;
22
import eu.etaxonomy.cdm.persistence.dao.hibernate.media.MediaDaoHibernateImpl;
20 23
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
21 24
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
22 25
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.MediaCreator;
......
61 64
    }
62 65

  
63 66
    @Override
64
    public boolean delete(Media entity) throws ReferencedObjectUndeletableException {
65
        return CdmStore.getService(IMediaService.class).delete(entity) != null;
67
    public boolean delete(Media entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
68
    	MediaDeletionConfigurator mediaConfig = null;
69
    	if (config instanceof MediaDeletionConfigurator){
70
    		mediaConfig = (MediaDeletionConfigurator) config;
71
    	} else{
72
    		
73
    	}
74
        return CdmStore.getService(IMediaService.class).delete(entity.getUuid(), mediaConfig) != null;
66 75
    }
67 76

  
68 77
    @Override
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java
15 15
import java.util.UUID;
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.INameService;
18
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
18 19
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
20
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
19 21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
20 22
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
21 23
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
......
112 114
		return CdmStore.getService(INameService.class).load(uuid, propertyPaths);
113 115
	}
114 116
*/
115
	/** {@inheritDoc}
116
	 **/
117 117
	@Override
118
    public boolean delete(TaxonNameBase entity)  {
119
		return CdmStore.getService(INameService.class).delete(entity) != null;
118
    public boolean delete(TaxonNameBase entity, DeleteConfiguratorBase config)  {
119
		NameDeletionConfigurator nameConfig = null;
120
		if (config instanceof NameDeletionConfigurator){
121
			nameConfig = (NameDeletionConfigurator) config;
122
		} else{
123
			
124
		}
125
		return CdmStore.getService(INameService.class).delete(entity.getUuid(), nameConfig) != null;
120 126
	}
121

  
127
	
122 128
	/** {@inheritDoc} */
123 129
	@Override
124 130
    public TaxonNameBase save(TaxonNameBase entity) {
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameRelationshipEditorInput.java
14 14
import java.util.List;
15 15
import java.util.UUID;
16 16

  
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
17 18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
18 19
import eu.etaxonomy.cdm.model.name.NameRelationship;
19 20
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
......
84 85
	 */
85 86
	/** {@inheritDoc} */
86 87
	@Override
87
	public boolean delete(NameRelationship entity) {
88
	public boolean delete(NameRelationship entity, DeleteConfiguratorBase config) {
88 89
		// TODO Auto-generated method stub
89 90
		return false;
90 91
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java
15 15
import java.util.UUID;
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
18
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
18 19
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19 20
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
20 21
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
129 130
	/** {@inheritDoc}
130 131
	 * @throws ReferencedObjectUndeletableException */
131 132
	@Override
132
    public boolean delete(SpecimenOrObservationBase entity) throws ReferencedObjectUndeletableException {
133
    public boolean delete(SpecimenOrObservationBase entity, DeleteConfiguratorBase config ) throws ReferencedObjectUndeletableException {
133 134
		return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
134 135
	}
135 136

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java
14 14
import java.util.UUID;
15 15

  
16 16
import eu.etaxonomy.cdm.api.service.IReferenceService;
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
17 18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
18 19
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
19 20
import eu.etaxonomy.cdm.model.common.MarkerType;
......
132 133
	/** {@inheritDoc}
133 134
	 * @throws ReferencedObjectUndeletableException */
134 135
	@Override
135
    public boolean delete(Reference entity) throws ReferencedObjectUndeletableException {
136
		return CdmStore.getService(IReferenceService.class).delete(entity) != null;
136
    public boolean delete(Reference entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
137
		return CdmStore.getService(IReferenceService.class).delete(entity.getUuid()) != null;
137 138
	}
138 139

  
139 140
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
15 15
import java.util.UUID;
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.IUserService;
18
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
18 19
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19 20
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
20 21
import eu.etaxonomy.cdm.model.common.User;
......
71 72
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
72 73
	 */
73 74
	@Override
74
	public boolean delete(User entity) throws ReferencedObjectUndeletableException {
75
	public boolean delete(User entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
75 76
		return CdmStore.getService(IUserService.class).delete(entity) != null;
76 77
	}
77 78

  

Also available in: Unified diff