View | Details | Raw Unified | Return to bug 214752 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java (-30 / +28 lines)
Lines 83-111 Link Here
83
83
84
  public CDORevision readRevision(CDOID id, int referenceChunk)
84
  public CDORevision readRevision(CDOID id, int referenceChunk)
85
  {
85
  {
86
    InternalCDORevision storeRevision = (InternalCDORevision)getStore().getRevision(id);
86
    CDORevision storeRevision = getStore().getRevision(id);
87
    // IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
87
    return CDORevisionUtil.copy(storeRevision);
88
    // InternalCDORevision newRevision = new InternalCDORevision(revisionManager, storeRevision.getCDOClass(),
89
    // storeRevision
90
    // .getID());
91
    // newRevision.setResourceID(storeRevision.getResourceID());
92
    //
93
    // for (CDOFeature feature : storeRevision.getCDOClass().getAllFeatures())
94
    // {
95
    // if (feature.isMany())
96
    // {
97
    // newRevision.setListSize(feature, storeRevision.getList(feature).size());
98
    // MoveableList<Object> list = newRevision.getList(feature);
99
    // int size = referenceChunk == CDORevision.UNCHUNKED ? list.size() : referenceChunk;
100
    // for (int i = 0; i < size; i++)
101
    // {
102
    // list.set(i, storeRevision.get(feature, i));
103
    // }
104
    // }
105
    // }
106
    //
107
    // return newRevision;
108
    return storeRevision;
109
  }
88
  }
110
89
111
  public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
90
  public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
Lines 115-121 Link Here
115
94
116
  public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
95
  public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
117
  {
96
  {
118
    throw new UnsupportedOperationException();
97
    CDORevision rev = getStore().getRevisionByVersion(id, version);
98
    if (rev == null)
99
    {
100
      throw new IllegalStateException("Cannot find id " + id + " with version " + version);
101
    }
102
    return CDORevisionUtil.copy(rev);
119
  }
103
  }
120
104
121
  public CDOID readResourceID(String path)
105
  public CDOID readResourceID(String path)
Lines 134-140 Link Here
134
118
135
  public void writeRevision(InternalCDORevision revision)
119
  public void writeRevision(InternalCDORevision revision)
136
  {
120
  {
137
    newRevisions.add(revision);
121
    CDORevision newRevision = CDORevisionUtil.copy(revision);
122
    getStore().addRevision(newRevision);
123
    newRevisions.add(newRevision);
138
  }
124
  }
139
125
140
  @Override
126
  @Override
Lines 143-152 Link Here
143
    InternalCDORevision revision = (InternalCDORevision)getStore().getRevision(delta.getID());
129
    InternalCDORevision revision = (InternalCDORevision)getStore().getRevision(delta.getID());
144
    InternalCDORevision newRevision = (InternalCDORevision)CDORevisionUtil.copy(revision);
130
    InternalCDORevision newRevision = (InternalCDORevision)CDORevisionUtil.copy(revision);
145
    delta.apply(newRevision);
131
    delta.apply(newRevision);
132
    getStore().addRevision(newRevision);
146
    newRevisions.add(newRevision);
133
    newRevisions.add(newRevision);
147
  }
134
  }
148
135
149
  @Override
136
  @Override
137
  public InternalCDORevision verifyRevision(CDORevision revision)
138
  {
139
    InternalCDORevision storeRevision = (InternalCDORevision)getStore().getRevision(revision.getID());
140
    if (storeRevision.getVersion() != revision.getVersion())
141
    {
142
      revision = CDORevisionUtil.copy(storeRevision);
143
    }
144
    return (InternalCDORevision)revision;
145
  }
146
147
  @Override
150
  public void release()
148
  public void release()
