Revision 287ae15a
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java | ||
---|---|---|
71 | 71 |
if(rowWrapper1.equals(rowWrapper2)){ |
72 | 72 |
return 0; |
73 | 73 |
} |
74 |
TaxonNodeDto node1 = rowWrapper1.getTaxonNode(); |
|
75 |
TaxonNodeDto node2 = rowWrapper2.getTaxonNode(); |
|
76 |
if(node1!=null && node2!=null){ |
|
77 |
//compare by taxon node |
|
78 |
int compare = comparator.compare(node1, node2); |
|
79 |
if(compare!=0){ |
|
80 |
return compare; |
|
81 |
} |
|
82 |
DescriptionBase description1 = rowWrapper1.getDescription(); |
|
83 |
DescriptionBase description2 = rowWrapper2.getDescription(); |
|
84 |
//compare by taxon description type |
|
85 |
if(description1 instanceof TaxonDescription){ |
|
86 |
if(description2 instanceof SpecimenDescription){ |
|
87 |
return -1; |
|
88 |
} |
|
89 |
} |
|
90 |
else{ |
|
91 |
if(description2 instanceof TaxonDescription){ |
|
92 |
return 1; |
|
93 |
} |
|
94 |
} |
|
95 |
//both descriptions are of the same type |
|
96 |
if(description1 instanceof SpecimenDescription){ |
|
97 |
//description2 has to also be a SpecimenDescription |
|
98 |
return compareSpecimenDescriptions((SpecimenDescription)description1, (SpecimenDescription)description2); |
|
74 |
TaxonNodeDto taxonTaxonNode = rowWrapper1.getTaxonNode(); |
|
75 |
TaxonNodeDto specimenTaxonNode = rowWrapper2.getTaxonNode(); |
|
76 |
int nodeCompare = comparator.compare(taxonTaxonNode, specimenTaxonNode); |
|
77 |
if(nodeCompare!=0){ |
|
78 |
// different taxon nodes |
|
79 |
return nodeCompare; |
|
80 |
} |
|
81 |
else{ |
|
82 |
// same taxon node |
|
83 |
} |
|
84 |
DescriptionBase description1 = rowWrapper1.getDescription(); |
|
85 |
DescriptionBase description2 = rowWrapper2.getDescription(); |
|
86 |
//compare by taxon description type |
|
87 |
if(description1 instanceof TaxonDescription){ |
|
88 |
if(description2 instanceof SpecimenDescription){ |
|
89 |
return -1; |
|
99 | 90 |
} |
100 |
else if(description1 instanceof TaxonDescription){ |
|
101 |
//description2 has to also be a TaxonDescription |
|
102 |
return compareTaxonDescriptions((TaxonDescription)description1, (TaxonDescription)description2); |
|
91 |
} |
|
92 |
else{ |
|
93 |
if(description2 instanceof TaxonDescription){ |
|
94 |
return 1; |
|
103 | 95 |
} |
104 | 96 |
} |
97 |
//both descriptions are of the same type |
|
98 |
if(description1 instanceof SpecimenDescription){ |
|
99 |
//description2 has to also be a SpecimenDescription |
|
100 |
return compareSpecimenDescriptions((SpecimenDescription)description1, (SpecimenDescription)description2); |
|
101 |
} |
|
102 |
else if(description1 instanceof TaxonDescription){ |
|
103 |
//description2 has to also be a TaxonDescription |
|
104 |
return compareTaxonDescriptions((TaxonDescription)description1, (TaxonDescription)description2); |
|
105 |
} |
|
105 | 106 |
} |
106 | 107 |
return o1.hashCode()-o2.hashCode(); |
107 | 108 |
} |
Also available in: Unified diff
ref #8450 Fix matrix taxon node hierarchy