Package com.opengamma.id

Examples of com.opengamma.id.UniqueIdentifiable


    final Map<Pair<Double, Double>, Double> values = new HashMap<Pair<Double, Double>, Double>();
    for (int i = 0; i < xs.length; i++) {
      values.put(Pair.of(xs[i], ys[i]), vols[i]);
    }
    final String name = "test";
    final UniqueIdentifiable target = Currency.USD;
    final VolatilitySurfaceData<Double, Double> data = new VolatilitySurfaceData<Double, Double>(name, name, target, xs, ys, values);
    assertArrayEquals(xs, data.getXs());
    assertArrayEquals(ys, data.getYs());
    assertArrayEquals(new Double[]{1., 2., 3., 4.}, data.getUniqueXValues().toArray(new Double[3]));
    assertEquals(Arrays.asList(Pair.of(4., 10.), Pair.of(5., 11.), Pair.of(6., 12.)), data.getYValuesForX(1.));
View Full Code Here


    Mockito.when(second.deepResolver()).thenReturn(deepSecond);
    final ObjectResolver chained = ChainedResolver.CREATE.execute(second, first);
    final DeepResolver deep = chained.deepResolver();
    final ResolutionLogger logger = Mockito.mock(ResolutionLogger.class);
    assertNotNull(deep);
    UniqueIdentifiable o1 = Mockito.mock(UniqueIdentifiable.class);
    UniqueIdentifiable o2 = Mockito.mock(UniqueIdentifiable.class);
    Mockito.when(deepFirst.withLogger(o1, logger)).thenReturn(o1);
    Mockito.when(deepFirst.withLogger(o2, logger)).thenReturn(null);
    Mockito.when(deepSecond.withLogger(o2, logger)).thenReturn(o2);
    assertSame(deep.withLogger(o1, logger), o1);
    assertSame(deep.withLogger(o2, logger), o2);
