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/ChangeConceptToSynonymOperation.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 ChangeConceptToSynonymOperation extends
39 39
		AbstractPostTaxonOperation {
40
	
40

  
41 41
	private Taxon concept;
42 42

  
43 43
	private HomotypicalGroup homotypicalGroup;
44 44

  
45 45
	private TaxonRelationship taxonRelationship;
46 46
	private TaxonRelationshipType oldRelationshipType;
47
	
47

  
48 48
	private SynonymRelationship newSynonymRelationship;
49 49

  
50 50
	/**
......
61 61
			IUndoContext undoContext, Taxon taxon, Taxon concept, HomotypicalGroup homotypicalGroup,
62 62
			IPostOperationEnabled editor) {
63 63
		super(label, undoContext, taxon, editor);
64
		
64

  
65 65
		Set<TaxonRelationship> taxonRelationships = taxon.getTaxonRelations(concept);
66
		
66

  
67 67
		if(taxonRelationships.size() > 1){
68 68
			StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " +
69 69
					"accepted and the related taxon. This case is not handled by the software yet");
70 70
			return;
71 71
		}
72
		
72

  
73 73
		this.taxonRelationship = taxonRelationships.iterator().next();
74 74
		this.oldRelationshipType = taxonRelationship.getType();
75
		
75

  
76 76
		this.concept = concept;
77 77
		this.homotypicalGroup = homotypicalGroup != null ? homotypicalGroup : HomotypicalGroup.NewInstance();
78 78
	}
......
84 84
	@Override
85 85
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
86 86
			throws ExecutionException {
87
		
87

  
88 88
		// Create new synonym using concept name
89 89
		TaxonNameBase<?, ?> synonymName = concept.getName();
90
		
90

  
91 91
		// Remove concept relation from taxon
92
		taxon.removeTaxon(concept, oldRelationshipType);
92
		element.removeTaxon(concept, oldRelationshipType);
93 93
		monitor.worked(20);
94
        
94

  
95 95
		// Add name to new homotypic group
96 96
		homotypicalGroup.addTypifiedName(synonymName);
97 97
		monitor.worked(40);
98
		
98

  
99 99
        // Create a new synonym for the taxon
100
		newSynonymRelationship = taxon.addHeterotypicSynonymName(synonymName);
101
			
100
		newSynonymRelationship = element.addHeterotypicSynonymName(synonymName);
101

  
102 102
		return postExecute(newSynonymRelationship.getSynonym());
103 103
	}
104 104

  

Also available in: Unified diff