@Override public Map<JmsTopicNameResolveRequest, String> resolve( Collection<JmsTopicNameResolveRequest> requests) { Map<JmsTopicNameResolveRequest, String> returnValue = new HashMap<JmsTopicNameResolveRequest, String>(); Map<String, Collection<JmsTopicNameResolveRequest>> lookupKey2Requests = new HashMap<String, Collection<JmsTopicNameResolveRequest>>(); for (JmsTopicNameResolveRequest request : requests) { ExternalId marketDataUniqueId = request.getMarketDataUniqueId(); if (!marketDataUniqueId.getScheme().equals(SecurityUtils.BLOOMBERG_BUID)) { s_logger.info("No Bloomberg BUID found, was given: " + marketDataUniqueId); returnValue.put(request, null); continue; } String lookupKey = BloombergDomainIdentifierResolver.toBloombergKey(marketDataUniqueId); Collection<JmsTopicNameResolveRequest> requestsForLookupKey = lookupKey2Requests.get(lookupKey); if (requestsForLookupKey == null) { requestsForLookupKey = new ArrayList<JmsTopicNameResolveRequest>(); lookupKey2Requests.put(lookupKey, requestsForLookupKey); } requestsForLookupKey.add(request); } if (!lookupKey2Requests.keySet().isEmpty()) { ReferenceDataResult referenceData = _referenceDataProvider.getFields( lookupKey2Requests.keySet(), BloombergConstants.JMS_TOPIC_NAME_RESOLVER_FIELDS); for (Map.Entry<String, Collection<JmsTopicNameResolveRequest>> entry : lookupKey2Requests.entrySet()) { String lookupKey = entry.getKey(); PerSecurityReferenceDataResult result = referenceData.getResult(lookupKey); for (JmsTopicNameResolveRequest request : entry.getValue()) { String jmsTopicName = getJmsTopicName(request, result); returnValue.put(request, jmsTopicName); } } } return returnValue; }
private String getJmsTopicName( JmsTopicNameResolveRequest request, PerSecurityReferenceDataResult result) { if (result == null) { s_logger.info("No reference data available for " + request); return null; } else if (!result.getExceptions().isEmpty()) { s_logger.info( "Failed to retrieve reference data for " + request + ": " + result.getExceptions()); return null; } FudgeMsg resultFields = result.getFieldData(); final String prefix = "LiveData" + SEPARATOR + "Bloomberg" + SEPARATOR; final String suffix = request.getNormalizationRule().getJmsTopicSuffix(); final String bbgUniqueId = request.getMarketDataUniqueId().getValue(); final String defaultTopicName = prefix + bbgUniqueId + suffix; String bbgSecurityType = resultFields.getString(BloombergConstants.FIELD_SECURITY_TYPE); if (bbgSecurityType == null) { return defaultTopicName; } else if (BBG_VALID_EQUITY_TYPES.contains(bbgSecurityType)) { String bbgExchange = resultFields.getString(BloombergConstants.FIELD_PRIMARY_EXCHANGE_NAME); String bbgTicker = resultFields.getString(BloombergConstants.FIELD_TICKER); if (bbgExchange == null || bbgTicker == null) { return defaultTopicName; } return prefix + "Equity" + SEPARATOR + bbgExchange + SEPARATOR + bbgTicker + suffix; } else if (bbgSecurityType.equals( BloombergConstants.BLOOMBERG_US_DOMESTIC_BOND_SECURITY_TYPE)) { String issuer = resultFields.getString(BloombergConstants.FIELD_ISSUER); String cusip = resultFields.getString(BloombergConstants.FIELD_ID_CUSIP); if (issuer == null || cusip == null) { return defaultTopicName; } return prefix + "Bond" + SEPARATOR + issuer + SEPARATOR + cusip + suffix; } else if (bbgSecurityType.equals(BloombergConstants.BLOOMBERG_GLOBAL_BOND_SECURITY_TYPE)) { String issuer = resultFields.getString(BloombergConstants.FIELD_ISSUER); String isin = resultFields.getString(BloombergConstants.FIELD_ID_ISIN); if (issuer == null || isin == null) { return defaultTopicName; } return prefix + "Bond" + SEPARATOR + issuer + SEPARATOR + isin + suffix; } else if (bbgSecurityType.equals(BloombergConstants.BLOOMBERG_EQUITY_OPTION_SECURITY_TYPE)) { String underlyingTicker = resultFields.getString(BloombergConstants.FIELD_OPT_UNDL_TICKER); String ticker = resultFields.getString(BloombergConstants.FIELD_TICKER); if (underlyingTicker == null || ticker == null) { return defaultTopicName; } return prefix + "EquityOption" + SEPARATOR + underlyingTicker + SEPARATOR + ticker + suffix; } else { return defaultTopicName; } }