Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.ManageablePortfolioNode


    String s = getFreemarker().build(JSON_DIR + "portfolionode.ftl", out);
    return Response.ok(s).build();
  }

  private FlexiBean createPortfolioNodeData() {
    ManageablePortfolioNode node = data().getNode();
    PositionSearchRequest positionSearch = new PositionSearchRequest();
    positionSearch.setPositionObjectIds(node.getPositionIds());
    PositionSearchResult positionsResult = data().getPositionMaster().search(positionSearch);
    resolveSecurities(positionsResult.getPositions());

    FlexiBean out = createRootData();
    out.put("positionsResult", positionsResult);
View Full Code Here


   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    PortfolioDocument doc = data().getVersioned();
    ManageablePortfolioNode node = data().getNode();
    out.put("portfolioDoc", doc);
    out.put("portfolio", doc.getPortfolio());
    out.put("parentNode", data().getParentNode());
    out.put("node", node);
    out.put("childNodes", node.getChildNodes());
    out.put("deleted", !doc.isLatest());
    out.put("pathNodes", getPathNodes(node));
    return out;
  }
View Full Code Here

    String s = getFreemarker().build(JSON_DIR + "portfolionode.ftl", out);
    return Response.ok(s).build();
  }

  private FlexiBean createPortfolioNodeData() {
    ManageablePortfolioNode node = data().getNode();
    PositionSearchRequest positionSearch = new PositionSearchRequest();
    positionSearch.setPositionObjectIds(node.getPositionIds());
    PositionSearchResult positionsResult = data().getPositionMaster().search(positionSearch);
    resolveSecurities(positionsResult.getPositions());
   
    FlexiBean out = createRootData();
    out.put("positionsResult", positionsResult);
View Full Code Here

    URI uri = createPortfolioNode(name);
    return Response.created(uri).build();
  }

  private URI createPortfolioNode(String name) {
    ManageablePortfolioNode newNode = new ManageablePortfolioNode(name);
    ManageablePortfolioNode node = data().getNode();
    node.addChildNode(newNode);
    PortfolioDocument doc = data().getPortfolio();
    doc = data().getPortfolioMaster().update(doc);
    URI uri = WebPortfolioNodeResource.uri(data())// lock URI before updating data()
    data().setPortfolio(doc);
    return uri;
View Full Code Here

    updatePortfolioNode(name, doc);
    return Response.ok().build();
  }

  private URI updatePortfolioNode(String name, PortfolioDocument doc) {
    ManageablePortfolioNode node = data().getNode();
    URI uri = WebPortfolioNodeResource.uri(data())// lock URI before updating data()
    if (Objects.equal(node.getName(), name) == false) {
      node.setName(name);
      doc = data().getPortfolioMaster().update(doc);
      data().setPortfolio(doc);
    }
    return uri;
  }
View Full Code Here

   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    PortfolioDocument doc = data().getPortfolio();
    ManageablePortfolioNode node = data().getNode();
    out.put("portfolioDoc", doc);
    out.put("portfolio", doc.getPortfolio());
    out.put("parentNode", data().getParentNode());
    out.put("node", node);
    out.put("childNodes", node.getChildNodes());
    out.put("deleted", !doc.isLatest());
    out.put("pathNodes", getPathNodes(node));
    return out;
  }
View Full Code Here

   * @return      a list of <UniqueId, String> pairs denoting all nodes on the path from root to current node
   */
  protected List<ObjectsPair<UniqueId, String>> getPathNodes(ManageablePortfolioNode node) {
    LinkedList<ObjectsPair<UniqueId, String>> result = new LinkedList<ObjectsPair<UniqueId, String>>();

    ManageablePortfolioNode currentNode = node;
    while (currentNode != null) {
      result.addFirst(new ObjectsPair<UniqueId, String>(currentNode.getUniqueId(), currentNode.getName()));
      currentNode = (currentNode.getParentNodeId() == null)
          ? null
          : data().getPortfolioMaster().getNode(currentNode.getParentNodeId());      
    }
    return result;
  }
View Full Code Here

  }

  @Override
  public PortfolioNode getPortfolioNode(UniqueId uniqueId, VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(uniqueId, "uniqueId");
    final ManageablePortfolioNode manNode = getPortfolioMaster().getNode(uniqueId);
    if (manNode == null) {
      throw new DataNotFoundException("Unable to find node: " + uniqueId);
    }
    final SimplePortfolioNode node = new SimplePortfolioNode();
    convertNode(manNode, node, versionCorrection);
View Full Code Here

  private void persistToPortfolio(final Collection<FXOptionSecurity> fxOptions, final String portfolioName) {
    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 FXOptionSecurity fxOption : fxOptions) {
      final SecurityDocument fxOptionToAddDoc = new SecurityDocument();
      fxOptionToAddDoc.setSecurity(fxOption);
      securityMaster.add(fxOptionToAddDoc);
      final ManageablePosition fxOptionPosition = new ManageablePosition(BigDecimal.ONE, fxOption.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(fxOptionPosition));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
    portfolioMaster.add(portfolioDoc);
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test
  public void testGetPortfolio() {
    final ManageablePortfolioNode target = new ManageablePortfolioNode("Node");
    when(_underlying.getNode(UID)).thenReturn(target);
   
    Response test = _resource.get();
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertSame(target, test.getEntity());
View Full Code Here

TOP

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

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.