Search in sources :

Example 6 with FLUXFAReportMessage

use of un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage in project UVMS-Docker by UnionVMS.

the class RulesRestIT method evaluateFLUXFAReportMessageTest.

/**
 * Evaluate FLUXFA report message test.
 *
 * @throws Exception the exception
 */
@Test
@Ignore
public void evaluateFLUXFAReportMessageTest() throws Exception {
    FLUXFAReportMessage fluxfaReportMessage = new FLUXFAReportMessage();
    final HttpResponse response = Request.Post(getBaseUrl() + "rules/rest/rules/evaluate/fluxfareportmessage").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(fluxfaReportMessage).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) HttpResponse(org.apache.http.HttpResponse) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 7 with FLUXFAReportMessage

use of un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapper method mapToFLUXFAReportMessage.

@SneakyThrows
public FLUXFAReportMessage mapToFLUXFAReportMessage(List<FaReportDocumentEntity> faReportMessageEntity) {
    FLUXFAReportMessage target = new FLUXFAReportMessage();
    FLUXReportDocument fluxReportDocument = new FLUXReportDocument();
    CodeType codeType = new CodeType();
    codeType.setValue("9");
    codeType.setListID("FLUX_GP_PURPOSE");
    fluxReportDocument.setPurposeCode(codeType);
    IDType idType = new IDType();
    idType.setSchemeID("UUID");
    idType.setValue(UUID.randomUUID().toString());
    fluxReportDocument.setIDS(Collections.singletonList(idType));
    DateTimeType dateTimeType = new DateTimeType();
    dateTimeType.setDateTime(DateUtils.getCurrentDate());
    fluxReportDocument.setCreationDateTime(dateTimeType);
    TextType textType = new TextType();
    textType.setValue("LOAD_REPORTS");
    fluxReportDocument.setPurpose(textType);
    FLUXParty party = new FLUXParty();
    IDType idType1 = new IDType();
    idType1.setSchemeID("FLUX_GP_PARTY");
    idType1.setValue("TODO_SET_NODE_ALIAS");
    party.setIDS(Collections.singletonList(idType1));
    fluxReportDocument.setOwnerFLUXParty(party);
    target.setFLUXReportDocument(fluxReportDocument);
    if (CollectionUtils.isNotEmpty(faReportMessageEntity)) {
        mapFAReportDocuments(target, faReportMessageEntity);
    }
    return target;
}
Also used : FLUXReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXReportDocument) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) FLUXParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXParty) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._20.TextType) SneakyThrows(lombok.SneakyThrows)

Example 8 with FLUXFAReportMessage

use of un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage 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)

Example 9 with FLUXFAReportMessage

use of un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage 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);
    }
}
Also used : FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) JAXBException(javax.xml.bind.JAXBException) MapToSubscriptionRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest) JMSException(javax.jms.JMSException) SubscriptionDataRequest(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionDataRequest) TextMessage(javax.jms.TextMessage)

Example 10 with FLUXFAReportMessage

use of un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceIT method shouldSaveFaReportDocument.

@Test
public void shouldSaveFaReportDocument() throws Exception {
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("fa_flux_message.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(FLUXFAReportMessage.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    FLUXFAReportMessage fluxfaReportMessage = (FLUXFAReportMessage) jaxbUnmarshaller.unmarshal(is);
    fluxResponseMessageService.saveFishingActivityReportDocuments(fluxfaReportMessage, FaReportSourceEnum.FLUX);
}
Also used : FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Aggregations

FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)10 Test (org.junit.Test)4 FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)3 InputStream (java.io.InputStream)3 JAXBContext (javax.xml.bind.JAXBContext)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 SneakyThrows (lombok.SneakyThrows)3 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)2 ArrayList (java.util.ArrayList)2 JMSException (javax.jms.JMSException)2 TextMessage (javax.jms.TextMessage)2 Before (org.junit.Before)2 FLUXFAQueryMessage (un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage)2 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)2 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 ActivityModuleException (eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException)1 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 MapToSubscriptionRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest)1 SetFLUXFAReportOrQueryMessageRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.SetFLUXFAReportOrQueryMessageRequest)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1