Package com.opengamma.engine

Examples of com.opengamma.engine.ComputationTarget


      spec = getResolver().getSpecificationResolver().getTargetSpecification(req);
      if (spec == null) {
        return null;
      }
    }
    final ComputationTarget resolved = getResolver().resolve(spec);
    if (resolved == null) {
      return null;
    }
    return resolved.getValue(type);
  }
View Full Code Here


        } else {
          successfulTargets.add(targetSpec);
        }

        // storing target data
        ComputationTarget computationTarget = _computationTargetResolver.resolve(targetSpec, VersionCorrection.LATEST);
        Object targetValue = computationTarget.getValue();
        if (targetValue instanceof Bean) {
          Bean bean = (Bean) targetValue;
          for (String propertyName : bean.propertyNames()) {
            Property<Object> property = bean.property(propertyName);
            final long targetPropertyId = nextId(RSK_SEQUENCE_NAME);
View Full Code Here

    final String calculationConfigName = "config_1";

    EquitySecurity aapl = new EquitySecurity("EXCH", "EXCH_CODE", "APPLE", Currency.USD);
    aapl.setUniqueId(UniqueId.of("Sec", "APPL"));
    ComputationTarget target = new ComputationTarget(ComputationTargetType.SECURITY, aapl);
    computationTargetResolver.addTarget(target);

    _compTargetSpec = target.getLeafSpecification();
    _requirement = new ValueRequirement("FAIR_VALUE", _compTargetSpec);
    _specification = new ValueSpecification("FAIR_VALUE", _compTargetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "IDENTITY_FUNCTION").get());

    final Instant _valuationTime = Instant.parse("2011-12-14T14:20:17.143Z");
View Full Code Here

  public Object get(ComputationTargetType type, ExternalId identifier) {
    final ComputationTargetSpecification specification = getResolver().getSpecificationResolver().getTargetSpecification(new ComputationTargetRequirement(type, identifier));
    if (specification == null) {
      return null;
    }
    final ComputationTarget target = getResolver().resolve(specification);
    if (target == null) {
      return null;
    }
    return target.getValue();
  }
View Full Code Here

      node.addChildNode(createNode(node.getUniqueId(), depth - 1));
      node.addChildNode(createNode(node.getUniqueId(), depth - 1));
    }
    node.addPosition(createPosition());
    node.addPosition(createPosition());
    addTarget(new ComputationTarget(ComputationTargetType.PORTFOLIO_NODE, portfolioNode(node)));
    return node;
  }
View Full Code Here

      }

    };
    trade.setUniqueId(UniqueId.of("Trade", Integer.toString(_tradeId++)));
    trade.setSecurityLink(security(security));
    addTarget(new ComputationTarget(ComputationTargetType.TRADE, trade(trade)));
    position.addTrade(trade);
    addTarget(new ComputationTarget(ComputationTargetType.POSITION, position(position)));
    return position;
  }
View Full Code Here

  }

  private Security createSecurity() {
    final Security security = new MockSecurity(_securityId++);
    _securitySource.addSecurity(security);
    addTarget(new ComputationTarget(ComputationTargetType.SECURITY, security));
    return security;
  }
View Full Code Here

    final ComputationTargetResolver.AtVersionCorrection underlying = Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class);
    final ConcurrentMap<ComputationTargetReference, UniqueId> resolutions = new ConcurrentHashMap<ComputationTargetReference, UniqueId>();
    final Set<UniqueId> expiredResolutions = new HashSet<UniqueId>();
    final ComputationTargetResolver.AtVersionCorrection resolver = TargetResolutionLogger.of(underlying, resolutions, expiredResolutions);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    final ComputationTarget target = new ComputationTarget(spec.replaceIdentifier(UniqueId.of("Foo", "Bar", "Cow")), new Primitive(UniqueId.of("Foo", "Bar", "Cow")));
    Mockito.when(underlying.resolve(spec)).thenReturn(target);
    final ObjectResolver shallowResolver = Mockito.mock(ObjectResolver.class);
    Mockito.when(underlying.getResolver(spec)).thenReturn(shallowResolver);
    assertSame(resolver.resolve(spec), target);
  }
View Full Code Here

    final ComputationTargetResolver.AtVersionCorrection underlying = Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class);
    final ConcurrentMap<ComputationTargetReference, UniqueId> resolutions = new ConcurrentHashMap<ComputationTargetReference, UniqueId>();
    final Set<UniqueId> expiredResolutions = new HashSet<UniqueId>();
    final ComputationTargetResolver.AtVersionCorrection resolver = TargetResolutionLogger.of(underlying, resolutions, expiredResolutions);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    final ComputationTarget target = new ComputationTarget(spec.replaceIdentifier(UniqueId.of("Foo", "Bar", "Cow")), new Primitive(UniqueId.of("Foo", "Bar", "Cow")));
    Mockito.when(underlying.resolve(spec)).thenReturn(target);
    final ObjectResolver deepResolver = Mockito.mock(ObjectResolver.class);
    Mockito.when(deepResolver.deepResolver()).thenReturn(new DeepResolver() {
      @SuppressWarnings("serial")
      @Override
      public UniqueIdentifiable withLogger(final UniqueIdentifiable underlying, final ResolutionLogger logger) {
        assertSame(underlying, target.getValue());
        return new Primitive(UniqueId.of("Foo", "Bar", "Cow")) {
          @Override
          public int hashCode() {
            // Pretend that this is a deep-resolving operation
            logger.log(spec, underlying.getUniqueId());
            return super.hashCode();
          }
        };
      }
    });
    Mockito.when(underlying.getResolver(spec)).thenReturn(deepResolver);
    final ComputationTarget resolvedTarget = resolver.resolve(spec);
    assertNotSame(resolvedTarget, target);
    assertTrue(resolutions.isEmpty());
    resolvedTarget.getValue().hashCode();
    assertFalse(resolutions.isEmpty());
  }
View Full Code Here

  private static final SimplePortfolioNode NODE = new SimplePortfolioNode(UniqueId.of("A", "B", "C"), "Name");
  private static final Position POSITION = new SimplePosition(UniqueId.of("Test", "1", "0"), new BigDecimal(1), ExternalIdBundle.EMPTY);

  public void testCreateResolvedTarget_noRewrite() {
    // No re-write
    ComputationTarget target = ComputationTargetResolverUtils.createResolvedTarget(
        new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO_NODE, NODE.getUniqueId()).containing(ComputationTargetType.POSITION, POSITION.getUniqueId()), POSITION);
    assertEquals(target.getType(), ComputationTargetType.PORTFOLIO_NODE.containing(ComputationTargetType.of(SimplePosition.class)));
    assertEquals(target.getContextSpecification(), ComputationTargetSpecification.of(NODE));
    assertSame(target.getValue(), POSITION);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.ComputationTarget

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.