Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolio


    _prtMaster.update(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_noPortfolioId() {
    ManageablePortfolio position = new ManageablePortfolio("Test");
    PortfolioDocument doc = new PortfolioDocument();
    doc.setPortfolio(position);
    _prtMaster.update(doc);
  }
View Full Code Here


    _prtMaster.update(doc);
  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void test_update_notFound() {
    ManageablePortfolio port = new ManageablePortfolio("Test");
    port.setUniqueId(UniqueId.of("DbPrt", "0", "0"));
    port.setRootNode(new ManageablePortfolioNode("Root"));
    PortfolioDocument doc = new PortfolioDocument(port);
    _prtMaster.update(doc);
  }
View Full Code Here

    _prtMaster.update(doc);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_notLatestVersion() {
    ManageablePortfolio port = new ManageablePortfolio("Test");
    port.setUniqueId(UniqueId.of("DbPrt", "201", "0"));
    port.setRootNode(new ManageablePortfolioNode("Root"));
    PortfolioDocument doc = new PortfolioDocument(port);
    _prtMaster.update(doc);
  }
View Full Code Here

   
    UniqueId oldPortfolioId = UniqueId.of("DbPrt", "101", "0");
    PortfolioDocument base = _prtMaster.get(oldPortfolioId);
    Map<String, String> oldAttr = base.getPortfolio().getAttributes();
    assertNotNull(oldAttr);
    ManageablePortfolio port = new ManageablePortfolio("NewName");
    port.setUniqueId(oldPortfolioId);
    port.setRootNode(base.getPortfolio().getRootNode());
    Map<String, String> newAttr = getNewAttributes();
    port.setAttributes(newAttr);
    PortfolioDocument input = new PortfolioDocument(port);
   
    PortfolioDocument updated = _prtMaster.update(input);
    assertEquals(UniqueId.of("DbPrt", "101"), updated.getUniqueId().toLatest());
    assertEquals(false, base.getUniqueId().getVersion().equals(updated.getUniqueId().getVersion()));
View Full Code Here

    }
    s_logger.info("Creating portfolio {}", portfolioName);
    final Portfolio portfolio = instance.createPortfolio(portfolioName);
    if (write) {
      s_logger.info("Writing portfolio to the database");
      final ManageablePortfolio newPortfolio = new ManageablePortfolio(portfolio.getName());
      newPortfolio.setAttributes(portfolio.getAttributes());
      newPortfolio.setRootNode(createPortfolioNode(context.getPositionMaster(), portfolio.getRootNode()));
      final PortfolioSearchRequest request = new PortfolioSearchRequest();
      request.setDepth(0);
      request.setIncludePositions(false);
      request.setName(portfolio.getName());
      final PortfolioSearchResult result = context.getPortfolioMaster().search(request);
View Full Code Here

    PortfolioSearchRequest searchReq = new PortfolioSearchRequest();
    searchReq.setName(portfolioName);
    s_logger.info("Searching for portfolio " + portfolioName + "...");
    PortfolioSearchResult searchResult = portfolioMaster.search(searchReq);
    s_logger.info("Done. Got " + searchResult.getDocuments().size() + " results");
    ManageablePortfolio manageablePortfolio = searchResult.getFirstPortfolio();
    if (manageablePortfolio == null) {
      s_logger.error("Portfolio " + portfolioName + " was not found");
      System.exit(1);
    }
    s_logger.info("Reloading portfolio from position source...");
    Portfolio portfolio = positionSource.getPortfolio(manageablePortfolio.getUniqueId(), VersionCorrection.LATEST);
    if (portfolio == null) {
      s_logger.error("Portfolio " + portfolioName + " was not found from PositionSource");
      System.exit(1);
    }
    s_logger.info("Done.");
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 Map.Entry<SwaptionSecurity, SwapSecurity> entry : securities.entrySet()) {
      final SecurityDocument swapToAddDoc = new SecurityDocument();
View Full Code Here

    _prtMaster.correct(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_correct_noPortfolioId() {
    ManageablePortfolio position = new ManageablePortfolio("Test");
    PortfolioDocument doc = new PortfolioDocument();
    doc.setPortfolio(position);
    _prtMaster.correct(doc);
  }
View Full Code Here

    _prtMaster.correct(doc);
  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void test_correct_notFound() {
    ManageablePortfolio port = new ManageablePortfolio("Test");
    port.setUniqueId(UniqueId.of("DbPrt", "0", "0"));
    port.setRootNode(new ManageablePortfolioNode("Root"));
    PortfolioDocument doc = new PortfolioDocument(port);
    _prtMaster.correct(doc);
  }
View Full Code Here

  public void test_correct_getUpdateGet() {
    Instant now = Instant.now(_prtMaster.getClock());
   
    UniqueId oldPortfolioId = UniqueId.of("DbPrt", "201", "0");
    PortfolioDocument base = _prtMaster.get(oldPortfolioId);
    ManageablePortfolio port = new ManageablePortfolio("NewName");
    port.setUniqueId(oldPortfolioId);
    port.setRootNode(base.getPortfolio().getRootNode());
    PortfolioDocument input = new PortfolioDocument(port);
   
    PortfolioDocument corrected = _prtMaster.correct(input);
    assertEquals(UniqueId.of("DbPrt", "201"), corrected.getUniqueId().toLatest());
    assertEquals(false, base.getUniqueId().getVersion().equals(corrected.getUniqueId().getVersion()));
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.