View Full Code Here

        _portfolioGrid = _portfolioGrid.withUpdatedRows(_portfolioSupplier.get());
        // return the IDs of all grids because the portfolio structure has changed
        // TODO if we had separate IDs for rows and columns it would save the client rebuilding the column metadata
        return getGridIds();
      } else {
        UniqueIdentifiable entity = notification.getEntity();
        _cache.put(entity);
        List<ObjectId> entityIds = Lists.newArrayList(entity.getUniqueId().getObjectId());
        // TODO get rid of this duplication when ManageablePosition implements Position
        // TODO would it be nicer to have a getEntities() method on MasterChangeNotification?
        // would need different impls for different entity types. probably not worth it
        if (entity instanceof Position) {
          for (Trade trade : ((Position) entity).getTrades()) {
View Full Code Here

    return message;
  }

  @Override
  public FuturePriceCurveSpecification buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
    final UniqueIdentifiable target = deserializer.fieldValueToObject(UniqueIdentifiable.class, message.getByName("target"));
    final String name = message.getString("name");
    final FudgeField field = message.getByName("curveInstrumentProvider");
    Object providerObject = deserializer.fieldValueToObject(field);
    final FuturePriceCurveInstrumentProvider<?> curveInstrumentProvider = (FuturePriceCurveInstrumentProvider<?>) deserializer.fieldValueToObject(field);
    return new FuturePriceCurveSpecification(name, target, curveInstrumentProvider);
View Full Code Here

  protected TempTargetRepository getTempTargets() {
    return _tempTargets;
  }

  protected ViewEvaluationTarget getTarget(final ComputationTargetSpecification targetSpec) {
    final UniqueIdentifiable targetObject = getTempTargets().get(targetSpec.getUniqueId());
    if (!(targetObject instanceof ViewEvaluationTarget)) {
      s_logger.warn("Invalid ViewEvaluationTarget {} for {}", targetObject, targetSpec);
      return null;
    }
    return (ViewEvaluationTarget) targetObject;
View Full Code Here

    // DeepResolver

    @Override
    public UniqueIdentifiable withLogger(final UniqueIdentifiable underlying, final ResolutionLogger logger) {
      UniqueIdentifiable result = _first.withLogger(underlying, logger);
      if (result == null) {
        result = _second.withLogger(underlying, logger);
      }
      return result;
    }
View Full Code Here

    ComputationTarget target = _underlying.resolve(specification);
    if (target != null) {
      final ObjectResolver<?> resolver = getResolver(specification);
      final DeepResolver deep = resolver.deepResolver();
      if (deep != null) {
        final UniqueIdentifiable logged = deep.withLogger(target.getValue(), _specificationResolver);
        if (logged != null) {
          target = ComputationTargetResolverUtils.createResolvedTarget(specification, logged);
        }
      }
    }
View Full Code Here

      final Map<Iterator<ValueSpecification>, ValueRequirement> inputs = new HashMap<Iterator<ValueSpecification>, ValueRequirement>();
      for (final ValueRequirement requirement : requirements) {
        final ComputationTargetReference targetRef = requirement.getTargetReference();
        if (targetRef instanceof ComputationTargetSpecification) {
          final ComputationTargetSpecification targetSpec = targetRef.getSpecification();
          final UniqueIdentifiable requirementTarget = _targetCache.get(targetSpec.getUniqueId());
          if (isAvailable(targetSpec, requirementTarget, requirement)) {
            s_logger.debug("Requirement {} can be satisfied by market data", requirement);
            inputs.put(new SingleItem<ValueSpecification>(new ValueSpecification(requirement.getValueName(), targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "marketdata").get())),
                requirement);
          } else {
View Full Code Here

  @Override
  public ComputationTarget buildObject(FudgeDeserializer deserializer, FudgeMsg message) {
    final ComputationTargetSpecification specification = ComputationTargetReferenceFudgeBuilder.buildObjectImpl(deserializer, message).getSpecification();
    final Class<? extends UniqueIdentifiable> valueType = specification.getType().accept(s_getLeafType, null);
    if (valueType != null) {
      final UniqueIdentifiable value = deserializer.fieldValueToObject(valueType, message.getByName(VALUE_FIELD));
      return new ComputationTarget(specification, value);
    } else {
      return ComputationTarget.NULL;
    }
  }
View Full Code Here

    ComputationTarget result = isDeep ? _frontTargetCacheDeep.get(versionCorrection, specification) : _frontTargetCache.get(specification);
    if (result != null) {
      return result;
    }
    final UniqueId uid = specification.getUniqueId();
    UniqueIdentifiable target = isDeep ? _frontObjectCacheDeep.get(versionCorrection, uid) : _frontObjectCache.get(uid);
    if (target != null) {
      // The cached object may be from an earlier lookup with a different resolution strategy. For example
      // CTSpec[PRIMITIVE, Foo~Bar] will store the UniqueId object in the cache which is not suitable to
      // return for CTSpec[SECURITY, Foo~Bar].
      if (specification.getType().isCompatible(target)) {
        result = ComputationTargetResolverUtils.createResolvedTarget(specification, target);
        final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.putIfAbsent(specification, result);
        if (newResult != null) {
          return newResult;
        } else {
          return result;
        }
      }
    }
    final Object key = isDeep ? Pair.of(uid, versionCorrection) : uid;
    final Element e = _computationTarget.get(key);
    if (e != null) {
      target = (UniqueIdentifiable) e.getObjectValue();
      if (specification.getType().isCompatible(target)) {
        final UniqueIdentifiable existing = isDeep ? _frontObjectCacheDeep.putIfAbsent(versionCorrection, uid, target) : _frontObjectCache.putIfAbsent(uid, target);
        if (existing != null) {
          result = ComputationTargetResolverUtils.createResolvedTarget(specification, existing);
        } else {
          result = ComputationTargetResolverUtils.createResolvedTarget(specification, target);
        }
        final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.put(specification, result);
        if (newResult != null) {
          return newResult;
        } else {
          return result;
        }
      }
    }
    result = super.resolve(specification, versionCorrection);
    if (result != null) {
      final UniqueIdentifiable existing = isDeep ? _frontObjectCacheDeep.putIfAbsent(versionCorrection, uid, result.getValue()) : _frontObjectCache.putIfAbsent(uid, result.getValue());
      if (existing == null) {
        addToCacheImpl(key, result.getValue());
      }
      final ComputationTarget newResult = isDeep ? _frontTargetCacheDeep.putIfAbsent(versionCorrection, specification, result) : _frontTargetCache.putIfAbsent(specification, result);
      if (newResult != null) {
View Full Code Here

TOP

Related Classes of com.opengamma.id.UniqueIdentifiable

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.