Project

General

Profile

Revision 7dc115d1

ID7dc115d100fe1d9c63785826fc5b749b2f73a0fd
Parent 49078739
Child 4a3a3258

Added by Katja Luther about 1 year ago

adapt display of multiple status in distr editor to preference value

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionColumnAccessor.java
78 78
            if (distributionsForArea.size() > 1){
79 79
                List<String> labels = new ArrayList();
80 80
                distributionsForArea.forEach(desc -> labels.add(((Distribution)desc).getStatus().getLabel()));
81
                return labels;
81
                return distributionsForArea;
82 82
            }
83 83
        }
84 84
        return null;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/FilterStatusDisplayConverter.java
11 11
import org.apache.commons.lang.StringUtils;
12 12
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
13 13

  
14
import eu.etaxonomy.cdm.model.term.Representation;
15 14
import eu.etaxonomy.cdm.model.description.Distribution;
16 15
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
17 16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
18 17
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
18
import eu.etaxonomy.cdm.model.term.Representation;
19 19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20 20
import eu.etaxonomy.taxeditor.store.CdmStore;
21 21

  
......
38 38
                Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
39 39
                String displayStatus = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatus.getKey());
40 40
                String label = rep.getLabel();
41
                if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
41
                if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary)){
42 42
                    return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
43
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
43
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1)){
44 44

  
45 45
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
46
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
46
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2)){
47 47
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
48 48
                }else{
49 49
                    return (label != null)?label:DEFAULT_ENTRY;
......
62 62
            if (status.getId() == 0){
63 63
                return DEFAULT_ENTRY;
64 64
            }
65
            if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
65
            if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary)){
66 66
                return (StringUtils.isNotBlank(status.getIdInVocabulary()))?status.getIdInVocabulary():label;
67
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
67
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1)){
68 68

  
69 69
                return (StringUtils.isNotBlank(status.getSymbol() ))?status.getSymbol():label;
70
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
70
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2)){
71 71
                return (StringUtils.isNotBlank(status.getSymbol2() ))?status.getSymbol2():label;
72 72
            }else{
73 73
                return (label != null)?label:DEFAULT_ENTRY;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusDataDisplayConverter.java
14 14
import org.apache.commons.lang.StringUtils;
15 15
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
16 16

  
17
import eu.etaxonomy.cdm.model.term.Representation;
18 17
import eu.etaxonomy.cdm.model.description.Distribution;
19
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
20 18
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
19
import eu.etaxonomy.cdm.model.term.Representation;
21 20
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22 21
import eu.etaxonomy.taxeditor.store.CdmStore;
23 22

  
......
36 35
        if(canonicalValue instanceof Distribution){
37 36

  
38 37
            Distribution distribution = (Distribution) canonicalValue;
39
            PresenceAbsenceTerm term = distribution.getStatus();
40
            Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
41
            String label = rep.getLabel();
42

  
43
            if (label == null){
44
                label = distribution.getStatus().getTitleCache();
45
            }
46
            if (PreferencesUtil.displayStatusInChecklistEditor() != null){
47
                if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
48
                    return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
49
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
50

  
51
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
52
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
53
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
54
                }else{
55
                    return (label != null)?label:DEFAULT_ENTRY;
56
                }
57 38

  
58
            }else{
59
                return (label != null)?label:DEFAULT_ENTRY;
60
            }
39
            return extractStatusString(distribution);
61 40
        }
62 41
        else if(canonicalValue instanceof HashSet<?>){
63 42
            HashSet<?> distributionSet = (HashSet<?>) canonicalValue;
64 43
            Iterator<?> distributions = distributionSet.iterator();
65 44
            String result = "";
66 45
            while(distributions.hasNext()){
67
                result.concat(((Distribution)distributions.next()).getStatus().getLabel()+", ");
46
                result.concat(extractStatusString((Distribution)distributions.next())+", ");
68 47
            }
69 48
            result = result.substring(1, result.length() - 1);
70 49
            return result;
......
73 52
        return null;
74 53
    }
75 54

  
55
    public Object extractStatusString(Distribution distribution) {
56
        if (distribution.getStatus() == null){
57
            return DEFAULT_ENTRY;
58
        }
59

  
60
        Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
61
        String label = rep.getLabel();
62

  
63
        if (label == null){
64
            label = distribution.getStatus().getTitleCache();
65
        }
66
        if (PreferencesUtil.displayStatusInChecklistEditor() != null){
67
            if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary)){
68
                return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
69
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1)){
70

  
71
                return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
72
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2)){
73
                return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
74
            }else{
75
                return (label != null)?label:DEFAULT_ENTRY;
76
            }
