Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6c9678906132510427fdb980a6c9a145f7bd0313 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/**
 * Copyright (c) 2004 - 2011 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:
 *    Simon McDuff - initial API and implementation
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.spi.cdo;

import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
import org.eclipse.emf.cdo.transaction.CDOTransaction;

import org.eclipse.net4j.util.collection.Pair;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Simon McDuff
 * @since 2.0
 * @noextend This interface is not intended to be extended by clients.
 * @noimplement This interface is not intended to be implemented by clients.
 */
public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserTransaction, InternalCDOView
{
  public InternalCDOCommitContext createCommitContext();

  /**
   * @since 3.0
   */
  public InternalCDOSavepoint setSavepoint();

  /**
   * @since 3.0
   */
  public InternalCDOSavepoint getLastSavepoint();

  /**
   * @since 3.0
   */
  public InternalCDOSavepoint handleSetSavepoint();

  /**
   * @since 3.0
   */
  public void handleRollback(InternalCDOSavepoint savepoint);

  public CDOTransactionStrategy getTransactionStrategy();

  public void setTransactionStrategy(CDOTransactionStrategy transactionStrategy);

  /**
   * @return never <code>null</code>;
   */
  public CDOResourceFolder getOrCreateResourceFolder(List<String> names);

  public void detachObject(InternalCDOObject object);

  /**
   * @deprecated {@link #createIDForNewObject(EObject)} is called since 4.1.
   */
  @Deprecated
  public CDOIDTemp getNextTemporaryID();

  /**
   * @since 4.1
   */
  public CDOID createIDForNewObject(EObject object);

  /**
   * @since 4.0
   */
  public void registerAttached(InternalCDOObject object, boolean isNew);

  public void registerDirty(InternalCDOObject object, CDOFeatureDelta featureDelta);

  public void registerFeatureDelta(InternalCDOObject object, CDOFeatureDelta featureDelta);

  public void registerRevisionDelta(CDORevisionDelta revisionDelta);

  public void setConflict(InternalCDOObject object);

  /**
   * @param source
   *          May be <code>null</code> if changeSetData does not result from a
   *          {@link #merge(CDOBranchPoint, org.eclipse.emf.cdo.transaction.CDOMerger) merge} or if the merge was not in
   *          a {@link CDOBranch#isLocal() local} branch.
   * @since 4.0
   * @deprecated Use
   *             {@link #applyChangeSet(CDOChangeSetData, CDORevisionProvider, CDORevisionProvider, CDOBranchPoint, boolean)}
   */
  @Deprecated
  public Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>> applyChangeSetData(
      CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider,
      CDOBranchPoint source);

  /**
   * @param source
   *          May be <code>null</code> if changeSetData does not result from a
   *          {@link #merge(CDOBranchPoint, org.eclipse.emf.cdo.transaction.CDOMerger) merge} or if the merge was not in
   *          a {@link CDOBranch#isLocal() local} branch.
   * @since 4.1
   */
  public ApplyChangeSetResult applyChangeSet(CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider,
      CDORevisionProvider targetProvider, CDOBranchPoint source, boolean keepVersions)
      throws ChangeSetOutdatedException;

  /**
   * @since 4.0
   */
  public Map<InternalCDOObject, InternalCDORevision> getCleanRevisions();

  /**
   * Provides a context for a commit operation.
   * 
   * @author Simon McDuff
   */
  public interface InternalCDOCommitContext extends CDOCommitContext
  {
    public InternalCDOTransaction getTransaction();

    /**
     * @since 3.0
     */
    public CDOCommitData getCommitData();

    public void preCommit();

    public void postCommit(CommitTransactionResult result);
  }

  /**
   * @author Eike Stepper
   * @since 4.1
   */
  public final class ApplyChangeSetResult
  {
    private CDOChangeSetData changeSetData = new CDOChangeSetDataImpl();

    private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();

    private List<CDOID> adjustedObjects = new ArrayList<CDOID>();

    public ApplyChangeSetResult()
    {
    }

    public CDOChangeSetData getChangeSetData()
    {
      return changeSetData;
    }

    public Map<CDOID, CDOID> getIDMappings()
    {
      return idMappings;
    }

    public List<CDOID> getAdjustedObjects()
    {
      return adjustedObjects;
    }
  }

  /**
   * @author Eike Stepper
   * @since 4.1
   */
  public static final class ChangeSetOutdatedException extends RuntimeException
  {
    private static final long serialVersionUID = 1L;

    public ChangeSetOutdatedException()
    {
      super("Change set is outdated");
    }
  }
}

Back to the top