Package com.opengamma.engine

Examples of com.opengamma.engine.ComputationTargetResolver$AtVersionCorrection


    final ExecutorService executor = Executors.newCachedThreadPool();
    try {
      final Map<ComputationTargetReference, UniqueId> resolutions = new HashMap<ComputationTargetReference, UniqueId>();
      resolutions.put(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO, UniqueId.of("Test", "0")), UniqueId.of("Test", "0", "0"));
      final ChangeManager changeManager = new BasicChangeManager();
      final ComputationTargetResolver targetResolver = Mockito.mock(ComputationTargetResolver.class);
      Mockito.when(targetResolver.changeManager()).thenReturn(changeManager);
      final FunctionCompilationContext ctx = new FunctionCompilationContext();
      ctx.setRawComputationTargetResolver(targetResolver);
      final CompiledFunctionService cfs = Mockito.mock(CompiledFunctionService.class);
      Mockito.when(cfs.getFunctionCompilationContext()).thenReturn(ctx);
      final ViewProcessContext vpContext = Mockito.mock(ViewProcessContext.class);
View Full Code Here


    factory.setClientBrokerUri(uri);
    final JmsConnector jmsConnector = factory.getObjectCreating();

    final ViewProcessor viewProcessor = new RemoteViewProcessor(viewProcessorInfo.getUri(), jmsConnector, Executors.newSingleThreadScheduledExecutor());
    // TODO: Not ideal; the published resolver should be used rather than an ad-hoc one created based just on the security source
    final ComputationTargetResolver targetResolver = new DefaultComputationTargetResolver(new RemoteSecuritySource(securitySourceInfo.getUri()));
    return new WatchListRecorder(viewProcessor, targetResolver);
  }
View Full Code Here

  protected CachingComputationTargetResolver createCachedTargetResolver(final ComputationTargetResolver underlying) {
    return new DefaultCachingComputationTargetResolver(underlying, getCacheManager());
  }

  private ComputationTargetResolver initTargetResolver() {
    ComputationTargetResolver resolver = createTargetResolver();
    if (getCacheManager() != null) {
      resolver = createCachedTargetResolver(resolver);
    }
    return resolver;
  }
View Full Code Here

@Test
public class LazyComputationTargetResolverTest {

  public void testPortfolioNode() {
    final MockComputationTargetResolver mock = MockComputationTargetResolver.unresolved();
    final ComputationTargetResolver resolver = new LazyComputationTargetResolver(mock);
    final ComputationTarget target = resolver.resolve(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO_NODE, UniqueId.of("Node", "0")), VersionCorrection.LATEST);
    final PortfolioNode node = target.getPortfolioNode();
    assertEquals(node.getUniqueId(), UniqueId.of("Node", "0"));
    assertEquals(mock.getResolveCalls(), 0);
    assertEquals(node.getName(), "Node 0");
    assertEquals(mock.getResolveCalls(), 1);
View Full Code Here

    assertEquals(mock.getResolveCalls(), 5);
  }

  public void testPosition() {
    final MockComputationTargetResolver mock = MockComputationTargetResolver.unresolved();
    final ComputationTargetResolver resolver = new LazyComputationTargetResolver(mock);
    final ComputationTarget target = resolver.resolve(new ComputationTargetSpecification(ComputationTargetType.POSITION, UniqueId.of("Position", "0")), VersionCorrection.LATEST);
    final Position position = target.getPosition();
    assertEquals(position.getUniqueId(), UniqueId.of("Position", "0"));
    assertEquals(mock.getResolveCalls(), 0);
    assertEquals(position.getAttributes(), Collections.emptyMap());
    assertEquals(position.getQuantity(), BigDecimal.ONE);
View Full Code Here

    assertEquals(mock.getResolveCalls(), 3);
  }

  public void testTrade() {
    final MockComputationTargetResolver mock = MockComputationTargetResolver.unresolved();
    final ComputationTargetResolver resolver = new LazyComputationTargetResolver(mock);
    final ComputationTarget target = resolver.resolve(new ComputationTargetSpecification(ComputationTargetType.TRADE, UniqueId.of("Trade", "0")), VersionCorrection.LATEST);
    final Trade trade = target.getTrade();
    assertEquals(trade.getUniqueId(), UniqueId.of("Trade", "0"));
    assertEquals(mock.getResolveCalls(), 0);
    assertEquals(trade.getAttributes(), Collections.emptyMap());
    trade.setAttributes(ImmutableMap.of("K1", "V1"));
View Full Code Here

    assertEquals(mock.getResolveCalls(), 2);
  }

  public void testSecurity() {
    final MockComputationTargetResolver mock = MockComputationTargetResolver.unresolved();
    final ComputationTargetResolver resolver = new LazyComputationTargetResolver(mock);
    final ComputationTarget target = resolver.resolve(new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "0")), VersionCorrection.LATEST);
    final Security security = target.getSecurity();
    assertEquals(mock.getResolveCalls(), 1);
    assertEquals(security.getSecurityType(), "MOCK");
    assertEquals(mock.getResolveCalls(), 1);
  }
