Revision f60aaf9c
Added by Katja Luther over 3 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java | ||
---|---|---|
512 | 512 |
return addChildTaxon(taxon, this.childNodes.size(), citation, microCitation); |
513 | 513 |
} |
514 | 514 |
|
515 |
@Override |
|
516 |
public TaxonNode addChildTaxon(Taxon taxon, DescriptionElementSource source) { |
|
517 |
return addChildTaxon(taxon, this.childNodes.size(), source); |
|
518 |
} |
|
519 |
|
|
515 | 520 |
@Override |
516 | 521 |
public TaxonNode addChildTaxon(Taxon taxon, int index, Reference citation, String microCitation) { |
517 | 522 |
Classification classification = CdmBase.deproxy(this.getClassification()); |
... | ... | |
522 | 527 |
return addChildNode(new TaxonNode(taxon), index, citation, microCitation); |
523 | 528 |
} |
524 | 529 |
|
530 |
|
|
531 |
@Override |
|
532 |
public TaxonNode addChildTaxon(Taxon taxon, int index, DescriptionElementSource source) { |
|
533 |
Classification classification = CdmBase.deproxy(this.getClassification()); |
|
534 |
taxon = HibernateProxyHelper.deproxy(taxon, Taxon.class); |
|
535 |
if (classification.isTaxonInTree(taxon)){ |
|
536 |
throw new IllegalArgumentException(String.format("Taxon may not be in a classification twice: %s", taxon.getTitleCache())); |
|
537 |
} |
|
538 |
return addChildNode(new TaxonNode(taxon), index, source); |
|
539 |
} |
|
540 |
|
|
525 | 541 |
/** |
526 | 542 |
* Moves a taxon node to a new parent. Descendents of the node are moved as well |
527 | 543 |
* |
... | ... | |
567 | 583 |
return child; |
568 | 584 |
} |
569 | 585 |
|
586 |
|
|
587 |
/** |
|
588 |
* Inserts the given taxon node in the list of children of <i>this</i> taxon node |
|
589 |
* at the given (index + 1) position. If the given index is out of bounds |
|
590 |
* an exception will arise.<BR> |
|
591 |
* Due to bidirectionality this method must also assign <i>this</i> taxon node |
|
592 |
* as the parent of the given child. |
|
593 |
* |
|
594 |
* @param child the taxon node to be added |
|
595 |
* @param index the integer indicating the position at which the child |
|
596 |
* should be added |
|
597 |
* @see #getChildNodes() |
|
598 |
* @see #addChildNode(TaxonNode, Reference, String, Synonym) |
|
599 |
* @see #deleteChildNode(TaxonNode) |
|
600 |
* @see #deleteChildNode(int) |
|
601 |
*/ |
|
602 |
@Override |
|
603 |
public TaxonNode addChildNode(TaxonNode child, int index, DescriptionElementSource source){ |
|
604 |
if (index < 0 || index > childNodes.size() + 1){ |
|
605 |
throw new IndexOutOfBoundsException("Wrong index: " + index); |
|
606 |
} |
|
607 |
// check if this node is a descendant of the childNode |
|
608 |
if(child.getParent() != this && child.isAncestor(this)){ |
|
609 |
throw new IllegalAncestryException("New parent node is a descendant of the node to be moved."); |
|
610 |
} |
|
611 |
|
|
612 |
child.setParentTreeNode(this, index); |
|
613 |
|
|
614 |
child.setSource(source); |
|
615 |
|
|
616 |
|
|
617 |
return child; |
|
618 |
} |
|
619 |
|
|
570 | 620 |
/** |
571 | 621 |
* Sets this nodes classification. Updates classification of child nodes recursively. |
572 | 622 |
* |
... | ... | |
589 | 639 |
} |
590 | 640 |
} |
591 | 641 |
|
642 |
|
|
643 |
|
|
644 |
|
|
592 | 645 |
@Override |
593 | 646 |
public boolean deleteChildNode(TaxonNode node) { |
594 | 647 |
boolean result = removeChildNode(node); |
Also available in: Unified diff
ref #9116: adapt taxonnode methods to source instead of reference