Merge branch 'master' of wp5.e-taxonomy.eu:/var/git/taxeditor into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / TaxonEditorInput.java
index 5452a0458934f0005106036673d3807183766aed..ff10a6f5b6c9418d5d5f6405af5e5f343fa3784e 100644 (file)
@@ -1,15 +1,17 @@
 /**
-* Copyright (C) 2007 EDIT
-* 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.
-*/
+ * Copyright (C) 2007 EDIT
+ * 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.
+ */
 
 package eu.etaxonomy.taxeditor.editor;
 
+import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.UUID;
 
@@ -46,64 +48,123 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @created 19.03.2009
  * @version 1.0
  */
-public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPersistableElement {
+public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorInput, IConversationEnabled, IPersistableElement {
 
-       private final ConversationHolder conversation;
+    private final ConversationHolder conversation;
 
-       private final TaxonNode taxonNode;
+    private TaxonNode taxonNode;
 
-       private TaxonEditorInputDataChangeBehaviour dataChangeBehavior;
+    private TaxonEditorInputDataChangeBehaviour dataChangeBehavior;
 
-       private TaxonBase initiallySelectedTaxonBase;
+    private TaxonBase initiallySelectedTaxonBase;
 
-       private TaxonEditorInput(TaxonNode taxonNode, ConversationHolder conversation){
-               this.conversation = conversation;
-               this.taxonNode = taxonNode;
-       }
+    private final ITaxonNodeService service;
 
+    private enum CdmType {
+        TAXON_NODE,
+        TAXON_BASE,
+        PARENT_TAXON_NODE
+    }
 
+    private TaxonEditorInput(UUID uuid, CdmType type) {
+        this.conversation = CdmStore.createConversation();
+        service = CdmStore.getService(ITaxonNodeService.class);
+        switch(type) {
+        case PARENT_TAXON_NODE:
+            initForParentTaxonNode(uuid);
+            break;
+        case TAXON_BASE:
+            initForTaxonBase(uuid);
+            break;
+        case TAXON_NODE:
+            initForTaxonNode(uuid);
+            break;
+        }
+    }
+
+    private void init(TaxonNode taxonNode) {
+        this.taxonNode = taxonNode;
+    }
 
-       /**
-        * <p>NewInstance</p>
-        *
-        * @param taxonNodeUuid a {@link java.util.UUID} object.
-        * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
-        * @throws java.lang.Exception if any.
-        */
-       public static TaxonEditorInput NewInstance(UUID taxonNodeUuid) throws Exception{
-               try{
-                       ConversationHolder conversation = CdmStore.createConversation();
-                       return NewInstance(taxonNodeUuid, conversation);
-               }catch(Exception e){
-                       throw e;
-               }
-       }
 
     /**
+     * <p>NewInstance</p>
      *
-     * @param taxonNodeUuid
-     * @param conversation
-     * @return
+     * @param taxonNodeUuid a {@link java.util.UUID} object.
+     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
+     * @throws java.lang.Exception if any.
      */
-    private static TaxonEditorInput NewInstance(UUID taxonNodeUuid, ConversationHolder conversation){
+    private void initForTaxonNode(UUID taxonNodeUuid) {
+
 
+        TaxonNode taxonNode = getCdmEntitySession().remoteLoad(service,taxonNodeUuid, null);
+
+        if(taxonNode == null){
+            MessagingUtils.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
+        }
+        init(taxonNode);
 
-       TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid, null);
 
                if(taxonNode == null){
                        MessagingUtils.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not of type TaxonNode but [null].");
                        return null;
                }
+    }
 
-       return new TaxonEditorInput(taxonNode, conversation);
+    private void initForTaxonBase(UUID taxonBaseUuid) {
+
+        TaxonBase taxonBase = getCdmEntitySession().remoteLoad(CdmStore.getService(ITaxonService.class),taxonBaseUuid);
+        if (taxonBase != null){
+            if(taxonBase.isInstanceOf(Taxon.class)){
+                Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
+
+                if (taxon.getTaxonNodes().size() == 0 && taxon.isMisapplication()){
+                    // TODO get accepted taxon
+                    MessagingUtils.info("trying to open Mispplied Name ");
+
+                    Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
+                    Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
+                    for(TaxonRelationship relation : relations){
+                        if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
+                            acceptedTaxa.add(relation.getToTaxon());
+                        }
+                    }
+                    setInputForMultipleTaxa(conversation, acceptedTaxa);
+
+                }else{
+                    setInputForMultipleNodes(conversation, taxon.getTaxonNodes());
+                }
+            }else if(taxonBase instanceof Synonym){
+                Synonym synonym = (Synonym) taxonBase;
+
+                Set<Taxon> taxa = synonym.getAcceptedTaxa();
+                setInputForMultipleTaxa(conversation, taxa);
+            }
+        }
     }
 
+
     /**
-     * <p>NewInstanceFromTaxonBase</p>
+     * <p>NewEmptyInstance</p>
      *
-     * @param taxonBaseUuid a {@link java.util.UUID} object.
+     * @param parentNodeUuid a {@link java.util.UUID} object.
      * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
      */
+    private void initForParentTaxonNode(UUID parentNodeUuid){
+
+
+        TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
+        ITaxonTreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
+
+        Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
+        TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
+
+        // add the new taxon to the editors persistence context
+        UUID newTaxonNodeUuid = getCdmEntitySession().remoteSave(CdmStore.getService(ITaxonNodeService.class),newTaxonNode);
+
+        initForTaxonNode(newTaxonNodeUuid);
+    }
+
     public static TaxonEditorInput NewInstanceFromTaxonBase(UUID taxonBaseUuid){
        ConversationHolder conversation = CdmStore.createConversation();
 
@@ -145,246 +206,260 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe
        return input;
     }
 
-       private static TaxonEditorInput getInputForMultipleNodes(ConversationHolder conversation, Set<TaxonNode> taxonNodes){
-       if(taxonNodes.size() == 1){
-               TaxonNode taxonNode = taxonNodes.iterator().next();
-               return NewInstance(taxonNode.getUuid(), conversation);
-       }else if(taxonNodes.size() > 1){
-                       TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(taxonNodes);
-                       if(taxonNode != null){
-                               return NewInstance(taxonNode.getUuid(), conversation);
-                       }
-               }else if(taxonNodes.size() == 0){
-                       // this is an undesired state
-                       MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "The accepted taxon is not part of any classification. This should not have happened.");
-               }
-       return null;
+
+    private void setInputForMultipleNodes(ConversationHolder conversation, Set<TaxonNode> taxonNodes){
+        if(taxonNodes.size() == 1){
+            TaxonNode taxonNode = taxonNodes.iterator().next();
+            init(taxonNode);
+        }else if(taxonNodes.size() > 1){
+            TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(taxonNodes);
+            if(taxonNode != null){
+                init(taxonNode);
+            }
+        }else if(taxonNodes.size() == 0){
+            // this is an undesired state
+            MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "The accepted taxon is not part of any classification. This should not have happened.");
+        }
     }
 
