eu.etaxonomy.cdm.model.taxon
Class TaxonomicTree

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.common.IdentifiableEntity
                  extended by eu.etaxonomy.cdm.model.taxon.TaxonomicTree
All Implemented Interfaces:
IAnnotatableEntity, ICdmBase, IIdentifiableEntity, IReferencedEntity, ISourceable<IdentifiableSource>, IVersionableEntity, ITreeNode, Serializable

@Indexed(index="eu.etaxonomy.cdm.model.taxon.TaxonomicTree")
public class TaxonomicTree
extends IdentifiableEntity
implements IReferencedEntity, ITreeNode

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

Field Summary
 
Fields inherited from class eu.etaxonomy.cdm.model.common.IdentifiableEntity
cacheStrategy, NOT_PROTECTED, PROTECTED, protectedTitleCache, titleCache
 
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 TaxonomicTree()
           
protected TaxonomicTree(String name, ReferenceBase reference, Language language)
           
 
Method Summary
 TaxonNode addChildNode(TaxonNode childNode, ReferenceBase citation, String microCitation, Synonym synonymToBeUsed)
          Adds a taxon node as a child of the ITreeNode
 TaxonNode addChildTaxon(Taxon taxon, ReferenceBase citation, String microCitation, Synonym synonymToBeUsed)
          Adds a taxon as a child of the ITreeNode
 TaxonNode addParentChild(Taxon parent, Taxon child, ReferenceBase citation, String microCitation)
          Relates two taxa as parent-child nodes within a taxonomic tree.
 int compareTo(Object o)
           
 boolean deleteChildNode(TaxonNode node)
          This recursively removes all child nodes from this node and from this taxonomic view.
 String generateTitle()
           
 Set<TaxonNode> getAllNodes()
          Returns a set containing all nodes in this taxonomic tree.
 Set<TaxonNode> getChildNodes()
           
 ReferenceBase getCitation()
           
 String getMicroReference()
           
 LanguageString getName()
           
 TaxonNode getNode(Taxon taxon)
          Checks if the given taxon is part of this tree.
 ReferenceBase getReference()
           
 TaxonNode getTopmostNode(Taxon taxon)
          Checks if the taxon is a direct child of this tree and returns the according node if true.
 boolean hasChildNodes()
          Whether this TreeNode has child nodes attached
 boolean isTaxonInTree(Taxon taxon)
          Checks if the given taxon is part of this tree.
 boolean isTopmostInTree(Taxon taxon)
          Checks if the given taxon is one of the topmost taxa in this tree.
 void makeTopmostNodeChildOfOtherNode(TaxonNode topmostNode, TaxonNode otherNode, ReferenceBase ref, String microReference)
          Appends an existing topmost node to another node of this tree.
static TaxonomicTree NewInstance(String name)
           
static TaxonomicTree NewInstance(String name, Language language)
           
static TaxonomicTree NewInstance(String name, ReferenceBase reference)
           
static TaxonomicTree NewInstance(String name, ReferenceBase reference, Language language)
           
protected  boolean removeChildNode(TaxonNode node)
           
 void setMicroReference(String microReference)
           
 void setName(LanguageString name)
           
 void setReference(ReferenceBase reference)
           
 
Methods inherited from class eu.etaxonomy.cdm.model.common.IdentifiableEntity
addCredit, addCredit, addExtension, addExtension, addRights, addSource, addSource, clone, compareTo, getCacheStrategy, getCredits, getCredits, getData, getExtensions, getLsid, getRights, getSources, getTitleCache, getTruncatedCache, initListener, isProtectedTitleCache, removeCredit, removeCredit, removeExtension, removeRights, removeSource, setCacheStrategy, setLsid, setProtectedTitleCache, setTitleCache, setTitleCache, toString
 
Methods inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, 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, invokeSetMethod, invokeSetMethodWithNull, isInstanceOf, removePropertyChangeListener, removePropertyChangeListener, setCreated, setCreatedBy, setId, setUuid
 
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, 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

TaxonomicTree

protected TaxonomicTree(String name,
                        ReferenceBase reference,
                        Language language)

