Package com.opengamma.engine.target

Examples of com.opengamma.engine.target.ComputationTargetType$Parser


  public void testSimplifyType() {
    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 ComputationTargetType type = ComputationTargetType.of(TestSecurity.class);
    Mockito.when(underlying.simplifyType(type)).thenReturn(ComputationTargetType.SECURITY);
    assertSame(resolver.simplifyType(type), ComputationTargetType.SECURITY);
  }
View Full Code Here


    int i = 0, j = 0;
    types[i++] = ComputationTargetType.PRIMITIVE;
    types[i++] = ComputationTargetType.POSITION;
    types[i++] = ComputationTargetType.of(Foo.class);
    while (i < types.length) {
      final ComputationTargetType type = types[j++];
      types[i++] = type.containing(ComputationTargetType.PRIMITIVE);
      types[i++] = ComputationTargetType.PORTFOLIO_NODE.containing(type);
      types[i++] = type.or(types[j]);
    }
    for (ComputationTargetType type : types) {
      assertEncodeDecodeCycle(ComputationTargetType.class, type);
    }
  }
View Full Code Here

 
  private void processStatusResult(ViewComputationResultModel fullResult, PerViewStatusResult statusResult) {
    ViewCalculationResultModel calculationResult = fullResult.getCalculationResult(DEFAULT_CALC_CONFIG);
    Collection<ComputationTargetSpecification> allTargets = calculationResult.getAllTargets();
    for (ComputationTargetSpecification targetSpec : allTargets) {
      ComputationTargetType targetType = targetSpec.getSpecification().getType();
      if (isValidTargetType(targetType)) {
        Map<Pair<String, ValueProperties>, ComputedValueResult> values = calculationResult.getValues(targetSpec);
        for (Map.Entry<Pair<String, ValueProperties>, ComputedValueResult> valueEntry : values.entrySet()) {
          String valueName = valueEntry.getKey().getFirst();
          String currency = getCurrency(targetSpec.getUniqueId(), targetType);
          s_logger.debug("{} currency returned for id:{} targetType:{}", currency, targetSpec.getUniqueId(), targetType);
          if (currency != null) {
            ComputedValueResult computedValue = valueEntry.getValue();
            if (isGoodValue(computedValue)) {
              statusResult.put(new ViewStatusKeyBean(_securityType, valueName, currency, targetType.getName()), ViewStatus.VALUE);
            }
          } else {
            s_logger.error("Discarding result as NULL return as Currency for id: {} targetType:{}", targetSpec.getUniqueId(), targetType);
          }
        }
View Full Code Here

    public void viewDefinitionCompiled(CompiledViewDefinition compiledViewDefinition, boolean hasMarketDataPermissions) {
      s_logger.error("View definition compiled");
      CompiledViewCalculationConfiguration compiledCalculationConfiguration = compiledViewDefinition.getCompiledCalculationConfiguration(DEFAULT_CALC_CONFIG);
      Map<ValueSpecification, Set<ValueRequirement>> terminalOutputs = compiledCalculationConfiguration.getTerminalOutputSpecifications();
      for (ValueSpecification valueSpec : terminalOutputs.keySet()) {
        ComputationTargetType computationTargetType = valueSpec.getTargetSpecification().getType();
        if (isValidTargetType(computationTargetType)) {
          UniqueId uniqueId = valueSpec.getTargetSpecification().getUniqueId();
          String currency = getCurrency(uniqueId, computationTargetType);
          if (currency != null) {
            _statusResult.put(new ViewStatusKeyBean(_securityType, valueSpec.getValueName(), currency, computationTargetType.getName()), ViewStatus.NO_VALUE);
          } else {
            s_logger.error("Discarding result as NULL return as Currency for id: {} targetType:{}", uniqueId, computationTargetType);
          }
        }
      }
View Full Code Here

    return new PortfolioTreeModel(portfolioId, toolContext);
  }
 
  private ResolutionFailureTreeTableModel createResolutionFailureTreeTableModel(final Object leafNode, final String valueReq) {
    DependencyGraphTraceBuilderProperties properties = new DependencyGraphTraceBuilderProperties();
    ComputationTargetType targetType = null;
    if (leafNode instanceof Position) {
      targetType = ComputationTargetType.POSITION;
    } else if (leafNode instanceof Trade) {
      targetType = ComputationTargetType.TRADE;
    } else if (leafNode instanceof PortfolioNode) {
View Full Code Here

    for (ViewResultEntry viewResultEntry : allResults) {
      String calcConfig = viewResultEntry.getCalculationConfiguration();
      ValueSpecification valueSpec = viewResultEntry.getComputedValue().getSpecification();
      ComputedValue computedValue = viewResultEntry.getComputedValue();
     
      ComputationTargetType type = valueSpec.getTargetSpecification().getType();
     
      if (type.isTargetType(ComputationTargetType.POSITION)) {
       
        String destinationName = _jmsTopicNameResolver.resolve(new JmsTopicNameResolveRequest(calcConfig, valueSpec));
        FudgeMsg fudgeMsg = _fudgeContext.toFudgeMsg(computedValue).getMessage();
        final byte[] bytes = _fudgeContext.toByteArray(fudgeMsg);
       
View Full Code Here

    String valueName = "name";
    String targetType = "POSITION";
    String externalId = "Foo~1";

    //expected arg
    ComputationTargetType expectedTargetType = ComputationTargetType.POSITION;
    ExternalId expectedExternalId = ExternalId.parse(externalId);
    ValueRequirement valueRequirement = new ValueRequirement(valueName, new ComputationTargetRequirement(expectedTargetType, expectedExternalId));

    DependencyGraphTraceProviderResource newResource = _resource.setValueRequirementByExternalId(valueName, targetType, externalId);
View Full Code Here

    String targetType = "POSITION";
    String uniqueId = "Foo~1";

    //expected arg
    UniqueId expectedUniqueId = UniqueId.parse(uniqueId);
    ComputationTargetType expectedTargetType = ComputationTargetType.POSITION;
    ValueRequirement valueRequirement = new ValueRequirement(valueName, new ComputationTargetSpecification(expectedTargetType, expectedUniqueId));

    DependencyGraphTraceProviderResource newResource = _resource.setValueRequirementByUniqueId(valueName, targetType, uniqueId);

    assertTrue(newResource.getProperties().getRequirements().contains(valueRequirement));
View Full Code Here

    details.put("indent", row.getDepth());
    if (row.getParentRow() != null) {
      final int[] parentRowIds = getGridStructure().getRowIds(row.getParentRow().getTarget());
      details.put("parentRowId", parentRowIds[0]);
    }
    ComputationTargetType targetType = row.getTarget().getType();
    details.put("type", targetType.toString());

    if (targetType == ComputationTargetType.POSITION) {
      Position position = row.getPosition();
      details.put("posId", position.getUniqueId());
      details.put("position", position.getSecurity().getName());
View Full Code Here

                                ResultsCache cache,
                                Class<?> columnType,
                                Object inlineKey) {
    PortfolioGridRow row = _rows.get(rowIndex);
    ComputationTargetReference target = row.getTarget();
    ComputationTargetType targetType = target.getType();
    // TODO do I need to use the target type to figure out the row type? can I just have different row types?
    if (targetType.isTargetType(ComputationTargetType.POSITION)) {
      RowTarget rowTarget;
      UniqueId securityId = row.getSecurityId();
      ResultsCache.Result securityResult = cache.getEntity(securityId.getObjectId());
      Security security = (Security) securityResult.getValue();
      if (isOtc(security)) {
        // TODO different type for OTC positions with no trades? they are effecively the same but the client
        // needs to know when a position has no trades because it will be a different endpoint to trigger editing
        // OTC trades and positions are shown as a single row as there's always one trade per position
        rowTarget = new OtcTradeTarget(row.getName(), row.getNodeId(), row.getPositionId(), row.getTradeId());
      } else {
        // Positions in fungible trades can contain multiple trades so the position has its own row and child rows
        // for each of its trades
        rowTarget = new PositionTarget(row.getName(), row.getNodeId(), row.getPositionId());
      }
      // TODO check the cache items for the position, security, underlying to find out whether they've been updated
      return ResultsCell.forStaticValue(rowTarget, columnType, format);
    } else if (targetType.isTargetType(ComputationTargetType.PORTFOLIO_NODE)) {
      return ResultsCell.forStaticValue(new NodeTarget(row.getName(), row.getNodeId()), columnType, format);
    } else if (targetType.isTargetType(ComputationTargetType.TRADE)) {
      // only fungible trades have their own row, OTC trades are shown on the same row as their parent position
      FungibleTradeTarget tradeTarget =
          new FungibleTradeTarget(row.getName(), row.getNodeId(), row.getPositionId(), row.getTradeId());
      // TODO check cache item for trade to see if it's been updated
      return ResultsCell.forStaticValue(tradeTarget, columnType, format);
View Full Code Here

TOP

Related Classes of com.opengamma.engine.target.ComputationTargetType$Parser

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.