return Collections.singleton(new ValueSpecification(input.getValueName(), input.getTargetSpecification(), properties));
}
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final ComputedValue input = inputs.getAllValues().iterator().next();
final ValueSpecification inputSpec = input.getSpecification();
final SnapshotDataBundle marketData = (SnapshotDataBundle) input.getValue();
final ValueRequirement desiredValue = desiredValues.iterator().next();
final String shift = desiredValue.getConstraint(SHIFT);
final ValueProperties.Builder properties = createValueProperties(inputSpec).with(SHIFT, shift);
final OverrideOperationCompiler compiler = OpenGammaExecutionContext.getOverrideOperationCompiler(executionContext);
if (compiler == null) {
throw new IllegalStateException("No override operation compiler for " + shift + " in execution context");
}
s_logger.debug("Applying {} to {}", shift, marketData);
final OverrideOperation operation = compiler.compile(shift, executionContext.getComputationTargetResolver());
for (final Map.Entry<ExternalIdBundle, Double> dataPoint : marketData.getDataPointSet()) {
s_logger.debug("Applying to {}", dataPoint);
final Object result = operation.apply(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, dataPoint.getKey()),
dataPoint.getValue());
s_logger.debug("Got result {}", result);
if (result instanceof Number) {
dataPoint.setValue(((Number) result).doubleValue());
} else {
s_logger.warn("Result of override operation was not numeric");
}
}
return Collections.singleton(new ComputedValue(new ValueSpecification(inputSpec.getValueName(), inputSpec.getTargetSpecification(), properties.get()), marketData));
}