Search in sources :

Example 1 with GetNonUniqueIdsRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method getNonUniqueIdsRequest.

@Override
public void getNonUniqueIdsRequest(@Observes @GetNonUniqueIdsRequestEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "Non Matching Ids of different Tables : ");
    try {
        log.debug(message.getJmsMessage().getText());
        GetNonUniqueIdsRequest getNonUniqueIdsRequest = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), GetNonUniqueIdsRequest.class);
        GetNonUniqueIdsResponse faCatchSummaryReportResponse = matchingIdsService.getMatchingIdsResponse(getNonUniqueIdsRequest.getActivityUniquinessLists());
        String response = JAXBMarshaller.marshallJaxBObjectToString(faCatchSummaryReportResponse);
        producer.sendResponseMessageToSender(message.getJmsMessage(), response);
    } catch (ActivityModelMarshallException | JMSException | MessageException e) {
        sendError(message, e);
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) GetNonUniqueIdsRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) JMSException(javax.jms.JMSException)

Example 2 with GetNonUniqueIdsRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method deleteDuplicatedReportsFromXMLDocument.

private void deleteDuplicatedReportsFromXMLDocument(FLUXFAReportMessage repMsg) {
    GetNonUniqueIdsRequest getNonUniqueIdsRequest = null;
    try {
        getNonUniqueIdsRequest = ActivityModuleRequestMapper.mapToGetNonUniqueIdRequestObject(collectAllIdsFromMessage(repMsg));
    } catch (ActivityModelMarshallException e) {
        log.error("[ERROR] Error while trying to get the unique ids from FaReportDocumentIdentifiers table...");
    }
    GetNonUniqueIdsResponse matchingIdsResponse = matchingIdsService.getMatchingIdsResponse(getNonUniqueIdsRequest.getActivityUniquinessLists());
    List<ActivityUniquinessList> activityUniquinessLists = matchingIdsResponse.getActivityUniquinessLists();
    final List<FAReportDocument> faReportDocuments = repMsg.getFAReportDocuments();
    if (CollectionUtils.isNotEmpty(activityUniquinessLists)) {
        for (ActivityUniquinessList unique : activityUniquinessLists) {
            deleteBranchesThatMatchWithTheIdsList(unique.getIds(), faReportDocuments);
        }
    }
}
Also used : ActivityUniquinessList(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) GetNonUniqueIdsRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)

Example 3 with GetNonUniqueIdsRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageConsumerBeanTest method testOnMessageMethod.

@Test
@SneakyThrows
public void testOnMessageMethod() {
    mockStatic(MappedDiagnosticContext.class);
    PowerMockito.doNothing().when(MappedDiagnosticContext.class, "addMessagePropertiesToThreadMappedDiagnosticContext", Mockito.any(TextMessage.class));
    for (ActivityModuleMethod moduleMethod : ActivityModuleMethod.values()) {
        GetNonUniqueIdsRequest request = new GetNonUniqueIdsRequest();
        request.setMethod(moduleMethod);
        ActiveMQTextMessage textMessage = new ActiveMQTextMessage(session);
        final String strReq = JAXBMarshaller.marshallJaxBObjectToString(request);
        Whitebox.setInternalState(textMessage, "text", new SimpleString(strReq));
        consumer.onMessage(textMessage);
        PowerMockito.verifyStatic();
        MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
    }
    verify(mapToSubscriptionRequest, times(1)).fire(any(EventMessage.class));
    verify(receiveFishingActivityEvent, times(2)).fire(any(EventMessage.class));
    verify(getFishingTripListEvent, times(1)).fire(any(EventMessage.class));
    verify(getFACatchSummaryReportEvent, times(1)).fire(any(EventMessage.class));
    verify(getNonUniqueIdsRequest, times(1)).fire(any(EventMessage.class));
}
Also used : ActivityModuleMethod(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod) EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) GetNonUniqueIdsRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

GetNonUniqueIdsRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest)3 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)2 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)2 EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)1 ActivityModuleMethod (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod)1 ActivityUniquinessList (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 SneakyThrows (lombok.SneakyThrows)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQTextMessage (org.apache.activemq.artemis.jms.client.ActiveMQTextMessage)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)1