use of eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException in project UVMS-ActivityModule-APP by UnionVMS.
the class MdrModuleServiceBean method getAcronymFromMdr.
@Override
public Map<String, List<String>> getAcronymFromMdr(String acronym, String filter, List<String> filterColumns, Integer nrOfResults, String... returnColumns) throws ServiceException {
Map<String, List<String>> columnNameValuesMap = prepareColumnNameValuesMap(returnColumns);
try {
String request = MdrModuleMapper.createFluxMdrGetCodeListRequest(acronym, filter, filterColumns, nrOfResults);
String correlationId = mdrProducer.sendModuleMessage(request, activityConsumer.getDestination());
TextMessage message = activityConsumer.getMessage(correlationId, TextMessage.class);
if (null != message) {
String messageStr = message.getText();
MdrGetCodeListResponse response = JAXBMarshaller.unmarshallTextMessage(messageStr, MdrGetCodeListResponse.class);
for (ObjectRepresentation objectRep : response.getDataSets()) {
for (ColumnDataType nameVal : objectRep.getFields()) {
if (columnNameValuesMap.containsKey(nameVal.getColumnName())) {
columnNameValuesMap.get(nameVal.getColumnName()).add(nameVal.getColumnValue());
}
}
}
return columnNameValuesMap;
} else {
throw new ServiceException("Unable to get data from MDR Module");
}
} catch (JMSException | MessageException | MdrModelMarshallException | ActivityModelMarshallException e) {
log.error("MdrModelMarshallException in communication with mdr", e.getCause());
throw new ServiceException("Exception caught in mdrModuleServiceBean", e.getCause());
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException 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);
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException 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);
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException 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);
}
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEventServiceBean method getFishingTripList.
@Override
public void getFishingTripList(@Observes @GetFishingTripListEvent EventMessage message) {
log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "FishingTripIds:");
try {
log.debug("JMS Incoming text message: {}", message.getJmsMessage().getText());
FishingTripRequest baseRequest = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), FishingTripRequest.class);
log.debug("FishingTriId Request Unmarshalled");
FishingTripResponse baseResponse = fishingTripService.filterFishingTripsForReporting(FishingActivityRequestMapper.buildFishingActivityQueryFromRequest(baseRequest));
log.debug("FishingTripResponse ::: " + FACatchSummaryHelper.printJsonstructure(baseResponse));
String response = JAXBMarshaller.marshallJaxBObjectToString(baseResponse);
log.debug("FishingTriId response marshalled");
producer.sendResponseMessageToSender(message.getJmsMessage(), response);
log.debug("Response sent back.");
} catch (ActivityModelMarshallException | JMSException | ServiceException | MessageException e) {
sendError(message, e);
}
}
Aggregations