use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class SearchQueryBuilder method applyListValuesToQuery.
/**
* Applies the values stored in the searchCriteriaMapMultipleValues map to the typedQuery
*
* @param searchCriteriaMap
* @param typedQuery
* @return
* @throws ServiceException
*/
private void applyListValuesToQuery(Map<SearchFilter, List<String>> searchCriteriaMap, Query typedQuery) throws ServiceException {
// Assign values to created SQL Query
for (Map.Entry<SearchFilter, List<String>> entry : searchCriteriaMap.entrySet()) {
SearchFilter key = entry.getKey();
List<String> valueList = entry.getValue();
// For WeightMeasure there is no mapping present, In that case
if (queryParameterMappings.get(key) == null) {
continue;
}
if (valueList == null || valueList.isEmpty()) {
throw new ServiceException("valueList for filter " + key + " is null or empty");
}
switch(key) {
case MASTER:
List<String> uppperCaseValList = new ArrayList<>();
for (String val : valueList) {
uppperCaseValList.add(val.toUpperCase());
}
typedQuery.setParameter(queryParameterMappings.get(key), uppperCaseValList);
break;
default:
typedQuery.setParameter(queryParameterMappings.get(key), valueList);
break;
}
}
}
use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class SearchQueryBuilder method applySingleValuesToQuery.
private void applySingleValuesToQuery(Map<SearchFilter, String> searchCriteriaMap, Query typedQuery) throws ServiceException {
// Assign values to created SQL Query
for (Map.Entry<SearchFilter, String> entry : searchCriteriaMap.entrySet()) {
SearchFilter key = entry.getKey();
String value = entry.getValue();
// For WeightMeasure there is no mapping present, In that case
if (queryParameterMappings.get(key) == null) {
continue;
}
if (StringUtils.isEmpty(value)) {
throw new ServiceException("Value for filter " + key + " is null or empty");
}
applyValueDependingOnKey(searchCriteriaMap, typedQuery, key, value);
}
}
Aggregations