Revision c5aa066b
Added by Katja Luther almost 8 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java | ||
---|---|---|
194 | 194 |
// ************************* GETTER / SETTER *******************************/ |
195 | 195 |
|
196 | 196 |
public Integer getSortIndex() { |
197 |
TaxonNode parent = HibernateProxyHelper.deproxy(this.parent, TaxonNode.class); |
|
198 |
parent.removeNullValueFromChildren(); |
|
199 |
|
|
197 | 200 |
return sortIndex; |
198 | 201 |
} |
199 | 202 |
/** |
... | ... | |
224 | 227 |
|
225 | 228 |
@Override |
226 | 229 |
public List<TaxonNode> getChildNodes() { |
230 |
|
|
227 | 231 |
return childNodes; |
228 | 232 |
} |
229 | 233 |
protected void setChildNodes(List<TaxonNode> childNodes) { |
... | ... | |
361 | 365 |
@Override |
362 | 366 |
public TaxonNode addChildTaxon(Taxon taxon, int index, Reference citation, String microCitation) { |
363 | 367 |
Classification classification = HibernateProxyHelper.deproxy(this.getClassification(), Classification.class); |
364 |
|
|
368 |
taxon = HibernateProxyHelper.deproxy(taxon, Taxon.class); |
|
365 | 369 |
if (this.getClassification().isTaxonInTree(taxon)){ |
366 | 370 |
throw new IllegalArgumentException(String.format("Taxon may not be in a classification twice: %s", taxon.getTitleCache())); |
367 | 371 |
} |
... | ... | |
486 | 490 |
*/ |
487 | 491 |
protected boolean removeChildNode(TaxonNode childNode){ |
488 | 492 |
boolean result = true; |
489 |
while (childNodes.contains(null)){ |
|
490 |
childNodes.remove(null); |
|
491 |
} |
|
493 |
removeNullValueFromChildren(); |
|
492 | 494 |
if(childNode == null){ |
493 | 495 |
throw new IllegalArgumentException("TaxonNode may not be null"); |
494 | 496 |
} |
... | ... | |
621 | 623 |
parent = HibernateProxyHelper.deproxy(parent, TaxonNode.class); |
622 | 624 |
List<TaxonNode> parentChildren = parent.getChildNodes(); |
623 | 625 |
//TODO: Only as a workaround. We have to find out why merge creates null entries. |
626 |
|
|
624 | 627 |
while (parentChildren.contains(null)){ |
625 | 628 |
parentChildren.remove(null); |
626 | 629 |
} |
... | ... | |
854 | 857 |
return hasTaxon() ? getTaxon().getNullSafeRank() : null; |
855 | 858 |
} |
856 | 859 |
|
860 |
private void removeNullValueFromChildren(){ |
|
861 |
if (childNodes.contains(null)){ |
|
862 |
while(childNodes.contains(null)){ |
|
863 |
childNodes.remove(null); |
|
864 |
} |
|
865 |
} |
|
866 |
this.updateSortIndex(0); |
|
867 |
} |
|
868 |
|
|
857 | 869 |
|
858 | 870 |
|
859 | 871 |
//*********************** CLONE ********************************************************/ |
Also available in: Unified diff
fix move taxonnode and remove null values from childrenlists in several places