final List<RemoteViewProcessor> viewProcessors = getRemoteComponentFactory().getViewProcessors();
if (viewProcessors.size() == 0) {
s_logger.warn("No view processors found at {}", getRemoteComponentFactory().getBaseUri());
return;
}
final MarketDataSnapshotMaster marketDataSnapshotMaster = getRemoteComponentFactory().getMarketDataSnapshotMaster(DEFAULT_PREFERRED_CLASSIFIERS);
if (marketDataSnapshotMaster == null) {
s_logger.warn("No market data snapshot masters found at {}", getRemoteComponentFactory().getBaseUri());
return;
}
final Collection<ConfigMaster> configMasters = getRemoteComponentFactory().getConfigMasters().values();
if (configMasters.size() == 0) {
s_logger.warn("No config masters found at {}", getRemoteComponentFactory().getBaseUri());
return;
}
final RemoteViewProcessor viewProcessor = viewProcessors.get(0);
final MarketDataSnapshotter marketDataSnapshotter = viewProcessor.getMarketDataSnapshotter();
Set<ConfigDocument> viewDefinitions = Sets.newHashSet();
for (final ConfigMaster configMaster : configMasters) {
final ConfigSearchRequest<ViewDefinition> request = new ConfigSearchRequest<ViewDefinition>(ViewDefinition.class);
request.setName(viewDefinitionName);
Iterables.addAll(viewDefinitions, ConfigSearchIterator.iterable(configMaster, request));
}
if (viewDefinitions.isEmpty()) {
endWithError("Unable to resolve any view definitions with name '%s'", viewDefinitionName);
}
if (viewDefinitions.size() > 1) {
endWithError("Multiple view definitions resolved when searching for string '%s': %s", viewDefinitionName, viewDefinitions);
}
ConfigItem<?> value = Iterables.get(viewDefinitions, 0).getValue();
StructuredMarketDataSnapshot snapshot = makeSnapshot(marketDataSnapshotter, viewProcessor, (ViewDefinition) value.getValue(), viewExecutionOptions);
final ManageableMarketDataSnapshot manageableMarketDataSnapshot = new ManageableMarketDataSnapshot(snapshot);
manageableMarketDataSnapshot.setName(snapshot.getBasisViewName() + "/" + valuationInstant);
marketDataSnapshotMaster.add(new MarketDataSnapshotDocument(manageableMarketDataSnapshot));
}