use of eu.europa.ec.fisheries.ers.service.search.FilterDetails in project UVMS-ActivityModule-APP by UnionVMS.
the class SearchQueryBuilder method createWherePartForQueryForFilters.
public StringBuilder createWherePartForQueryForFilters(StringBuilder sql, FishingActivityQuery query) {
Map<SearchFilter, FilterDetails> filterMappings = filterMap.getFilterMappings();
Set<SearchFilter> keySet = new HashSet<>();
if (MapUtils.isNotEmpty(query.getSearchCriteriaMap())) {
keySet.addAll(query.getSearchCriteriaMap().keySet());
}
if (MapUtils.isNotEmpty(query.getSearchCriteriaMapMultipleValues())) {
keySet.addAll(query.getSearchCriteriaMapMultipleValues().keySet());
}
// Create Where part of SQL Query
int i = 0;
for (SearchFilter key : keySet) {
if (!appendWhereQueryPart(sql, filterMappings, keySet, i, key)) {
continue;
}
i++;
}
return sql;
}
use of eu.europa.ec.fisheries.ers.service.search.FilterDetails in project UVMS-ActivityModule-APP by UnionVMS.
the class SearchQueryBuilder method createJoinTablesPartForQuery.
/**
* Create Table Joins based on Filters provided by user. Avoid joining unnecessary tables
*
* @param sql
* @param query
* @return
*/
public StringBuilder createJoinTablesPartForQuery(StringBuilder sql, FishingActivityQuery query) {
LOG.debug("Create Join Tables part of Query");
Map<SearchFilter, FilterDetails> filterMappings = filterMap.getFilterMappings();
Set<SearchFilter> keySet = new HashSet<>();
if (MapUtils.isNotEmpty(query.getSearchCriteriaMap())) {
keySet.addAll(query.getSearchCriteriaMap().keySet());
}
if (MapUtils.isNotEmpty(query.getSearchCriteriaMapMultipleValues())) {
keySet.addAll(query.getSearchCriteriaMapMultipleValues().keySet());
}
for (SearchFilter key : keySet) {
FilterDetails details = filterMappings.get(key);
String joinString = null;
if (details != null) {
joinString = details.getJoinString();
}
if (joinString == null || sql.indexOf(joinString) != -1) {
// If the Table join for the Filter is already present in SQL, do not join the table again
continue;
}
completeQueryDependingOnKey(sql, key, joinString);
}
getJoinPartForSortingOptions(sql, query);
// LOG.debug("Generated SQL for JOIN Part :" + sql);
return sql;
}
Aggregations