TaxonomicTree

protected TaxonomicTree()
Method Detail

NewInstance

public static TaxonomicTree NewInstance(String name)

NewInstance

public static TaxonomicTree NewInstance(String name,
                                        Language language)

NewInstance

public static TaxonomicTree NewInstance(String name,
                                        ReferenceBase reference)

NewInstance

public static TaxonomicTree NewInstance(String name,
                                        ReferenceBase reference,
                                        Language language)

addChildNode

public TaxonNode addChildNode(TaxonNode childNode,
                              ReferenceBase citation,
                              String microCitation,
                              Synonym synonymToBeUsed)
Description copied from interface: ITreeNode
Adds a taxon node as a child of the ITreeNode

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

addChildTaxon

public TaxonNode addChildTaxon(Taxon taxon,
                               ReferenceBase 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

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 node)
Parameters:
node -
Returns:

makeTopmostNodeChildOfOtherNode

public void makeTopmostNodeChildOfOtherNode(TaxonNode topmostNode,
                                            TaxonNode otherNode,
                                            ReferenceBase ref,
                                            String microReference)
                                     throws IllegalArgumentException
Appends an existing topmost node to another node of this tree. The existing topmost node becomes an ordinary node.

Parameters:
topmostNode -
otherNode -
ref -
microReference -
Throws:
IllegalArgumentException

isTaxonInTree

public boolean isTaxonInTree(Taxon taxon)
Checks if the given taxon is part of this tree.

Parameters:
taxon -
Returns:

getNode

public TaxonNode getNode(Taxon taxon)
Checks if the given taxon is part of this tree. If so the according TaxonNode is returned. Otherwise null is returned.

Parameters:
taxon -
Returns:

isTopmostInTree

public boolean isTopmostInTree(Taxon taxon)
Checks if the given taxon is one of the topmost taxa in this tree.

Parameters:
taxon -
Returns:

getTopmostNode

public TaxonNode getTopmostNode(Taxon taxon)
Checks if the taxon is a direct child of this tree and returns the according node if true. Returns null otherwise.

Parameters:
taxon -
Returns:

addParentChild

public TaxonNode addParentChild(Taxon parent,
                                Taxon child,
                                ReferenceBase citation,
                                String microCitation)
                         throws IllegalStateException
Relates two taxa as parent-child nodes within a taxonomic tree.
If the taxa are not yet part of the tree they are added to it.
If the child taxon is a topmost node still it is added as child and deleted from the rootNode set.
If the child is a child of another parent already an IllegalStateException is thrown because a child can have only one parent.
If the parent-child relationship between these two taxa already exists nothing is changed. Only citation and microcitation are overwritten by the new values if these values are not null.

Parameters:
parent -
child -
citation -
microCitation -
Returns:
the childNode
Throws:
IllegalStateException - If the child is a child of another parent already

getCitation

public ReferenceBase getCitation()
Specified by:
getCitation in interface IReferencedEntity

getName

public LanguageString getName()

setName

public void setName(LanguageString name)

getAllNodes

public Set<TaxonNode> getAllNodes()
Returns a set containing all nodes in this taxonomic tree. Caution: Use this method with care. It can be very time and resource consuming and might run into OutOfMemoryExceptions for big trees.

Returns:

getChildNodes

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

getReference

public ReferenceBase getReference()
Specified by:
getReference in interface ITreeNode
Returns:
the citation for the parent child relationship or the tree itself

setReference

public void setReference(ReferenceBase reference)

getMicroReference

public String getMicroReference()
Specified by:
getMicroReference in interface ITreeNode
Returns:
the microReference

setMicroReference

public void setMicroReference(String microReference)
Parameters:
microReference - the microReference to set

generateTitle

public String generateTitle()
Specified by:
generateTitle in interface IIdentifiableEntity
Overrides:
generateTitle in class IdentifiableEntity

compareTo

public int compareTo(Object o)

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: ITreeNode
Whether this TreeNode has child nodes attached

Specified by:
hasChildNodes in interface ITreeNode
Returns:
true if this node has children


Copyright © 2007-2010 EDIT. All Rights Reserved.