Examples of OrganizationDocument


Examples of com.opengamma.master.orgs.OrganizationDocument

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

    UniqueId uniqueId = UniqueId.of("DbOrg", "101", "0");
    OrganizationDocument base = _orgMaster.get(uniqueId);
    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 input = new OrganizationDocument(org);

    OrganizationDocument corrected = _orgMaster.correct(input);
    assertEquals(false, base.getUniqueId().equals(corrected.getUniqueId()));
    assertEquals(base.getVersionFromInstant(), corrected.getVersionFromInstant());
    assertEquals(base.getVersionToInstant(), corrected.getVersionToInstant());
    assertEquals(now, corrected.getCorrectionFromInstant());
    assertEquals(null, corrected.getCorrectionToInstant());
    assertEquals(input.getOrganization(), corrected.getOrganization());

    OrganizationDocument old = _orgMaster.get(UniqueId.of("DbOrg", "101", "0"));
    assertEquals(base.getUniqueId(), old.getUniqueId());
    assertEquals(base.getVersionFromInstant(), old.getVersionFromInstant());
    assertEquals(base.getVersionToInstant(), old.getVersionToInstant());
    assertEquals(base.getCorrectionFromInstant(), old.getCorrectionFromInstant());
    assertEquals(now, old.getCorrectionToInstant())// old version ended
    assertEquals(base.getOrganization(), old.getOrganization());

    OrganizationHistoryRequest search = new OrganizationHistoryRequest(base.getUniqueId(), now, null);
    OrganizationHistoryResult searchResult = _orgMaster.history(search);
    assertEquals(2, searchResult.getDocuments().size());
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

  @Override
  public OrganizationDocument get(ObjectIdentifiable objectId, VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(objectId, "objectId");
    ArgumentChecker.notNull(versionCorrection, "versionCorrection");
    final OrganizationDocument document = _store.get(objectId.getObjectId());
    if (document == null) {
      throw new DataNotFoundException("Organization not found: " + objectId);
    }
    return cloneOrganizationDocument(document);
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

    }
    return cloneOrganizationDocument(document);
  }

  private OrganizationDocument cloneOrganizationDocument(OrganizationDocument document) {
    OrganizationDocument clone = JodaBeanUtils.clone(document);
    ManageableOrganization organizationClone = JodaBeanUtils.clone(document.getOrganization());
    clone.setOrganization(organizationClone);
    return clone;
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

    final ObjectId objectId = _objectIdSupplier.get();
    final UniqueId uniqueId = objectId.atVersion("");
    final Instant now = Instant.now();

    final OrganizationDocument clonedDoc = cloneOrganizationDocument(document);
    setDocumentId(document, clonedDoc, uniqueId);
    setVersionTimes(document, clonedDoc, now, null, now, null);
    _store.put(objectId, clonedDoc);

    _changeManager.entityChanged(ChangeType.ADDED, objectId, document.getVersionFromInstant(), document.getVersionToInstant(), now);
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

    ArgumentChecker.notNull(document.getUniqueId(), "document.uniqueId");
    ArgumentChecker.notNull(document.getOrganization(), "document.organization");

    final UniqueId uniqueId = document.getUniqueId();
    final Instant now = Instant.now();
    final OrganizationDocument storedDocument = _store.get(uniqueId.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Organization not found: " + uniqueId);
    }

    final OrganizationDocument clonedDoc = cloneOrganizationDocument(document);


    setVersionTimes(document, clonedDoc, now, null, now, null);

    if (_store.replace(uniqueId.getObjectId(), storedDocument, clonedDoc) == false) {
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument


  @Override
  public void remove(ObjectIdentifiable objectIdentifiable) {
    ArgumentChecker.notNull(objectIdentifiable, "objectIdentifiable");
    OrganizationDocument storedDocument = _store.remove(objectIdentifiable.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Organization not found " + objectIdentifiable);
    }   
    _changeManager.entityChanged(ChangeType.REMOVED, objectIdentifiable.getObjectId(), null, null, Instant.now());
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

  }

  @POST
  @Path("organizations")
  public Response add(@Context UriInfo uriInfo, OrganizationDocument request) {
    OrganizationDocument result = getOrganizationMaster().add(request);
    URI createdUri = (new DataOrganizationResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId());
    return responseCreatedFudge(createdUri, result);
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

    return getMaster().getOrganization(uniqueId);
  }

  @Override
  public Organization get(ObjectId objectId, VersionCorrection versionCorrection) {
    OrganizationDocument document = getMaster().get(objectId, versionCorrection);
    return document == null ? null : document.getOrganization();
  }
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

    ManageableOrganization org = new ManageableOrganization("ShortName", "39FF64", "Ticker", Region.NORTHAMERICA,
                                                            "US", Sector.FINANCIALS, CreditRating.NR, CreditRating.NR,
                                                            CreditRatingFitch.NR, CreditRatingMoodys.NR,
                                                            CreditRatingStandardAndPoors.NR, false);

    _organizationMaster.add(new OrganizationDocument(org));

    SecurityDocument document = new SecurityDocument();
    ManageableSecurity cds = createCdsWithRedCode("39FF64");
    ExternalId secId = ExternalId.of("SEC_ID", "12345");
    cds.addExternalId(secId);
View Full Code Here

Examples of com.opengamma.master.orgs.OrganizationDocument

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    OrganizationDocument latestOrgDoc = data().getOrganization();
    OrganizationDocument versionedOrganization = data().getVersioned();
    out.put("latestOrganizationDoc", latestOrgDoc);
    out.put("latestOrganization", latestOrgDoc.getOrganization());
    out.put("organizationDoc", versionedOrganization);
    out.put("organization", versionedOrganization.getOrganization());
    out.put("deleted", !latestOrgDoc.isLatest());
    return out;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.