Skip to main content
summaryrefslogtreecommitdiffstats
blob: b87b81e2352e912a6f7c9be0d0f277bc4c3b4b71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * Copyright (c) 2009-2013 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
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.net4j.util.event.INotifier;

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
 * @noextend This interface is not intended to be extended by clients.
 * @noimplement This interface is not intended to be implemented by clients.
 * @apiviz.landmark
 * @apiviz.has {@link CDORevisionFactory}
 * @apiviz.has {@link CDORevisionCache}
 * @apiviz.uses {@link CDORevision} - - loads
 */
public interface CDORevisionManager extends INotifier
{
  /**
   * 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);

  /**
   * @since 4.3
   */
  public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime,
      CDORevisionHandler handler);
}

Back to the top