/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* @version 1.0
*/
public class ChangeConceptRelationshipTypeOperation extends AbstractPostTaxonOperation {
-
+
private Taxon relatedTaxon;
-
+
private TaxonRelationship taxonRelationship;
-
+
private TaxonRelationshipType oldRelationshipType;
-
+
private TaxonRelationshipType newRelationshipType;
/**
IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon, TaxonRelationshipType type, IPostOperationEnabled postOperationEnabled) {
super(label, undoContext, taxon, postOperationEnabled);
this.relatedTaxon = relatedTaxon;
-
+
Set<TaxonRelationship> taxonRelationships = taxon.getTaxonRelations(relatedTaxon);
-
+
if(taxonRelationships.size() > 1){
StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " +
"accepted and the related taxon. This case is not handled by the software yet");
return;
}
-
+
this.taxonRelationship = taxonRelationships.iterator().next();
this.oldRelationshipType = taxonRelationship.getType();
this.newRelationshipType = type;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
*/
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
-
+
// Remove relatedTaxon and old relationship
// FIXME since taxon relationships come in a set, which relationships are we going to delete here?
- taxon.removeTaxon(relatedTaxon, oldRelationshipType);
+ element.removeTaxon(relatedTaxon, oldRelationshipType);
monitor.worked(20);
-
+
// Add new relationship
// TODO add microcitation for misapplied name to property sheet
- relatedTaxon.addTaxonRelation(taxon, newRelationshipType, null, null);
+ relatedTaxon.addTaxonRelation(element, newRelationshipType, null, null);
monitor.worked(40);
-
+
return postExecute(relatedTaxon);
}