Package com.opengamma.engine.view.helper

Examples of com.opengamma.engine.view.helper.AvailableOutputs


    }
    if (filtered.getRootNode().getChildNodes().isEmpty() && filtered.getRootNode().getPositions().isEmpty()) {
      s_logger.debug("Ignoring {} ({})", portfolio.getName(), portfolio.getUniqueId());
    } else {
      s_logger.info("Calculating available outputs from {} ({})", portfolio.getName(), portfolio.getUniqueId());
      final AvailableOutputs outputs = new AvailablePortfolioOutputs(filtered, getFunctionRepository(), getFunctionExclusionGroups(), getMarketDataAvailability(), null);
      synchronized (_availableOutputsBySecurityType) {
        for (final AvailableOutput output : outputs.getOutputs()) {
          for (final String securityType : output.getSecurityTypes()) {
            storeMapSet(securityType, output, _availableOutputsBySecurityType);
          }
          if (output.isAvailableOnPortfolioNode()) {
            storeMapSet("", output, _availableOutputsBySecurityType);
          }
        }
      }
      synchronized (_availableOutputsByName) {
        for (final AvailableOutput output : outputs.getOutputs()) {
          storeMapSet(output.getValueName(), output, _availableOutputsByName);
        }
      }
    }
  }
View Full Code Here


    if (availableOutputsProvider == null) {
      throw new OpenGammaRuntimeException("AvailableOutputsProvider missing from ToolContext");
    }
    final SetMultimap<String, String> valueNamesBySecurityType = TreeMultimap.create();
   
    AvailableOutputs portfolioOutputs = availableOutputsProvider.getPortfolioOutputs(portfolioId, null);
    Set<String> securityTypes = portfolioOutputs.getSecurityTypes();
    for (String securityType : securityTypes) {
      Set<AvailableOutput> positionOutputs = portfolioOutputs.getPositionOutputs(securityType);
      for (AvailableOutput availableOutput : positionOutputs) {
        valueNamesBySecurityType.put(securityType, availableOutput.getValueName());
      }       
    }
    return valueNamesBySecurityType.asMap();
View Full Code Here

    final long t1 = System.nanoTime();
    Portfolio portfolio = getPortfolio(portfolioName);
    final long t2 = System.nanoTime();
    portfolio = PortfolioCompiler.resolvePortfolio(portfolio, _executorService, _securitySource);
    final long t3 = System.nanoTime();
    final AvailableOutputs outputs = new AvailablePortfolioOutputs(portfolio, _functionRepository, _functionExclusionGroups, _marketDataAvailability, "?");
    final long t4 = System.nanoTime();
    s_logger.info("Fetch={}ms, Resolve={}ms, Outputs={}ms", new Object[] {(t2 - t1) / 1e6, (t3 - t2) / 1e6, (t4 - t3) / 1e6 });
    s_logger.info("Outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getOutputs()) {
      s_logger.info("{}", output);
    }
    s_logger.info("Portfolio node outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getPortfolioNodeOutputs()) {
      s_logger.info("{}", output);
    }
    s_logger.info("Position outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getPositionOutputs()) {
      s_logger.info("{}", output);
    }
    for (final String securityType : outputs.getSecurityTypes()) {
      s_logger.info("{} security outputs for {}", securityType, portfolio.getName());
      for (final AvailableOutput output : outputs.getPositionOutputs(securityType)) {
        s_logger.info("{}", output);
      }
    }
    return outputs;
  }
View Full Code Here

    }

    @Path("{portfolioId}")
    public FudgeFieldContainerBrowser portfolioOutputsByPortfolioId(@PathParam("portfolioId") String portfolioUid) {
      try {
        final AvailableOutputs outputs = _provider.getPortfolioOutputs(UniqueId.parse(portfolioUid), _instant, _maxNodes, _maxPositions);
        final FudgeSerializer serializer = new FudgeSerializer(_fudgeContext);
        return new FudgeFieldContainerBrowser(serializer.objectToFudgeMsg(outputs));
      } catch (DataNotFoundException e) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
      }
