Package com.opengamma.core.change

Examples of com.opengamma.core.change.BasicChangeManager


   * Creates an instance specifying the supplier of object identifiers.
   *
   * @param objectIdSupplier the supplier of object identifiers, not null
   */
  public InMemoryConfigMaster(final Supplier<ObjectId> objectIdSupplier) {
    this(objectIdSupplier, new BasicChangeManager());
  }
View Full Code Here


   * Creates a fresh mock master and configures it to respond as though it contains the above documents
   * @return the mock master
   */
  protected AbstractChangeProvidingMaster<D> populateMockMaster(M mockUnderlyingMaster) {

    ChangeManager changeManager = new BasicChangeManager();
    when(mockUnderlyingMaster.changeManager()).thenReturn(changeManager);

    // Set up VersionFrom, VersionTo, CorrectionFrom, CorrectionTo

    // Document A 100: v 1999 to 2010, c to 2011
View Full Code Here

                                                  new UidToDocumentCacheEntryFactory<>(_underlying));
    getCacheManager().replaceCacheWithDecoratedCache(_cacheManager.getCache(name + CACHE_NAME_SUFFIX),
                                                     getUidToDocumentCache());

    // Listen to change events from underlying, clean this cache accordingly and relay events to our change listeners
    _changeManager = new BasicChangeManager();
    _changeListener = new ChangeListener() {
      @Override
      public void entityChanged(ChangeEvent event) {
        final ObjectId oid = event.getObjectId();
        final Instant versionFrom = event.getVersionFrom();
View Full Code Here

   * Creates an instance specifying the supplier of object identifiers.
   *
   * @param objectIdSupplier  the supplier of object identifiers, not null
   */
  public InMemorySnapshotMaster(final Supplier<ObjectId> objectIdSupplier) {
    this(objectIdSupplier, new BasicChangeManager());
  }
View Full Code Here

   * Creates an instance.
   *
   * @param baseUri  the base target URI for all RESTful web services, not null
   */
  public AbstractRemoteMaster(final URI baseUri) {
    this(baseUri, new BasicChangeManager());
  }
View Full Code Here

   * Creates an instance.
   *
   * @param baseUri  the base target URI for all RESTful web services, not null
   */
  public AbstractRemoteDocumentMaster(final URI baseUri) {
    super(baseUri, new BasicChangeManager());
  }
View Full Code Here

   * Creates an instance specifying the supplier of object identifiers.
   *
   * @param objectIdSupplier  the supplier of object identifiers, not null
   */
  public SimpleAbstractInMemoryMaster(final Supplier<ObjectId> objectIdSupplier) {
    this(objectIdSupplier, new BasicChangeManager());
  }
View Full Code Here

    return wrap(underlying, Clock.systemUTC());
  }

  public static <D extends AbstractDocument> AbstractChangeProvidingMaster<D> wrap(final AbstractMaster<D> underlying, final Clock clock) {
    return new AbstractChangeProvidingMaster<D>() {
      private final BasicChangeManager _changeManager = new BasicChangeManager();

      @Override
      public ChangeManager changeManager() {
        return _changeManager;
      }

      @Override
      public D add(D document) {
        D doc = underlying.add(document);
        _changeManager.entityChanged(ChangeType.CHANGED, doc.getObjectId(), doc.getVersionFromInstant(), doc.getVersionToInstant(), Instant.now(clock));
        return doc;
      }

      @Override
      public UniqueId addVersion(ObjectIdentifiable objectId, D documentToAdd) {
        UniqueId uid = underlying.addVersion(objectId, documentToAdd);
        _changeManager.entityChanged(ChangeType.ADDED, uid.getObjectId(), null, null, Instant.now(clock));
        return uid;
      }

      @Override
      public D correct(D document) {
        D doc = underlying.correct(document);
        _changeManager.entityChanged(ChangeType.CHANGED, doc.getObjectId(), doc.getVersionFromInstant(), doc.getVersionToInstant(), Instant.now(clock));
        return doc;
      }

      @Override
      public D get(ObjectIdentifiable objectId, VersionCorrection versionCorrection) {
        return underlying.get(objectId, versionCorrection);
      }

      @Override
      public D get(UniqueId uniqueId) {
        return underlying.get(uniqueId);
      }

      @Override
      public Map<UniqueId, D> get(Collection<UniqueId> uniqueIds) {
        return underlying.get(uniqueIds);
      }

      @Override
      public void remove(ObjectIdentifiable objectIdentifiable) {
        underlying.remove(objectIdentifiable);
        _changeManager.entityChanged(ChangeType.REMOVED, objectIdentifiable.getObjectId(), null, null, Instant.now(clock));
      }

      @Override
      public void removeVersion(UniqueId uniqueId) {
        underlying.removeVersion(uniqueId);
        _changeManager.entityChanged(ChangeType.REMOVED, uniqueId.getObjectId(), null, null, Instant.now(clock));
      }

      @Override
      public List<UniqueId> replaceAllVersions(ObjectIdentifiable objectId, List<D> replacementDocuments) {
        List<UniqueId> removed = underlying.replaceAllVersions(objectId, replacementDocuments);
        _changeManager.entityChanged(ChangeType.REMOVED, objectId.getObjectId(), null, null, Instant.now(clock));
        return removed;
      }

      @Override
      public UniqueId replaceVersion(D replacementDocument) {
        UniqueId uid = underlying.replaceVersion(replacementDocument);
        _changeManager.entityChanged(ChangeType.CHANGED, uid.getObjectId(), null, null, Instant.now(clock));
        return uid;
      }

      @Override
      public List<UniqueId> replaceVersion(UniqueId uniqueId, List<D> replacementDocuments) {
        List<UniqueId> replaced = underlying.replaceVersion(uniqueId, replacementDocuments);
        _changeManager.entityChanged(ChangeType.CHANGED, uniqueId.getObjectId(), null, null, Instant.now(clock));
        return replaced;
      }

      @Override
      public List<UniqueId> replaceVersions(ObjectIdentifiable objectId, List<D> replacementDocuments) {
        List<UniqueId> replaced = underlying.replaceVersions(objectId, replacementDocuments);
        _changeManager.entityChanged(ChangeType.CHANGED, objectId.getObjectId(), null, null, Instant.now(clock));
        return replaced;
      }

      @Override
      public D update(D document) {
        D doc = underlying.update(document);
        _changeManager.entityChanged(ChangeType.CHANGED, doc.getObjectId(), doc.getVersionFromInstant(), doc.getVersionToInstant(), Instant.now(clock));
        return doc;
      }
    };

  }
View Full Code Here

TOP

Related Classes of com.opengamma.core.change.BasicChangeManager

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.