-    private static TaxonEditorInput getInputForMultipleTaxa(ConversationHolder conversation, Set<Taxon> taxa){
-       if(taxa.size() == 1){
-               Taxon taxon = taxa.iterator().next();
-               Set<TaxonNode> nodes = taxon.getTaxonNodes();
-               return getInputForMultipleNodes(conversation, nodes);
-       }else if(taxa.size() > 1){
-               Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
-                       for ( Taxon taxon : taxa ){
-                               taxonNodes.addAll(taxon.getTaxonNodes());
-                       }
-                       return getInputForMultipleNodes(conversation, taxonNodes);
-               }else if(taxa.size() == 0){
-                       // this is an undesired state
-                       MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "Trying to open accepted taxon for a synonym or misapplication but" +
-                                       " no accepted taxa are present. This should not have happened.");
-               }
-       return null;
+    private void setInputForMultipleTaxa(ConversationHolder conversation, Set<Taxon> taxa){
+        if(taxa.size() == 1){
+            Taxon taxon = taxa.iterator().next();
+            Set<TaxonNode> nodes = taxon.getTaxonNodes();
+            setInputForMultipleNodes(conversation, nodes);
+        }else if(taxa.size() > 1){
+            Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
+            for ( Taxon taxon : taxa ){
+                taxonNodes.addAll(taxon.getTaxonNodes());
+            }
+            setInputForMultipleNodes(conversation, taxonNodes);
+        }else if(taxa.size() == 0){
+            // this is an undesired state
+            MessagingUtils.warningDialog("Incorrect state", TaxonEditorInput.class, "Trying to open accepted taxon for a synonym or misapplication but" +
+                    " no accepted taxa are present. This should not have happened.");
+        }
     }
 
     /**
-     * <p>NewEmptyInstance</p>
+     * <p>NewInstance</p>
      *
-     * @param parentNodeUuid a {@link java.util.UUID} object.
+     * @param taxonNodeUuid a {@link java.util.UUID} object.
      * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
+     * @throws java.lang.Exception if any.
      */
