ref #9603: add new Comparator for term.symbol und term.symbol2
authorKatja Luther <k.luther@bgbm.org>
Tue, 4 May 2021 10:16:55 +0000 (12:16 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 4 May 2021 10:18:19 +0000 (12:18 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol1Comparator.java [new file with mode: 0755]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol2Comparator.java [new file with mode: 0755]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/PreferencePredicate.java

diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol1Comparator.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol1Comparator.java
new file mode 100755 (executable)
index 0000000..438a91c
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+* Copyright (C) 2021 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.compare.term;
+
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+
+/**
+ * @author k.luther
+ * @since May 4, 2021
+ */
+public class TermSymbol1Comparator<T extends DefinedTermBase> implements Comparator<T> {
+
+    @Override
+    public int compare(T term1, T term2) {
+        String label1;
+        String label2;
+        if (term1.getUuid().equals(term2.getUuid())){
+            return 0;
+        }
+
+        if (term1.getSymbol() == null){
+            label1 = CdmUtils.Nz(term1.getTitleCache());
+        }else{
+            label1 = CdmUtils.Nz(term1.getSymbol());
+        }
+        if (term2.getSymbol() == null){
+            label2 = CdmUtils.Nz(term2.getTitleCache());
+        }else{
+            label2 = CdmUtils.Nz(term2.getSymbol());
+        }
+
+        return  label1.compareTo(label2);
+    }
+
+}
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol2Comparator.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/compare/term/TermSymbol2Comparator.java
new file mode 100755 (executable)
index 0000000..457bca1
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+* Copyright (C) 2021 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.compare.term;
+
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+
+/**
+ * @author k.luther
+ * @since May 4, 2021
+ */
+public class TermSymbol2Comparator<T extends DefinedTermBase> implements Comparator<T> {
+
+    @Override
+    public int compare(T term1, T term2) {
+        String label1;
+        String label2;
+        if (term1.getUuid().equals(term2.getUuid())){
+            return 0;
+        }
+
+        if (term1.getSymbol2() == null){
+            label1 = CdmUtils.Nz(term1.getTitleCache());
+        }else{
+            label1 = CdmUtils.Nz(term1.getSymbol2());
+        }
+        if (term2.getSymbol2() == null){
+            label2 = CdmUtils.Nz(term2.getTitleCache());
+        }else{
+            label2 = CdmUtils.Nz(term2.getSymbol2());
+        }
+
+        return  label1.compareTo(label2);
+    }
+
+}
\ No newline at end of file
index 55ac01e8f12f377bce10f42fbec87418a97eb060..167e3f8fd6aae95c0da5ca55ab83828b1bb8b5ae 100644 (file)
@@ -94,7 +94,7 @@ public enum PreferencePredicate
     //Distribution editor\r
     DistributionEditorActivated(UUID.fromString("733e9bce-4394-4fae-97d3-1b7dfc48ee3c"), "Distribution Editor Is activated", "distribution.editor.activated",  Boolean.TRUE),\r
     AreasSortedInDistributionEditor(UUID.fromString("513d7de9-fec4-432c-b4dd-75f9f6e74ad0"), "Distribution Editor: Areas sorted in Distribution Editor", "distribution.editor.areas.sortedInDistributionEditor", TermOrder.IdInVoc),  //unsure about correct default value, please decide\r
-    StatusSortedInDistributionEditor(UUID.fromString("83e9ddb7-e498-4e00-bfdc-69c68f3ad5eb"), "Distribution Editor: Status sorted in Distribution Editor", "distribution.editor.areas.sortedStatusInDistributionEditor", TermOrder.IdInVoc),  //unsure about correct default value, please decide\r
+    StatusSortedInDistributionEditor(UUID.fromString("83e9ddb7-e498-4e00-bfdc-69c68f3ad5eb"), "Distribution Editor: Status sorted in Distribution Editor", "distribution.editor.areas.sortedStatusInDistributionEditor", TermDisplayEnum.IdInVocabulary),  //unsure about correct default value, please decide\r
     //the following 4 should be replaced by termLabelPreferenceEnum , enum should contain label, abbrevLabel, idInVoc, symbol1, symbol2, ...\r
     DisplayOfStatus(UUID.fromString("1ee6b945-0a81-4f05-b867-f9d105882249"), "Distribution Editor: Display of Status", "distribution.editor.status.display", TermDisplayEnum.Title),\r
     DisplayOfStatusInCombo(UUID.fromString("a8ff1763-987f-4935-aaba-910f3a870d07"), "Distribution Editor: Display of Status", "distribution.editor.status.combo_display", TermComboEnum.TermDisplayPlusTitle),\r