Project

General

Profile

« Previous | Next » 

Revision 77c9b8f8

Added by Andreas Müller almost 2 years ago

ref #3722, ref #8127, ref #10067 fully remove sortindex updating and collection null handling workaround from TaxonNode

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java
36 36
import javax.xml.bind.annotation.XmlType;
37 37
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
38 38

  
39
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
40
import org.hibernate.LazyInitializationException;
39
import org.apache.logging.log4j.LogManager;
40
import org.apache.logging.log4j.Logger;
41 41
import org.hibernate.annotations.Cascade;
42 42
import org.hibernate.annotations.CascadeType;
43 43
import org.hibernate.annotations.Parameter;
......
687 687
            childNodes.remove(index);
688 688
            child.setClassification(null);
689 689

  
690
            //update sortindex
691
            //TODO workaround (see sortIndex doc)
692 690
            this.countChildren = childNodes.size();
693 691
            child.setParent(null);
694 692
            child.setTreeIndex(null);
695
            updateSortIndex(index);
696 693
            child.setSortIndex(null);
697 694
        }
698 695
    }
......
770 767
        // add this node to the parent's child nodes
771 768
        parent = CdmBase.deproxy(parent);
772 769
        List<TaxonNode> parentChildren = parent.getChildNodes();
773
       //TODO: Only as a workaround. We have to find out why merge creates null entries.
774 770

  
775
//        HHH_9751_Util.removeAllNull(parentChildren);
776
//        parent.updateSortIndex(0);
777 771
        if (index > parent.getChildNodes().size()){
778 772
            index = parent.getChildNodes().size();
779 773
        }
......
788 782
            parentChildren.add(index, this);
789 783
        }
790 784

  
791
        //sortIndex
792
        //TODO workaround (see sortIndex doc)
793
       // this.getParent().removeNullValueFromChildren();
794
        this.getParent().updateSortIndex(index);
795
        //only for debugging
796
        if (this.getSortIndex() == null){
797
            logger.warn("sortindex is null. This should not happen.");
798
        }else if (! this.getSortIndex().equals(index)){
799
        	logger.warn("index and sortindex are not equal: " +  this.getSortIndex() + ";" + index);
800
        }
785
//        //only for debugging
786
//        if (this.getSortIndex() == null){
787
//            logger.warn("sortindex is null. This should not happen.");
788
//        }else if (! this.getSortIndex().equals(index)){
789
//        	logger.warn("index and sortindex are not equal: " +  this.getSortIndex() + ";" + index);
790
//        }
801 791

  
802 792
        // update the children count
803 793
        parent.setCountChildren(parent.getChildNodes().size());
......
809 799
	 * @param parentChildren
810 800
	 * @param index
811 801
	 */
812
	private void updateSortIndex(int index) {
802
	private void updateSortIndex_old(int index) {
813 803
	    if (this.hasChildNodes()){
814 804
    	    List<TaxonNode> children = this.getChildNodes();
815 805
    	    HHH_9751_Util.removeAllNull(children);
......
1042 1032
        return getTaxon() == null? null: getTaxon().getName();
1043 1033
    }
1044 1034

  
1045
    public void removeNullValueFromChildren(){
1046
        try {
1047
            //HHH_9751_Util.removeAllNull(childNodes);
1048
            this.updateSortIndex(0);
1049
        } catch (LazyInitializationException e) {
1050
            logger.info("Cannot clean up uninitialized children without a session, skipping.");
1051
        }
1052
    }
1035
//    public void removeNullValueFromChildren(){
1036
//        try {
1037
//            //HHH_9751_Util.removeAllNull(childNodes);
1038
//            this.updateSortIndex(0);
1039
//        } catch (LazyInitializationException e) {
1040
//            logger.info("Cannot clean up uninitialized children without a session, skipping.");
1041
//        }
1042
//    }
1053 1043

  
1054 1044
    private boolean hasStatus(TaxonNodeStatus status) {
1055 1045
        return CdmUtils.nullSafeEqual(this.status, status);

Also available in: Unified diff