Search in sources :

Example 1 with ColumnDataType

use of un.unece.uncefact.data.standard.mdr.communication.ColumnDataType 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());
    }
}
Also used : MdrModelMarshallException(eu.europa.ec.fisheries.uvms.mdr.model.exception.MdrModelMarshallException) ColumnDataType(un.unece.uncefact.data.standard.mdr.communication.ColumnDataType) JMSException(javax.jms.JMSException) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MdrGetCodeListResponse(un.unece.uncefact.data.standard.mdr.communication.MdrGetCodeListResponse) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ArrayList(java.util.ArrayList) List(java.util.List) TextMessage(javax.jms.TextMessage) ObjectRepresentation(un.unece.uncefact.data.standard.mdr.communication.ObjectRepresentation)

Aggregations

ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 MdrModelMarshallException (eu.europa.ec.fisheries.uvms.mdr.model.exception.MdrModelMarshallException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 ColumnDataType (un.unece.uncefact.data.standard.mdr.communication.ColumnDataType)1 MdrGetCodeListResponse (un.unece.uncefact.data.standard.mdr.communication.MdrGetCodeListResponse)1 ObjectRepresentation (un.unece.uncefact.data.standard.mdr.communication.ObjectRepresentation)1