2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.e4
;
11 import org
.apache
.commons
.lang3
.StringUtils
;
13 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
14 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
15 import eu
.etaxonomy
.cdm
.model
.metadata
.TermComboEnum
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.TermDisplayEnum
;
17 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
24 public class StatusHelper
{
25 PresenceAbsenceTerm term
;
28 public StatusHelper(PresenceAbsenceTerm term
){
30 TermDisplayEnum display
;
32 display
= PreferencesUtil
.displayStatusInChecklistEditor();
33 }catch(IllegalArgumentException e
){
34 display
= TermDisplayEnum
.Title
;
36 String result
= PreferencesUtil
.getStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey());
37 if (StringUtils
.isBlank(result
)){
38 result
= ((TermComboEnum
) PreferencePredicate
.DisplayOfStatusInCombo
.getDefaultValue()).getKey();
40 TermComboEnum comboDisplay
= TermComboEnum
.byKey(result
);
41 if(term
.getTitleCache().trim().equals("-")){
42 label
= term
.getTitleCache();
43 }else if (comboDisplay
.equals(TermComboEnum
.IdInVocabulary
) && term
.getIdInVocabulary() != null){
44 label
= term
.getIdInVocabulary();
45 }else if (comboDisplay
.equals(TermComboEnum
.Symbol1
) && term
.getSymbol() != null){
46 label
= term
.getSymbol();
47 } else if (comboDisplay
.equals(TermComboEnum
.Symbol2
) && term
.getSymbol2() != null){
48 label
= term
.getSymbol2();
49 } else if (comboDisplay
.equals(TermComboEnum
.Title
) && term
.getLabel() != null){
50 label
= term
.getLabel();
51 } else if (comboDisplay
.equals(TermComboEnum
.TermDisplayPlusTitle
)){
52 if (display
.equals(TermDisplayEnum
.IdInVocabulary
)){
53 label
= "["+term
.getIdInVocabulary()+"] "+ term
.getTitleCache();
54 }else if (display
.equals(TermDisplayEnum
.Symbol1
)){
55 label
= "["+term
.getSymbol()+"] "+ term
.getTitleCache();
56 }else if (display
.equals(TermDisplayEnum
.Symbol2
)){
57 label
= "["+term
.getSymbol2()+"] "+ term
.getTitleCache();
58 } else if (display
.equals(TermDisplayEnum
.Title
)){
59 label
= term
.getLabel();
61 label
= term
.getTitleCache();
70 public String
toString(){