}
@Override
protected void doRun() throws Exception {
ViewProcessor viewProcessor = getToolContext().getViewProcessor();
ConfigSource configSource = getToolContext().getConfigSource();
String viewDefName = getCommandLine().getOptionValue(VIEW_DEF_NAME_OPTION);
boolean batchMode = getCommandLine().hasOption(BATCH_MODE_OPTION);
ViewResultListener listener;
if (getCommandLine().hasOption(RESULT_LISTENER_CLASS_OPTION)) {
String listenerClass = getCommandLine().getOptionValue(RESULT_LISTENER_CLASS_OPTION);
listener = instantiate(listenerClass, ViewResultListener.class);
} else {
listener = null;
}
String[] marketDataSpecStrs = getCommandLine().getOptionValues(MARKET_DATA_OPTION);
List<MarketDataSpecification> marketDataSpecs = Lists.newArrayListWithCapacity(marketDataSpecStrs.length);
for (String marketDataSpecStr : marketDataSpecStrs) {
try {
marketDataSpecs.add(MarketDataSpecificationParser.parse(marketDataSpecStr));
} catch (IllegalArgumentException e) {
s_logger.warn(MarketDataSpecificationParser.getUsageMessage());
throw e;
}
}
Map<String, Object> paramValues;
if (getCommandLine().hasOption(PARAMETER_SCRIPT_OPTION)) {
String paramScript = getCommandLine().getOptionValue(PARAMETER_SCRIPT_OPTION);
ScenarioDslParameters params = new ScenarioDslParameters(FileUtils.readFileToString(new File(paramScript)));
paramValues = params.getParameters();
} else {
paramValues = null;
}
String simulationScript = getCommandLine().getOptionValue(SIMULATION_SCRIPT_OPTION);
Simulation simulation = SimulationUtils.createSimulationFromDsl(simulationScript, paramValues);
VersionCorrection viewDefVersionCorrection = VersionCorrection.LATEST;
Collection<ConfigItem<ViewDefinition>> viewDefs =
configSource.get(ViewDefinition.class, viewDefName, viewDefVersionCorrection);
if (viewDefs.isEmpty()) {
throw new IllegalStateException("View definition " + viewDefName + " not found");
}
ConfigItem<ViewDefinition> viewDef = viewDefs.iterator().next();
UniqueId viewDefId = viewDef.getUniqueId();