1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.vaadin.presenter.dbstatus.settings;
|
11
|
|
12
|
import java.util.Arrays;
|
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.api.service.ITaxonNodeService;
|
21
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
22
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
23
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
24
|
import eu.etaxonomy.cdm.model.common.TermType;
|
25
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
27
|
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
|
28
|
import eu.etaxonomy.cdm.vaadin.util.DistributionEditorUtil;
|
29
|
|
30
|
/**
|
31
|
* @author alex
|
32
|
* @date 22.04.2015
|
33
|
*
|
34
|
*/
|
35
|
public class SettingsPresenter {
|
36
|
|
37
|
private Container distributionContainer;
|
38
|
private Container distributionStatusContainer;
|
39
|
private IVocabularyService vocabularyService;
|
40
|
private ITermService termService;
|
41
|
private ITaxonNodeService taxonNodeService;
|
42
|
private UUID taxonNodeUuid;
|
43
|
private UUID termUUID;
|
44
|
|
45
|
|
46
|
|
47
|
public SettingsPresenter(){
|
48
|
taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
|
49
|
Object taxonNodeUuidString = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_TAXON_NODE_UUID);
|
50
|
Object selectedVocabularyUuidString = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_VOCABULARY_UUID);
|
51
|
if(taxonNodeUuidString!=null){
|
52
|
taxonNodeUuid = UUID.fromString(taxonNodeUuidString.toString());
|
53
|
}
|
54
|
if(selectedVocabularyUuidString!=null){
|
55
|
termUUID = UUID.fromString(selectedVocabularyUuidString.toString());
|
56
|
}
|
57
|
distributionContainer = new IndexedContainer(getNamedAreaList());
|
58
|
distributionStatusContainer = new IndexedContainer(getPresenceAbsenceVocabulary());
|
59
|
}
|
60
|
|
61
|
public TaxonNode getChosenTaxonNode(){
|
62
|
return taxonNodeService.load(taxonNodeUuid);
|
63
|
}
|
64
|
|
65
|
public TermVocabulary getChosenArea(){
|
66
|
return vocabularyService.load(termUUID);
|
67
|
}
|
68
|
|
69
|
public Container getDistributionContainer() {
|
70
|
return distributionContainer;
|
71
|
}
|
72
|
|
73
|
public void setDistributionContainer(Container distributionContainer) {
|
74
|
this.distributionContainer = distributionContainer;
|
75
|
}
|
76
|
|
77
|
public Container getDistributionStatusContainer() {
|
78
|
return distributionStatusContainer;
|
79
|
}
|
80
|
|
81
|
public void setDistributionStatusContainer(Container distributionStatusContainer) {
|
82
|
this.distributionStatusContainer = distributionStatusContainer;
|
83
|
}
|
84
|
|
85
|
private List<TermVocabulary<DefinedTermBase>> getNamedAreaList() {
|
86
|
vocabularyService = CdmSpringContextHelper.getVocabularyService();
|
87
|
List<TermVocabulary<DefinedTermBase>> termList = vocabularyService.findByTermType(TermType.NamedArea);
|
88
|
return termList;
|
89
|
}
|
90
|
|
91
|
private List<DefinedTermBase<?>> getPresenceAbsenceVocabulary(){
|
92
|
termService = CdmSpringContextHelper.getTermService();
|
93
|
return termService.listByTermType(TermType.PresenceAbsenceTerm, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
94
|
}
|
95
|
|
96
|
protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
|
97
|
"$",
|
98
|
"annotations",
|
99
|
"markers",
|
100
|
"sources.citation.authorship",
|
101
|
"sources.nameUsedInSource",
|
102
|
"media",
|
103
|
});
|
104
|
|
105
|
}
|