use of eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery 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.search.v1.MovementQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class MovementModuleServiceBean method addRangeCriteria.
private void addRangeCriteria(Date startDate, Date endDate, MovementQuery movementQuery) {
RangeCriteria rangeCriteria = new RangeCriteria();
rangeCriteria.setKey(RangeKeyType.DATE);
rangeCriteria.setFrom(DateFormatUtils.format(DateUtils.addDays(startDate, -1), "yyyy-MM-dd HH:mm:ss Z"));
rangeCriteria.setTo(DateFormatUtils.format(DateUtils.addDays(endDate, 1), "yyyy-MM-dd HH:mm:ss Z"));
movementQuery.getMovementRangeSearchCriteria().add(rangeCriteria);
}
use of eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class MovementModuleServiceBean method addListCriteria.
private void addListCriteria(List<String> vesselIds, MovementQuery movementQuery) {
for (String vesselId : vesselIds) {
ListCriteria listCriteria = new ListCriteria();
listCriteria.setKey(SearchKey.CONNECT_ID);
listCriteria.setValue(vesselId);
movementQuery.getMovementSearchCriteria().add(listCriteria);
}
}
use of eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery in project UVMS-Docker by UnionVMS.
the class MovementMovementRestIT method createMovementQueryNumberOfLatestReports.
/**
* Creates the movement query number of latest reports.
*
* @param numberPositions the number positions
* @return the movement query
*/
private MovementQuery createMovementQueryNumberOfLatestReports(int numberPositions) {
MovementQuery movementQuery = new MovementQuery();
movementQuery.setExcludeFirstAndLastSegment(false);
ListPagination listPagination = new ListPagination();
listPagination.setListSize(BigInteger.valueOf(1000000));
listPagination.setPage(BigInteger.valueOf(1));
movementQuery.setPagination(listPagination);
ListCriteria listCriteria = new ListCriteria();
listCriteria.setKey(SearchKey.NR_OF_LATEST_REPORTS);
listCriteria.setValue("" + numberPositions);
movementQuery.getMovementSearchCriteria().add(listCriteria);
RangeCriteria rangeCriteria = new RangeCriteria();
rangeCriteria.setKey(RangeKeyType.DATE);
rangeCriteria.setFrom("2017-09-25 15:33:14 +0200");
rangeCriteria.setTo("2017-10-09 15:33:14 +0200");
movementQuery.getMovementRangeSearchCriteria().add(rangeCriteria);
return movementQuery;
}
use of eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery in project UVMS-Docker by UnionVMS.
the class MovementMovementRestIT method createMovementQuery.
/**
* Creates the movement query.
*
* @return the movement query
*/
private MovementQuery createMovementQuery() {
MovementQuery movementQuery = new MovementQuery();
movementQuery.setExcludeFirstAndLastSegment(false);
ListPagination listPagination = new ListPagination();
listPagination.setListSize(BigInteger.valueOf(100));
listPagination.setPage(BigInteger.valueOf(1));
movementQuery.setPagination(listPagination);
ListCriteria listCriteria = new ListCriteria();
listCriteria.setKey(SearchKey.CONNECT_ID);
listCriteria.setValue("Some connectId");
movementQuery.getMovementSearchCriteria().add(listCriteria);
return movementQuery;
}
Aggregations