use of eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processMovement.
@Override
public void processMovement(@Observes @SetMovementEvent ExchangeMessageEvent message) {
try {
SetMovementReportRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetMovementReportRequest.class);
log.info("Process movement:{}", request);
String username;
// A person has created a position
if (MovementSourceType.MANUAL.equals(request.getRequest().getMovement().getSource())) {
username = request.getUsername();
// Send some response to Movement, if it originated from there (manual movement)
ProcessedMovementAck response = MovementModuleResponseMapper.mapProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.common.v1.AcknowledgeTypeType.OK, message.getJmsMessage().getJMSMessageID(), "Movement successfully processed");
producer.sendModuleAckMessage(message.getJmsMessage().getJMSMessageID(), MessageQueue.MOVEMENT_RESPONSE, JAXBMarshaller.marshallJaxBObjectToString(response));
} else // A plugin has reported a position
{
username = request.getRequest().getPluginType().name();
}
String pluginName = request.getRequest().getPluginName();
ServiceResponseType service = exchangeService.getService(pluginName);
PluginType pluginType = request.getRequest().getPluginType();
if (validate(request.getRequest(), service, message.getJmsMessage())) {
MovementBaseType baseMovement = request.getRequest().getMovement();
RawMovementType rawMovement = MovementMapper.getInstance().getMapper().map(baseMovement, RawMovementType.class);
if (rawMovement.getAssetId() != null && rawMovement.getAssetId().getAssetIdList() != null) {
rawMovement.getAssetId().getAssetIdList().addAll(MovementMapper.mapAssetIdList(baseMovement.getAssetId().getAssetIdList()));
}
if (baseMovement.getMobileTerminalId() != null && baseMovement.getMobileTerminalId().getMobileTerminalIdList() != null) {
rawMovement.getMobileTerminal().getMobileTerminalIdList().addAll(MovementMapper.mapMobileTerminalIdList(baseMovement.getMobileTerminalId().getMobileTerminalIdList()));
}
rawMovement.setPluginType(pluginType.value());
rawMovement.setPluginName(pluginName);
rawMovement.setDateRecieved(request.getRequest().getTimestamp());
// TODO: Temporary - probably better to change corr id to have the same though the entire flow; then we can use this to send response to original caller from anywhere needed
rawMovement.setAckResponseMessageID(message.getJmsMessage().getJMSMessageID());
String msg = RulesModuleRequestMapper.createSetMovementReportRequest(PluginTypeMapper.map(pluginType), rawMovement, username);
forwardToRules(msg, message, service);
} else {
log.debug("Validation error. Event sent to plugin {}", message);
}
} catch (ExchangeServiceException e) {
// TODO send back to plugin
} catch (ExchangeModelMarshallException e) {
// Cannot send back fault to unknown sender
log.error("Couldn't map to SetMovementReportRequest when processing movement from plugin:{} {}", message, e);
} catch (JMSException e) {
log.error("Failed to get response queue:{} {}", message, e);
} catch (RulesModelMapperException e) {
log.error("Failed to build Rules momvent request:{} {}", message, e);
;
}
}
use of eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest in project UVMS-Docker by UnionVMS.
the class SetMovementReportRequestJmsIT method createSetReportMovementType.
/**
* Creates the set report movement type.
*
* @param testAsset
* the test asset
* @param mobileTerminalType
* the mobile terminal type
* @param createMovementRequest
* the create movement request
* @return the sets the movement report request
*/
private SetMovementReportRequest createSetReportMovementType(Asset testAsset, MobileTerminalType mobileTerminalType, CreateMovementRequest createMovementRequest) {
final SetMovementReportRequest request = new SetMovementReportRequest();
request.setUsername("vms_admin_com");
request.setDate(new Date());
request.setMethod(ExchangeModuleMethod.SET_MOVEMENT_REPORT);
request.setPluginType(PluginType.NAF);
final SetReportMovementType movementType = new SetReportMovementType();
request.setRequest(movementType);
movementType.setPluginType(PluginType.NAF);
movementType.setTimestamp(new Date());
movementType.setPluginName(mobileTerminalType.getPlugin().getServiceName());
MovementBaseType movementBaseType = new MovementBaseType();
movementType.setMovement(movementBaseType);
MovementActivityType movementActivityType = new MovementActivityType();
movementBaseType.setActivity(movementActivityType);
AssetId assetId = new AssetId();
movementBaseType.setAssetId(assetId);
assetId.setAssetType(AssetType.VESSEL);
AssetIdList assetIdList = new AssetIdList();
{
assetIdList.setIdType(AssetIdType.GUID);
assetIdList.setValue(testAsset.getAssetId().getGuid());
assetId.getAssetIdList().add(assetIdList);
}
{
assetIdList.setIdType(AssetIdType.IRCS);
assetIdList.setValue(testAsset.getIrcs());
assetId.getAssetIdList().add(assetIdList);
}
{
assetIdList.setIdType(AssetIdType.CFR);
assetIdList.setValue(testAsset.getCfr());
assetId.getAssetIdList().add(assetIdList);
}
{
assetIdList.setIdType(AssetIdType.MMSI);
assetIdList.setValue(testAsset.getMmsiNo());
assetId.getAssetIdList().add(assetIdList);
}
movementBaseType.setAssetName(testAsset.getName());
movementBaseType.setComChannelType(MovementComChannelType.NAF);
movementBaseType.setExternalMarking(testAsset.getExternalMarking());
movementBaseType.setFlagState(testAsset.getCountryCode());
movementBaseType.setInternalReferenceNumber(testAsset.getIrcs());
movementBaseType.setIrcs(testAsset.getIrcs());
movementBaseType.setMmsi(testAsset.getMmsiNo());
MobileTerminalId mobileTerminalId = new MobileTerminalId();
mobileTerminalId.setConnectId(mobileTerminalType.getConnectId());
mobileTerminalId.setGuid(mobileTerminalType.getMobileTerminalId().getGuid());
movementBaseType.setMobileTerminalId(mobileTerminalId);
movementBaseType.setMovementType(MovementTypeType.POS);
MovementPoint movementPoint = new MovementPoint();
movementPoint.setLongitude(createMovementRequest.getMovement().getPosition().getLongitude());
movementPoint.setLatitude(createMovementRequest.getMovement().getPosition().getLatitude());
movementPoint.setAltitude(createMovementRequest.getMovement().getPosition().getAltitude());
movementBaseType.setPosition(movementPoint);
movementBaseType.setPositionTime(new Date());
movementBaseType.setReportedCourse(1d);
movementBaseType.setReportedSpeed(1d);
movementBaseType.setSource(MovementSourceType.INMARSAT_C);
movementBaseType.setTripNumber(1d);
return request;
}
Aggregations