1 |
51fe9924
|
Cherian Mathew
|
// $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 |
aee16929
|
Cherian Mathew
|
import java.util.Collection;
|
14 |
aceb7b1d
|
Cherian Mathew
|
import java.util.UUID;
|
15 |
51fe9924
|
Cherian Mathew
|
|
16 |
aee16929
|
Cherian Mathew
|
import com.vaadin.data.util.filter.Compare;
|
17 |
|
|
import com.vaadin.data.util.filter.Compare.Equal;
|
18 |
|
|
|
19 |
aceb7b1d
|
Cherian Mathew
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
20 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
21 |
|
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
22 |
51fe9924
|
Cherian Mathew
|
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
|
23 |
|
|
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer;
|
24 |
5cf75203
|
Cherian Mathew
|
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
|
25 |
aceb7b1d
|
Cherian Mathew
|
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
|
26 |
51fe9924
|
Cherian Mathew
|
import eu.etaxonomy.cdm.vaadin.view.IStatusComposite.StatusComponentListener;
|
27 |
|
|
|
28 |
|
|
/**
|
29 |
|
|
* @author cmathew
|
30 |
|
|
* @date 10 Mar 2015
|
31 |
|
|
*
|
32 |
|
|
*/
|
33 |
|
|
public class StatusPresenter implements StatusComponentListener {
|
34 |
|
|
|
35 |
45da4f57
|
Cherian Mathew
|
|
36 |
9f53671d
|
Cherian Mathew
|
public final static String C_TCACHE_ID = "titleCache";
|
37 |
51fe9924
|
Cherian Mathew
|
|
38 |
53c75a2d
|
Cherian Mathew
|
private LeafNodeTaxonContainer leafNodeTaxonContainer;
|
39 |
|
|
|
40 |
|
|
private CdmSQLContainer classificationContainer;
|
41 |
374bb513
|
Cherian Mathew
|
|
42 |
5cf75203
|
Cherian Mathew
|
private final ITaxonService taxonService;
|
43 |
1d066036
|
Cherian Mathew
|
|
44 |
|
|
private int totalNoOfTaxa = 0;
|
45 |
374bb513
|
Cherian Mathew
|
|
46 |
45da4f57
|
Cherian Mathew
|
public StatusPresenter() {
|
47 |
aceb7b1d
|
Cherian Mathew
|
taxonService = CdmSpringContextHelper.getTaxonService();
|
48 |
|
|
}
|
49 |
1d066036
|
Cherian Mathew
|
|
50 |
5cf75203
|
Cherian Mathew
|
|
51 |
1d066036
|
Cherian Mathew
|
@Override
|
52 |
|
|
public void removeFilters() {
|
53 |
|
|
removeUnplacedFilter();
|
54 |
|
|
removeUnpublishedFilter();
|
55 |
|
|
removeNameFilter();
|
56 |
51fe9924
|
Cherian Mathew
|
}
|
57 |
|
|
|
58 |
|
|
/* (non-Javadoc)
|
59 |
|
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComponent.StatusComponentListener#load()
|
60 |
|
|
*/
|
61 |
|
|
@Override
|
62 |
|
|
public LeafNodeTaxonContainer loadTaxa(int classificationId) throws SQLException {
|
63 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer = new LeafNodeTaxonContainer(classificationId);
|
64 |
|
|
totalNoOfTaxa = leafNodeTaxonContainer.getTotalNoOfTaxa();
|
65 |
|
|
return leafNodeTaxonContainer;
|
66 |
51fe9924
|
Cherian Mathew
|
}
|
67 |
|
|
|
68 |
aee16929
|
Cherian Mathew
|
@Override
|
69 |
|
|
public Object getClassificationId(String classification) {
|
70 |
|
|
if(classification == null) {
|
71 |
|
|
return null;
|
72 |
|
|
}
|
73 |
|
|
Equal cnameFilter = new Compare.Equal("titleCache", classification);
|
74 |
|
|
classificationContainer.addContainerFilter(cnameFilter);
|
75 |
|
|
Collection<?> itemIds = classificationContainer.getItemIds();
|
76 |
|
|
Object itemId = null;
|
77 |
|
|
if(!itemIds.isEmpty()) {
|
78 |
|
|
itemId = itemIds.iterator().next();
|
79 |
|
|
}
|
80 |
|
|
classificationContainer.removeContainerFilter(cnameFilter);
|
81 |
|
|
return itemId;
|
82 |
|
|
}
|
83 |
|
|
|
84 |
1d066036
|
Cherian Mathew
|
@Override
|
85 |
|
|
public void refresh() {
|
86 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.refresh();
|
87 |
1d066036
|
Cherian Mathew
|
}
|
88 |
374bb513
|
Cherian Mathew
|
@Override
|
89 |
|
|
public void setUnplacedFilter() {
|
90 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.setUnplacedFilter();
|
91 |
374bb513
|
Cherian Mathew
|
}
|
92 |
|
|
|
93 |
|
|
@Override
|
94 |
|
|
public void removeUnplacedFilter() {
|
95 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.removeUnplacedFilter();
|
96 |
374bb513
|
Cherian Mathew
|
}
|
97 |
|
|
|
98 |
|
|
@Override
|
99 |
|
|
public void setUnpublishedFilter() {
|
100 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.setUnpublishedFilter();
|
101 |
374bb513
|
Cherian Mathew
|
}
|
102 |
|
|
|
103 |
|
|
@Override
|
104 |
|
|
public void removeUnpublishedFilter() {
|
105 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.removeUnpublishedFilter();
|
106 |
374bb513
|
Cherian Mathew
|
}
|
107 |
|
|
|
108 |
|
|
@Override
|
109 |
|
|
public void setNameFilter(String filterString) {
|
110 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.setNameFilter(filterString);
|
111 |
374bb513
|
Cherian Mathew
|
}
|
112 |
|
|
|
113 |
|
|
@Override
|
114 |
|
|
public void removeNameFilter() {
|
115 |
53c75a2d
|
Cherian Mathew
|
leafNodeTaxonContainer.removeNameFilter();
|
116 |
374bb513
|
Cherian Mathew
|
}
|
117 |
|
|
|
118 |
218fbd04
|
Cherian Mathew
|
@Override
|
119 |
|
|
public void setIdFilter(Object itemId) {
|
120 |
|
|
leafNodeTaxonContainer.setIdFilter(itemId);
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
@Override
|
124 |
|
|
public void removeIdFilter() {
|
125 |
|
|
leafNodeTaxonContainer.removeDynamicFilters();
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
@Override
|
129 |
|
|
public void removeDynamicFilters() {
|
130 |
|
|
leafNodeTaxonContainer.removeDynamicFilters();
|
131 |
|
|
}
|
132 |
|
|
|
133 |
374bb513
|
Cherian Mathew
|
@Override
|
134 |
1d066036
|
Cherian Mathew
|
public int getCurrentNoOfTaxa() {
|
135 |
53c75a2d
|
Cherian Mathew
|
return leafNodeTaxonContainer.size();
|
136 |
374bb513
|
Cherian Mathew
|
}
|
137 |
|
|
|
138 |
|
|
@Override
|
139 |
1d066036
|
Cherian Mathew
|
public int getTotalNoOfTaxa() {
|
140 |
|
|
return totalNoOfTaxa;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
@Override
|
144 |
5cf75203
|
Cherian Mathew
|
public boolean isSynonym(Object itemId) {
|
145 |
53c75a2d
|
Cherian Mathew
|
return leafNodeTaxonContainer.isSynonym(itemId);
|
146 |
374bb513
|
Cherian Mathew
|
}
|
147 |
51fe9924
|
Cherian Mathew
|
|
148 |
218fbd04
|
Cherian Mathew
|
@Override
|
149 |
|
|
public void refreshSynonymCache() {
|
150 |
|
|
leafNodeTaxonContainer.refreshSynonymCache();
|
151 |
|
|
}
|
152 |
|
|
|
153 |
51fe9924
|
Cherian Mathew
|
/* (non-Javadoc)
|
154 |
|
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComponent.StatusComponentListener#loadClassifications()
|
155 |
|
|
*/
|
156 |
|
|
@Override
|
157 |
|
|
public CdmSQLContainer loadClassifications() throws SQLException {
|
158 |
53c75a2d
|
Cherian Mathew
|
classificationContainer = CdmSQLContainer.newInstance("Classification");
|
159 |
|
|
return classificationContainer;
|
160 |
51fe9924
|
Cherian Mathew
|
}
|
161 |
|
|
|
162 |
1d066036
|
Cherian Mathew
|
|
163 |
aceb7b1d
|
Cherian Mathew
|
@Override
|
164 |
|
|
public void updatePublished(boolean pb, Object itemId) {
|
165 |
53c75a2d
|
Cherian Mathew
|
UUID uuid = UUID.fromString((String)leafNodeTaxonContainer.getItem(itemId).getItemProperty(CdmQueryFactory.UUID_ID).getValue());
|
166 |
aceb7b1d
|
Cherian Mathew
|
Taxon taxon = CdmBase.deproxy(taxonService.load(uuid), Taxon.class);
|
167 |
|
|
boolean currentPb = taxon.isPublish();
|
168 |
|
|
if(currentPb != pb) {
|
169 |
|
|
taxon.setPublish(pb);
|
170 |
|
|
taxonService.merge(taxon);
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
|
175 |
5cf75203
|
Cherian Mathew
|
/* (non-Javadoc)
|
176 |
|
|
* @see eu.etaxonomy.cdm.vaadin.view.IStatusComposite.StatusComponentListener#getCurrentLeafNodeTaxonContainer()
|
177 |
|
|
*/
|
178 |
|
|
@Override
|
179 |
|
|
public LeafNodeTaxonContainer getCurrentLeafNodeTaxonContainer() {
|
180 |
53c75a2d
|
Cherian Mathew
|
return leafNodeTaxonContainer;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
@Override
|
184 |
|
|
public CdmSQLContainer getClassificationContainer() {
|
185 |
|
|
return classificationContainer;
|
186 |
5cf75203
|
Cherian Mathew
|
}
|
187 |
|
|
|
188 |
51fe9924
|
Cherian Mathew
|
}
|