Package com.opengamma.master.orgs

Examples of com.opengamma.master.orgs.ManageableOrganization


                            "organization.trade.obligor_standard_and_poors_credit_rating");

    final long docId = nextId("org_organisation_seq");
    final long docOid = (document.getUniqueId() != null ? extractOid(document.getUniqueId()) : docId);
    final UniqueId organizationUid = createUniqueId(docOid, docId);
    final ManageableOrganization organization = document.getOrganization();

    // the arguments for inserting into the organization table
    final DbMapSqlParameterSource docArgs = new DbMapSqlParameterSource()
        .addValue("doc_id", docId)
        .addValue("doc_oid", docOid)
        .addTimestamp("ver_from_instant", document.getVersionFromInstant())
        .addTimestampNullFuture("ver_to_instant", document.getVersionToInstant())
        .addTimestamp("corr_from_instant", document.getCorrectionFromInstant())
        .addTimestampNullFuture("corr_to_instant", document.getCorrectionToInstant())
        .addValue("provider_scheme",
            document.getProviderId() != null ? document.getProviderId().getScheme().getName() : null,
            Types.VARCHAR)
        .addValue("provider_value",
            document.getProviderId() != null ? document.getProviderId().getValue() : null,
            Types.VARCHAR)
        .addValue("obligor_short_name", organization.getObligor().getObligorShortName(), Types.VARCHAR)
        .addValue("obligor_red_code", organization.getObligor().getObligorREDCode(), Types.VARCHAR)
        .addValue("obligor_ticker", organization.getObligor().getObligorTicker(), Types.VARCHAR)
        .addValue("obligor_composite_rating", organization.getObligor().getCompositeRating().name(), Types.VARCHAR)
        .addValue("obligor_country", organization.getObligor().getCountry(), Types.VARCHAR)
        .addValue("obligor_fitch_credit_rating", organization.getObligor().getFitchCreditRating().name(), Types.VARCHAR)
        .addValue("obligor_implied_rating", organization.getObligor().getImpliedRating().name(), Types.VARCHAR)
        .addValue("obligor_moodys_credit_rating",
                  organization.getObligor().getMoodysCreditRating().name(),
                  Types.VARCHAR)
        .addValue("obligor_region", organization.getObligor().getRegion().name(), Types.VARCHAR)
        .addValue("obligor_sector", organization.getObligor().getSector().name(), Types.VARCHAR)
        .addValue("obligor_standard_and_poors_credit_rating",
                  organization.getObligor().getStandardAndPoorsCreditRating().name(),
                  Types.VARCHAR)
        .addValue("obligor_has_defaulted",
                  organization.getObligor().isHasDefaulted() ? 1 : 0,
                  Types.TINYINT);


    final String sqlDoc = getElSqlBundle().getSql("Insert", docArgs);
    getJdbcTemplate().update(sqlDoc, docArgs);

    // set the uniqueId
    organization.setUniqueId(organizationUid);
    document.setUniqueId(organizationUid);
    return document;
  }
