eu.etaxonomy.cdm.model.taxon
Class TaxonNode

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.CdmBase
      extended by eu.etaxonomy.cdm.model.common.VersionableEntity
          extended by eu.etaxonomy.cdm.model.common.AnnotatableEntity
              extended by eu.etaxonomy.cdm.model.taxon.TaxonNode
All Implemented Interfaces:
IAnnotatableEntity, ICdmBase, IVersionableEntity, ITreeNode, Serializable, Cloneable
Direct Known Subclasses:
AlternativeTreeRoot

@Entity
@Indexed(index="eu.etaxonomy.cdm.model.taxon.TaxonNode")
public class TaxonNode
extends AnnotatableEntity
implements ITreeNode, Cloneable

Version:
1.0
Author:
a.mueller
See Also:
Serialized Form

Field Summary
 
Fields inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
annotations, markers
 
Fields inherited from class eu.etaxonomy.cdm.model.common.CdmBase
uuid
 
Constructor Summary
protected TaxonNode()
           
protected TaxonNode(Taxon taxon)
          to create nodes either use Classification.addChildTaxon(Taxon, Reference, String, Synonym) or addChildTaxon(Taxon, Reference, String, Synonym)
protected TaxonNode(Taxon taxon, Classification classification)
          Deprecated. setting of classification is handled in the addTaxonNode() method, use TaxonNode(taxon) instead
 
Method Summary
 TaxonNode addChildNode(TaxonNode childNode, Reference reference, String microReference, Synonym synonymToBeUsed)
          Moves a taxon node to a new parent.
 TaxonNode addChildTaxon(Taxon taxon, Reference citation, String microCitation, Synonym synonymToBeUsed)
          Adds a taxon as a child of the ITreeNode
 Object clone()
          Clones this taxon node.
protected  TaxonNode cloneDescendants()
          Returns a set containing a clone of this node and of all nodes that are descendants of this node
 boolean delete()
          Remove this taxonNode From its taxonomic parent
 boolean deleteChildNode(TaxonNode node)
          This recursively removes all child nodes from this node and from this taxonomic view.
protected  Set<TaxonNode> getAncestors()
          Returns a
 Set<TaxonNode> getChildNodes()
           
 Classification getClassification()
           
 int getCountChildren()
           
protected  Set<TaxonNode> getDescendants()
          Returns a set containing this node and all nodes that are descendants of this node
 String getMicroReference()
           
 TaxonNode getParent()
           
 ITreeNode getParentTreeNode()
           
 Reference getReference()
          The reference for the parent child relationship
 Synonym getSynonymToBeUsed()
           
 Taxon getTaxon()
           
 boolean hasChildNodes()
          Whether this taxon has child nodes
 boolean isAncestor(TaxonNode possibleChild)
          Whether this TaxonNode is an ascendant of the given TaxonNode
 boolean isDescendant(TaxonNode possibleParent)
          Whether this TaxonNode is a descendant of the given TaxonNode Caution: use this method with care on big branches.
 boolean isTopmostNode()
          Whether this TaxonNode is a direct child of the classification TreeNode
protected  boolean removeChildNode(TaxonNode childNode)
          Removes the child node from this node.
protected  void setClassification(Classification classification)
          THIS METHOD SHOULD NOT BE CALLED! invisible part of the bidirectional relationship, for public use TaxonomicView.addRoot() or TaxonNode.addChild()
protected  void setCountChildren(int countChildren)
           
 void setMicroReference(String microReference)
           
protected  void setParent(ITreeNode parent)
          Sets the parent of this taxon node.
protected  void setParentTreeNode(ITreeNode parent)
          Sets the parent of this taxon node to the given parent.
 void setReference(Reference reference)
           
 void setSynonymToBeUsed(Synonym synonymToBeUsed)
           
protected  void setTaxon(Taxon taxon)
           
 
Methods inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, hasMarker, hasMarker, removeAnnotation, removeMarker
 
Methods inherited from class eu.etaxonomy.cdm.model.common.VersionableEntity
equals, getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from class eu.etaxonomy.cdm.model.common.CdmBase
addPropertyChangeListener, addPropertyChangeListener, clone, deproxy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCreated, getCreatedBy, getId, getUuid, hashCode, hasListeners, instanceToString, invokeSetMethod, invokeSetMethodWithNull, isInstanceOf, removePropertyChangeListener, removePropertyChangeListener, setCreated, setCreatedBy, setId, setUuid, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.IAnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, hasMarker, hasMarker, removeAnnotation, removeMarker
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.IVersionableEntity
getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.ICdmBase
getCreated, getCreatedBy, getId, getUuid, setCreated, setCreatedBy, setId, setUuid
 

Constructor Detail

TaxonNode

protected TaxonNode()

TaxonNode

protected TaxonNode(Taxon taxon,
                    Classification classification)
Deprecated. setting of classification is handled in the addTaxonNode() method, use TaxonNode(taxon) instead

to create nodes either use Classification.addChildTaxon(Taxon, Reference, String, Synonym) or addChildTaxon(Taxon, Reference, String, Synonym)

Parameters:
taxon -
classification -

TaxonNode

