1
|
/**
|
2
|
* Copyright (C) 2015 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
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.view.distributionStatus.settings;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.Collections;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import com.vaadin.data.Container;
|
17
|
import com.vaadin.data.util.IndexedContainer;
|
18
|
import com.vaadin.server.VaadinSession;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
21
|
import eu.etaxonomy.cdm.model.common.TermType;
|
22
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
25
|
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
|
26
|
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
|
27
|
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.DistributionSettingsConfigWindow;
|
28
|
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.SettingsConfigWindow;
|
29
|
|
30
|
/**
|
31
|
* Note: This presenter is used for {@link SettingsConfigWindow} AND {@link DistributionSettingsConfigWindow}
|
32
|
*
|
33
|
* @author alex
|
34
|
* @date 22.04.2015
|
35
|
*
|
36
|
*
|
37
|
*/
|
38
|
public class SettingsPresenter {
|
39
|
|
40
|
private Container distributionContainer;
|
41
|
private Container distributionStatusContainer;
|
42
|
private UUID vocUUID;
|
43
|
|
44
|
|
45
|
|
46
|
public SettingsPresenter(){
|
47
|
Object selectedVocabularyUuidString = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID);
|
48
|
if(selectedVocabularyUuidString!=null){
|
49
|
vocUUID = UUID.fromString(selectedVocabularyUuidString.toString());
|
50
|
}
|
51
|
distributionContainer = new IndexedContainer(getNamedAreaList());
|
52
|
distributionStatusContainer = new IndexedContainer(getPresenceAbsenceVocabulary());
|
53
|
}
|
54
|
|
55
|
public List<TaxonNode> getChosenTaxonNodes(){
|
56
|
List<UUID> nodeUuids = (List<UUID>) VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_TAXON_NODES_UUID);
|
57
|
if(nodeUuids!=null){
|
58
|
return CdmSpringContextHelper.getTaxonNodeService().load(nodeUuids, null);
|
59
|
}
|
60
|
return Collections.emptyList();
|
61
|
}
|
62
|
|
63
|
public Classification getChosenClassification(){
|
64
|
UUID uuid = (UUID) VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_CLASSIFICATION);
|
65
|
if(uuid!=null){
|
66
|
return CdmSpringContextHelper.getClassificationService().load(uuid);
|
67
|
}
|
68
|
return null;
|
69
|
}
|
70
|
|
71
|
public TermVocabulary getChosenAreaVoc(){
|
72
|
return CdmSpringContextHelper.getVocabularyService().load(vocUUID);
|
73
|
}
|
74
|
|
75
|
public Container getDistributionContainer() {
|
76
|
return distributionContainer;
|
77
|
}
|
78
|
|
79
|
public Container getDistributionStatusContainer() {
|
80
|
return distributionStatusContainer;
|
81
|
}
|
82
|
|
83
|
private List<TermVocabulary<DefinedTermBase>> getNamedAreaList() {
|
84
|
List<TermVocabulary<DefinedTermBase>> termList = CdmSpringContextHelper.getVocabularyService().findByTermType(TermType.NamedArea, VOCABULARY_INIT_STRATEGY);
|
85
|
return termList;
|
86
|
}
|
87
|
|
88
|
private List<DefinedTermBase<?>> getPresenceAbsenceVocabulary(){
|
89
|
return CdmSpringContextHelper.getTermService().listByTermType(TermType.PresenceAbsenceTerm, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
90
|
}
|
91
|
|
92
|
protected static final List<String> VOCABULARY_INIT_STRATEGY = Arrays.asList(new String []{
|
93
|
"$",
|
94
|
"terms",
|
95
|
"terms.*",
|
96
|
});
|
97
|
|
98
|
protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
|
99
|
"$",
|
100
|
"annotations",
|
101
|
"markers",
|
102
|
"sources.citation.authorship",
|
103
|
"sources.nameUsedInSource",
|
104
|
"media",
|
105
|
});
|
106
|
|
107
|
}
|