77

  
78
        }else{
79
            return (label != null)?label:DEFAULT_ENTRY;
80
        }
81
    }
82

  
76 83
    /**
77 84
     * {@inheritDoc}
78 85
     */
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusDisplayConverter.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.view.checklist.e4;
10 10

  
11
import java.util.HashSet;
12
import java.util.Iterator;
13

  
11 14
import org.apache.commons.lang.StringUtils;
12 15
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
13 16

  
14
import eu.etaxonomy.cdm.model.term.Representation;
17
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
15 18
import eu.etaxonomy.cdm.model.description.Distribution;
16 19
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
17 20
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
21
import eu.etaxonomy.cdm.model.term.Representation;
18 22
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19 23
import eu.etaxonomy.taxeditor.store.CdmStore;
20 24

  
......
31 35
    @Override
32 36
    public Object canonicalToDisplayValue(Object canonicalValue) {
33 37
        if(canonicalValue instanceof Distribution){
34
            Distribution distribution = (Distribution)canonicalValue;
35
            if (distribution.getStatus() != null){
36

  
37
                Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
38
                String label = rep.getLabel();
39

  
40
                if (label == null){
41
                    label = distribution.getStatus().getTitleCache();
42
                }
43
                if (PreferencesUtil.displayStatusInChecklistEditor() != null){
44
                    if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
45
                        return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
46
                    }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
47

  
48
                        return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
49
                    }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
50
                        return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
51
                    }else{
52
                        return (label != null)?label:DEFAULT_ENTRY;
53
                    }
38
            Distribution distribution = HibernateProxyHelper.deproxy(canonicalValue, Distribution.class);
39
            return extractStatusString(distribution);
54 40

  
55
                }else{
56
                    return (label != null)?label:DEFAULT_ENTRY;
57
                }
58
            }
59

  
60
            return DEFAULT_ENTRY;
61 41
        }else if(canonicalValue instanceof PresenceAbsenceTerm){
62 42
            return ((PresenceAbsenceTerm)canonicalValue).getLabel();
63
        } else if(canonicalValue!=null){
43
        } else if(canonicalValue instanceof HashSet<?>){
44
            HashSet<Distribution> statusSet = (HashSet<Distribution>) canonicalValue;
45
            Iterator<Distribution> status = statusSet.iterator();
46
            String result = "";
47
            while(status.hasNext()){
48
                result= extractStatusString(status.next()) + ", " +result   ;
49
            }
50
            result = result.substring(0, result.length() - 2);
51
            return result;
52
        }else if (canonicalValue != null){
64 53
            return canonicalValue.toString();
65 54
        }
66 55
        return null;
......
74 63
        return null;
75 64
    }
76 65

  
66
    public Object extractStatusString(Object distribution) {
67
        PresenceAbsenceTerm status = null;
68
        if (distribution instanceof Distribution){
69
            status = HibernateProxyHelper.deproxy(((Distribution)distribution).getStatus(), PresenceAbsenceTerm.class);
70
        }
71
//        if (distribution instanceof String){
72
//            status = (PresenceAbsenceTerm)distribution;
73
//        }
74
        if (status == null){
75
            return DEFAULT_ENTRY;
76
        }
77

  
78
        Representation rep = status.getPreferredRepresentation(CdmStore.getDefaultLanguage());
79
        String label = rep.getLabel();
80

  
81
        if (label == null){
82
            label = status.getTitleCache();
83
        }
84
        if (PreferencesUtil.displayStatusInChecklistEditor() != null){
85
            if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary)){
86

  
87
                return (StringUtils.isNotBlank(status.getIdInVocabulary()))?status.getIdInVocabulary():label;
88
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1)){
89

  
90
                return (StringUtils.isNotBlank(status.getSymbol() ))?status.getSymbol():label;
91
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2)){
92
                return (StringUtils.isNotBlank(status.getSymbol2() ))?status.getSymbol2():label;
93
            }else{
94
                return (label != null)?label:DEFAULT_ENTRY;
95
            }
96

  
97
        }else{
98
            return (label != null)?label:DEFAULT_ENTRY;
99
        }
100
    }
101

  
77 102
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)