Search in sources :

Example 1 with SetFLUXFAReportOrQueryMessageRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.SetFLUXFAReportOrQueryMessageRequest 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);
    }
}
Also used : SetFLUXFAReportOrQueryMessageRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.SetFLUXFAReportOrQueryMessageRequest) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) JMSException(javax.jms.JMSException) ActivityModuleException(eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException) TextMessage(javax.jms.TextMessage)

Aggregations

ActivityModuleException (eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException)1 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 SetFLUXFAReportOrQueryMessageRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.SetFLUXFAReportOrQueryMessageRequest)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 FLUXFAQueryMessage (un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage)1 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)1