protected TaxonNode(Taxon taxon)
to create nodes either use Classification.addChildTaxon(Taxon, Reference, String, Synonym) or addChildTaxon(Taxon, Reference, String, Synonym)

Parameters:
taxon -
Method Detail

addChildTaxon

public TaxonNode addChildTaxon(Taxon taxon,
                               Reference citation,
                               String microCitation,
                               Synonym synonymToBeUsed)
Description copied from interface: ITreeNode
Adds a taxon as a child of the ITreeNode

Specified by:
addChildTaxon in interface ITreeNode
Returns:
the child node

addChildNode

public TaxonNode addChildNode(TaxonNode childNode,
                              Reference reference,
                              String microReference,
                              Synonym synonymToBeUsed)
Moves a taxon node to a new parent. Descendents of the node are moved as well

Specified by:
addChildNode in interface ITreeNode
Parameters:
childNode - the taxon node to be moved to the new parent
Returns:
the child node in the state of having a new parent

deleteChildNode

public boolean deleteChildNode(TaxonNode node)
Description copied from interface: ITreeNode
This recursively removes all child nodes from this node and from this taxonomic view. TODO remove orphan nodes completely

Specified by:
deleteChildNode in interface ITreeNode
Returns:
true on success

removeChildNode

protected boolean removeChildNode(TaxonNode childNode)
Removes the child node from this node. Sets the parent and the classification of the child node to null

Parameters:
childNode -
Returns:

delete

public boolean delete()
Remove this taxonNode From its taxonomic parent

Returns:
true on success

getTaxon

public Taxon getTaxon()

setTaxon

protected void setTaxon(Taxon taxon)

getParentTreeNode

public ITreeNode getParentTreeNode()

getParent

public TaxonNode getParent()

setParent

protected void setParent(ITreeNode parent)
Sets the parent of this taxon node. In most cases you would want to call setParentTreeNode(ITreeNode) which handles updating of the bidirectional relationship

Parameters:
parent -
See Also:
setParentTreeNode(ITreeNode)

setParentTreeNode

protected void setParentTreeNode(ITreeNode parent)
Sets the parent of this taxon node to the given parent. Cleans up references to old parents and sets the classification to the new parents classification

Parameters:
parent -

getClassification

public Classification getClassification()

setClassification

protected void setClassification(Classification classification)
THIS METHOD SHOULD NOT BE CALLED! invisible part of the bidirectional relationship, for public use TaxonomicView.addRoot() or TaxonNode.addChild()

Parameters:
classification -

getChildNodes

public Set<TaxonNode> getChildNodes()
Specified by:
getChildNodes in interface ITreeNode

getDescendants

protected Set<TaxonNode> getDescendants()
Returns a set containing this node and all nodes that are descendants of this node

Returns:

cloneDescendants

protected TaxonNode cloneDescendants()
Returns a set containing a clone of this node and of all nodes that are descendants of this node

Returns:

getAncestors

protected Set<TaxonNode> getAncestors()
Returns a

Returns:

getReference

public Reference getReference()
The reference for the parent child relationship

Specified by:
getReference in interface ITreeNode
Returns:
the citation for the parent child relationship or the tree itself
See Also:
ITreeNode.getReference()

setReference

public void setReference(Reference reference)

getMicroReference

public String getMicroReference()
Specified by:
getMicroReference in interface ITreeNode
Returns:
the microCitation for the parent child relationship or the tree itself
See Also:
ITreeNode.getMicroReference()

setMicroReference

public void setMicroReference(String microReference)

getCountChildren

public int getCountChildren()
Returns:
the count of children this taxon node has

setCountChildren

protected void setCountChildren(int countChildren)
Parameters:
countChildren -

getSynonymToBeUsed

public Synonym getSynonymToBeUsed()

setSynonymToBeUsed

public void setSynonymToBeUsed(Synonym synonymToBeUsed)

isTopmostNode

public boolean isTopmostNode()
Whether this TaxonNode is a direct child of the classification TreeNode

Returns:

isDescendant

public boolean isDescendant(TaxonNode possibleParent)
Whether this TaxonNode is a descendant of the given TaxonNode Caution: use this method with care on big branches. -> performance and memory hungry Protip: Try solving your problem with the isAscendant method which traverses the tree in the other direction (up). It will always result in a rather small set of consecutive parents beeing generated. TODO implement more efficiently without generating the set of descendants first

Parameters:
possibleParent -
Returns:
true if this is a descendant

isAncestor

public boolean isAncestor(TaxonNode possibleChild)
Whether this TaxonNode is an ascendant of the given TaxonNode

Parameters:
possibleChild -
Returns:
true if there are ascendants

hasChildNodes

public boolean hasChildNodes()
Whether this taxon has child nodes

Specified by:
hasChildNodes in interface ITreeNode
Returns:
true if the taxonNode has childNodes

clone

public Object clone()
Clones this taxon node. This is a shortcut that enables to create a new instance that differs only slightly from this taxon node by modifying only some of the attributes.

The child nodes are not copied.
The taxon and parent are the same as for the original taxon node.

Overrides:
clone in class AnnotatableEntity
See Also:
eu.etaxonomy.cdm.model.media.IdentifiableEntity#clone(), Object.clone()


Copyright © 2007-2013 EDIT. All Rights Reserved.