View Full Code Here


      final String sector = rs.getString("obligor_sector");
      final String standardAndPoorsCreditRating = rs.getString("obligor_standard_and_poors_credit_rating");
      final boolean hasDefaulted = rs.getBoolean("obligor_has_defaulted");


      _organization = new ManageableOrganization(
          shortName,
          redCode,
          ticker,
          Region.valueOf(region),
          country,
View Full Code Here

  @Test
  public void test_add_Organization() {
    Instant now = Instant.now(_orgMaster.getClock());

    ManageableOrganization org = new ManageableOrganization("TestOrganization101",
                                                            "RED_code_101",
                                                            "ticker_101",
                                                            Region.AFRICA,
                                                            "CountryA",
                                                            Sector.BASICMATERIALS,
                                                            CreditRating.A,
                                                            CreditRating.A,
                                                            CreditRatingFitch.A,
                                                            CreditRatingMoodys.A,
                                                            CreditRatingStandardAndPoors.A,
                                                            false);
    OrganizationDocument doc = new OrganizationDocument(org);
    String shortName = doc.getOrganization().getObligor().getObligorShortName();

    String redCode = doc.getOrganization().getObligor().getObligorREDCode();
    String ticker = doc.getOrganization().getObligor().getObligorTicker();

    CreditRatingFitch creditRatingFitch = doc.getOrganization().getObligor().getFitchCreditRating();
    CreditRating compositeCreditRating = doc.getOrganization().getObligor().getCompositeRating();
    CreditRating impliedCreditRating = doc.getOrganization().getObligor().getImpliedRating();
    CreditRatingMoodys creditRatingMoodys = doc.getOrganization().getObligor().getMoodysCreditRating();
    CreditRatingStandardAndPoors creditRatingStandardAndPoors = doc.getOrganization().getObligor().getStandardAndPoorsCreditRating();

    String country = doc.getOrganization().getObligor().getCountry();
    Sector sector = doc.getOrganization().getObligor().getSector();
    Region region = doc.getOrganization().getObligor().getRegion();
    boolean hasDefaulted = doc.getOrganization().getObligor().isHasDefaulted();

    OrganizationDocument test = _orgMaster.add(doc);

    UniqueId uniqueId = test.getUniqueId();
    assertNotNull(uniqueId);
    assertEquals("DbOrg", uniqueId.getScheme());
    assertTrue(uniqueId.isVersioned());
    assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
    assertEquals("0", uniqueId.getVersion());
    assertEquals(now, test.getVersionFromInstant());
    assertEquals(null, test.getVersionToInstant());
    assertEquals(now, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableOrganization testOrganization = test.getOrganization();
    assertNotNull(testOrganization);
    assertEquals(uniqueId, testOrganization.getUniqueId());

    assertEquals(shortName, test.getOrganization().getObligor().getObligorShortName());
    assertEquals(redCode, test.getOrganization().getObligor().getObligorREDCode());
    assertEquals(ticker, test.getOrganization().getObligor().getObligorTicker());
View Full Code Here

  }

  @Test
  public void test_add_addThenGet() {
    ManageableOrganization org = new ManageableOrganization("TestOrganization101",
                                                            "RED_code_101",
                                                            "ticker_101",
                                                            Region.AFRICA,
                                                            "CountryA",
                                                            Sector.BASICMATERIALS,
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_add_addWithMissingProperties() {

    OrganizationDocument doc = new OrganizationDocument();
    ManageableOrganization org = new ManageableOrganization();
    doc.setOrganization(org);
    _orgMaster.add(doc);
  }
View Full Code Here

    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version1Instant, test.getVersionFromInstant());
    assertEquals(null, test.getVersionToInstant());
    assertEquals(_version1Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableOrganization organization = test.getOrganization();
    assertNotNull(organization);
    assertEquals(uniqueId, organization.getUniqueId());
    assertEquals(ExternalId.of(PROVIDER_SCHEME, "1"), test.getProviderId());
    assertEquals("TestOrganization101", test.getOrganization().getObligor().getObligorShortName());
    assertEquals("RED_code_101", test.getOrganization().getObligor().getObligorREDCode());
    assertEquals("ticker_101", test.getOrganization().getObligor().getObligorTicker());
    assertEquals("CountryA", test.getOrganization().getObligor().getCountry());
View Full Code Here

    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version1Instant, test.getVersionFromInstant());
    assertEquals(null, test.getVersionToInstant());
    assertEquals(_version1Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableOrganization organization = test.getOrganization();
    assertNotNull(organization);
    assertEquals(uniqueId, organization.getUniqueId());
    assertEquals(ExternalId.of(PROVIDER_SCHEME, "2"), test.getProviderId());
    assertEquals("TestOrganization102", test.getOrganization().getObligor().getObligorShortName());
    assertEquals("RED_code_102", test.getOrganization().getObligor().getObligorREDCode());
    assertEquals("ticker_102", test.getOrganization().getObligor().getObligorTicker());
    assertEquals("CountryB", test.getOrganization().getObligor().getCountry());
View Full Code Here

    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version1Instant, test.getVersionFromInstant());
    assertEquals(_version2Instant, test.getVersionToInstant());
    assertEquals(_version1Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableOrganization organization = test.getOrganization();
    assertNotNull(organization);
    assertEquals(uniqueId, organization.getUniqueId());
    assertEquals(ExternalId.of(PROVIDER_SCHEME, "3"), test.getProviderId());
    assertEquals("TestOrganization201", test.getOrganization().getObligor().getObligorShortName());
    assertEquals("RED_code_201", test.getOrganization().getObligor().getObligorREDCode());
    assertEquals("ticker_201", test.getOrganization().getObligor().getObligorTicker());
    assertEquals("CountryC", test.getOrganization().getObligor().getCountry());
View Full Code Here

    assertEquals(uniqueId, test.getUniqueId());
    assertEquals(_version2Instant, test.getVersionFromInstant());
    assertEquals(null, test.getVersionToInstant());
    assertEquals(_version2Instant, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableOrganization organization = test.getOrganization();
    assertNotNull(organization);
    assertEquals(uniqueId, organization.getUniqueId());
    assertEquals(ExternalId.of(PROVIDER_SCHEME, "3"), test.getProviderId());
    assertEquals("TestOrganization201", test.getOrganization().getObligor().getObligorShortName());
    assertEquals("RED_code_201", test.getOrganization().getObligor().getObligorREDCode());
    assertEquals("ticker_201", test.getOrganization().getObligor().getObligorTicker());
    assertEquals("CountryD", test.getOrganization().getObligor().getCountry());
View Full Code Here

  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_noOrganizationId() {
    UniqueId uniqueId = UniqueId.of("DbOrg", "101");
    ManageableOrganization org = new ManageableOrganization("TestOrganization101",
                                                            "RED_code_101",
                                                            "ticker_101",
                                                            Region.AFRICA,
                                                            "CountryA",
                                                            Sector.BASICMATERIALS,
                                                            CreditRating.A,
                                                            CreditRating.A,
                                                            CreditRatingFitch.A,
                                                            CreditRatingMoodys.A,
                                                            CreditRatingStandardAndPoors.A,
                                                            false);
    org.setUniqueId(uniqueId);
    OrganizationDocument doc = new OrganizationDocument();
    doc.setOrganization(org);
    _orgMaster.update(doc);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.orgs.ManageableOrganization

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.