Project

General

Profile

« Previous | Next » 

Revision a5b15eef

Added by Katja Luther almost 8 years ago

further development of the checklist editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java
28 28

  
29 29
import eu.etaxonomy.cdm.api.service.IDescriptionService;
30 30
import eu.etaxonomy.cdm.api.service.ITermService;
31
import eu.etaxonomy.cdm.common.CdmUtils;
31 32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
32 33
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
33 34
import eu.etaxonomy.cdm.model.common.Language;
......
90 91
    /** {@inheritDoc} */
91 92
	@Override
92 93
    public String getColumnText(Object element, int columnIndex) {
93
        descriptionService = CdmStore.getService(IDescriptionService.class);
94
       // descriptionService = CdmStore.getService(IDescriptionService.class);
94 95
        Taxon taxon = (Taxon) element;
95 96
        //TODO load areas by this list
96 97

  
97
        List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
98
       // List<TaxonDescription> listTaxonDescriptions = descriptionService.listTaxonDescriptions(taxon, null, null, null, null, null, DESC_INIT_STRATEGY);;
99
        Set<TaxonDescription> listTaxonDescriptions = taxon.getDescriptions();
98 100
        NonViralName<?> nonViralName = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
99 101

  
100 102
        switch (columnIndex) {
......
103 105
            taxonName = (nonViralName != null) ? nonViralName.getNameCache() : null;
104 106
            return (taxonName != null) ? taxonName : DEFAULT_ENTRY;
105 107

  
106
        case 1:
107
            String authorship = null;
108
            authorship = (nonViralName != null) ? nonViralName.getAuthorshipCache() : null;
109
            return (authorship != null) ? authorship : DEFAULT_ENTRY;
108
 //       case 1:
109
//            String authorship = null;
110
//            authorship = (nonViralName != null) ? nonViralName.getAuthorshipCache() : null;
111
//            return (authorship != null) ? authorship : DEFAULT_ENTRY;
110 112
//        case 2:
111 113
//            String ref = null;
112 114
//            if (taxon.getName() != null) {
......
115 117
//                ref = (nomenclaturalReference != null) ? nomenclaturalReference.getAbbrevTitleCache() : null;
116 118
//            }
117 119
//            return (ref != null) ? ref : DEFAULT_ENTRY;
118
        case 2:
119
            String rank = null;
120
            if (taxon.getName().getRank() != null) {
121
                rank = taxon.getName().getRank().toString();
120
        case 1:
121
            if (PreferencesUtil.isShowRankInChecklistEditor()){
122
                String rank = null;
123

  
124
                if (taxon.getName().getRank() != null) {
125
                    rank = taxon.getName().getRank().toString();
126
                }
127
                return (rank != null) ? rank : DEFAULT_ENTRY;
122 128
            }
123
            return (rank != null) ? rank : DEFAULT_ENTRY;
124 129
        }
125 130

  
126
        if(columnIndex >2){
131
        if(columnIndex >2 || (!PreferencesUtil.isShowRankInChecklistEditor() && columnIndex > 1)){
127 132

  
128 133
            for (TaxonDescription td : listTaxonDescriptions) {
129 134
                for (DescriptionElementBase deb : td.getElements()) {
......
132 137
                        String area = null;
133 138
                        if (distribution.getArea() != null ){
134 139
                            if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
135
                                area = distribution.getArea().getIdInVocabulary();
140
                                if (distribution.getArea().getIdInVocabulary() != null){
141
                                    area = distribution.getArea().getIdInVocabulary();
142
                                } else{
143
                                    area = distribution.getArea().getTitleCache();
144
                                }
136 145
                            }else{
137 146
                                area = distribution.getArea().getTitleCache();
138 147
                            }
......
143 152
                        if(viewer != null){
144 153
                        	TableColumn column = viewer.getTable().getColumn(columnIndex);
145 154
                        	if (area.equalsIgnoreCase(column.getText())) {
146
                        	    return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
155
                        	    if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
156
                        	        return (distribution.getStatus().getIdInVocabulary() != null)?distribution.getStatus().getIdInVocabulary():CdmUtils.Nz(distribution.getStatus().getTitleCache());
157
                        	    }else{
158
                        	        return (distribution.getStatus().getTitleCache() != null)?distribution.getStatus().getTitleCache():DEFAULT_ENTRY;
159
                        	    }
147 160
                            }
148 161

  
149 162
                        }
......
162 175
    private SortedSet<DefinedTermBase> loadNamedAreas() {
163 176
        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
164 177
        String values = preferenceStore.getString(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS);
178

  
165 179
        if (values != null && values != "") {
166 180
            String[] split = values.split(",");
167 181
            List<String> listValue = Arrays.asList(split);
168 182
            List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>();
169
           Set<UUID> uuidList = new HashSet<UUID>();
170
           UUID uuid;
183
            Set<UUID> uuidList = new HashSet<UUID>();
184
            UUID uuid;
171 185
            for(String s : listValue){
172 186
                uuid = UUID.fromString(s);
173 187
                uuidList.add(uuid);
......
175 189
            }
176 190
            ITermService service = CdmStore.getService(ITermService.class);
177 191
            termlist = service.find(uuidList);
178

  
179
            return getTermsOrderedByIdInVocabulary(termlist);
192
            if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
193
                return getTermsOrderedByIdInVocabulary(termlist);
194
            } else {
195
                return getTermsOrderedByLabels(termlist, CdmStore.getDefaultLanguage());
196
            }
180 197
        }
181 198
        return null;
182 199
    }
183 200

  
184
    public SortedSet<?> getTermsOrderedByLabels(List<DefinedTermBase<?>> listTerm,Language language){
201
    public SortedSet<DefinedTermBase> getTermsOrderedByLabels(List<DefinedTermBase> listTerm,Language language){
185 202
        TermLanguageComparator comp = new TermLanguageComparator();
186 203
        comp.setCompareLanguage(language);
187 204
        SortedSet result = new TreeSet(comp);

Also available in: Unified diff