Package com.opengamma.core.position

Examples of com.opengamma.core.position.PortfolioNode


  @Override
  public Portfolio generateRestrictedPortfolio(Portfolio portfolio) {

    PortfolioPermissionChecker checker = new PortfolioPermissionChecker(portfolio, _nodeChecker);
    PortfolioNode rootNode = portfolio.getRootNode();

    Optional<? extends PortfolioNode> newRoot = buildRestrictedRootNode(checker, rootNode);

    if (newRoot.isPresent()) {
      PortfolioNode node = newRoot.get();
      return node.equals(rootNode) ? portfolio : createPortfolioForNode(trimParents(node));
    } else {
      return new SimplePortfolio("Access Denied");
    }
  }
View Full Code Here


            new SimplePortfolioNode(UniqueId.of("RESTRICTED_NODE", "PN_" + s_portfolioNodeId++),
                                    node.getName() + " [restricted]");
        newRoot.addPositions(node.getPositions());

        for (Map.Entry<PortfolioNode, PortfolioPermission> entry : getAccessibleChildNodes(node, checker).entrySet()) {
          PortfolioNode childNode = entry.getValue() == ALLOW ?
              entry.getKey() :
              buildRestrictedRootNode(checker, entry.getKey()).get();
          newRoot.addChildNode(childNode);
        }
View Full Code Here

   * @return the root node, null if parent node hierarchy incomplete
   * @deprecated This is broken as it assumes the "latest" version of the node returned
   */
  @Deprecated
  public PortfolioNode getRootPortfolioNode(final ComputationTarget position) {
    final PortfolioNode node = getParentNode(position);
    if (node == null) {
      return null;
    }
    return getRootPortfolioNodeImpl(node);
  }
View Full Code Here

    assertThat(portfolio.getName(), is("node-1 [restricted]"));



    PortfolioNode rootNode = portfolio.getRootNode();
    assertThat(rootNode.getName(), is("node-1 [restricted]"));
    List<PortfolioNode> children = rootNode.getChildNodes();
    assertThat(children.size(), is(2));
    assertThat(children.get(0).getName(), is("node-2"));
    assertThat(children.get(1).getName(), is("node-4"));
  }
View Full Code Here

        4, DENY);

    Portfolio portfolio = new NodeCheckingPortfolioFilter(createMappedNodeChecker(permissions)).generateRestrictedPortfolio(pf);

    assertThat(portfolio.getName(), is("node-2"));
    PortfolioNode rootNode = portfolio.getRootNode();
    assertThat(rootNode.getName(), is("node-2"));
    assertThat(rootNode.getChildNodes().size(), is(0));
  }
View Full Code Here

            .build();

    Portfolio portfolio = new NodeCheckingPortfolioFilter(createMappedNodeChecker(permissions)).generateRestrictedPortfolio(pf);

    assertThat(portfolio.getName(), is("node-5"));
    PortfolioNode rootNode = portfolio.getRootNode();
    assertThat(rootNode.getName(), is("node-5"));
    List<PortfolioNode> children = rootNode.getChildNodes();
    assertThat(children.size(), is(2));
    assertThat(children.get(0).getName(), is("node-6"));
    assertThat(children.get(1).getName(), is("node-7"));
  }
View Full Code Here

          .build();

    Portfolio portfolio = new NodeCheckingPortfolioFilter(createMappedNodeChecker(permissions)).generateRestrictedPortfolio(pf);

    assertThat(portfolio.getName(), is("node-1 [restricted]"));
    PortfolioNode rootNode = portfolio.getRootNode();
    assertThat(rootNode.getName(), is("node-1 [restricted]"));
    List<PortfolioNode> n1children = rootNode.getChildNodes();
    assertThat(n1children.size(), is(2));

    PortfolioNode n2 = n1children.get(0);
    assertThat(n2.getName(), is("node-2 [restricted]"));
    PortfolioNode n3 = n1children.get(1);
    assertThat(n3.getName(), is("node-3 [restricted]"));

  }
View Full Code Here

    // When we add child nodes, it's possible they are copied,
    // so we can't just pull these vars out as we construct
    // the tree
    List<PortfolioNode> childNodes = root.getChildNodes();
    PortfolioNode node2 = childNodes.get(0);
    PortfolioNode node3 = childNodes.get(1);
    PortfolioNode node4 = childNodes.get(2);

    Map< Integer, PortfolioPermission> permissions =
        ImmutableMap.<Integer, PortfolioPermission>builder()
            .put(1, ALLOW)
            .put(2, ALLOW)
View Full Code Here

    getUnderlying().addAttribute(key, value);
  }

  @Override
  public PortfolioNode getRootNode() {
    final PortfolioNode rootNode = getUnderlying().getRootNode();
    // log(ComputationTargetType.PORTFOLIO_NODE, rootNode); // [PLAT-4491] Nodes are linked to portfolio by UID not OID
    return new LoggedResolutionPortfolioNode(rootNode, getLogger());
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  public void testBasicMethods() {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final PortfolioNode underlying = resolver.getPositionSource().getPortfolioNode(UniqueId.of("Node", "0"), VersionCorrection.LATEST);
    final PortfolioNode node = new LazyResolvedPortfolioNode(new LazyResolveContext(resolver.getSecuritySource(), null).atVersionCorrection(VersionCorrection.LATEST), underlying);
    assertEquals(node.getName(), underlying.getName());
    assertEquals(node.getParentNodeId(), underlying.getParentNodeId());
    assertEquals(node.getUniqueId(), underlying.getUniqueId());
    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    assertEquals(node.getPositions().size(), underlying.getPositions().size());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.PortfolioNode

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.