-    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
-       ConversationHolder conversation = CdmStore.createConversation();
+    public static TaxonEditorInput NewInstance(UUID taxonNodeUuid) throws Exception {
+        return new TaxonEditorInput(taxonNodeUuid, CdmType.TAXON_NODE);
 
-               TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
-               ITaxonTreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
+    }
+
+    /**
+     * <p>NewInstanceFromTaxonBase</p>
+     *
+     * @param taxonBaseUuid a {@link java.util.UUID} object.
+     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
+     */
+    public static TaxonEditorInput NewInstanceFromTaxonBase(UUID taxonBaseUuid){
+        return new TaxonEditorInput(taxonBaseUuid, CdmType.TAXON_BASE);
+    }
 
-               Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
-               TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
 
-               // add the new taxon to the editors persistence context
-               UUID newTaxonNodeUuid = CdmStore.getService(ITaxonNodeService.class).save(newTaxonNode);
 
-               return new TaxonEditorInput(newTaxonNode, conversation);
+
+    /**
+     * <p>NewEmptyInstance</p>
+     *
+     * @param parentNodeUuid a {@link java.util.UUID} object.
+     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
+     */
+    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
+        return new TaxonEditorInput(parentNodeUuid, CdmType.PARENT_TAXON_NODE);
     }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#exists()
