use of un.unece.uncefact.data.standard.mdr.communication.MdrGetCodeListResponse 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());
}
}
Aggregations