Project

General

Profile

Revision 65107bf3

ID65107bf34868fc063c4397f965cf646cdfbe0cb0
Parent 1fe09983
Child 3fad5b84

Added by Katja Luther over 3 years ago

fix #6547: implement unplaced/excluded comparison also for TaxonNodeByNameComparator

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNodeByNameComparator.java
35 35
    private boolean sortInfraGenericFirst = true;
36 36

  
37 37
    @Override
38
    public int compare(TaxonNode o1, TaxonNode o2) {
39

  
40
        if (o1 == null && o2 == null) {
38
    public int compare(TaxonNode node1, TaxonNode node2) {
39
        if (node1 == null && node2 == null) {
41 40
            return 0;
42 41
        }
43
        else if (o1 == null) {
42
        else if (node1 == null) {
44 43
            return 1;
45 44
        }
46
        else if (o2 == null) {
45
        else if (node2 == null) {
47 46
            return -1;
48 47
        }
49
        if (o1.equals(o2)){
48
        if (node1.equals(node2)){
50 49
        	return 0;
51 50
        }
51
        boolean node1Excluded = node1.isExcluded();
52
        boolean node2Excluded = node2.isExcluded();
53
        boolean node1Unplaced = node1.isUnplaced();
54
        boolean node2Unplaced = node2.isUnplaced();
55

  
56
      //They should both be put to the end (first unplaced then excluded)
57
        if (node2Excluded && !node1Excluded){
58
            return -1;
59
        }
60
        if (node2Unplaced && !(node1Unplaced || node1Excluded)){
61
            return -1;
62
        }
63

  
64
        if (node1Excluded && !node2Excluded){
65
            return 1;
66
        }
67
        if (node1Unplaced && !(node2Unplaced || node2Excluded)){
68
            return 1;
69
        }
70

  
71
        if (node1Unplaced && node2Excluded){
72
            return -1;
73
        }
74
        if (node2Unplaced && node1Excluded){
75
            return 1;
76
        }
52 77

  
53
        String titleCache1 = createSortableTitleCache(o1);
54
        String titleCache2 = createSortableTitleCache(o2);
78
        String titleCache1 = createSortableTitleCache(node1);
79
        String titleCache2 = createSortableTitleCache(node2);
55 80

  
56 81
        if(isIgnoreHybridSign()) {
57 82
            if (logger.isTraceEnabled()){logger.trace("ignoring Hybrid Signs: " + HYBRID_SIGN);}
......
85 110
        if (result != 0){
86 111
        	return result;
87 112
        }else{
88
        	return o1.getUuid().compareTo(o2.getUuid());
113
        	return node1.getUuid().compareTo(node2.getUuid());
89 114
        }
90 115
    }
91 116

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)