-        */
-       /**
-        * <p>exists</p>
-        *
-        * @return a boolean.
-        */
-       @Override
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    /**
+     * <p>exists</p>
+     *
+     * @return a boolean.
+     */
+    @Override
     public boolean exists() {
-               return taxonNode != null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
-        */
-       /**
-        * <p>getImageDescriptor</p>
-        *
-        * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
-        */
-       @Override
+        return taxonNode != null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    /**
+     * <p>getImageDescriptor</p>
+     *
+     * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
+     */
+    @Override
     public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getName()
-        */
-       /**
-        * <p>getName</p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       @Override
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    /**
+     * <p>getName</p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    @Override
     public String getName() {
-               if(getTaxon() == null){
-                       return null;
-               }
-               TaxonNameBase<?, ?> name = getTaxon().getName();
-               if (name == null || name.getTitleCache() == null) {
-                       return "New taxon";
-               } else {
-                       return name.getTitleCache();
-               }
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getPersistable()
-        */
-       /**
-        * <p>getPersistable</p>
-        *
-        * @return a {@link org.eclipse.ui.IPersistableElement} object.
-        */
-       @Override
+        if(getTaxon() == null){
+            return null;
+        }
+        TaxonNameBase<?, ?> name = getTaxon().getName();
+        if (name == null || name.getTitleCache() == null) {
+            return "New taxon";
+        } else {
+            return name.getTitleCache();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    /**
+     * <p>getPersistable</p>
+     *
+     * @return a {@link org.eclipse.ui.IPersistableElement} object.
+     */
+    @Override
     public IPersistableElement getPersistable() {
-//             if(CdmStore.isActive()){
-//                     TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
-//                     boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
-//                     if (isPersistable) {
-//                             return this;
-//                     }
-//             }
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getToolTipText()
-        */
-       /**
-        * <p>getToolTipText</p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       @Override
+        //             if(CdmStore.isActive()){
+        //                     TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
+        //                     boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
+        //                     if (isPersistable) {
+        //                             return this;
+        //                     }
+        //             }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    /**
+     * <p>getToolTipText</p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    @Override
     public String getToolTipText() {
-               return getName();
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-        */
-       /** {@inheritDoc} */
-       @Override
+        return getName();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    /** {@inheritDoc} */
+    @Override
     public Object getAdapter(Class adapter) {
 
-               if (adapter == Taxon.class) {
-                       return taxonNode.getTaxon();
-               }
+        if (adapter == Taxon.class) {
+            return getTaxon();
+        }
 
-               if (adapter == TaxonNode.class) {
-                       return taxonNode;
-               }
+        if (adapter == TaxonNode.class) {
+            return taxonNode;
+        }
 
-               return null;
-       }
+        return null;
+    }
 
-       /**
-        * {@inheritDoc}
-        *
-        * Overrides equals to ensure that a taxon can only be edited by
-        * one editor at a time.
-        */
-       @Override
+    /**
+     * {@inheritDoc}
+     *
+     * Overrides equals to ensure that a taxon can only be edited by
+     * one editor at a time.
+     */
+    @Override
     public boolean equals(Object obj) {
-               if (TaxonEditorInput.class.equals(obj.getClass())
-                               && getTaxon() != null
-                               && getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
-                       if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
-                               setInitiallySelectedTaxonBase(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase());
-                       }
-                       return true;
-               }
-               return false;
-       }
-
-       /**
-        * <p>getTaxon</p>
-        *
-        * @return the taxon
-        */
-       public Taxon getTaxon(){
-               return taxonNode.getTaxon();
-       }
-
-       /**
-        * <p>Getter for the field <code>taxonNode</code>.</p>
-        *
-        * @return the taxonNode
-        */
-       public TaxonNode getTaxonNode() {
-               return taxonNode;
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-        */
-       /**
-        * <p>getConversationHolder</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        */
-       @Override
+        if (TaxonEditorInput.class.equals(obj.getClass())
+                && getTaxon() != null
+                && getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
+            if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
+                setInitiallySelectedTaxonBase(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase());
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * <p>getTaxon</p>
+     *
+     * @return the taxon
+     */
+    public Taxon getTaxon(){
+        Taxon taxon = CdmBase.deproxy(taxonNode.getTaxon(), Taxon.class);
+        return taxon;
+    }
+
+    /**
+     * <p>Getter for the field <code>taxonNode</code>.</p>
+     *
+     * @return the taxonNode
+     */
+    public TaxonNode getTaxonNode() {
+        return taxonNode;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
+     */
+    /**
+     * <p>getConversationHolder</p>
+     *
+     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+     */
+    @Override
     public ConversationHolder getConversationHolder() {
-               return conversation;
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
+        return conversation;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
+     */
+    /** {@inheritDoc} */
+    @Override
     public void update(CdmDataChangeMap events) {
-               if(dataChangeBehavior == null){
-                       dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
-               }
+        if(dataChangeBehavior == null){
+            dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
+        }
 
-               DataChangeBridge.handleDataChange(events, dataChangeBehavior);
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IPersistableElement#getFactoryId()
-        */
-       /**
-        * <p>getFactoryId</p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       @Override
+        DataChangeBridge.handleDataChange(events, dataChangeBehavior);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+     */
+    /**
+     * <p>getFactoryId</p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    @Override
     public String getFactoryId() {
-               return TaxonEditorInputFactory.getFactoryId();
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
-        */
-       /** {@inheritDoc} */
-       @Override
+        return TaxonEditorInputFactory.getFactoryId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+     */
+    /** {@inheritDoc} */
+    @Override
     public void saveState(IMemento memento) {
-               TaxonEditorInputFactory.saveState(memento, this);
-       }
+        TaxonEditorInputFactory.saveState(memento, this);
+    }
 
 
     /**
@@ -393,20 +468,46 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe
      * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
      */
     public void setInitiallySelectedTaxonBase(TaxonBase taxonBase) {
-               this.initiallySelectedTaxonBase = taxonBase;
-       }
-
-       /**
-        * <p>Getter for the field <code>initiallySelectedTaxonBase</code>.</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
-        */
-       public TaxonBase getInitiallySelectedTaxonBase() {
-               return initiallySelectedTaxonBase;
-       }
-
-       @Override
-       public String toString() {
-               return String.format("%s[%s]", this.getClass().getSimpleName(), getTaxon());
-       }
+        this.initiallySelectedTaxonBase = taxonBase;
+    }
+
+    /**
+     * <p>Getter for the field <code>initiallySelectedTaxonBase</code>.</p>
+     *
+     * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
+     */
+    public TaxonBase getInitiallySelectedTaxonBase() {
+        return initiallySelectedTaxonBase;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("%s[%s]", this.getClass().getSimpleName(), getTaxon());
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#getService()
+     */
+    @Override
+    public ITaxonNodeService getService() {
+        return service;
+    }
+
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#getRootEntities()
+     */
+    @Override
+    public  List<TaxonNode> getRootEntities() {
+        return Arrays.asList(taxonNode);
+    }
+
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#update()
+     */
+    @Override
+    public <T extends CdmBase> void update() {
+        taxonNode = getCdmEntitySession().remoteUpdate(service, taxonNode);
+    }
 }