View Full Code Here

      final UniqueId portfolioId = getContext().getViewDefinition().getPortfolioId();
      if (portfolioId == null) {
        throw new OpenGammaRuntimeException("The view definition '" + getContext().getViewDefinition().getName()
            + "' contains required portfolio outputs, but it does not reference a portfolio.");
      }
      final ComputationTargetResolver resolver = getContext().getServices().getFunctionCompilationContext().getRawComputationTargetResolver();
      final ComputationTargetResolver.AtVersionCorrection versioned = resolver.atVersionCorrection(getContext().getResolverVersionCorrection());
      final ComputationTargetSpecification specification = versioned.getSpecificationResolver()
          .getTargetSpecification(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO, portfolioId));
      if (specification == null) {
        throw new OpenGammaRuntimeException("Unable to identify portfolio '" + portfolioId + "' for view '" + getContext().getViewDefinition().getName() + "'");
      }
View Full Code Here

                previousGraphs = getPreviousGraphs(previousGraphs, compiledViewDefinition);
                if ((compiledViewDefinition.getPortfolio() != null) && invalidIdentifiers.containsKey(compiledViewDefinition.getPortfolio().getUniqueId())) {
                  // The portfolio resolution is different, invalidate or rewrite PORTFOLIO and PORTFOLIO_NODE nodes in the graph. Note that incremental
                  // compilation under this circumstance can be flawed if the functions have made notable use of the overall portfolio structure such that
                  // a full re-compilation will yield a different dependency graph to just rewriting the previous one.
                  final ComputationTargetResolver resolver = getProcessContext().getFunctionCompilationService().getFunctionCompilationContext().getRawComputationTargetResolver();
                  final ComputationTargetSpecification portfolioSpec = resolver.getSpecificationResolver().getTargetSpecification(
                      new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO, getViewDefinition().getPortfolioId()), versionCorrection);
                  final ComputationTarget newPortfolio = resolver.resolve(portfolioSpec, versionCorrection);
                  unchangedNodes = rewritePortfolioNodes(previousGraphs, compiledViewDefinition, (Portfolio) newPortfolio.getValue());
                }
                // Invalidate any dependency graph nodes on the invalid targets
                filterPreviousGraphs(previousGraphs, new InvalidTargetDependencyNodeFilter(invalidIdentifiers.keySet()), unchangedNodes);
                previousResolutions = new ConcurrentHashMap<>(resolvedIdentifiers.size());
View Full Code Here

    return graph;
  }

  private FunctionCompilationContext createFunctionCompilationContext() {
    final FunctionCompilationContext context = new FunctionCompilationContext();
    final ComputationTargetResolver targetResolver = Mockito.mock(ComputationTargetResolver.class);
    Mockito.when(targetResolver.resolve(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO, UniqueId.of("Portfolio", "0", "V")), VersionCorrection.LATEST)).thenReturn(
        new ComputationTarget(ComputationTargetType.PORTFOLIO, createPortfolio()));
    Mockito.when(targetResolver.atVersionCorrection(VersionCorrection.LATEST)).thenReturn(Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class));
    context.setRawComputationTargetResolver(targetResolver);
    return context;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.ComputationTargetResolver$AtVersionCorrection

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.