//-------------------------------------------------------------------------
@Override
protected SecurityLoaderResult doBulkLoad(SecurityLoaderRequest request) {
ArgumentChecker.notNull(request, "request");
SecurityLoaderResult result = new SecurityLoaderResult();
// find missing
Map<ExternalIdBundle, Security> missingAndForcedIds = findMissing(request, result);
if (missingAndForcedIds.size() == 0) {
return result;
}
// load from provider
Map<ExternalIdBundle, Security> providedMap = _securityProvider.getSecurities(missingAndForcedIds.keySet());
// load any underlying securities
Map<ExternalIdBundle, Security> providedUnderlyingMap = loadUnderlyings(providedMap);
providedUnderlyingMap.keySet().removeAll(providedMap.keySet()); // requested IDs take precedence
// enhance
providedUnderlyingMap = enhance(providedUnderlyingMap);
providedMap = enhance(providedMap);
// store
providedUnderlyingMap = store(providedUnderlyingMap, Collections.<ExternalIdBundle, Security>emptyMap());
if (request.isForceUpdate()) {
providedMap = store(providedMap, missingAndForcedIds);
} else {
providedMap = store(providedMap, Collections.<ExternalIdBundle, Security>emptyMap());
}
// copy data into result
for (Entry<ExternalIdBundle, Security> entry : providedMap.entrySet()) {
result.getResultMap().put(entry.getKey(), entry.getValue().getUniqueId());
if (request.isReturnSecurityObjects()) {
result.getSecurityMap().put(entry.getValue().getUniqueId(), entry.getValue());
}
}
return result;
}