Search in sources :

Example 1 with MovementType

use of eu.europa.ec.fisheries.schema.movement.v1.MovementType in project UVMS-ActivityModule-APP by UnionVMS.

the class MovementModuleServiceBean method getMovement.

/**
 * {@inheritDoc}
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<MovementType> getMovement(List<String> vesselIds, Date startDate, Date endDate) throws ServiceException {
    try {
        MovementQuery movementQuery = new MovementQuery();
        addListCriteria(vesselIds, movementQuery);
        addRangeCriteria(startDate, endDate, movementQuery);
        movementQuery.setExcludeFirstAndLastSegment(true);
        String request = MovementModuleRequestMapper.mapToGetMovementMapByQueryRequest(movementQuery);
        String moduleMessage = movementProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage response = activityConsumer.getMessage(moduleMessage, TextMessage.class);
        if (response != null && !isUserFault(response)) {
            List<MovementMapResponseType> mapResponseTypes = MovementModuleResponseMapper.mapToMovementMapResponse(response);
            List<MovementType> movements = new ArrayList<>();
            for (MovementMapResponseType movementMap : mapResponseTypes) {
                movements.addAll(movementMap.getMovements());
            }
            return movements;
        } else {
            throw new ServiceException("FAILED TO GET DATA FROM MOVEMENT");
        }
    } catch (MovementDuplicateException | MovementFaultException | ServiceException | MessageException | JMSException | ModelMapperException e) {
        log.error("Exception in communication with movements", e);
        throw new ServiceException(e.getMessage(), e);
    }
}
Also used : MovementQuery(eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery) MovementFaultException(eu.europa.ec.fisheries.uvms.movement.model.exception.MovementFaultException) MovementDuplicateException(eu.europa.ec.fisheries.uvms.movement.model.exception.MovementDuplicateException) ArrayList(java.util.ArrayList) MovementMapResponseType(eu.europa.ec.fisheries.schema.movement.search.v1.MovementMapResponseType) JMSException(javax.jms.JMSException) MovementType(eu.europa.ec.fisheries.schema.movement.v1.MovementType) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ModelMapperException(eu.europa.ec.fisheries.uvms.movement.model.exception.ModelMapperException) TextMessage(javax.jms.TextMessage) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 2 with MovementType

use of eu.europa.ec.fisheries.schema.movement.v1.MovementType in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBean method interpolatePointFromMovements.

private Geometry interpolatePointFromMovements(List<MovementType> movements, Date activityDate) throws ServiceException {
    if (movements == null || movements.isEmpty()) {
        return null;
    }
    Geometry faReportGeom;
    Collections.sort(movements, new MovementTypeComparator());
    Map<String, MovementType> movementTypeMap = getPreviousAndNextMovement(movements, activityDate);
    MovementType nextMovement = movementTypeMap.get(NEXT);
    MovementType previousMovement = movementTypeMap.get(PREVIOUS);
    try {
        if (previousMovement == null && nextMovement == null) {
            faReportGeom = null;
        } else if (nextMovement == null) {
            faReportGeom = GeometryMapper.INSTANCE.wktToGeometry(previousMovement.getWkt()).getValue();
            faReportGeom.setSRID(dialect.defaultSRID());
        } else if (previousMovement == null) {
            faReportGeom = GeometryMapper.INSTANCE.wktToGeometry(nextMovement.getWkt()).getValue();
            faReportGeom.setSRID(dialect.defaultSRID());
        } else {
            faReportGeom = calculateIntermediatePoint(previousMovement, nextMovement, activityDate);
        }
    } catch (ParseException e) {
        throw new ServiceException(e.getMessage(), e);
    }
    return faReportGeom;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MovementTypeComparator(eu.europa.ec.fisheries.ers.fa.utils.MovementTypeComparator) ParseException(com.vividsolutions.jts.io.ParseException) MovementType(eu.europa.ec.fisheries.schema.movement.v1.MovementType)

Example 3 with MovementType

use of eu.europa.ec.fisheries.schema.movement.v1.MovementType in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBeanTest method getMockedMovements.

private List<MovementType> getMockedMovements() throws ParseException, DatatypeConfigurationException {
    MovementType movementType1 = new MovementType();
    movementType1.setCalculatedCourse(1.0);
    movementType1.setCalculatedSpeed(1.0);
    movementType1.setWkt("MULTIPOINT(11.09245 58.8386666666667,675 859)");
    movementType1.setPositionTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-07-01 09:15:00"));
    MovementType movementType2 = new MovementType();
    movementType2.setCalculatedCourse(1.0);
    movementType2.setCalculatedSpeed(1.0);
    movementType2.setWkt("MULTIPOINT(11.09245 58.8386666666667,675 859)");
    movementType2.setPositionTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-07-01 12:15:00"));
    return Arrays.asList(movementType1, movementType2);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) MovementType(eu.europa.ec.fisheries.schema.movement.v1.MovementType)

Aggregations

MovementType (eu.europa.ec.fisheries.schema.movement.v1.MovementType)3 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 ParseException (com.vividsolutions.jts.io.ParseException)1 MovementTypeComparator (eu.europa.ec.fisheries.ers.fa.utils.MovementTypeComparator)1 MovementMapResponseType (eu.europa.ec.fisheries.schema.movement.search.v1.MovementMapResponseType)1 MovementQuery (eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 ModelMapperException (eu.europa.ec.fisheries.uvms.movement.model.exception.ModelMapperException)1 MovementDuplicateException (eu.europa.ec.fisheries.uvms.movement.model.exception.MovementDuplicateException)1 MovementFaultException (eu.europa.ec.fisheries.uvms.movement.model.exception.MovementFaultException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1