Project

General

Profile

Download (4.74 KB) Statistics
| Branch: | Tag: | Revision:
1 1a3e979c Alexander Oppermann
// $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 5b5a7e10 Patrick Plitzner
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 1a3e979c Alexander Oppermann
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 5b5a7e10 Patrick Plitzner
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27 1a3e979c Alexander Oppermann
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
28
29
/**
30
 * @author alex
31
 * @date 22.04.2015
32
 *
33
 */
34
public class SettingsPresenter {
35
36
    private Container classificationContainer;
37
    private Container distributionContainer;
38
    private Container distributionStatusContainer;
39
    private IVocabularyService vocabularyService;
40
    private ITermService termService;
41 5b5a7e10 Patrick Plitzner
    private ITaxonNodeService taxonNodeService;
42
    private UUID taxonNodeUuid;
43 1a3e979c Alexander Oppermann
    private UUID termUUID;
44
45
46
47
    public SettingsPresenter(){
48
        init();
49
50
    }
51
52
    private void init() {
53 5b5a7e10 Patrick Plitzner
        taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
54
        taxonNodeUuid = UUID.fromString(VaadinSession.getCurrent().getAttribute("taxonNodeUUID").toString());
55 1a3e979c Alexander Oppermann
        termUUID = UUID.fromString(VaadinSession.getCurrent().getAttribute("selectedTerm").toString());
56
        classificationContainer = new IndexedContainer(getClassificationList());
57
        distributionContainer = new IndexedContainer(getNamedAreaList());
58
        distributionStatusContainer = new IndexedContainer(getPresenceAbsenceVocabulary());
59
    }
60
61 5b5a7e10 Patrick Plitzner
    public TaxonNode getChosenClassification(){
62
        return taxonNodeService.load(taxonNodeUuid);
63 1a3e979c Alexander Oppermann
    }
64
65
    public TermVocabulary getChosenArea(){
66
        return vocabularyService.load(termUUID);
67
    }
68
69
    public Container getClassificationContainer() {
70
        return classificationContainer;
71
    }
72
    public void setClassificationContainer(Container classificationContainer) {
73
        this.classificationContainer = classificationContainer;
74
    }
75
    public Container getDistributionContainer() {
76
        return distributionContainer;
77
    }
78
    public void setDistributionContainer(Container distributionContainer) {
79
        this.distributionContainer = distributionContainer;
80
    }
81
    public Container getDistributionStatusContainer() {
82
        return distributionStatusContainer;
83
    }
84
    public void setDistributionStatusContainer(Container distributionStatusContainer) {
85
        this.distributionStatusContainer = distributionStatusContainer;
86
    }
87
88 5b5a7e10 Patrick Plitzner
    private List<TaxonNode> getClassificationList() {
89
        List<TaxonNode> classificationList = taxonNodeService.loadChildNodesOfTaxonNode(getChosenClassification(), null, true, null);
90
        classificationList.add(getChosenClassification());
91 1a3e979c Alexander Oppermann
        return classificationList;
92
    }
93
94
95
    private List<TermVocabulary<DefinedTermBase>> getNamedAreaList() {
96
97
        vocabularyService = CdmSpringContextHelper.getVocabularyService();
98
        List<TermVocabulary<DefinedTermBase>> termList = vocabularyService.findByTermType(TermType.NamedArea);
99
        return termList;
100
    }
101
    private List<DefinedTermBase<?>> getPresenceAbsenceVocabulary(){
102
        termService = CdmSpringContextHelper.getTermService();
103
        return termService.listByTermType(TermType.PresenceAbsenceTerm, null, null, null, DESCRIPTION_INIT_STRATEGY);
104
    }
105
106
     private List<String> NODE_INIT_STRATEGY(){
107
            return Arrays.asList(new String[]{
108
                "taxon.sec",
109
                "taxon.name",
110
                "classification"
111
     });}
112
113
     protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
114
             "$",
115
             "elements.*",
116
             "elements.sources.citation.authorship.$",
117
             "elements.sources.nameUsedInSource.originalNameString",
118
             "elements.area.level",
119
             "elements.modifyingText",
120
             "elements.states.*",
121
             "elements.media",
122
             "elements.multilanguageText",
123
             "multilanguageText",
124
             "stateData.$",
125
             "annotations",
126
             "markers",
127
             "sources.citation.authorship",
128
             "sources.nameUsedInSource",
129
             "multilanguageText",
130
             "media",
131
             "name.$",
132
             "name.rank.representations",
133
             "name.status.type.representations",
134
             "taxon2.name"
135
     });
136
137
138
}