Search in sources :

Example 1 with GetFishingActivitiesForTripResponse

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

the class ActivityEventServiceBean method getFishingActivityForTripsRequest.

@Override
public void getFishingActivityForTripsRequest(@Observes @GetFishingActivityForTripsRequestEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + " Fishing activities related to trips.");
    try {
        log.debug(message.getJmsMessage().getText());
        GetFishingActivitiesForTripRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), GetFishingActivitiesForTripRequest.class);
        GetFishingActivitiesForTripResponse response = activityServiceBean.getFaAndTripIdsFromTripIds(request.getFaAndTripIds());
        String responseStr = JAXBMarshaller.marshallJaxBObjectToString(response);
        producer.sendResponseMessageToSender(message.getJmsMessage(), responseStr);
    } catch (ActivityModelMarshallException | JMSException | ServiceException | MessageException e) {
        sendError(message, e);
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) GetFishingActivitiesForTripRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripRequest) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) JMSException(javax.jms.JMSException)

Example 2 with GetFishingActivitiesForTripResponse

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

the class ActivityServiceBean method getFaAndTripIdsFromTripIds.

@Override
public GetFishingActivitiesForTripResponse getFaAndTripIdsFromTripIds(List<FishingActivityForTripIds> faAndTripIds) throws ServiceException {
    GetFishingActivitiesForTripResponse response = new GetFishingActivitiesForTripResponse();
    List<FaIdsListWithTripIdMap> responseList = new ArrayList<>();
    response.setFaWithIdentifiers(responseList);
    for (FishingActivityForTripIds faTripId : faAndTripIds) {
        List<FishingActivityEntity> fishingActivies = fishingActivityDao.getFishingActivityForTrip(faTripId.getTripId(), faTripId.getTripSchemeId(), faTripId.getFishActTypeCode(), faTripId.getFluxRepDocPurposeCodes());
        for (FishingActivityEntity faEntity : fishingActivies) {
            addToIdsList(responseList, faEntity);
        }
    }
    return response;
}
Also used : FaIdsListWithTripIdMap(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaIdsListWithTripIdMap) FishingActivityForTripIds(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivityForTripIds) ArrayList(java.util.ArrayList) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 3 with GetFishingActivitiesForTripResponse

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

the class ActivityEventServiceBeanTest method setUp.

@Before
@SneakyThrows
public void setUp() {
    nonUniqueIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(nonUniqueIdsMessage, "text", new SimpleString(getStrRequest1()));
    Whitebox.setInternalState(nonUniqueIdsMessage, "jmsCorrelationID", "SomeCorrId");
    nonUniqueIdsMessageEventMessage = new EventMessage(nonUniqueIdsMessage);
    faAndTripIdsFromTripIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "text", new SimpleString(getStrRequest2()));
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "jmsCorrelationID", "SomeCorrId");
    faAndTripIdsFromTripIdsEventMessage = new EventMessage(faAndTripIdsFromTripIdsMessage);
    getNonUniqueIdsResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr1(), GetNonUniqueIdsResponse.class);
    getFishingActivitiesForTripResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr2(), GetFishingActivitiesForTripResponse.class);
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 4 with GetFishingActivitiesForTripResponse

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

the class ActivityServiceBeanTest method testGetFaAndTripIdsResponse.

@Test
@SneakyThrows
public void testGetFaAndTripIdsResponse() {
    List<String> flRepPurpCodes = new ArrayList<String>() {

        {
            add("1");
            add("9");
        }
    };
    when(fishingActivityDao.getFishingActivityForTrip(any(String.class), any(String.class), any(String.class), any(flRepPurpCodes.getClass()))).thenReturn(mockFishActEntities());
    GetFishingActivitiesForTripResponse response = activityService.getFaAndTripIdsFromTripIds(Arrays.asList(new FishingActivityForTripIds("faTypeCode", "tripId", "tripSchemeId", flRepPurpCodes)));
    assertNotNull(response);
    assertTrue(CollectionUtils.isNotEmpty(response.getFaWithIdentifiers()));
}
Also used : FishingActivityForTripIds(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivityForTripIds) ArrayList(java.util.ArrayList) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

GetFishingActivitiesForTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse)4 FishingActivityForTripIds (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivityForTripIds)2 ArrayList (java.util.ArrayList)2 SneakyThrows (lombok.SneakyThrows)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)1 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 FaIdsListWithTripIdMap (eu.europa.ec.fisheries.uvms.activity.model.schemas.FaIdsListWithTripIdMap)1 GetFishingActivitiesForTripRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripRequest)1 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 JMSException (javax.jms.JMSException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQTextMessage (org.apache.activemq.artemis.jms.client.ActiveMQTextMessage)1 Before (org.junit.Before)1 Test (org.junit.Test)1