Package com.opengamma.master.security

Examples of com.opengamma.master.security.SecurityDocument


  }

  @Test
  public void testPositionSecurityWithRedCodeIsUsed() {

    SecurityDocument document = new SecurityDocument();
    ManageableSecurity cds = new StandardVanillaCDSSecurity(true, ExternalId.of("EXTERNAL_CODE" ,"ProtBuyer"),
                                                                    ExternalId.of("EXTERNAL_CODE" ,"ProtSeller"), ExternalSchemes.markItRedCode("39FF64"),
                                                                    DebtSeniority.SNRFOR, RestructuringClause.MM, ExternalSchemes.financialRegionId("US"),
                                                                    createZdt(2013, 3, 20), createZdt(2013, 3, 21), createZdt(2014,3,20), StubType.SHORT_START,
                                                                    SimpleFrequency.SEMI_ANNUAL, DayCountFactory.INSTANCE.getDayCount("Actual/360"),
                                                                    BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"),
                                                                    true, true, true, new InterestRateNotional(Currency.USD, 10000000), true, true, 500,
                                                                    new InterestRateNotional(Currency.USD, 500000), 500, createZdt(2013,3,21), true);
    ExternalId secId = ExternalId.of("SEC_ID", "12345");
    cds.addExternalId(secId);
    document.setSecurity(cds);
    _securityMaster.add(document);

    Position posn = new SimplePosition(BigDecimal.ONE, secId);

    assertEquals(_aggregator.classifyPosition(posn), "39FF64");
View Full Code Here


   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    SecurityDocument latestSecDoc = data().getSecurity();
    SecurityDocument versionedSecurity = data().getVersioned();
    out.put("latestSecurityDoc", latestSecDoc);
    out.put("latestSecurity", latestSecDoc.getSecurity());
    out.put("securityDoc", versionedSecurity);
    out.put("security", versionedSecurity.getSecurity());
    out.put("deleted", !latestSecDoc.isLatest());
    addSecuritySpecificMetaData(versionedSecurity.getSecurity(), out);
    out.put("customRenderer", FreemarkerCustomRenderer.INSTANCE);
    return out;
  }
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    SecurityDocument doc = data().getSecurity();
    out.put("securityDoc", doc);
    out.put("security", doc.getSecurity());
    out.put("deleted", !doc.isLatest());
    return out;
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Path("{versionId}")
  public WebSecurityVersionResource findVersion(@PathParam("versionId") String idStr) {
    data().setUriVersionId(idStr);
    SecurityDocument doc = data().getSecurity();
    UniqueId combined = doc.getUniqueId().withVersion(idStr);
    if (doc.getUniqueId().equals(combined) == false) {
      SecurityDocument versioned = data().getSecurityMaster().get(combined);
      data().setVersioned(versioned);
    } else {
      data().setVersioned(doc);
    }
    return new WebSecurityVersionResource(this);
View Full Code Here

    ManageableSecurity underlying = buildUnderlying(underlyingData);
    ManageableSecurity security;
    if (underlying == null) {
      security = BlotterUtils.buildSecurity(securityData);
    } else {
      ManageableSecurity savedUnderlying = getSecurityMaster().add(new SecurityDocument(underlying)).getSecurity();
      security = buildSecurity(securityData, savedUnderlying);
    }
    ManageableSecurity savedSecurity = getSecurityMaster().add(new SecurityDocument(security)).getSecurity();
    ManageableTrade trade = buildTrade(tradeData);
    trade.setSecurityLink(new ManageableSecurityLink(savedSecurity.getUniqueId()));
    ManageablePosition position = new ManageablePosition();
    position.setQuantity(BigDecimal.ONE);
    position.setSecurityLink(new ManageableSecurityLink(trade.getSecurityLink()));
View Full Code Here

      // need to set the unique ID to the ID from the previous version, securities aren't allowed to change
      // any changes in the security data are interpreted as edits to the security
      ManageableSecurity previousUnderlying = getUnderlyingSecurity(previousSecurity, VersionCorrection.LATEST);
      validateSecurity(underlying, previousUnderlying);
      underlying.setUniqueId(previousUnderlying.getUniqueId());
      ManageableSecurity savedUnderlying = getSecurityMaster().update(new SecurityDocument(underlying)).getSecurity();
      security = buildSecurity(securityData, savedUnderlying, previousSecurity.getExternalIdBundle());
    }
    // need to set the unique ID to the ID from the previous version, securities aren't allowed to change
    // any changes in the security data are interpreted as edits to the security
    validateSecurity(security, previousSecurity);
    security.setUniqueId(previousSecurity.getUniqueId());
    ManageableSecurity savedSecurity = getSecurityMaster().update(new SecurityDocument(security)).getSecurity();
    trade.setSecurityLink(new ManageableSecurityLink(savedSecurity.getUniqueId()));
    ManageablePosition position = getPositionMaster().get(positionId).getPosition();
    position.setTrades(Lists.newArrayList(trade));
    ManageablePosition savedPosition = getPositionMaster().update(new PositionDocument(position)).getPosition();
    ManageableTrade savedTrade = savedPosition.getTrades().get(0);
View Full Code Here

      throw new IllegalStateException("Security must have a unique ID");
    }
    ObjectId objectId = uniqueId.getObjectId();
    ExternalId externalId = ExternalId.of(ObjectId.EXTERNAL_SCHEME, objectId.toString());
    security.addExternalId(externalId);
    _securityMaster.update(new SecurityDocument(security));
    return externalId;
  }
View Full Code Here

      throw new IllegalStateException("Security must have a unique ID");
    }
    ObjectId objectId = uniqueId.getObjectId();
    ExternalId externalId = ExternalId.of(ObjectId.EXTERNAL_SCHEME, objectId.toString());
    security.addExternalId(externalId);
    _securityMaster.update(new SecurityDocument(security));
    return externalId;
  }
View Full Code Here

    FlexiBean out = createRootData();
    return getFreemarker().build(JSON_DIR + getFreemarkerTemplateName(), out);
  }

  private String getFreemarkerTemplateName() {
    SecurityDocument doc = data().getSecurity();
    ManageableSecurity security = doc.getSecurity();
    String result = "default-security.ftl";
    if (security instanceof FinancialSecurity) {
      FinancialSecurity financialSec = (FinancialSecurity) security;
      String templateName = financialSec.accept(getTemplateProvider());
      if (templateName != null) {
View Full Code Here

  @Produces(MediaType.TEXT_HTML)
  public Response putHTML(
      @FormParam("name") String name,
      @FormParam("idscheme") String idScheme,
      @FormParam("idvalue") String idValue) {
    SecurityDocument doc = data().getSecurity();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    URI uri = updateSecurity(doc);
    return Response.seeOther(uri).build();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.security.SecurityDocument

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.