Search in sources :

Example 41 with ServiceException

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;
        }
    }
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) ArrayList(java.util.ArrayList) List(java.util.List) FilterMap(eu.europa.ec.fisheries.ers.service.search.FilterMap) Map(java.util.Map)

Example 42 with ServiceException

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);
    }
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) FilterMap(eu.europa.ec.fisheries.ers.service.search.FilterMap) Map(java.util.Map)

Aggregations

ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)42 ArrayList (java.util.ArrayList)11 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)9 Geometry (com.vividsolutions.jts.geom.Geometry)8 ParseException (com.vividsolutions.jts.io.ParseException)7 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)7 TextMessage (javax.jms.TextMessage)7 List (java.util.List)6 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)5 GroupCriteria (eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)5 JMSException (javax.jms.JMSException)5 FilterMap (eu.europa.ec.fisheries.ers.service.search.FilterMap)4 Map (java.util.Map)4 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)3 GroupCriteriaMapper (eu.europa.ec.fisheries.ers.service.search.GroupCriteriaMapper)3 AssetModelMapperException (eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException)3 AreaIdentifierType (eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType)3 EnumMap (java.util.EnumMap)3 NotNull (org.jetbrains.annotations.NotNull)3