Search in sources :

Example 1 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class AssetModuleServiceBean method getAssetGuids.

@Override
public List<String> getAssetGuids(String vesselSearchStr, String vesselGroupSearch) throws ServiceException {
    List<String> guidsFromVesselSearchStr = null;
    List<String> guidsFromVesselGroup = null;
    String request;
    // Get the list of guids from assets if vesselSearchStr is provided
    if (StringUtils.isNotEmpty(vesselSearchStr)) {
        try {
            request = AssetModuleRequestMapper.createAssetListModuleRequest(createAssetListQuery(vesselSearchStr));
        } catch (AssetModelMapperException e) {
            log.error("Error while trying to map the request for assets Module.", e);
            throw new ServiceException(e.getMessage(), e.getCause());
        }
        guidsFromVesselSearchStr = getGuidsFromAssets(request);
    }
    // If the list of guids is not empty then we have to provide this on the query also
    if (StringUtils.isNotEmpty(vesselGroupSearch)) {
        try {
            request = AssetModuleRequestMapper.createAssetListModuleRequest(createAssetGroupQuery(vesselGroupSearch));
        } catch (AssetModelMapperException e) {
            log.error("Error while trying to map the request for assets Module.", e);
            throw new ServiceException(e.getMessage(), e.getCause());
        }
        guidsFromVesselGroup = getGuidsFromAssets(request);
    }
    return joinResults(guidsFromVesselSearchStr, guidsFromVesselGroup);
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException)

Example 2 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class AssetModuleServiceBean method getGuidsFromAssets.

@NotNull
protected List<String> getGuidsFromAssets(String request) throws ServiceException {
    try {
        String correlationId = assetProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage response = activityConsumer.getMessage(correlationId, TextMessage.class);
        if (response != null && !isUserFault(response)) {
            List<Asset> assets = AssetModuleResponseMapper.mapToAssetListFromResponse(response, correlationId);
            List<String> assetGuids = new ArrayList<>();
            for (Asset asset : assets) {
                assetGuids.add(asset.getAssetId().getGuid());
            }
            return assetGuids;
        } else {
            throw new ServiceException("FAILED TO GET DATA FROM ASSET");
        }
    } catch (ServiceException | MessageException | AssetModelMapperException e) {
        log.error("Exception in communication with movements", e);
        throw new ServiceException(e.getMessage(), e);
    }
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException) TextMessage(javax.jms.TextMessage) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getTripWidgetDto.

@Override
public /**
 *  Returns TripWidgetDto based on the tripId and activityId
 */
TripWidgetDto getTripWidgetDto(FishingActivityEntity activityEntity, String tripId) {
    if (activityEntity == null && tripId == null) {
        return null;
    }
    TripWidgetDto tripWidgetDto = new TripWidgetDto();
    try {
        if (tripId != null) {
            log.debug("Trip Id found for Fishing Activity. Get TripWidget information for tripID :" + tripId);
            TripOverviewDto tripOverviewDto = getTripOverviewDto(activityEntity, tripId);
            List<TripOverviewDto> tripOverviewDtoList = new ArrayList<>();
            tripOverviewDtoList.add(tripOverviewDto);
            tripWidgetDto.setTrips(tripOverviewDtoList);
            if (activityEntity != null && activityEntity.getFaReportDocument() != null && CollectionUtils.isNotEmpty(activityEntity.getFaReportDocument().getVesselTransportMeans())) {
                Set<VesselTransportMeansEntity> vesselTransportMeansEntities = activityEntity.getFaReportDocument().getVesselTransportMeans();
                for (VesselTransportMeansEntity vesselTransportMeansEntity : vesselTransportMeansEntities) {
                    if (vesselTransportMeansEntity.getFishingActivity() == null) {
                        tripWidgetDto.setVesselDetails(getVesselDetailsDTO(vesselTransportMeansEntity, activityEntity));
                        break;
                    }
                }
            }
            // VesselDetailsDTO detailsDTO = getVesselDetailsForFishingTrip(tripId);
            // tripWidgetDto.setVesselDetails(detailsDTO);
            log.debug("tripWidgetDto set for tripID :" + tripId);
        } else {
            log.debug("TripId is not received for the screen. Try to get TripSummary information for all the tripIds specified for FishingActivity:" + activityEntity.getId());
            return createTripWidgetDtoWithFishingActivity(activityEntity);
        }
    } catch (ServiceException e) {
        log.error("Error while creating TripWidgetDto.", e);
    }
    return tripWidgetDto;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) ArrayList(java.util.ArrayList) TripWidgetDto(eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto) TripOverviewDto(eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)

Example 4 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getMdrCodesEnrichWithAssetsModuleDataIfNeeded.

// To process MDR code list and compare with  database:vesselTransportMeansDao and then enrich with asset module
private void getMdrCodesEnrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
    final String ACRONYM = "FLUX_VESSEL_ID_TYPE";
    final String filter = "*";
    final List<String> columnsList = new ArrayList<String>();
    Integer nrOfResults = 9999999;
    if (vesselDetailsDTO != null) {
        List<String> codeList = null;
        try {
            codeList = mdrModuleService.getAcronymFromMdr(ACRONYM, filter, columnsList, nrOfResults, "code").get("code");
            Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
            List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapMdrCodeListToAssetListCriteriaPairList(vesselIdentifiers, codeList);
            log.info("Asset Criteria Pair List size is :" + assetListCriteriaPairs.size());
            log.info("Got code list of size from mdr:" + codeList.size());
            if (null != assetListCriteriaPairs && !CollectionUtils.isEmpty(assetListCriteriaPairs)) {
                AssetListCriteria criteria = new AssetListCriteria();
                // need to set this
                criteria.setIsDynamic(false);
                criteria.getCriterias().addAll(assetListCriteriaPairs);
                AssetListQuery query = new AssetListQuery();
                AssetListPagination assetListPagination = new AssetListPagination();
                // need to set this
                assetListPagination.setPage(1);
                // need to set this
                assetListPagination.setListSize(1000);
                query.setPagination(assetListPagination);
                query.setAssetSearchCriteria(criteria);
                List<Asset> assetList = assetModuleService.getAssetListResponse(query);
                if (null != assetList && !CollectionUtils.isEmpty(assetList)) {
                    vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
                }
            }
        } catch (ServiceException e) {
            log.error("Error while trying to send message to Assets module.", e);
        }
    }
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) ArrayList(java.util.ArrayList) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) AssetListPagination(eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination) BigInteger(java.math.BigInteger) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetListCriteria(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)

Example 5 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method checkThresholdForFishingTripList.

public void checkThresholdForFishingTripList(Set<FishingTripId> fishingTripIds) throws ServiceException {
    if (CollectionUtils.isNotEmpty(fishingTripIds)) {
        String tresholdTrips = activityConfigurationDao.getPropertyValue(ActivityConfiguration.LIMIT_FISHING_TRIPS);
        if (tresholdTrips != null) {
            int threshold = Integer.parseInt(tresholdTrips);
            log.debug("fishing trip threshold value:" + threshold);
            if (fishingTripIds.size() > threshold)
                throw new ServiceException("Fishing Trips found for matching criteria exceed threshold value. Please restrict resultset by modifying filters");
            log.info("fishing trip list size is within threshold value:" + fishingTripIds.size());
        }
    }
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)

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