151
  {
149
  {
152
    newRevisions.clear();
150
    newRevisions.clear();
Lines 154-167 Link Here
154
152
155
  public void commit()
153
  public void commit()
156
  {
154
  {
157
    MEMStore store = getStore();
158
    for (CDORevision revision : newRevisions)
159
    {
160
      store.addRevision(revision);
161
    }
162
  }
155
  }
163
156
164
  public void rollback()
157
  public void rollback()
165
  {
158
  {
159
    MEMStore store = getStore();
160
    for (CDORevision revision : newRevisions)
161
    {
162
      store.removeRevision(revision);
163
    }
166
  }
164
  }
167
}
165
}
(-)src/org/eclipse/emf/cdo/tests/RollbackTest.java (-1 / +39 lines)
Lines 56-64 Link Here
56
  {
56
  {
57
    // Client1
57
    // Client1
58
    CDOResource resource1 = transaction1.createResource("/test1");
58
    CDOResource resource1 = transaction1.createResource("/test1");
59
59
    Company company1 = Model1Factory.eINSTANCE.createCompany();
60
    Company company1 = Model1Factory.eINSTANCE.createCompany();
60
    resource1.getContents().add(company1);
61
    Category category1 = Model1Factory.eINSTANCE.createCategory();
61
    Category category1 = Model1Factory.eINSTANCE.createCategory();
62
63
    resource1.getContents().add(company1);
62
    company1.getCategories().add(category1);
64
    company1.getCategories().add(category1);
63
    transaction1.commit();
65
    transaction1.commit();
64
66
Lines 66-71 Link Here
66
    CDOResource resource2 = transaction2.getResource("/test1");
68
    CDOResource resource2 = transaction2.getResource("/test1");
67
    Company company2 = (Company)resource2.getContents().get(0);
69
    Company company2 = (Company)resource2.getContents().get(0);
68
    Category category2 = company2.getCategories().get(0);
70
    Category category2 = company2.getCategories().get(0);
71
72
    company2.setName("company2");
69
    category2.setName("client2");
73
    category2.setName("client2");
70
74
71
    // Client1
75
    // Client1
Lines 90-105 Link Here
90
    assertEquals(false, transaction2.isDirty());
94
    assertEquals(false, transaction2.isDirty());
91
    assertEquals(false, transaction2.hasConflict());
95
    assertEquals(false, transaction2.hasConflict());
92
    assertEquals("client1", category2.getName());
96
    assertEquals("client1", category2.getName());
97
    assertEquals(null, company2.getName());
98
    {
99
      CDOTransaction transaction3 = createNewTransaction();
100
      CDOResource resource3 = transaction3.getResource("/test1");
101
      Company company3 = (Company)resource3.getContents().get(0);
102
      Category category3 = company3.getCategories().get(0);
103
      assertEquals(null, company3.getName());
104
      assertEquals("client1", category3.getName());
105
      transaction3.close();
106
      transaction3.getSession().close();
107
    }
108
93
    category2.setName("client2");
109
    category2.setName("client2");
110
    company2.setName("company2");
111
94
    transaction2.commit();
112
    transaction2.commit();
95
    assertEquals(false, transaction2.isDirty());
113
    assertEquals(false, transaction2.isDirty());
96
    assertEquals(false, transaction2.hasConflict());
114
    assertEquals(false, transaction2.hasConflict());
115
    assertEquals("company2", company2.getName());
97
    assertEquals("client2", category2.getName());
116
    assertEquals("client2", category2.getName());
98
    sleep(500);
117
    sleep(500);
99
118
119
    {
120
      CDOTransaction transaction3 = createNewTransaction();
121
      CDOResource resource3 = transaction3.getResource("/test1");
122
      Company company3 = (Company)resource3.getContents().get(0);
123
      Category category3 = company3.getCategories().get(0);
124
      assertEquals("company2", company3.getName());
125
      assertEquals("client2", category3.getName());
126
      transaction3.close();
127
      transaction3.getSession().close();
128
    }
129
100
    // Client1
130
    // Client1
101
    assertEquals(false, transaction1.isDirty());
131
    assertEquals(false, transaction1.isDirty());
102
    assertEquals(false, transaction1.hasConflict());
132
    assertEquals(false, transaction1.hasConflict());
103
    assertEquals("client2", category1.getName());
133
    assertEquals("client2", category1.getName());
134
    assertEquals("company2", company1.getName());
135
  }
136
137
  private CDOTransaction createNewTransaction()
138
  {
139
    CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
140
    session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
141
    return session.openTransaction();
104
  }
142
  }
105
}
143
}
(-)src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java (-3 / +5 lines)
Lines 59-67 Link Here
59
  protected Repository createRepository()
59
  protected Repository createRepository()
60
  {
60
  {
61
    Map<String, String> props = new HashMap<String, String>();
61
    Map<String, String> props = new HashMap<String, String>();
62
    // props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true");
62
    props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true");
63
    // props.put(IRepository.PROP_CURRENT_LRU_CAPACITY, "20");
63
    props.put(IRepository.PROP_VERIFYING_REVISIONS, "true");
64
    // props.put(IRepository.PROP_REVISED_LRU_CAPACITY, "20");
64
65
    // props.put(IRepository.PROP_CURRENT_LRU_CAPACITY, "10");
66
    // props.put(IRepository.PROP_REVISED_LRU_CAPACITY, "10");
65
67
66
    IStore store = createStore();
68
    IStore store = createStore();
67
69
(-)src/org/eclipse/emf/cdo/tests/ChunkingWithMEMTest.java (-1 / +3 lines)
Lines 17-22 Link Here
17
import org.eclipse.emf.cdo.internal.server.Repository;
17
import org.eclipse.emf.cdo.internal.server.Repository;
18
import org.eclipse.emf.cdo.internal.server.RevisionManager;
18
import org.eclipse.emf.cdo.internal.server.RevisionManager;
19
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
19
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
20
import org.eclipse.emf.cdo.server.IRepository;
20
import org.eclipse.emf.cdo.server.IStore;
21
import org.eclipse.emf.cdo.server.IStore;
21
import org.eclipse.emf.cdo.tests.model1.Customer;
22
import org.eclipse.emf.cdo.tests.model1.Customer;
22
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
23
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
Lines 156-162 Link Here
156
  protected Repository createRepository()
157
  protected Repository createRepository()
157
  {
158
  {
158
    Map<String, String> props = new HashMap<String, String>();
159
    Map<String, String> props = new HashMap<String, String>();
159
    // props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true");
160
    props.put(IRepository.PROP_SUPPORTING_REVISION_DELTAS, "true");
161
    props.put(IRepository.PROP_VERIFYING_REVISIONS, "true");
160
162
161
    IStore store = createStore();
163
    IStore store = createStore();
162
    Repository repository = new Repository()
164
    Repository repository = new Repository()

Return to bug 214752