Package com.opengamma.master.portfolio

Examples of com.opengamma.master.portfolio.PortfolioDocument


  @DELETE
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteJSON() {
    ObjectId positionId = ObjectId.parse(data().getUriPositionId());
    PortfolioDocument doc = data().getPortfolio();
    if (doc.isLatest()) {
      ManageablePortfolioNode node = data().getNode();
      if (node.getPositionIds().remove(positionId) == false) {
        throw new DataNotFoundException("Position id not found: " + positionId);
      }
      doc = data().getPortfolioMaster().update(doc);
View Full Code Here


    return Response.seeOther(uri).build();
  }

  private URI createPortfolio(String name) {
    ManageablePortfolio portfolio = new ManageablePortfolio(name);
    PortfolioDocument doc = new PortfolioDocument(portfolio);
    PortfolioDocument added = data().getPortfolioMaster().add(doc);
    return data().getUriInfo().getAbsolutePathBuilder().path(added.getUniqueId().toLatest().toString()).build();
  }
View Full Code Here

  @Path("{portfolioId}")
  public WebPortfolioResource findPortfolio(@Subscribe @PathParam("portfolioId") String idStr) {
    data().setUriPortfolioId(idStr);
    UniqueId oid = UniqueId.parse(idStr);
    try {
      PortfolioDocument doc = data().getPortfolioMaster().get(oid);
      data().setPortfolio(doc);
      data().setNode(doc.getPortfolio().getRootNode());
    } catch (DataNotFoundException ex) {
      PortfolioHistoryRequest historyRequest = new PortfolioHistoryRequest(oid);
      historyRequest.setPagingRequest(PagingRequest.ONE);
      PortfolioHistoryResult historyResult = data().getPortfolioMaster().history(historyRequest);
      if (historyResult.getDocuments().size() == 0) {
View Full Code Here

    searchRequest.addNodeObjectId(nodeId.getObjectId());
    PortfolioSearchResult searchResult = getPortfolioMaster().search(searchRequest);
    ManageablePortfolio portfolio = searchResult.getSinglePortfolio();
    ManageablePortfolioNode node = findNode(portfolio, nodeId);
    node.addPosition(savedPosition.getUniqueId());
    getPortfolioMaster().update(new PortfolioDocument(portfolio));
    return savedTrade.getUniqueId();
  }
View Full Code Here

   * Creates the output root data.
   * @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

    FlexiBean out = createPortfolioData();
    return Response.ok(getFreemarker().build(JSON_DIR + "portfolio.ftl", out)).build();
  }

  private FlexiBean createPortfolioData() {
    PortfolioDocument doc = data().getVersioned();
    PositionSearchRequest positionSearch = new PositionSearchRequest();
    positionSearch.setPositionObjectIds(doc.getPortfolio().getRootNode().getPositionIds());
    PositionSearchResult positionsResult = data().getPositionMaster().search(positionSearch);
    resolveSecurities(positionsResult.getPositions());

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

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

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response getJSON() {
    FlexiBean out = createPortfolioNodeData();
    PortfolioDocument doc = data().getPortfolio();
    if (!doc.isLatest()) {
      return Response.status(Status.NOT_FOUND).build();
    }
   
    String s = getFreemarker().build(JSON_DIR + "portfolionode.ftl", out);
    return Response.ok(s).build();
View Full Code Here

  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

  //-------------------------------------------------------------------------
  @PUT
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_HTML)
  public Response putHTML(@FormParam("name") String name) {
    PortfolioDocument doc = data().getPortfolio();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    name = StringUtils.trimToNull(name);
    if (name == null) {
      FlexiBean out = createRootData();
View Full Code Here

TOP

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

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.