import javax.persistence.ManyToOne;\r
import javax.persistence.OneToMany;\r
import javax.persistence.OneToOne;\r
import javax.persistence.ManyToOne;\r
import javax.persistence.OneToMany;\r
import javax.persistence.OneToOne;\r
import org.hibernate.annotations.Cascade;\r
import org.hibernate.annotations.CascadeType;\r
import org.hibernate.envers.Audited;\r
import org.hibernate.annotations.Cascade;\r
import org.hibernate.annotations.CascadeType;\r
import org.hibernate.envers.Audited;\r
\r
import eu.etaxonomy.cdm.model.common.IReferencedEntity;\r
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
\r
import eu.etaxonomy.cdm.model.common.IReferencedEntity;\r
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
private static final long serialVersionUID = -753804821474209635L;\r
private static final Logger logger = Logger.getLogger(TaxonomicTree.class);\r
\r
private static final long serialVersionUID = -753804821474209635L;\r
private static final Logger logger = Logger.getLogger(TaxonomicTree.class);\r
\r
*/\r
public TaxonNode addChildNode(TaxonNode childNode, ReferenceBase citation,\r
String microCitation, Synonym synonymToBeUsed) {\r
*/\r
public TaxonNode addChildNode(TaxonNode childNode, ReferenceBase citation,\r
String microCitation, Synonym synonymToBeUsed) {\r
rootNodes.add(childNode);\r
childNode.setParent(null);\r
childNode.setTaxonomicTree(this);\r
childNode.setReference(citation);\r
childNode.setMicroReference(microCitation);\r
childNode.setSynonymToBeUsed(synonymToBeUsed);\r
rootNodes.add(childNode);\r
childNode.setParent(null);\r
childNode.setTaxonomicTree(this);\r
childNode.setReference(citation);\r
childNode.setMicroReference(microCitation);\r
childNode.setSynonymToBeUsed(synonymToBeUsed);\r
//no multiple parents are allowed in the tree\r
if (childNode != null && childNode.getParent() != null){\r
//...different to the parent taxon throw exception\r
//no multiple parents are allowed in the tree\r
if (childNode != null && childNode.getParent() != null){\r
//...different to the parent taxon throw exception\r
- if (! childNode.getParent().getTaxon().equals(parent) ){\r
- throw new IllegalStateException("The child taxon is already part of the tree but has an other parent taxon than the one than the parent to be added. Child: " + child.toString() + ", new parent:" + parent.toString() + ", old parent: " + childNode.getParent().getTaxon().toString()) ;\r
+ if ((childNode.getParent() instanceof TaxonNode) && !((TaxonNode)childNode.getParent()).getTaxon().equals(parent) ){\r
+ throw new IllegalStateException("The child taxon is already part of the tree but has an other parent taxon than the one than the parent to be added. Child: " + child.toString() + ", new parent:" + parent.toString() + ", old parent: " + ((TaxonNode) childNode.getParent()).getTaxon().toString()) ;\r
//... same as the parent taxon do nothing but overwriting citation and microCitation\r
}else{\r
handleCitationOverwrite(childNode, citation, microCitation);\r
//... same as the parent taxon do nothing but overwriting citation and microCitation\r
}else{\r
handleCitationOverwrite(childNode, citation, microCitation);\r
public List<TaxonNode> getRankSpecificRootNodes(Rank rank) {\r
List<TaxonNode> baseNodes = new ArrayList<TaxonNode>();\r
if(rank != null){\r
public List<TaxonNode> getRankSpecificRootNodes(Rank rank) {\r
List<TaxonNode> baseNodes = new ArrayList<TaxonNode>();\r
if(rank != null){\r