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;
|
11
|
|
12
|
import java.sql.SQLException;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
16
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
17
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
18
|
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
|
19
|
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer;
|
20
|
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
|
21
|
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
|
22
|
import eu.etaxonomy.cdm.vaadin.view.IStatusComposite.StatusComponentListener;
|
23
|
|
24
|
/**
|
25
|
* @author cmathew
|
26
|
* @date 10 Mar 2015
|
27
|
*
|
28
|
*/
|
29
|
public class StatusPresenter implements StatusComponentListener {
|
30
|
|
31
|
|
32
|
|
33
|
private LeafNodeTaxonContainer leafNodeTaxonContainer;
|
34
|
|
35
|
private CdmSQLContainer classificationContainer;
|
36
|
|
37
|
private final ITaxonService taxonService;
|
38
|
|
39
|
private int totalNoOfTaxa = 0;
|
40
|
|
41
|
public StatusPresenter() {
|
42
|
taxonService = CdmSpringContextHelper.getTaxonService();
|
43
|
}
|
44
|
|
45
|
|
46
|
@Override
|
47
|
public void removeFilters() {
|
48
|
removeUnplacedFilter();
|
49
|
removeUnpublishedFilter();
|
50
|
removeNameFilter();
|
51
|
}
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComponent.StatusComponentListener#load()
|
55
|
*/
|
56
|
@Override
|
57
|
public LeafNodeTaxonContainer loadTaxa(int classificationId) throws SQLException {
|
58
|
leafNodeTaxonContainer = new LeafNodeTaxonContainer(classificationId);
|
59
|
totalNoOfTaxa = leafNodeTaxonContainer.getTotalNoOfTaxa();
|
60
|
return leafNodeTaxonContainer;
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public void refresh() {
|
65
|
leafNodeTaxonContainer.refresh();
|
66
|
}
|
67
|
@Override
|
68
|
public void setUnplacedFilter() {
|
69
|
leafNodeTaxonContainer.setUnplacedFilter();
|
70
|
}
|
71
|
|
72
|
@Override
|
73
|
public void removeUnplacedFilter() {
|
74
|
leafNodeTaxonContainer.removeUnplacedFilter();
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void setUnpublishedFilter() {
|
79
|
leafNodeTaxonContainer.setUnpublishedFilter();
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public void removeUnpublishedFilter() {
|
84
|
leafNodeTaxonContainer.removeUnpublishedFilter();
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public void setNameFilter(String filterString) {
|
89
|
leafNodeTaxonContainer.setNameFilter(filterString);
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
public void removeNameFilter() {
|
94
|
leafNodeTaxonContainer.removeNameFilter();
|
95
|
}
|
96
|
|
97
|
@Override
|
98
|
public int getCurrentNoOfTaxa() {
|
99
|
return leafNodeTaxonContainer.size();
|
100
|
}
|
101
|
|
102
|
@Override
|
103
|
public int getTotalNoOfTaxa() {
|
104
|
return totalNoOfTaxa;
|
105
|
}
|
106
|
|
107
|
@Override
|
108
|
public boolean isSynonym(Object itemId) {
|
109
|
return leafNodeTaxonContainer.isSynonym(itemId);
|
110
|
}
|
111
|
|
112
|
/* (non-Javadoc)
|
113
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComponent.StatusComponentListener#loadClassifications()
|
114
|
*/
|
115
|
@Override
|
116
|
public CdmSQLContainer loadClassifications() throws SQLException {
|
117
|
classificationContainer = CdmSQLContainer.newInstance("Classification");
|
118
|
return classificationContainer;
|
119
|
}
|
120
|
|
121
|
|
122
|
@Override
|
123
|
public void updatePublished(boolean pb, Object itemId) {
|
124
|
UUID uuid = UUID.fromString((String)leafNodeTaxonContainer.getItem(itemId).getItemProperty(CdmQueryFactory.UUID_ID).getValue());
|
125
|
Taxon taxon = CdmBase.deproxy(taxonService.load(uuid), Taxon.class);
|
126
|
boolean currentPb = taxon.isPublish();
|
127
|
if(currentPb != pb) {
|
128
|
taxon.setPublish(pb);
|
129
|
taxonService.merge(taxon);
|
130
|
}
|
131
|
}
|
132
|
|
133
|
|
134
|
/* (non-Javadoc)
|
135
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComposite.StatusComponentListener#getCurrentLeafNodeTaxonContainer()
|
136
|
*/
|
137
|
@Override
|
138
|
public LeafNodeTaxonContainer getCurrentLeafNodeTaxonContainer() {
|
139
|
return leafNodeTaxonContainer;
|
140
|
}
|
141
|
|
142
|
@Override
|
143
|
public CdmSQLContainer getClassificationContainer() {
|
144
|
return classificationContainer;
|
145
|
}
|
146
|
|
147
|
}
|