summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-19 19:08:42 (EDT)
committerEike Stepper2007-08-19 19:08:42 (EDT)
commitb1808e58f09bb953fa3abec4a1d30de4e06eb57c (patch)
tree35606d6c5b92f2534ee88c0c3daf81e911d71051
parentfc2a3e906b9e73a56a83211b485f57046f58cc49 (diff)
downloadcdo-b1808e58f09bb953fa3abec4a1d30de4e06eb57c.zip
cdo-b1808e58f09bb953fa3abec4a1d30de4e06eb57c.tar.gz
cdo-b1808e58f09bb953fa3abec4a1d30de4e06eb57c.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java13
5 files changed, 56 insertions, 9 deletions
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 840d1b3..ecedbfa 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
@@ -112,7 +112,6 @@ public class DBStore extends Store implements IDBStore
try
{
-
nextPackageID = DBUtil.selectMaximum(connection, CDODBSchema.PACKAGES_ID) + 1;
nextClassID = DBUtil.selectMaximum(connection, CDODBSchema.CLASSES_ID) + 1;
nextFeatureID = DBUtil.selectMaximum(connection, CDODBSchema.FEATURES_ID) + 1;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
index a8e846f..a4c7c13 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -74,6 +74,11 @@ public class DBStoreReader implements IStoreReader
return store;
}
+ public Connection getConnection()
+ {
+ return connection;
+ }
+
public Collection<CDOPackageInfo> readPackageInfos()
{
final Collection<CDOPackageInfo> result = new ArrayList(0);
@@ -129,7 +134,7 @@ public class DBStoreReader implements IStoreReader
}
};
- String where = CDODBSchema.CLASSES_PACKAGE.getName() + " = " + cdoPackage.getServerInfo();
+ String where = CDODBSchema.CLASSES_PACKAGE.getName() + " = " + ((DBPackageInfo)cdoPackage.getServerInfo()).getID();
DBUtil.select(connection, rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
index 0c95a53..cd232c2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -19,10 +19,12 @@ import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBTable;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import java.sql.SQLException;
import java.util.Collection;
@@ -32,6 +34,8 @@ import java.util.Collection;
*/
public class DBStoreWriter extends DBStoreReader implements IStoreWriter
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreWriter.class);
+
private IView view;
public DBStoreWriter(DBStore store, IView view) throws DBException
@@ -69,12 +73,16 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
return view;
}
- public void writePackages(CDOPackageImpl[] cdoPackages)
+ public void writePackages(CDOPackageImpl... cdoPackages)
{
for (CDOPackageImpl cdoPackage : cdoPackages)
{
int id = store.getNextPackageID();
cdoPackage.setServerInfo(new DBPackageInfo(id));
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
+ }
String packageURI = cdoPackage.getPackageURI();
String name = cdoPackage.getName();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index 75f7a85..2326719 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -11,18 +11,22 @@
package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBTable;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import java.sql.Connection;
+import java.sql.Date;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -32,6 +36,8 @@ import java.util.Map.Entry;
*/
public class HorizontalMappingStrategy extends MappingStrategy
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HorizontalMappingStrategy.class);
+
public HorizontalMappingStrategy()
{
}
@@ -69,16 +75,34 @@ public class HorizontalMappingStrategy extends MappingStrategy
public void writeRevision(Connection connection, CDORevisionImpl revision)
{
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Inserting revision: {0}", revision);
+ }
+
CDOClassImpl cdoClass = revision.getCDOClass();
ClassMapping classMapping = getClassMapping(cdoClass);
Map<IDBTable, FeatureMapping[]> tables = classMapping.getTables();
- for (Entry<IDBTable, FeatureMapping[]> entry : tables.entrySet())
+ Entry<IDBTable, FeatureMapping[]> entry = tables.entrySet().iterator().next();
+ IDBTable table = entry.getKey();
+
+ Object[] values = new Object[table.getFieldCount()];
+ values[0] = revision.getID();
+ values[1] = ((DBClassInfo)revision.getCDOClass().getServerInfo()).getID();
+ values[2] = revision.getVersion();
+ values[3] = new Date(revision.getCreated());
+ values[4] = new Date(revision.getRevised());
+ values[5] = revision.getResourceID();
+ values[6] = revision.getContainerID();
+ values[7] = revision.getContainingFeatureID();
+
+ int i = 8;
+ for (CDOFeatureImpl feature : cdoClass.getAllFeatures())
{
- IDBTable table = entry.getKey();
- FeatureMapping[] featureMappings = entry.getValue();
-
- DBUtil.insertRow(connection, table);
+ values[i++] = revision.getValue(feature);
}
+
+ DBUtil.insertRow(connection, table, values);
}
public CDORevision readRevision(Connection connection, CDOID id)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index 818340e..c15dd97 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -44,6 +44,8 @@ import java.util.Map.Entry;
*/
public abstract class MappingStrategy implements IMappingStrategy
{
+ public static final int FULL_NUMBER_OF_FIELDS = 8;
+
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, MappingStrategy.class);
private IDBStore store;
@@ -215,13 +217,22 @@ public abstract class MappingStrategy implements IMappingStrategy
return new DBSchema(name);
}
- protected void initTable(IDBTable table, boolean full)
+ protected int initTable(IDBTable table, boolean full)
{
table.addField("cdo_id", DBType.BIGINT);
if (full)
{
table.addField("cdo_class", DBType.INTEGER);
+ table.addField("cdo_version", DBType.INTEGER);
+ table.addField("cdo_created", DBType.TIMESTAMP);
+ table.addField("cdo_revised", DBType.TIMESTAMP);
+ table.addField("cdo_resource", DBType.BIGINT);
+ table.addField("cdo_container", DBType.BIGINT);
+ table.addField("cdo_feature", DBType.INTEGER);
+ return FULL_NUMBER_OF_FIELDS;
}
+
+ return 1;
}
protected IDBTable addTable(CDOClass cdoClass)