From 34e93e77d33a9f95943a3e605a882f3f5456fc83 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Mon, 4 Apr 2016 17:14:39 +0200
Subject: [PATCH] Correctly implement compare contract #3185
---
.../DescriptionElementSourceSection.java | 24 ++++++++-----------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
index 708236672..314810d76 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
@@ -74,41 +74,37 @@ public class DescriptionElementSourceSection extends
Reference citation2 = o2.getCitation();
// the newly created should always be on top
- if (id1 == 0) {
+ if (id1 == 0 && id2!=0) {
return -1;
}
- if (id2 == 0) {
+ if (id1 != 0 && id2==0) {
return 1;
}
// sort by type (Primary taxonomic > Primary Media > others
// alphabetically by reference title cache)
- if (type1 != null && type1.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
- return -1;
+ if (type1 != null && type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && type2 != null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
+ return -1;
+ }
+ if (type1 != null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+ && type2 != null && type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
+ return 1;
}
if (type1 != null && type1.equals(OriginalSourceType.PrimaryMediaSource)
&& type2!=null && !type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
return -1;
}
- if (type2 != null && type2.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
- return 1;
- }
if (type2 != null && type2.equals(OriginalSourceType.PrimaryMediaSource)
&& type1!=null && !type1.equals(OriginalSourceType.PrimaryTaxonomicSource)) {
return 1;
}
//sort by citation title cache
- if(citation1==null){
- return -1;
- }
- if(citation2==null){
- return 1;
- }
if(citation1!=null && citation2!=null){
return citation1.getTitleCache().compareTo(citation2.getTitleCache());
}
- return 0;
+ return o2.getCreated().compareTo(o1.getCreated());
}
});
return sources;
--
2.34.1