Package com.opengamma.engine.target

Examples of com.opengamma.engine.target.ComputationTargetReference


   * Securities are already resolved when the functions see the positions, so the logging target resolver will not capture any uses of the security.
   *
   * @param link the link to store - the identifier is taken from this along with the resolved unique identifier
   */
  private void store(final SecurityLink link) {
    final ComputationTargetReference key;
    final UniqueId uid;
    if (link.getTarget() != null) {
      uid = link.getTarget().getUniqueId();
      if (link.getObjectId() != null) {
        key = new ComputationTargetSpecification(ComputationTargetType.SECURITY, uid.toLatest());
View Full Code Here


        return new ComputationTargetRequirement(type, deserializer.fieldValueToObject(ExternalIdBundle.class, field));
      } else {
        return new ComputationTargetSpecification(type, message.getFieldValue(UniqueId.class, field));
      }
    } else {
      ComputationTargetReference result = null;
      final Iterator<ComputationTargetType> itrType = types.iterator();
      for (final FudgeField field : message.getAllByName(IDENTIFIER_FIELD_NAME)) {
        type = itrType.next();
        if (field.getValue() instanceof FudgeMsg) {
          final ExternalIdBundle identifiers = deserializer.fieldValueToObject(ExternalIdBundle.class, field);
          if (result == null) {
            result = new ComputationTargetRequirement(type, identifiers);
          } else {
            result = result.containing(type, identifiers);
          }
        } else {
          final UniqueId identifier = message.getFieldValue(UniqueId.class, field);
          if (result == null) {
            result = new ComputationTargetSpecification(type, identifier);
          } else {
            result = result.containing(type, identifier);
          }
        }
      }
      return result;
    }
View Full Code Here

        // Rewrite the original value requirements that might have referenced the original nodes
        for (Map.Entry<ValueSpecification, Set<ValueRequirement>> terminalOutput : previousGraph.getTerminalOutputs().entrySet()) {
          final Set<ValueRequirement> oldReqs = terminalOutput.getValue();
          replacements.clear();
          for (ValueRequirement req : oldReqs) {
            final ComputationTargetReference newTarget = req.getTargetReference().accept(remapper);
            if (newTarget != null) {
              replacements.add(req);
              replacements.add(MemoryUtils.instance(new ValueRequirement(req.getValueName(), newTarget, req.getConstraints())));
            }
          }
View Full Code Here

   *
   * @param valueReq the requirement to process, not null
   * @return the possibly simplified requirement, not null
   */
  public ValueRequirement simplifyType(final ValueRequirement valueReq) {
    final ComputationTargetReference oldTargetRef = valueReq.getTargetReference();
    final ComputationTargetReference newTargetRef = ComputationTargetResolverUtils.simplifyType(oldTargetRef, getCompilationContext().getComputationTargetResolver());
    if (newTargetRef == oldTargetRef) {
      return valueReq;
    } else {
      return MemoryUtils.instance(new ValueRequirement(valueReq.getValueName(), newTargetRef, valueReq.getConstraints()));
    }
View Full Code Here

  public ComputationTargetIdentifierRemapVisitor(final Map<UniqueId, UniqueId> map) {
    _map = map;
  }

  public ComputationTargetRequirement remap(final ComputationTargetRequirement requirement) {
    ComputationTargetReference parent = requirement.getParent();
    if (parent != null) {
      final ComputationTargetReference rewriteParent = parent.accept(this);
      if (rewriteParent != null) {
        return rewriteParent.containing(requirement.getType().accept(s_getLeafType, null), requirement.getIdentifiers());
      }
    }
    return null;
  }
View Full Code Here

    return null;
  }

  public ComputationTargetSpecification remap(final ComputationTargetSpecification specification) {
    UniqueId rewriteSelf = _map.get(specification.getUniqueId());
    ComputationTargetReference parent = specification.getParent();
    if (parent != null) {
      final ComputationTargetReference rewriteParent = parent.accept(this);
      if (rewriteParent != null) {
        if (rewriteSelf != null) {
          return rewriteParent.containing(specification.getType().accept(s_getLeafType, null), rewriteSelf);
        } else {
          return rewriteParent.containing(specification.getType().accept(s_getLeafType, null), specification.getUniqueId());
        }
      }
    }
    if (rewriteSelf != null) {
      return specification.replaceIdentifier(rewriteSelf);
View Full Code Here

      for (ValueSpecification result : results) {
        if (!isUidMatch(uid, result.getTargetSpecification().getUniqueId())) {
          s_logger.warn("Invalid UID for result {} on target {}", result, target);
          return false;
        }
        ComputationTargetReference a = result.getTargetSpecification().getParent();
        ComputationTargetReference b = targetSpec.getParent();
        while ((a != null) && (b != null)) {
          if (!isUidMatch(a.getSpecification().getUniqueId(), b.getSpecification().getUniqueId())) {
            s_logger.warn("Parent context mismatch of result {} on target {}", result, target);
            return false;
          }
          a = a.getParent();
          b = b.getParent();
        }
        if ((a != null) || (b != null)) {
          s_logger.warn("Invalid parent context of result {} on target {}", result, target);
          return false;
        }
View Full Code Here

  public int compare(final ContextRunnable r1, final ContextRunnable r2) {
    if (r1 instanceof ResolveTask) {
      if (r2 instanceof ResolveTask) {
        final ResolveTask rt1 = (ResolveTask) r1;
        final ResolveTask rt2 = (ResolveTask) r2;
        final ComputationTargetReference ctr1 = rt1.getValueRequirement().getTargetReference();
        final ComputationTargetReference ctr2 = rt2.getValueRequirement().getTargetReference();
        final Integer p1 = s_priority.get(ctr1.getType());
        final Integer p2 = s_priority.get(ctr2.getType());
        if (p1.intValue() < p2.intValue()) {
          return 1;
        } else if (p1.intValue() > p2.intValue()) {
          return -1;
        } else {
          if (ctr1 instanceof ComputationTargetSpecification) {
            if (ctr2 instanceof ComputationTargetSpecification) {
              return ObjectUtils.compare(ctr2.getSpecification().getUniqueId(), ctr1.getSpecification().getUniqueId());
            } else {
              // Do requirement -> specification resolution (r2) first
              return -1;
            }
          } else {
            if (ctr2 instanceof ComputationTargetRequirement) {
              return ctr2.getRequirement().getIdentifiers().compareTo(ctr1.getRequirement().getIdentifiers());
            } else {
              // Do requirement -> specification resolution (r1) first
              return 1;
            }
          }
View Full Code Here

    if (!isInitialized()) {
      _unstructured = new InMemoryLKVMarketDataProvider();
      final UnstructuredMarketDataSnapshot globalValues = _snapshot.getGlobalValues();
      if (globalValues != null) {
        for (final ExternalIdBundle target : globalValues.getTargets()) {
          final ComputationTargetReference targetRef = new ComputationTargetRequirement(ComputationTargetType.PRIMITIVE, target);
          for (final Map.Entry<String, ValueSnapshot> valuePair : globalValues.getTargetValues(target).entrySet()) {
            ValueRequirement valueRequirement = new ValueRequirement(valuePair.getKey(), targetRef);
            _unstructured.addValue(valueRequirement, query(valuePair.getValue()));
          }
        }
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.