use of un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage in project UVMS-Docker by UnionVMS.
the class RulesRestIT method evaluateFLUXFAQueryMessageMessageTest.
/**
* Evaluate FLUXFA query message message test.
*
* @throws Exception the exception
*/
@Test
@Ignore
public void evaluateFLUXFAQueryMessageMessageTest() throws Exception {
FLUXFAQueryMessage fluxfaQueryMessage = new FLUXFAQueryMessage();
final HttpResponse response = Request.Post(getBaseUrl() + "rules/rest/rules/evaluate/fluxfaquerymessage").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(fluxfaQueryMessage).getBytes()).execute().returnResponse();
Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
use of un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEventServiceBean method getFishingActivityMessage.
@Override
public void getFishingActivityMessage(@Observes @ReceiveFishingActivityRequestEvent EventMessage eventMessage) {
log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "SetFLUXFAReportOrQueryMessageRequest");
try {
TextMessage jmsMessage = eventMessage.getJmsMessage();
SetFLUXFAReportOrQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetFLUXFAReportOrQueryMessageRequest.class);
log.info("SetFLUXFAReportOrQueryMessageRequest unmarshalled");
if (request == null) {
log.error("Unmarshalled SetFLUXFAReportOrQueryMessageRequest is null. Something went wrong during jms comm?!");
return;
}
switch(eventMessage.getMethod()) {
case GET_FLUX_FA_REPORT:
FLUXFAReportMessage fluxFAReportMessage = JAXBMarshaller.unmarshallTextMessage(request.getRequest(), FLUXFAReportMessage.class);
deleteDuplicatedReportsFromXMLDocument(fluxFAReportMessage);
if (CollectionUtils.isNotEmpty(fluxFAReportMessage.getFAReportDocuments())) {
fluxMessageService.saveFishingActivityReportDocuments(fluxFAReportMessage, extractPluginType(request.getPluginType()));
} else {
log.error("[ERROR] After checking faReportDocuments IDs, all of them exist already in Activity DB.. So nothing will be saved!!");
}
break;
case GET_FLUX_FA_QUERY:
log.error("TODO : FAQUERY mappers NOT implemented yet....");
FLUXFAQueryMessage fluxFAQueryMessage = JAXBMarshaller.unmarshallTextMessage(request.getRequest(), FLUXFAQueryMessage.class);
// TODO : Implement me... Map tp real HQl/SQL query and run the query and map the results to FLUXFAReportMessage and send it to
FLUXFAReportMessage faRepQueryResponseAfterMapping = new FLUXFAReportMessage();
activityRulesModuleServiceBean.sendSyncAsyncFaReportToRules(faRepQueryResponseAfterMapping, "getTheOnValueFromSomewahre", request.getRequestType(), jmsMessage.getJMSMessageID());
break;
}
} catch (ActivityModelMarshallException | ServiceException | ActivityModuleException | JMSException e) {
sendError(eventMessage, e);
}
}
use of un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEventServiceBean method getMapToSubscriptionMessage.
@Override
public void getMapToSubscriptionMessage(@Observes @MapToSubscriptionRequestEvent EventMessage message) {
log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "MapToSubscriptionRequestEvent");
try {
TextMessage jmsMessage = message.getJmsMessage();
String jmsCorrelationID = jmsMessage.getJMSMessageID();
String messageReceived = jmsMessage.getText();
SubscriptionDataRequest subscriptionDataRequest = null;
MapToSubscriptionRequest baseRequest = JAXBUtils.unMarshallMessage(messageReceived, MapToSubscriptionRequest.class);
switch(baseRequest.getMessageType()) {
case FLUX_FA_QUERY_MESSAGE:
FLUXFAQueryMessage fluxfaQueryMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAQueryMessage.class);
subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxfaQueryMessage.getFAQuery());
break;
case FLUX_FA_REPORT_MESSAGE:
FLUXFAReportMessage fluxFAReportMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAReportMessage.class);
subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxFAReportMessage);
break;
default:
sendError(message, new IllegalArgumentException("VERBODEN VRUCHT"));
}
subscriptionProducer.sendMessageWithSpecificIds(JAXBUtils.marshallJaxBObjectToString(subscriptionDataRequest), subscriptionProducer.getDestination(), JMSUtils.lookupQueue(MessageConstants.QUEUE_RULES), null, jmsCorrelationID);
} catch (JAXBException | MessageException | JMSException e) {
sendError(message, e);
}
}
use of un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityRulesModuleServiceBean method composeAndSendTripUpdateFaQueryToRules.
@Override
public void composeAndSendTripUpdateFaQueryToRules(String tripId) throws ActivityModuleException {
String sendTo = fishingTripService.getOwnerFluxPartyFromTripId(tripId);
if (StringUtils.isEmpty(sendTo)) {
throw new ActivityModuleException("Owner for the provided Trip Id [ " + tripId + " ] was not found, so the Update Trip Query cannot be executed!");
}
// TODO : Ask cedric where to get this parameter from! or ask Greg
boolean consolidated = false;
FAQuery faQueryForTrip = FaQueryFactory.createFaQueryForTrip(tripId, sendTo, consolidated);
if (faQueryForTrip == null) {
throw new ActivityModuleException("Fa Query is null!! Check the [tripId, sendTo] parameters!");
}
try {
SubscriptionPermissionResponse subscriptionPermissionResponse = permissionChecker.checkPermissionForFaQuery(faQueryForTrip);
if (SubscriptionPermissionAnswer.YES.equals(subscriptionPermissionResponse.getSubscriptionCheck())) {
final List<SubscriptionParameter> parameters = subscriptionPermissionResponse.getParameters();
String dataFlow = extractParameterByName(parameters, "DF");
// TODO : mocking up df value untill subscription is ready
if (StringUtils.isEmpty(dataFlow)) {
dataFlow = "urn:un:unece:uncefact:fisheries:FLUX:FA:EU:2";
}
// TODO : END Mocking
if (StringUtils.isEmpty(dataFlow)) {
log.error("[ERROR] Subscription is missing the dataFlow parameter! Cannot send FaQuery! ");
throw new ActivityModuleException("Subscription is missing the dataFlow parameter! Cannot send FaQuery!");
}
String logId = faQueryForTrip.getID().getValue();
FLUXFAQueryMessage fluxfaQueryMessage = new FLUXFAQueryMessage(faQueryForTrip);
final String faqReqStr = JAXBMarshaller.marshallJaxBObjectToString(fluxfaQueryMessage);
// TODO : change this values (username, senderOrReceiver (Node name?)) when got answer from CEDRIC
// senderOrReceiver : From subscription
// FR : system parameter
// username : Mock to FLUX
rulesProducerBean.sendModuleMessage(RulesModuleRequestMapper.createSendFaQueryMessageRequest(faqReqStr, "FLUX", logId, dataFlow, "BEL"), activityConsumerBean.getDestination());
} else {
throw new ActivityModuleException("The FaQuery that was build with the following parameters [" + tripId + "," + sendTo + ",consolidated : " + consolidated + "] doesn't match to any subscription!");
}
} catch (MessageException | RulesModelMapperException | ActivityModelMarshallException e) {
log.error("[ERROR] Error while trying to ActivityRulesModuleService.composeAndSendTripUpdateFaQueryToRules(...)!", e);
throw new ActivityModuleException("JAXBException or MessageException!", e);
}
}
Aggregations