View Full Code Here

    @Consumes(FudgeRest.MEDIA)
    @Produces(FudgeRest.MEDIA)
    public FudgeMsg portfolioOutputsByPortfolio(Portfolio portfolio) {
      try {
        FudgeSerializer serializer = new FudgeSerializer(_fudgeContext);
        AvailableOutputs availableOutputs = _provider.getPortfolioOutputs(portfolio, _instant, _maxNodes, _maxPositions);
        return serializer.objectToFudgeMsg(availableOutputs);
      } catch (DataNotFoundException e) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
      }
    }
View Full Code Here

@Test(groups = TestGroup.UNIT)
public class AvailableOutputsBuilderTest extends AbstractFudgeBuilderTestCase {

  public void testCycleEmptyObject() {
    final AvailableOutputsImpl outputs = new AvailableOutputsImpl();
    final AvailableOutputs cycled = cycleObject(AvailableOutputs.class, outputs);
    assertTrue(cycled.getOutputs().isEmpty());
    assertTrue(cycled.getPortfolioNodeOutputs().isEmpty());
    assertTrue(cycled.getPositionOutputs().isEmpty());
    assertTrue(cycled.getSecurityTypes().isEmpty());
  }
View Full Code Here

  public void testCyclePopulatedObject() {
    final AvailableOutputsImpl outputs = new AvailableOutputsImpl();
    outputs.portfolioNodeOutput("V", ValueProperties.with("P", "A", "B").get());
    outputs.positionOutput("V", "Swap", ValueProperties.with("P", "A", "C").get());
    outputs.positionOutput("V", "Option", ValueProperties.with("P", "A", "D").get());
    final AvailableOutputs cycled = cycleObject(AvailableOutputs.class, outputs);
    assertEquals(cycled.getOutputs().size(), 1);
    AvailableOutput output = cycled.getOutputs().iterator().next();
    assertEquals(output.getValueName(), "V");
    assertEquals(output.getProperties(), ValueProperties.with("P", "A", "B", "C", "D").get());
    assertEquals(output.getSecurityTypes(), new HashSet<String>(Arrays.asList("Swap", "Option")));
    assertEquals(output.getPositionProperties("Swap"), ValueProperties.with("P", "A", "C").get());
    assertEquals(output.getPositionProperties("Option"), ValueProperties.with("P", "A", "D").get());
    assertEquals(output.getPortfolioNodeProperties(), ValueProperties.with("P", "A", "B").get());
    assertEquals(cycled.getPortfolioNodeOutputs().size(), 1);
    output = cycled.getPortfolioNodeOutputs().iterator().next();
    assertEquals(output.getValueName(), "V");
    assertEquals(output.getProperties(), ValueProperties.with("P", "A", "B").get());
    assertEquals(output.getPortfolioNodeProperties(), ValueProperties.with("P", "A", "B").get());
    assertEquals(cycled.getPositionOutputs().size(), 1);
    output = cycled.getPositionOutputs().iterator().next();
    assertEquals(output.getValueName(), "V");
    assertEquals(output.getProperties(), ValueProperties.with("P", "A", "C", "D").get());
    assertEquals(output.getSecurityTypes(), new HashSet<String>(Arrays.asList("Swap", "Option")));
    assertEquals(output.getPositionProperties("Swap"), ValueProperties.with("P", "A", "C").get());
    assertEquals(output.getPositionProperties("Option"), ValueProperties.with("P", "A", "D").get());
    assertEquals(cycled.getPositionOutputs("Swap").size(), 1);
    output = cycled.getPositionOutputs("Swap").iterator().next();
    assertEquals(output.getValueName(), "V");
    assertEquals(output.getProperties(), ValueProperties.with("P", "A", "C").get());
    assertEquals(output.getSecurityTypes(), new HashSet<String>(Arrays.asList("Swap")));
    assertEquals(cycled.getPositionOutputs("Option").size(), 1);
    output = cycled.getPositionOutputs("Option").iterator().next();
    assertEquals(output.getValueName(), "V");
    assertEquals(output.getProperties(), ValueProperties.with("P", "A", "D").get());
    assertEquals(output.getSecurityTypes(), new HashSet<String>(Arrays.asList("Option")));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.helper.AvailableOutputs

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.