Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java119
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java19
3 files changed, 141 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
index 663a4f1331..ee535b97f7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
@@ -14,12 +14,16 @@ package org.eclipse.emf.cdo.common.revision;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
/**
- * Encapsulates the immutable information of a single CDO object between two commits in a {@link CDOBranch branch}.
+ * Encapsulates the immutable system information of a <b>single</b> CDO {@link EObject object} between two
+ * {@link CDOCommitInfo commits} in a {@link CDOBranch branch} and provides access to its modeled
+ * {@link CDORevisionData data}.
*
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java
index 46f52bcf04..5cfc2f926e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java
@@ -11,17 +11,36 @@
package org.eclipse.emf.cdo.common.revision;
import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import java.util.List;
/**
* Provides access to {@link CDORevision revisions} in a CDO {@link CDOCommonRepository repository} by demand loading
* and caching them.
+ * <p>
+ * Revisions are generally queried by:
+ * <p>
+ * <ul>
+ * <li>their object {@link CDOID ID} <b>and</b>
+ * <li>their {@link CDOBranch branch} plus <b>either</b>:
+ * <ul>
+ * <li>a timestamp <b>or</b>
+ * <li>a version
+ * </ul>
+ * </ul>
+ * <p>
+ * If querying by timestamp it's also possible to ask for multiple revisions (identified by a list of object IDs) in one
+ * round trip (to the server if this revision manager is contained by a {@link CDOCommonSession session} or to the
+ * backend store if it is contained by a {@link CDOCommonRepository repository}.
*
* @author Eike Stepper
* @since 3.0
@@ -35,20 +54,118 @@ import java.util.List;
public interface CDORevisionManager
{
/**
- * @return The type of an object if a revision for that object is in the revision cache, <code>null</code> otherwise.
+ * Returns the {@link CDORevision#getEClass() type} of an object if a revision for that object is in the revision
+ * cache, <code>null</code> otherwise.
+ * <p>
+ * Same as calling {@link #getObjectType(CDOID, CDOBranchManager) getObjectType(id, null)}.
+ *
+ * @see EObject#eClass()
+ * @see #getObjectType(CDOID, CDOBranchManager)
*/
public EClass getObjectType(CDOID id);
+ /**
+ * Returns the {@link CDORevision#getEClass() type} of an object.
+ * <p>
+ * If no revision for that object is found in the revision cache the following is tried:
+ * <ol>
+ * <li>If <code>branchManagerForLoadOnDemand</code> is not <code>null</code> the first revision of the object in the
+ * main branch is loaded from the server and its type is returned.
+ * <li>Otherwise (i.e., if <code>branchManagerForLoadOnDemand</code> is <code>null</code> or the object does not
+ * exist) <code>null</code> is returned.
+ * </ol>
+ * <p>
+ * A {@link CDOBranchManager branch manager} is required instead of just a boolean value to specify whether to
+ * demand-load or not because this revision manager must be able to access the
+ * {@link CDOBranchManager#getMainBranch() main branch} while demand-loading.
+ *
+ * @see EObject#eClass()
+ * @see #getObjectType(CDOID)
+ * @since 4.1
+ */
+ public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand);
+
+ /**
+ * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision}
+ * with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch point} (branch + timestamp),
+ * <code>false</code> otherwise.
+ *
+ * @see CDORevisionManager#getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ * @see CDORevisionManager#getRevisions(List, CDOBranchPoint, int, int, boolean)
+ */
public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint);
+ /**
+ * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch
+ * point} (branch + timestamp), optionally demand loading it if it is not already in the {@link CDORevisionCache
+ * cache}.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or
+ * {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param prefetchDepth
+ * The number of nested containment levels to load revisions for in one round trip. Use the symbolic
+ * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or
+ * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revision is
+ * returned by this method. If additional revisions are prefetched they are placed in the revision cache to
+ * speed up subsequent calls to this method.
+ * @param loadOnDemand
+ * If the requested revision is not contained in the revision cache it depends on this parameter's value
+ * whether the revision is loaded from the server or <code>null</code> is returned.
+ * @see #getRevisions(List, CDOBranchPoint, int, int, boolean)
+ * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean)
+ */
public CDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
boolean loadOnDemand);
+ /**
+ * Returns the {@link CDORevision revisions} with the given {@link CDOID IDs} at the given {@link CDOBranchPoint
+ * branch point} (branch + timestamp), optionally demand loading them if they are not already in the
+ * {@link CDORevisionCache cache}.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revisions,
+ * or {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param prefetchDepth
+ * The number of nested containment levels to load revisions for in one round trip. Use the symbolic
+ * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or
+ * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revisions are
+ * returned by this method. If additional revisions are prefetched they are placed in the revision cache to
+ * speed up subsequent calls to this method.
+ * @param loadOnDemand
+ * If one or more of the requested revisions is/are not contained in the revision cache it depends on this
+ * parameter's value whether the revision(s) is/are loaded from the server or <code>null</code> is placed in
+ * the list that is returned.
+ * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ */
public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
int prefetchDepth, boolean loadOnDemand);
+ /**
+ * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision}
+ * with the given {@link CDOID ID} at the given {@link CDOBranchVersion branch version} (branch + version),
+ * <code>false</code> otherwise.
+ *
+ * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean)
+ */
public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion);
+ /**
+ * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchVersion
+ * branch version} (branch + version), optionally demand loading it if it is not already in the
+ * {@link CDORevisionCache cache}.
+ * <p>
+ * Prefetching of nested containment levels is not support by this method because the version of a particular revision
+ * can not serve as a reasonable baseline criterium for a consistent graph of multiple revisions.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or
+ * {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param loadOnDemand
+ * If the requested revision is not contained in the revision cache it depends on this parameter's value
+ * whether the revision is loaded from the server or <code>null</code> is returned.
+ * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ */
public CDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
boolean loadOnDemand);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
index cfa16e5796..893ee7ea7a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
@@ -13,6 +13,7 @@
package org.eclipse.emf.cdo.internal.common.revision;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
@@ -151,9 +152,25 @@ public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevi
this.cache = (InternalCDORevisionCache)cache;
}
+ public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
+ {
+ EClass type = cache.getObjectType(id);
+ if (type == null && branchManagerForLoadOnDemand != null)
+ {
+ CDOBranch mainBranch = branchManagerForLoadOnDemand.getMainBranch();
+ CDORevision revision = getRevisionByVersion(id, mainBranch.getVersion(CDOBranchVersion.FIRST_VERSION), 0, true);
+ if (revision != null)
+ {
+ type = revision.getEClass();
+ }
+ }
+
+ return type;
+ }
+
public EClass getObjectType(CDOID id)
{
- return cache.getObjectType(id);
+ return getObjectType(id, null);
}
public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)

Back to the top