summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2009-04-21 04:27:03 (EDT)
committerStefan Winkler2009-04-21 04:27:03 (EDT)
commit0f1a10584c8fd62f98331d479113568f97467d35 (patch)
tree080ab66529c9f8d5dfc6c7d4d0a0b9d9f8c299f4
parent0614d2a4b04c2e36b4a772e4e1a0f79852cc025a (diff)
downloadcdo-0f1a10584c8fd62f98331d479113568f97467d35.zip
cdo-0f1a10584c8fd62f98331d479113568f97467d35.tar.gz
cdo-0f1a10584c8fd62f98331d479113568f97467d35.tar.bz2
Now all is working - next comes statement caching.
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingAuditSupport.java (renamed from plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IAuditSupport.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingDeltaSupport.java (renamed from plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IDeltaSupport.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingDeltaSupport.java83
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java134
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbNonAudit.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/AbstractDBStoreVerifier.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/NonAuditDBStoreIntegrityVerifier.java275
18 files changed, 367 insertions, 293 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IAuditSupport.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingAuditSupport.java
index 15bf3cc..e7120b4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IAuditSupport.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingAuditSupport.java
@@ -25,7 +25,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
*
* @since 2.0
*/
-public interface IAuditSupport
+public interface IClassMappingAuditSupport
{
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IDeltaSupport.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingDeltaSupport.java
index 4e73d84..c602528 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IDeltaSupport.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMappingDeltaSupport.java
@@ -26,7 +26,7 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor;
* @author Stefan Winkler
* @since 2.0
*/
-public interface IDeltaSupport
+public interface IClassMappingDeltaSupport
{
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingDeltaSupport.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingDeltaSupport.java
index 823c760..0bf019f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingDeltaSupport.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingDeltaSupport.java
@@ -1,17 +1,18 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 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
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.db.mapping;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
/**
@@ -24,75 +25,21 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
public interface IListMappingDeltaSupport
{
/**
- * Insert a list item at a specified position.
- *
- * @param accessor
- * the accessor to use
- * @param id
- * the id of the revision to insert the value
- * @param newVersion
- * the new version of the revision after the value is inserted.
- * @param index
- * the position at which the value should be inserted.
- * @param value
- * the value to insert.
- */
- void insertListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value);
-
- /**
- * Set a value at a specified position to the given value.
- *
- * @param accessor
- * the accessor to use
- * @param id
- * the id of the revision to set the value
- * @param newVersion
- * the new version of the revision after the value is set.
- * @param index
- * the position at which the value should be set.
- * @param value
- * the value to be set.
- */
- void setListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value);
-
- /**
- * Move a list item from one position to another. Indices between both positions are updated so that the list remains
- * consistent.
- *
- * @param accessor
- * the accessor to use
- * @param id
- * the id of the revision in which to move the item
- * @param newVersion
- * the new version of the revision after the item is moved.
- * @param oldPosition
- * the old position of the item.
- * @param newPosition
- * the new position of the item.
- */
- void moveListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int oldPosition, int newPosition);
-
- /**
- * Remove a list item from a specified a position.
+ * Process a set of CDOFeatureDeltas for a many-valued feature.
*
* @param accessor
* the accessor to use
* @param id
- * the id of the revision from which to remove the item
+ * the ID of the revision affected
+ * @param oldVersion
+ * the original version of the revision
* @param newVersion
- * the new version of the revision after the item is removed.
- * @param index
- * the index of the item to be removed.
- */
- void removeListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index);
-
- /**
- * Clear a list of a given revision.
- *
- * @param accessor
- * the accessor to use
- * @param id
- * the id of the revision from which to remove all items
+ * the new revision of the revision (after the change)
+ * @param created
+ * the creation date for the new revision
+ * @param delta
+ * the {@link CDOListFeatureDelta} which contains the list deltas.
*/
- void clearList(IDBStoreAccessor accessor, CDOID id);
+ public void processDelta(IDBStoreAccessor accessor, CDOID id, int oldVersion, int newVersion, long created,
+ CDOListFeatureDelta delta);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
index 2ffd5ac..b89e07a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
@@ -164,7 +164,7 @@ public interface IMappingStrategy
/**
* Query if this mapping supports revision deltas. <br>
* If this method returns <code>true</code>, it is guaranteed that all class mappings returned by
- * {@link #getClassMapping(EClass)} implement {@link IDeltaSupport}.
+ * {@link #getClassMapping(EClass)} implement {@link IClassMappingDeltaSupport}.
*
* @return <code>true</code> if revision deltas are supported, <code>false</code> else.
*/
@@ -173,7 +173,7 @@ public interface IMappingStrategy
/**
* Query if this mapping supports audits. <br>
* If this method returns <code>true</code>, it is guaranteed that all class mappings returned by
- * {@link #getClassMapping(EClass)} implement {@link IAuditSupport}.
+ * {@link #getClassMapping(EClass)} implement {@link IClassMappingAuditSupport}.
*
* @return <code>true</code> if audits are supported, <code>false</code> else.
*/
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 68e1524..f591140 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -4,11 +4,11 @@
* 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
* Stefan Winkler - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259402
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db;
@@ -84,7 +84,7 @@ public class DBStore extends LongIDStore implements IDBStore
public DBStore()
{
- super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), //
+ super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), //
set(RevisionTemporality.AUDITING, RevisionTemporality.NONE), //
set(RevisionParallelism.NONE));
}
@@ -211,6 +211,7 @@ public class DBStore extends LongIDStore implements IDBStore
{
super.doActivate();
+ dbSchema = createSchema();
metaDataManager = new MetaDataManager(this);
LifecycleUtil.activate(metaDataManager);
@@ -229,8 +230,6 @@ public class DBStore extends LongIDStore implements IDBStore
reStart(connection);
}
- dbSchema = createSchema();
-
connection.commit();
}
finally
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 68c7ec9..9d34133 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 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
@@ -23,9 +23,9 @@ import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.mapping.IAuditSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingAuditSupport;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IDeltaSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
@@ -178,7 +178,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
EClass eClass = getObjectType(id);
InternalCDORevision revision = (InternalCDORevision)CDORevisionUtil.create(eClass, id);
- IAuditSupport mapping = (IAuditSupport)mappingStrategy.getClassMapping(eClass);
+ IClassMappingAuditSupport mapping = (IClassMappingAuditSupport)mappingStrategy.getClassMapping(eClass);
if (mapping.readRevisionByTime(this, revision, timeStamp, listChunk))
{
return revision;
@@ -206,7 +206,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
}
// if audit support is present, just use the audit method
- success = ((IAuditSupport)mapping).readRevisionByVersion(this, revision, version, listChunk);
+ success = ((IClassMappingAuditSupport)mapping).readRevisionByVersion(this, revision, version, listChunk);
}
else
{
@@ -297,7 +297,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
protected void writeRevisionDelta(InternalCDORevisionDelta delta, long created, OMMonitor monitor)
{
EClass eClass = getObjectType(delta.getID());
- IDeltaSupport mapping = (IDeltaSupport)getStore().getMappingStrategy().getClassMapping(eClass);
+ IClassMappingDeltaSupport mapping = (IClassMappingDeltaSupport)getStore().getMappingStrategy().getClassMapping(eClass);
mapping.writeRevisionDelta(this, delta, created, monitor);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
index 8dd6bc4..5bce265 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
@@ -1,13 +1,13 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 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
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
@@ -223,7 +223,7 @@ public abstract class AbstractListTableMapping implements IListMapping
{
MoveableList<Object> list = revision.getList(getFeature());
- int listSize = 0;
+ int listSize = -1;
if (listChunk != CDORevision.UNCHUNKED)
{
@@ -274,13 +274,13 @@ public abstract class AbstractListTableMapping implements IListMapping
list.add(value);
}
- while (listSize-- > 0)
+ while (listSize-- >= 0)
{
- list.add(InternalCDORevision.UNINITIALIZED);
if (TRACER.isEnabled())
{
- TRACER.format("Added UNINITIALIZED for index {0} ", list.size());
+ TRACER.format("Adding UNINITIALIZED for index {0} ", list.size());
}
+ list.add(InternalCDORevision.UNINITIALIZED);
}
}
catch (SQLException ex)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
index 041856f..fb0eba0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
@@ -17,7 +17,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.mapping.IAuditSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingAuditSupport;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
@@ -42,7 +42,7 @@ import java.sql.SQLException;
* @author Stefan Winkler
* @since 2.0
*/
-public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping, IAuditSupport
+public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping, IClassMappingAuditSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HorizontalAuditClassMapping.class);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
index 1688055..764bc06 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
@@ -4,7 +4,7 @@
* 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
* Stefan Winkler - major refactoring
@@ -17,7 +17,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
@@ -29,7 +28,7 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IDeltaSupport;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
@@ -59,7 +58,7 @@ import java.util.List;
* @since 2.0
*/
public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMapping implements IClassMapping,
- IDeltaSupport
+ IClassMappingDeltaSupport
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HorizontalNonAuditClassMapping.class);
@@ -366,6 +365,8 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
{
private CDOID id;
+ private int oldVersion;
+
private int newVersion;
private long created;
@@ -399,6 +400,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
reset();
id = d.getID();
+ oldVersion = d.getOriginVersion();
newVersion = d.getDirtyVersion();
created = c;
accessor = a;
@@ -420,30 +422,22 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
public void visit(CDOMoveFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).moveListItem(accessor, id, newVersion, delta.getOldPosition(),
- delta.getNewPosition());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOSetFeatureDelta delta)
{
if (delta.getFeature().isMany())
{
- IListMappingDeltaSupport rm = getListMappingDeltaSupport(delta.getFeature());
- if (rm == null)
- {
- throw new IllegalArgumentException("ReferenceMapping for " + delta.getFeature() + " is null!");
- }
- rm.setListItem(accessor, id, newVersion, delta.getIndex(), delta.getValue());
+ throw new ImplementationError("Should not be called");
}
- else
+ ITypeMapping am = getValueMapping(delta.getFeature());
+ if (am == null)
{
- ITypeMapping am = getValueMapping(delta.getFeature());
- if (am == null)
- {
- throw new IllegalArgumentException("AttributeMapping for " + delta.getFeature() + " is null!");
- }
- attributeChanges.add(new Pair<ITypeMapping, Object>(am, delta.getValue()));
+ throw new IllegalArgumentException("AttributeMapping for " + delta.getFeature() + " is null!");
}
+ attributeChanges.add(new Pair<ITypeMapping, Object>(am, delta.getValue()));
+
}
public void visit(CDOUnsetFeatureDelta delta)
@@ -456,26 +450,23 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
public void visit(CDOListFeatureDelta delta)
{
- for (CDOFeatureDelta listChange : delta.getListChanges())
- {
- listChange.accept(this);
- }
+ IListMappingDeltaSupport listMapping = (IListMappingDeltaSupport)getListMapping(delta.getFeature());
+ listMapping.processDelta(accessor, id, oldVersion, newVersion, created, delta);
}
public void visit(CDOClearFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).clearList(accessor, id);
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOAddFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).insertListItem(accessor, id, newVersion, delta.getIndex(),
- delta.getValue());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDORemoveFeatureDelta delta)
{
- getListMappingDeltaSupport(delta.getFeature()).removeListItem(accessor, id, newVersion, delta.getIndex());
+ throw new ImplementationError("Should not be called");
}
public void visit(CDOContainerFeatureDelta delta)
@@ -485,11 +476,6 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
newResourceID = delta.getResourceID();
updateContainer = true;
}
-
- private IListMappingDeltaSupport getListMappingDeltaSupport(EStructuralFeature feature)
- {
- return (IListMappingDeltaSupport)getListMapping(feature);
- }
}
public void updateAttributes(IDBStoreAccessor accessor, CDOID id, int newVersion, long created, CDOID newContainerId,
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 0f4e3fe..73714b1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -1,19 +1,29 @@
/**
- * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2009 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
- * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
@@ -24,6 +34,7 @@ import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -185,6 +196,14 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
clearList(accessor, id);
}
+ /**
+ * Clear a list of a given revision.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision from which to remove all items
+ */
public void clearList(IDBStoreAccessor accessor, CDOID id)
{
PreparedStatement stmt = null;
@@ -205,7 +224,19 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void insertListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value)
+ /**
+ * Insert a list item at a specified position.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision to insert the value
+ * @param index
+ * the index where to insert the element
+ * @param value
+ * the value to insert.
+ */
+ public void insertListItem(IDBStoreAccessor accessor, CDOID id, int index, Object value)
{
move1up(accessor, id, index, UNBOUNDED_MOVE);
insertValue(accessor, id, index, value);
@@ -234,7 +265,20 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void moveListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int oldPosition, int newPosition)
+ /**
+ * Move a list item from one position to another. Indices between both positions are updated so that the list remains
+ * consistent.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision in which to move the item
+ * @param oldPosition
+ * the old position of the item.
+ * @param newPosition
+ * the new position of the item.
+ */
+ public void moveListItem(IDBStoreAccessor accessor, CDOID id, int oldPosition, int newPosition)
{
if (oldPosition == newPosition)
{
@@ -281,7 +325,17 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void removeListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index)
+ /**
+ * Remove a list item from a specified a position.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision from which to remove the item
+ * @param index
+ * the index of the item to remoce
+ */
+ public void removeListItem(IDBStoreAccessor accessor, CDOID id, int index)
{
deleteItem(accessor, id, index);
move1down(accessor, id, index, UNBOUNDED_MOVE);
@@ -370,7 +424,19 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- public void setListItem(IDBStoreAccessor accessor, CDOID id, int newVersion, int index, Object value)
+ /**
+ * Set a value at a specified position to the given value.
+ *
+ * @param accessor
+ * the accessor to use
+ * @param id
+ * the id of the revision to set the value
+ * @param index
+ * the index of the item to set
+ * @param value
+ * the value to be set.
+ */
+ public void setListItem(IDBStoreAccessor accessor, CDOID id, int index, Object value)
{
PreparedStatement stmt = null;
@@ -391,4 +457,58 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
DBUtil.close(stmt);
}
}
+
+ public void processDelta(final IDBStoreAccessor accessor, final CDOID id, int oldVersion, final int newVersion,
+ long created, CDOListFeatureDelta listDelta)
+ {
+ CDOFeatureDeltaVisitor visitor = new CDOFeatureDeltaVisitor()
+ {
+
+ public void visit(CDOMoveFeatureDelta delta)
+ {
+ moveListItem(accessor, id, delta.getOldPosition(), delta.getNewPosition());
+ }
+
+ public void visit(CDOAddFeatureDelta delta)
+ {
+ insertListItem(accessor, id, delta.getIndex(), delta.getValue());
+ }
+
+ public void visit(CDORemoveFeatureDelta delta)
+ {
+ removeListItem(accessor, id, delta.getIndex());
+ }
+
+ public void visit(CDOSetFeatureDelta delta)
+ {
+ setListItem(accessor, id, delta.getIndex(), delta.getValue());
+ }
+
+ public void visit(CDOUnsetFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ public void visit(CDOListFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ public void visit(CDOClearFeatureDelta delta)
+ {
+ clearList(accessor, id);
+ }
+
+ public void visit(CDOContainerFeatureDelta delta)
+ {
+ throw new ImplementationError("Should not be called");
+ }
+
+ };
+
+ for (CDOFeatureDelta delta : listDelta.getListChanges())
+ {
+ delta.accept(visitor);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
index b3f9bb5..4f58bd7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java
@@ -4,7 +4,7 @@
* 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
* Stefan Winkler - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259402
@@ -185,7 +185,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
table = schema.addTable(CDODBSchema.CDO_OBJECTS);
idField = table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT);
typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.BIGINT);
- table.addIndex(IDBIndex.Type.PRIMARY_KEY, idField);
+ table.addIndex(IDBIndex.Type.UNIQUE, idField);
IDBAdapter dbAdapter = mappingStrategy.getStore().getDBAdapter();
@@ -215,6 +215,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
public long getMaxId(Connection connection)
{
+ initialize(connection);
return DBUtil.selectMaximumLong(connection, idField);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index 2a75eee..1e019c2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -4,7 +4,7 @@
* 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
*/
@@ -26,6 +26,6 @@ public class AllTests extends AllTestsAllConfigs
@Override
protected void initConfigSuites(TestSuite parent)
{
- addScenario(parent, COMBINED, MEM, TCP, NATIVE);
+ addScenario(parent, COMBINED, MEM, JVM, NATIVE);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java
index 960e95a..fb7565b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java
@@ -4,13 +4,12 @@
* 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.tests;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248052_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
@@ -40,13 +39,7 @@ public class AllTestsDBHsqldb extends AllTestsAllConfigs
{
super.initTestClasses(testClasses);
- // delta-support not available for audit db-store
- testClasses.remove(Bugzilla_248052_Test.class);
-
// this takes ages ...
testClasses.remove(Bugzilla_266982_Test.class);
-
- testClasses.clear();
- testClasses.add(ChunkingTest.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbNonAudit.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbNonAudit.java
index d3baeb5..035499d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbNonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbNonAudit.java
@@ -4,7 +4,7 @@
* 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:
* Stefan Winkler - initial API and implementation
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
index fa86a7f..969f443 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
@@ -4,7 +4,7 @@
* 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
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index e21e78a..18c926a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -4,7 +4,7 @@
* 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
* Stefan Winkler - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259402
@@ -23,6 +23,9 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
import org.eclipse.emf.cdo.tests.bundle.OM;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.store.verifier.AbstractDBStoreVerifier;
+import org.eclipse.emf.cdo.tests.store.verifier.AuditDBStoreIntegrityVerifier;
+import org.eclipse.emf.cdo.tests.store.verifier.NonAuditDBStoreIntegrityVerifier;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
@@ -248,6 +251,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
{
private static final long serialVersionUID = 1L;
+ public static boolean USE_VERIFIER = false;
+
public static final Hsqldb INSTANCE = new Hsqldb("HSQLDB");
private transient HSQLDBDataSource dataSource;
@@ -291,8 +296,33 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
@Override
public void tearDown() throws Exception
{
- super.tearDown();
- shutDownHsqldb();
+ try
+ {
+ if (USE_VERIFIER)
+ {
+ IRepository testRepository = getRepository(REPOSITORY_NAME);
+ if (testRepository != null)
+ {
+ getVerifier(testRepository).verify();
+ }
+ }
+ }
+ finally
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ shutDownHsqldb();
+ }
+ }
+ }
+
+ protected AbstractDBStoreVerifier getVerifier(IRepository repository)
+ {
+ return new AuditDBStoreIntegrityVerifier(repository);
}
private void shutDownHsqldb() throws SQLException
@@ -341,6 +371,12 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
{
return CDODBUtil.createHorizontalNonAuditMappingStrategy();
}
+
+ @Override
+ protected AbstractDBStoreVerifier getVerifier(IRepository repository)
+ {
+ return new NonAuditDBStoreIntegrityVerifier(repository);
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/AbstractDBStoreVerifier.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/AbstractDBStoreVerifier.java
index 67ed540..01af44d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/AbstractDBStoreVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/AbstractDBStoreVerifier.java
@@ -4,7 +4,7 @@
* 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:
* Stefan Winkler - initial API and implementation
*/
@@ -45,7 +45,10 @@ public abstract class AbstractDBStoreVerifier
public AbstractDBStoreVerifier(IRepository repository)
{
this.repository = repository;
- assertTrue(repository.getStore() instanceof IDBStore);
+ if (repository != null)
+ {
+ assertTrue(repository.getStore() instanceof IDBStore);
+ }
}
protected IRepository getRepository()
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/NonAuditDBStoreIntegrityVerifier.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/NonAuditDBStoreIntegrityVerifier.java
index 997869c..2614829 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/NonAuditDBStoreIntegrityVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/store/verifier/NonAuditDBStoreIntegrityVerifier.java
@@ -4,21 +4,33 @@
* 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:
* Stefan Winkler - initial API and implementation
*/
package org.eclipse.emf.cdo.tests.store.verifier;
+import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
+import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
+import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
+
+import org.eclipse.net4j.util.collection.Pair;
+
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Stefan Winkler
*/
-public abstract class NonAuditDBStoreIntegrityVerifier extends AbstractDBStoreVerifier
+public class NonAuditDBStoreIntegrityVerifier extends AbstractDBStoreVerifier
{
public NonAuditDBStoreIntegrityVerifier(IRepository repo)
{
@@ -27,147 +39,124 @@ public abstract class NonAuditDBStoreIntegrityVerifier extends AbstractDBStoreVe
// this is a verifier for non-auditing mode
assertTrue(getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
// ... and for horizontal class mapping
- // assertTrue(getStore().getMappingStrategy() instanceof HorizontalMappingStrategy);
+ assertTrue(getStore().getMappingStrategy() instanceof HorizontalNonAuditMappingStrategy);
+ }
+
+ @Override
+ protected void doVerify() throws Exception
+ {
+ for (IClassMapping mapping : getClassMappings())
+ {
+ if (mapping != null && mapping.getDBTables().size() > 0)
+ {
+ verifyClassMapping(mapping);
+ }
+ }
+ }
+
+ private void verifyClassMapping(IClassMapping mapping) throws Exception
+ {
+ verifyNoUnrevisedRevisions(mapping);
+ verifyUniqueId(mapping);
+ verifyReferences(mapping);
+ }
+
+ /**
+ * Verify that there is no row with cdo_revised == 0.
+ */
+ private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ assertTrue(resultSet.next());
+ assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Verify that the id is unique.
+ */
+ private void verifyUniqueId(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
+ + CDODBSchema.ATTRIBUTES_ID;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
}
- // @Override
- // protected void doVerify() throws Exception
- // {
- // for (IClassMapping mapping : getClassMappings())
- // {
- // if (mapping != null && mapping.getTable() != null)
- // {
- // verifyClassMapping(mapping);
- // }
- // }
- // }
- //
- // private void verifyClassMapping(IClassMapping mapping) throws Exception
- // {
- // verifyNoUnrevisedRevisions(mapping);
- // verifyUniqueId(mapping);
- // verifyReferences(mapping);
- // }
- //
- // /**
- // * Verify that there is no row with cdo_revised == 0.
- // */
- // private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
- // {
- // String tableName = mapping.getTable().getName();
- // String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
- // ResultSet resultSet = getStatement().executeQuery(sql);
- // try
- // {
- // assertTrue(resultSet.next());
- // assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
- // }
- // finally
- // {
- // resultSet.close();
- // }
- // }
- //
- // /**
- // * Verify that the id is unique.
- // */
- // private void verifyUniqueId(IClassMapping mapping) throws Exception
- // {
- // String tableName = mapping.getTable().getName();
- // String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
- // + CDODBSchema.ATTRIBUTES_ID;
- //
- // ResultSet resultSet = getStatement().executeQuery(sql);
- //
- // try
- // {
- // while (resultSet.next())
- // {
- // assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
- // }
- // }
- // finally
- // {
- // resultSet.close();
- // }
- // }
- //
- // private void verifyReferences(IClassMapping mapping) throws Exception
- // {
- // List<IManyMapping> referenceMappings = mapping.getReferenceMappings();
- // if (referenceMappings == null)
- // {
- // return;
- // }
- //
- // String tableName = mapping.getTable().getName();
- // String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
- //
- // ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
- //
- // ResultSet resultSet = getStatement().executeQuery(sql);
- // try
- // {
- // while (resultSet.next())
- // {
- // idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
- // }
- // }
- // finally
- // {
- // resultSet.close();
- // }
- //
- // for (IManyMapping refMapping : referenceMappings)
- // {
- // for (Pair<Long, Integer> idVersion : idVersions)
- // {
- // verifyOnlyLatestReferences(refMapping, idVersion.getElement1(), idVersion.getElement2());
- // verifyCorrectIndices(refMapping, idVersion.getElement1());
- // }
- // }
- // }
- //
- // /**
- // * Verify that no reference with sourceId == ID exist which have another version
- // */
- // private void verifyOnlyLatestReferences(IManyMapping refMapping, long id, int version) throws Exception
- // {
- // String tableName = refMapping.getTable().getName();
- // String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.FEATURE_REVISION_ID + "=" + id + " AND "
- // + CDODBSchema.FEATURE_REVISION_VERSION + "<>" + version;
- //
- // ResultSet resultSet = getStatement().executeQuery(sql);
- // try
- // {
- // assertTrue(resultSet.next());
- // assertEquals("Table " + tableName + " contains old references for id " + id + "(version should be " + version
- // + ")", 0, resultSet.getInt(1));
- // }
- // finally
- // {
- // resultSet.close();
- // }
- // }
- //
- // private void verifyCorrectIndices(IManyMapping refMapping, long id) throws Exception
- // {
- // String tableName = refMapping.getTable().getName();
- // String sql = "SELECT " + CDODBSchema.FEATURE_IDX + " FROM " + tableName + " WHERE "
- // + CDODBSchema.FEATURE_REVISION_ID + "=" + id + " ORDER BY " + CDODBSchema.FEATURE_IDX;
- //
- // ResultSet resultSet = getStatement().executeQuery(sql);
- // int indexShouldBe = 0;
- // try
- // {
- // while (resultSet.next())
- // {
- // assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
- // }
- // }
- // finally
- // {
- // resultSet.close();
- // }
- // }
+ private void verifyReferences(IClassMapping mapping) throws Exception
+ {
+ List<IListMapping> referenceMappings = ((HorizontalNonAuditClassMapping)mapping).getListMappings();
+ if (referenceMappings == null)
+ {
+ return;
+ }
+
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+
+ ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+
+ for (IListMapping refMapping : referenceMappings)
+ {
+ for (Pair<Long, Integer> idVersion : idVersions)
+ {
+ verifyCorrectIndices(refMapping, idVersion.getElement1());
+ }
+ }
+ }
+
+ private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
+ {
+ String tableName = refMapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
+ + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ int indexShouldBe = 0;
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
}