Revision 60e38397
Added by Fabian Reimeier over 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTablePresenter.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
1 | 9 |
package eu.etaxonomy.cdm.vaadin.view.distributionStatus; |
2 | 10 |
|
3 | 11 |
import java.sql.SQLException; |
... | ... | |
12 | 20 |
import java.util.UUID; |
13 | 21 |
|
14 | 22 |
import com.vaadin.server.VaadinSession; |
23 |
import com.vaadin.spring.annotation.SpringComponent; |
|
24 |
import com.vaadin.spring.annotation.ViewScope; |
|
15 | 25 |
import com.vaadin.ui.Notification; |
16 | 26 |
|
17 | 27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
32 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory; |
33 | 43 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
34 | 44 |
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil; |
45 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
|
35 | 46 |
|
47 |
/** |
|
48 |
* @author freimeier |
|
49 |
* @since 18.10.2017 |
|
50 |
* |
|
51 |
*/ |
|
52 |
@SpringComponent |
|
53 |
@ViewScope |
|
54 |
public class DistributionTablePresenter extends AbstractPresenter<DistributionTableView> { |
|
36 | 55 |
|
37 |
public class DistributionTablePresenter {
|
|
56 |
private static final long serialVersionUID = 3313043335587777217L;
|
|
38 | 57 |
|
39 |
private final DistributionTableView view; |
|
40 |
|
|
41 |
public DistributionTablePresenter(DistributionTableView dtv){ |
|
42 |
this.view = dtv; |
|
43 |
view.addListener(this); |
|
44 |
} |
|
45 |
|
|
46 |
public int updateDistributionField(String distributionAreaString, Object comboValue, Taxon taxon) { |
|
58 |
public int updateDistributionField(String distributionAreaString, Object comboValue, Taxon taxon) { |
|
47 | 59 |
Set<DefinedTermBase> chosenTerms = getChosenTerms(); |
60 |
Set<NamedArea> termSet = getTermSet(); |
|
48 | 61 |
NamedArea namedArea = null; |
49 | 62 |
for(DefinedTermBase term:chosenTerms){ |
50 | 63 |
Representation representation = term.getRepresentation(Language.DEFAULT()); |
... | ... | |
114 | 127 |
public Set<DefinedTermBase> getChosenTerms() { |
115 | 128 |
VaadinSession session = VaadinSession.getCurrent(); |
116 | 129 |
UUID termUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_VOCABULARY_UUID); |
117 |
TermVocabulary<DefinedTermBase> term = CdmSpringContextHelper.getVocabularyService().load(termUUID); |
|
118 |
term = CdmBase.deproxy(term, TermVocabulary.class); |
|
130 |
getConversationHolder().getSession(); |
|
131 |
TermVocabulary<DefinedTermBase> term = CdmSpringContextHelper.getVocabularyService().load(termUUID, Arrays.asList("terms.representations")); |
|
132 |
term = CdmBase.deproxy(term); |
|
119 | 133 |
return term.getTerms(); |
120 | 134 |
} |
121 | 135 |
|
... | ... | |
141 | 155 |
private Set<NamedArea> getTermSet(){ |
142 | 156 |
VaadinSession session = VaadinSession.getCurrent(); |
143 | 157 |
UUID termUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_VOCABULARY_UUID); |
144 |
TermVocabulary<NamedArea> vocabulary = CdmSpringContextHelper.getVocabularyService().load(termUUID); |
|
158 |
TermVocabulary<NamedArea> vocabulary = CdmSpringContextHelper.getVocabularyService().load(termUUID, Arrays.asList("terms.representations"));
|
|
145 | 159 |
vocabulary = CdmBase.deproxy(vocabulary, TermVocabulary.class); |
146 | 160 |
return vocabulary.getTermsOrderedByLabels(Language.DEFAULT()); |
147 | 161 |
} |
... | ... | |
170 | 184 |
} |
171 | 185 |
|
172 | 186 |
public List<Distribution> getDistributions(Taxon taxon) { |
173 |
Set<Feature> setFeature = new HashSet<Feature>(Arrays.asList(Feature.DISTRIBUTION()));
|
|
187 |
Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION())); |
|
174 | 188 |
List<Distribution> listTaxonDescription = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY); |
175 | 189 |
return listTaxonDescription; |
176 | 190 |
|
177 | 191 |
} |
178 | 192 |
|
179 | 193 |
public List<TaxonNode> getAllNodes(){ |
180 |
List<TaxonNode> allNodes = new ArrayList<TaxonNode>();
|
|
194 |
List<TaxonNode> allNodes = new ArrayList<>(); |
|
181 | 195 |
|
182 | 196 |
List<TaxonNode> taxonNodes = getChosenTaxonNodes(); |
183 | 197 |
for (TaxonNode taxonNode : taxonNodes) { |
... | ... | |
208 | 222 |
} |
209 | 223 |
|
210 | 224 |
public CdmSQLContainer getSQLContainer() throws SQLException{ |
211 |
List<Integer> nodeIds = new ArrayList<Integer>();
|
|
225 |
List<Integer> nodeIds = new ArrayList<>(); |
|
212 | 226 |
for (TaxonNode taxonNode : getAllNodes()) { |
213 | 227 |
nodeIds.add(taxonNode.getId()); |
214 | 228 |
} |
... | ... | |
244 | 258 |
}); |
245 | 259 |
|
246 | 260 |
/**Helper Methods*/ |
247 |
|
|
248 | 261 |
private void sort(List<DescriptionElementBase> list){ |
249 | 262 |
Collections.sort(list, new Comparator<DescriptionElementBase>() { |
250 | 263 |
|
Also available in: Unified diff
Fixed #6802 and switched to mvp