Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolio


    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version2Instant, test.getVersionFromInstant());
    assertEquals(now, test.getVersionToInstant());
    assertEquals(_version2Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageablePortfolio portfolio = test.getPortfolio();
    assertNotNull(portfolio);
    assertEquals(uniqueId, portfolio.getUniqueId());
    assertEquals("TestNode212", portfolio.getRootNode().getName());
    assertEquals(0, portfolio.getRootNode().getChildNodes().size());
  }
View Full Code Here


    return node;
  }
 
  private void createPortfolio(final String portfolioName, final Iterable<ManageablePortfolioNode> nodes) {
    final ManageablePortfolioNode rootNode = new ManageablePortfolioNode("ROOT");
    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    for (ManageablePortfolioNode node : nodes) {
      rootNode.addChildNode(node);
    }
    _portfolios.add(new PortfolioDocument(portfolio));
  }
View Full Code Here

    ArgumentChecker.notNull(rowParser, "rowParser");
    _rowParser = rowParser;

    // create virtual manageable portfolio
    _currentNode = new ManageablePortfolioNode("Root");
    _portfolio = new ManageablePortfolio("Portfolio", _currentNode);
    _currentNode.setPortfolioId(_portfolio.getUniqueId());

    _includeTrades = includeTrades;
  }
View Full Code Here

   * @param <T> Type of the function's result
   * @return Values returned from the function, not including any nulls
   */
  public <T> List<T> map(String portfolioObjectId, Function<T> function) {
    ObjectId objectId = ObjectId.parse(portfolioObjectId);
    ManageablePortfolio portfolio = _portfolioMaster.get(objectId, _versionCorrection).getPortfolio();
    return map(portfolio.getRootNode(), function);
  }
View Full Code Here

   * @param function Called for every position in the portfolio
   * @param <T> Type of the function's result
   * @return Values returned from the function, not including any nulls
   */
  public <T> List<T> map(ObjectId portfolioId, Function<T> function) {
    ManageablePortfolio portfolio = _portfolioMaster.get(portfolioId, _versionCorrection).getPortfolio();
    return map(portfolio.getRootNode(), function);
  }
View Full Code Here

    if (unversionedPortfolioId.isVersioned()) {
      throw new IllegalArgumentException("Portfolio ID " + unversionedPortfolioId + " should be unversioned, " +
                                              "version/correction is set in the constructor");
    }
    ObjectId objectId = unversionedPortfolioId.getObjectId();
    ManageablePortfolio portfolio = _portfolioMaster.get(objectId, _versionCorrection).getPortfolio();
    return map(portfolio.getRootNode(), function);
  }
View Full Code Here

    ArgumentChecker.notNull(rowParsers, "rowParsers");
    _parserMap = rowParsers;

    // create virtual manageable portfolio
    _currentNode = new ManageablePortfolioNode("Root");
    _portfolio = new ManageablePortfolio("Portfolio", _currentNode);
    _currentNode.setPortfolioId(_portfolio.getUniqueId());

    _includeTrades = false;
  }
View Full Code Here

    // If it doesn't, create it (add)
    if (_portfolioDocument == null) {
      // Create a new root node
      ManageablePortfolioNode rootNode = new ManageablePortfolioNode(portfolioName);

      ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
      _portfolioDocument = new PortfolioDocument();
      _portfolioDocument.setPortfolio(portfolio);
      _portfolioDocument = _portfolioMaster.add(_portfolioDocument);
      _originalRoot = null;
      _originalNode = null;

      // Set current node to the root node
      _currentNode = rootNode;

      // If it does, create a new version of the existing portfolio (update)
    } else {
      ManageablePortfolio portfolio = _portfolioDocument.getPortfolio();
      _originalRoot = portfolio.getRootNode();
      _originalNode = _originalRoot;

      if (_keepCurrentPositions) {
        // Use the original root node
        portfolio.setRootNode(cloneTree(_originalRoot));
        _portfolioDocument.setPortfolio(portfolio);

        // Set current node to the root node
        _currentNode = portfolio.getRootNode();
      } else {
        // Create a new root node
        ManageablePortfolioNode rootNode;
        rootNode = JodaBeanUtils.clone(_originalRoot);
        rootNode.setChildNodes(new ArrayList<ManageablePortfolioNode>());
        rootNode.setPositionIds(new ArrayList<ObjectId>());
        portfolio.setRootNode(rootNode);
        _portfolioDocument.setPortfolio(portfolio);

        // Set current node to the root node
        _currentNode = rootNode;
      }
View Full Code Here

    final PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    final PositionMaster positionMaster = getToolContext().getPositionMaster();
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    final ManageablePortfolioNode rootNode = new ManageablePortfolioNode(portfolioName);
    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final SwapSecurity swap : swaps) {
      final SecurityDocument swapToAddDoc = new SecurityDocument();
View Full Code Here

    return clonePortfolioDocument(document);
  }
 
  private PortfolioDocument clonePortfolioDocument(PortfolioDocument document) {
    PortfolioDocument clone = JodaBeanUtils.clone(document);
    ManageablePortfolio portfolioClone = JodaBeanUtils.clone(document.getPortfolio());
    portfolioClone.setRootNode(clonePortfolioNode(portfolioClone.getRootNode()));
    clone.setPortfolio(portfolioClone);
    return clone;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.portfolio.ManageablePortfolio

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.