Package com.opengamma.engine.target

Examples of com.opengamma.engine.target.ComputationTargetReference


      _shift = shift;
    }

    @Override
    public Object apply(final ValueRequirement valueRequirement, final Object value) {
      final ComputationTargetReference targetSpec = valueRequirement.getTargetReference();
      // Only shift equities
      if (targetSpec.getType().isTargetType(ComputationTargetType.SECURITY) || !MarketDataRequirementNames.MARKET_VALUE.equals(valueRequirement.getValueName())) {
        return value;
      }
      final ExternalIdBundle bundle = targetSpec.accept(new ComputationTargetReferenceVisitor<ExternalIdBundle>() {

        @Override
        public ExternalIdBundle visitComputationTargetRequirement(final ComputationTargetRequirement requirement) {
          return requirement.getIdentifiers();
        }
View Full Code Here


      String contraintStr = constraints.isEmpty() ? "" : constraints.toString();

      String constrainedValueName = valueName + contraintStr;

      ComputationTargetReference targetReference = valueRequirement.getTargetReference();
      String targetType = targetReference.getType().toString();

      if (targetReference instanceof ComputationTargetRequirement) {
        ComputationTargetRequirement requirement = (ComputationTargetRequirement) targetReference;
        Set<ExternalId> externalIds = requirement.getIdentifiers().getExternalIds();
        ArgumentChecker.isTrue(externalIds.size() == 1, "One (and only one) external id must be specified currently.");
View Full Code Here

  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()) {
View Full Code Here

        targetEids = ((ExternalBundleIdentifiable) target.getValue()).getExternalIdBundle();
      } else {
        targetEids = null;
      }
      final ComputationTargetSpecification targetSpec = target.toSpecification();
      final ComputationTargetReference targetContextSpec = target.getContextSpecification();
      final ComputationTargetReferenceVisitor<Set<String>> getTargetType = new ComputationTargetReferenceVisitor<Set<String>>() {

        @Override
        public Set<String> visitComputationTargetRequirement(final ComputationTargetRequirement requirement) {
          if (target.getUniqueId() == null) {
View Full Code Here

    assertTrue(b.isCompatible(a));
  }

  @Test(expectedExceptions = {IllegalStateException.class })
  public void test_getRequirement() {
    final ComputationTargetReference a = ComputationTargetSpecification.of(SECURITY);
    a.getRequirement();
  }
View Full Code Here

    final ComputationTargetReference a = ComputationTargetSpecification.of(SECURITY);
    a.getRequirement();
  }

  public void test_getSpecification() {
    final ComputationTargetReference a = ComputationTargetSpecification.of(SECURITY);
    assertEquals(a.getSpecification(), a);
  }
View Full Code Here

    final ComputationTargetReference a = ComputationTargetSpecification.of(SECURITY);
    assertEquals(a.getSpecification(), a);
  }

  public void testContaining_id() {
    final ComputationTargetReference ref = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Foo", "Bar"));
    final ComputationTargetReference underlying = ref.containing(ComputationTargetType.SECURITY, ExternalId.of("Foo", "Underlying"));
    assertEquals(underlying.getParent(), ref);
    assertEquals(underlying.getType(), ComputationTargetType.SECURITY.containing(ComputationTargetType.SECURITY));
  }
View Full Code Here

    assertEquals(underlying.getParent(), ref);
    assertEquals(underlying.getType(), ComputationTargetType.SECURITY.containing(ComputationTargetType.SECURITY));
  }

  public void testContaining_uid() {
    final ComputationTargetReference ref = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Foo", "Bar"));
    final ComputationTargetReference underlying = ref.containing(ComputationTargetType.SECURITY, UniqueId.of("Foo", "Underlying"));
    assertEquals(underlying.getParent(), ref);
    assertEquals(underlying.getType(), ComputationTargetType.SECURITY.containing(ComputationTargetType.SECURITY));
  }
View Full Code Here

    }
    assertEquals(resolutions.size(), 2);
    assertTrue(resolutions.containsValue(UniqueId.of("Test", "3", "X")));
    assertTrue(resolutions.containsValue(UniqueId.of("Test", "Bar", "OLD")));
    assertEquals(expiredResolutions.size(), 0);
    final ComputationTargetReference ref = new ComputationTargetRequirement(ComputationTargetType.PRIMITIVE, ExternalId.of("Foo", "Bar"));
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "Bar", "NEW"));
    Mockito.when(underlyingResolver.getTargetSpecification(ref)).thenReturn(spec);
    assertSame(specificationResolver.getTargetSpecification(ref), spec);
    assertEquals(resolutions.size(), 2);
    assertTrue(resolutions.containsValue(UniqueId.of("Test", "3", "X")));
View Full Code Here

  /**
   * @param security the target's security
   * @return Engine Function requirements for the current / live price
   */
  protected Set<ValueRequirement> createLivePriceRequirement(Security security) {
    final ComputationTargetReference securityTarget = new ComputationTargetSpecification(ComputationTargetType.SECURITY, security.getUniqueId());
    final ValueRequirement securityValueReq = new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, securityTarget);
    return Collections.singleton(securityValueReq);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.target.ComputationTargetReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.