Project

General

Profile

« Previous | Next » 

Revision 0a534d09

Added by Patrick Plitzner over 10 years ago

  • adapted sub classes of AbstractPostOperation

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
37 37
 */
38 38
public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOperation {
39 39

  
40
	private Synonym synonym;
40
	private final Synonym synonym;
41 41
	private Taxon misapplication;
42 42
	private Set<SynonymRelationshipType> synonymTypes;
43 43

  
......
53 53
	public ChangeSynonymToMisapplicationOperation(String label,
54 54
			IUndoContext undoContext, Taxon taxon, Synonym synonym, IPostOperationEnabled editor) {
55 55
		super(label, undoContext, taxon, editor);
56
		
56

  
57 57
		this.synonym = synonym;
58 58
	}
59 59

  
......
61 61
	@Override
62 62
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
63 63
			throws ExecutionException {
64
		
64

  
65 65
    	// get name from synonym
66 66
		TaxonNameBase<?, ?> synonymName = synonym.getName();
67 67

  
......
69 69
		misapplication = Taxon.NewInstance(synonymName, null);
70 70
		CdmStore.getService(ITaxonService.class).saveOrUpdate(misapplication);
71 71
		monitor.worked(20);
72
		
72

  
73 73
		// store synonymRelationshipType for later undo operations
74
		synonymTypes = synonym.getRelationType(taxon);
75
		
76
		// remove synonym from taxon		
77
		taxon.removeSynonym(synonym);
74
		synonymTypes = synonym.getRelationType(element);
75

  
76
		// remove synonym from taxon
77
		element.removeSynonym(synonym);
78 78
		monitor.worked(40);
79
		
79

  
80 80
		// add misapplied name to taxon
81 81
		// TODO add microcitation for misapplied name to property sheet (if microcitation is indeed needed?!)
82
		taxon.addMisappliedName(misapplication, null, null);
83
		
82
		element.addMisappliedName(misapplication, null, null);
83

  
84 84
		// redraw editor if exists
85 85
		return postExecute(misapplication);
86 86
	}
......
91 91
			throws ExecutionException {
92 92
		// add misapplied name to taxon
93 93
		// TODO add citation for misapplied name to property sheet
94
		taxon.addMisappliedName(misapplication, null, null);
95
		
94
		element.addMisappliedName(misapplication, null, null);
95

  
96 96
		// remove synonym from taxon
97
		taxon.removeSynonym(synonym);
98
		
97
		element.removeSynonym(synonym);
98

  
99 99
		// redraw editor if exists
100 100
		return postExecute(null);
101 101
	}
......
104 104
	@Override
105 105
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
106 106
			throws ExecutionException {
107
		
107

  
108 108
		// remove misapplied name from taxon
109
		taxon.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
110
		
109
		element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
110

  
111 111
		// add synonym to taxon
112 112
		for (SynonymRelationshipType synonymType : synonymTypes){
113
			taxon.addSynonym(synonym, synonymType);
113
			element.addSynonym(synonym, synonymType);
114 114
		}
115
		
115

  
116 116
		// redraw editor if exists
117 117
		return postExecute(null);
118 118
	}

Also available in: Unified diff