private static final Set<String> s_ignoreConstraints = ImmutableSet.of(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY, HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY,
HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY, HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY, MARKET_DATA_MODE_PROPERTY, ValuePropertyNames.FUNCTION);
protected ValueRequirement getNestedRequirement(final ComputationTargetResolver.AtVersionCorrection resolver, final ComputationTarget target, final ValueProperties constraints) {
String valueName = ValueRequirementNames.VALUE;
ComputationTargetReference requirementTarget = null;
final ValueProperties.Builder requirementConstraints = ValueProperties.builder();
if (constraints.getProperties() != null) {
for (final String constraintName : constraints.getProperties()) {
final Set<String> constraintValues = constraints.getValues(constraintName);
if (VALUE_PROPERTY.equals(constraintName)) {
if (constraintValues.isEmpty()) {
valueName = ValueRequirementNames.VALUE;
} else if (constraintValues.size() > 1) {
return null;
} else {
valueName = constraintValues.iterator().next();
}
} else if (TARGET_SPECIFICATION_PROPERTY.equals(constraintName)) {
if (constraintValues.isEmpty() || constraintValues.contains(TARGET_SPECIFICATION_UNIQUE)) {
requirementTarget = target.toSpecification();
} else if (constraintValues.contains(TARGET_SPECIFICATION_OBJECT)) {
final ComputationTargetSpecification targetSpec = target.toSpecification();
if (targetSpec.getUniqueId() != null) {
requirementTarget = ComputationTargetResolverUtils.simplifyType(targetSpec.replaceIdentifier(target.getUniqueId().toLatest()), resolver);
} else {
// Null - special case
requirementTarget = targetSpec;
}
} else if (constraintValues.contains(TARGET_SPECIFICATION_EXTERNAL)) {
final ExternalIdBundle identifiers;
if (target.getValue() instanceof ExternalIdentifiable) {
final ExternalId identifier = ((ExternalIdentifiable) target.getValue()).getExternalId();
if (identifier == null) {
identifiers = ExternalIdBundle.EMPTY;
} else {
identifiers = identifier.toBundle();
}
} else if (target.getValue() instanceof ExternalBundleIdentifiable) {
identifiers = ((ExternalBundleIdentifiable) target.getValue()).getExternalIdBundle();
} else if (target.getValue() == null) {
// Null - special case
identifiers = ExternalIdBundle.EMPTY;
} else {
return null;
}
final ComputationTargetReference context = target.getContextSpecification();
if (context == null) {
requirementTarget = new ComputationTargetRequirement(resolver.simplifyType(target.getType()), identifiers);
} else {
requirementTarget = context.containing(resolver.simplifyType(target.getLeafSpecification().getType()), identifiers);
}
}
} else if (constraintName.startsWith(PASSTHROUGH_PREFIX)) {
final String name = constraintName.substring(PASSTHROUGH_PREFIX.length());
if (constraintValues.isEmpty()) {