Revision 073d62ba
Added by Patrick Plitzner over 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.vaadin.util; |
11 | 11 |
|
12 |
import java.sql.SQLException; |
|
13 | 12 |
import java.util.Collection; |
14 | 13 |
import java.util.Iterator; |
15 | 14 |
import java.util.List; |
... | ... | |
40 | 39 |
public static final String ID = "id"; |
41 | 40 |
public static final String UUID_ID = "uuid"; |
42 | 41 |
|
43 |
public static QueryDelegate generateTaxonTreeQuery(String name_id, String classificationId) throws SQLException {
|
|
42 |
public static QueryDelegate generateTaxonTreeQuery(String name_id, String classificationId) { |
|
44 | 43 |
String FROM_QUERY = " FROM TaxonBase tb " + |
45 | 44 |
"INNER JOIN TaxonNode tn on tn.taxon_id=tb.id " + |
46 | 45 |
"INNER JOIN TaxonNameBase tnb on tb.name_id=tnb.id " + |
... | ... | |
60 | 59 |
String pb_id, |
61 | 60 |
String unp_id, |
62 | 61 |
String rank_id, |
63 |
String has_syn_id) throws SQLException {
|
|
62 |
String has_syn_id) { |
|
64 | 63 |
String FROM_QUERY = " FROM TaxonBase tb " + |
65 | 64 |
"INNER JOIN TaxonNode tn on tn.taxon_id=tb.id " + |
66 | 65 |
"INNER JOIN TaxonNameBase tnb on tb.name_id=tnb.id " + |
... | ... | |
79 | 78 |
return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
80 | 79 |
} |
81 | 80 |
|
82 |
public static QueryDelegate generateTaxonDistributionQuery(List<Integer> taxonNodeIds, Collection<NamedArea> namedAreas) throws SQLException {
|
|
81 |
public static QueryDelegate generateTaxonDistributionQuery(List<Integer> taxonNodeIds, Collection<NamedArea> namedAreas) { |
|
83 | 82 |
|
84 | 83 |
String idString = ""; |
85 | 84 |
Iterator<Integer> nodeIterator = taxonNodeIds.iterator(); |
... | ... | |
142 | 141 |
return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
143 | 142 |
} |
144 | 143 |
|
145 |
public static QueryDelegate generateSynonymofTaxonQuery(String name_id) throws SQLException {
|
|
144 |
public static QueryDelegate generateSynonymofTaxonQuery(String name_id) { |
|
146 | 145 |
String FROM_QUERY = " FROM TaxonBase tb " + |
147 | 146 |
"INNER JOIN TaxonNameBase tnb on tb.name_id=tnb.id " + |
148 | 147 |
"INNER JOIN SynonymRelationship sr on tb.id=sr.relatedfrom_id "; |
... | ... | |
159 | 158 |
String reltype_id, |
160 | 159 |
String to_id, |
161 | 160 |
String touuid_id, |
162 |
String toname_id) throws SQLException {
|
|
161 |
String toname_id) { |
|
163 | 162 |
String FROM_QUERY = " FROM TaxonRelationship tr " + |
164 | 163 |
"INNER JOIN TaxonBase tb on tr.relatedto_id = tb.id " + |
165 | 164 |
"INNER JOIN TaxonNode tn on tb.id = tn.taxon_id "; |
... | ... | |
182 | 181 |
* |
183 | 182 |
* @param tableName |
184 | 183 |
* @return |
185 |
* @throws SQLException |
|
186 | 184 |
*/ |
187 |
public static QueryDelegate generateTableQuery(String tableName) throws SQLException {
|
|
185 |
public static QueryDelegate generateTableQuery(String tableName) { |
|
188 | 186 |
String FROM_QUERY = " FROM " + tableName; |
189 | 187 |
String SELECT_QUERY=" SELECT * " + |
190 | 188 |
FROM_QUERY; |
... | ... | |
194 | 192 |
return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
195 | 193 |
} |
196 | 194 |
|
197 |
public static QueryDelegate generateQueryDelegate(String SELECT_QUERY, String COUNT_QUERY, String CONTAINS_QUERY) throws SQLException {
|
|
195 |
public static QueryDelegate generateQueryDelegate(String SELECT_QUERY, String COUNT_QUERY, String CONTAINS_QUERY) { |
|
198 | 196 |
FreeformQuery query = new FreeformQuery("This query is not used", CdmSpringContextHelper.getCurrent().getConnectionPool(), ID); |
199 | 197 |
CdmStatementDelegate delegate = new CdmStatementDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY); |
200 | 198 |
query.setDelegate(delegate); |
201 | 199 |
return query; |
202 | 200 |
} |
203 |
|
|
204 | 201 |
} |
Also available in: Unified diff
ref #5458 Refactor SQLException handling