Package com.opengamma.engine.marketdata

Examples of com.opengamma.engine.marketdata.MarketDataProvider


                             new ComputationTargetSpecification(ComputationTargetType.POSITION, UniqueId.of("id", "4")),
                             ValueProperties.with(ValuePropertyNames.FUNCTION, "function4").get());

  @Test
  public void permissionProvider() {
    MarketDataProvider historicalProvider1 = mock(MarketDataProvider.class);
    MarketDataProvider historicalProvider2 = mock(MarketDataProvider.class);
    MarketDataProvider baseProvider = mock(MarketDataProvider.class);
    MarketDataPermissionProvider pp1 = mock(MarketDataPermissionProvider.class);
    MarketDataPermissionProvider pp2 = mock(MarketDataPermissionProvider.class);
    MarketDataPermissionProvider pp3 = mock(MarketDataPermissionProvider.class);
    when(historicalProvider1.getPermissionProvider()).thenReturn(pp1);
    when(historicalProvider2.getPermissionProvider()).thenReturn(pp2);
    when(baseProvider.getPermissionProvider()).thenReturn(pp3);
    Set<ValueSpecification> specs = ImmutableSet.of(SPEC1, SPEC2, SPEC3, SPEC4);
    when(pp1.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC1));
    when(pp2.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC2));
    when(pp3.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC3));
    HistoricalShockMarketDataProvider provider =
View Full Code Here


  private MarketDataProviderResolver createResolver() {
    return new MarketDataProviderResolver() {
      @Override
      public MarketDataProvider resolve(UserPrincipal marketDataUser, MarketDataSpecification snapshotSpec) {

        MarketDataProvider mock = mock(MarketDataProvider.class);
        when(mock.snapshot(any(MarketDataSpecification.class))).thenReturn(mock(CompositeMarketDataSnapshot.class));
        return mock;
      }
    };
  }
View Full Code Here

    final DependencyGraphBuilderResourceContextBean bean = new DependencyGraphBuilderResourceContextBean();
    final CompiledFunctionService cfs = createFunctionCompilationService();
    cfs.initialize();
    bean.setFunctionCompilationContext(cfs.getFunctionCompilationContext());
    bean.setFunctionResolver(new DefaultFunctionResolver(cfs));
    bean.setMarketDataProviderResolver(new SingleMarketDataProviderResolver(new MarketDataProvider() {

      @Override
      public void addListener(final MarketDataListener listener) {
      }
View Full Code Here

    ArgumentChecker.notEmpty(specs, "specs");
    ArgumentChecker.notNull(resolver, "resolver");
    _user = user;
    _specs = ImmutableList.copyOf(specs);
    if (_specs.size() == 1) {
      final MarketDataProvider provider = resolver.resolve(user, _specs.get(0));
      if (provider == null) {
        throw new IllegalArgumentException("Unable to resolve market data spec " + _specs.get(0));
      }
      _providers = Collections.singletonList(provider);
      _permissionsProvider = provider.getPermissionProvider();
    } else {
      _providers = Lists.newArrayListWithCapacity(_specs.size());
      for (final MarketDataSpecification spec : _specs) {
        final MarketDataProvider provider = resolver.resolve(user, spec);
        if (provider == null) {
          throw new IllegalArgumentException("Unable to resolve market data spec " + spec);
        }
        _providers.add(provider);
      }
View Full Code Here

    s_logger.debug("Resolving {} for {}", snapshotSpec, marketDataUser);
    return getUnderlying().resolve(marketDataUser, snapshotSpec);
  }

  protected MarketDataProvider updateCache(final UserPrincipal marketDataUser, final MarketDataSpecification snapshotSpec, final MarketDataProvider provider) {
    final MarketDataProvider existing = getCache().putIfAbsent(marketDataUser, snapshotSpec, provider);
    if (existing == null) {
      s_logger.debug("Stored cache entry of {} for {}", snapshotSpec, marketDataUser);
      return provider;
    } else {
      s_logger.debug("Using existing cached entry of {} for {}", snapshotSpec, marketDataUser);
View Full Code Here

  // MarketDataProviderResolver

  @Override
  public MarketDataProvider resolve(final UserPrincipal marketDataUser, final MarketDataSpecification snapshotSpec) {
    MarketDataProvider provider = resolveCached(marketDataUser, snapshotSpec);
    if (provider != null) {
      s_logger.info("Already resolved {} for {}", snapshotSpec, marketDataUser);
      return provider;
    }
    provider = resolveUnderlying(marketDataUser, snapshotSpec);
View Full Code Here

    _overrideInjector = overrideInjector;
  }

  @Override
  public MarketDataProvider resolve(UserPrincipal user, MarketDataSpecification marketDataSpec) {
    MarketDataProvider provider = _underlying.resolve(user, marketDataSpec);
    if (provider == null) {
      return null;
    }
    return new MarketDataProviderWithOverride(provider, _overrideInjector);
  }
View Full Code Here

    ArgumentChecker.notNull(marketDataProviderResolver, "marketDataProviderResolver");
    _marketDataProviderResolver = marketDataProviderResolver;
  }

  private MarketDataProviderResolver generateMarketDataProviderResolver() {
    final MarketDataProvider marketDataProvider = getMarketDataProvider() != null ? getMarketDataProvider() : generateMarketDataProvider();
    final MarketDataProviderResolver resolver = new SingleMarketDataProviderResolver(marketDataProvider);
    setMarketDataProviderResolver(resolver);
    return resolver;
  }
View Full Code Here

      final List<MarketDataSpecification> specs,
      final MarketDataProviderResolver resolver) {
    super(user, specs, resolver);
    final MarketDataListener listener = new Listener();
    if (getSpecifications().size() == 1) {
      final MarketDataProvider provider = getProviders().get(0);
      provider.addListener(listener);
      _availabilityProvider = provider.getAvailabilityProvider(getSpecifications().get(0));
    } else {
      int index = 0;
      for (MarketDataProvider provider : getProviders()) {
        provider.addListener(new CompositeListener(index++, listener));
      }
      _availabilityProvider = new CompositeAvailabilityProvider(getProviders(), getSpecifications());
    }
  }
View Full Code Here

  public HistoricalShockMarketDataProvider create(UserPrincipal user, MarketDataSpecification marketDataSpec) {
    if (!(marketDataSpec instanceof HistoricalShockMarketDataSpecification)) {
      throw new IllegalArgumentException("Market data spec must be a HistoricalShockMarketDataSpecification: " + marketDataSpec);
    }
    HistoricalShockMarketDataSpecification shockSpec = (HistoricalShockMarketDataSpecification) marketDataSpec;
    MarketDataProvider provider1 = resolve(user, shockSpec.getHistoricalSpecification1());
    MarketDataProvider provider2 = resolve(user, shockSpec.getHistoricalSpecification2());
    MarketDataProvider baseProvider = resolve(user, shockSpec.getBaseSpecification());
    return new HistoricalShockMarketDataProvider(provider1, provider2, baseProvider);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.marketdata.MarketDataProvider

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.