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);
}
}
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;
}
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);
}
Aggregations