Examples of ExchangeDocument


Examples of com.opengamma.master.exchange.ExchangeDocument

      final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
      final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
      List<ExchangeDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        ManageableExchange ex = new ManageableExchange(bundle, "replace_" + i, region, null);
        ExchangeDocument doc = new ExchangeDocument(ex);
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }

      _exgMaster.replaceVersion(baseOid.atVersion("no such uid"), replacement);
    } finally {
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_replaceVersion_noExchangeId() {
    UniqueId uniqueId = UniqueId.of("DbExg", "101");
    ManageableExchange exchange = new ManageableExchange(BUNDLE, "Test", REGION, null);
    exchange.setUniqueId(uniqueId);
    ExchangeDocument doc = new ExchangeDocument(exchange);
    doc.setUniqueId(null);
    _exgMaster.replaceVersion(doc);
  }
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

  @Test(expectedExceptions = DataNotFoundException.class)
  public void test_replaceVersion_notFound() {
    UniqueId uniqueId = UniqueId.of("DbExg", "0", "0");
    ManageableExchange exchange = new ManageableExchange(BUNDLE, "Test", REGION, null);
    exchange.setUniqueId(uniqueId);
    ExchangeDocument doc = new ExchangeDocument(exchange);
    _exgMaster.replaceVersion(doc);
  }
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

      _exgMaster.setClock(Clock.fixed(now, ZoneOffset.UTC));

      final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
      final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
      ManageableExchange exchange = new ManageableExchange(bundle, "initial", region, null);
      ExchangeDocument initialDoc = new ExchangeDocument(exchange);

      _exgMaster.add(initialDoc);

      ObjectId baseOid = initialDoc.getObjectId();

      List<ExchangeDocument> firstReplacement = newArrayList();
      for (int i = 0; i < 5; i++) {
        ManageableExchange ex = new ManageableExchange(bundle, "setup_" + i, region, null);
        ExchangeDocument doc = new ExchangeDocument(ex);
        doc.setVersionFromInstant(now.plus(i, MINUTES));
        firstReplacement.add(doc);
      }
      _exgMaster.setClock(Clock.fixed(now.plus(1, HOURS), ZoneOffset.UTC));
      _exgMaster.replaceVersions(baseOid, firstReplacement);
      return baseOid;
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

  }

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

Examples of com.opengamma.master.exchange.ExchangeDocument

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

Examples of com.opengamma.master.exchange.ExchangeDocument

    final UniqueId uniqueId = objectId.atVersion("");
    final ManageableExchange exchange = document.getExchange().clone();
    exchange.setUniqueId(uniqueId);
    document.setUniqueId(uniqueId);
    final Instant now = Instant.now();
    final ExchangeDocument doc = new ExchangeDocument(exchange);
    doc.setVersionFromInstant(now);
    doc.setCorrectionFromInstant(now);
    _store.put(objectId, doc);
    _changeManager.entityChanged(ChangeType.ADDED, objectId, doc.getVersionFromInstant(), doc.getVersionToInstant(), now);
    return doc;
  }
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

    ArgumentChecker.notNull(document.getUniqueId(), "document.uniqueId");
    ArgumentChecker.notNull(document.getExchange(), "document.exchange");

    final UniqueId uniqueId = document.getUniqueId();
    final Instant now = Instant.now();
    final ExchangeDocument storedDocument = _store.get(uniqueId.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Exchange not found: " + uniqueId);
    }
    document.setVersionFromInstant(now);
    document.setVersionToInstant(null);
    document.setCorrectionFromInstant(now);
    document.setCorrectionToInstant(null);
    document.setUniqueId(uniqueId.withVersion(""));
    if (_store.replace(uniqueId.getObjectId(), storedDocument, document) == false) {
      throw new IllegalArgumentException("Concurrent modification");
    }
    _changeManager.entityChanged(ChangeType.CHANGED, document.getObjectId(), storedDocument.getVersionFromInstant(), document.getVersionToInstant(), now);
    return document;
  }
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

  public ExchangeHistoryResult history(final ExchangeHistoryRequest request) {
    ArgumentChecker.notNull(request, "request");
    ArgumentChecker.notNull(request.getObjectId(), "request.objectId");

    final ExchangeHistoryResult result = new ExchangeHistoryResult();
    final ExchangeDocument doc = get(request.getObjectId(), VersionCorrection.LATEST);
    if (doc != null) {
      result.getDocuments().add(doc);
    }
    result.setPaging(Paging.ofAll(result.getDocuments()));
    return result;
View Full Code Here

Examples of com.opengamma.master.exchange.ExchangeDocument

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_noExchangeId() {
    UniqueId uniqueId = UniqueId.of("DbExg", "101");
    ManageableExchange exchange = new ManageableExchange(BUNDLE, "Test", REGION, null);
    exchange.setUniqueId(uniqueId);
    ExchangeDocument doc = new ExchangeDocument();
    doc.setExchange(exchange);
    _exgMaster.update(doc);
  }
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.