summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-21 12:34:25 (EDT)
committerEike Stepper2007-08-21 12:34:25 (EDT)
commit0c15b2074e24a142bbceeee2f86021912724d92a (patch)
tree9a64bb337dd4cb45b6e179dbbea4ee1890124b01
parent0d0a4c5209df8b49af87ca19152af28665e7d3bf (diff)
downloadcdo-0c15b2074e24a142bbceeee2f86021912724d92a.zip
cdo-0c15b2074e24a142bbceeee2f86021912724d92a.tar.gz
cdo-0c15b2074e24a142bbceeee2f86021912724d92a.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java (renamed from plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java)157
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java167
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AttributeMapper.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/ClassMapper.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java30
9 files changed, 241 insertions, 208 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
index 17d9917..32b3f18 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
@@ -12,9 +12,9 @@ package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.net4j.db.ConnectionProvider;
import org.eclipse.net4j.db.IDBAdapter;
-import javax.sql.DataSource;
/**
* @author Eike Stepper
@@ -25,5 +25,5 @@ public interface IDBStore extends IStore
public IDBAdapter getDBAdapter();
- public DataSource getDataSource();
+ public ConnectionProvider getConnectionProvider();
}
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 aefb938..648c152 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
@@ -16,12 +16,11 @@ import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.net4j.db.ConnectionProvider;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
-import javax.sql.DataSource;
-
import java.sql.Connection;
/**
@@ -35,7 +34,7 @@ public class DBStore extends Store implements IDBStore
private IDBAdapter dbAdapter;
- private DataSource dataSource;
+ private ConnectionProvider connectionProvider;
private int nextPackageID;
@@ -43,7 +42,7 @@ public class DBStore extends Store implements IDBStore
private int nextFeatureID;
- public DBStore(IMappingStrategy mappingStrategy, IDBAdapter dbAdapter, DataSource dataSource)
+ public DBStore(IMappingStrategy mappingStrategy, IDBAdapter dbAdapter, ConnectionProvider connectionProvider)
{
super(TYPE);
if (dbAdapter == null)
@@ -51,14 +50,14 @@ public class DBStore extends Store implements IDBStore
throw new IllegalArgumentException("dbAdapter is null");
}
- if (dataSource == null)
+ if (connectionProvider == null)
{
- throw new IllegalArgumentException("dataSource is null");
+ throw new IllegalArgumentException("connectionProvider is null");
}
this.mappingStrategy = mappingStrategy;
this.dbAdapter = dbAdapter;
- this.dataSource = dataSource;
+ this.connectionProvider = connectionProvider;
}
public IMappingStrategy getMappingStrategy()
@@ -71,9 +70,9 @@ public class DBStore extends Store implements IDBStore
return dbAdapter;
}
- public DataSource getDataSource()
+ public ConnectionProvider getConnectionProvider()
{
- return dataSource;
+ return connectionProvider;
}
public boolean hasAuditSupport()
@@ -81,14 +80,14 @@ public class DBStore extends Store implements IDBStore
return true;
}
- public DBStoreReader getReader(ISession session) throws DBException
+ public DBStoreAccessor getReader(ISession session) throws DBException
{
- return new DBStoreReader(this);
+ return new DBStoreAccessor(this, session);
}
- public DBStoreWriter getWriter(IView view) throws DBException
+ public DBStoreAccessor getWriter(IView view) throws DBException
{
- return new DBStoreWriter(this, view);
+ return new DBStoreAccessor(this, view);
}
public int getNextPackageID()
@@ -110,8 +109,8 @@ public class DBStore extends Store implements IDBStore
protected void doActivate() throws Exception
{
super.doActivate();
- CDODBSchema.INSTANCE.create(dbAdapter, dataSource);
- DBStoreWriter writer = getWriter(null);
+ CDODBSchema.INSTANCE.create(dbAdapter, connectionProvider);
+ DBStoreAccessor writer = getWriter(null);
Connection connection = writer.getConnection();
try
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/DBStoreAccessor.java
index dd79905..d03e2fc 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/DBStoreAccessor.java
@@ -17,21 +17,29 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreReader;
+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.emf.cdo.server.internal.db.info.ClassServerInfo;
import org.eclipse.emf.cdo.server.internal.db.info.FeatureServerInfo;
-import org.eclipse.emf.cdo.server.internal.db.info.ServerInfo;
import org.eclipse.emf.cdo.server.internal.db.info.PackageServerInfo;
+import org.eclipse.emf.cdo.server.internal.db.info.ServerInfo;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBRowHandler;
+import org.eclipse.net4j.db.IDBTable;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import java.sql.Connection;
import java.sql.SQLException;
@@ -41,19 +49,28 @@ import java.util.Collection;
/**
* @author Eike Stepper
*/
-public class DBStoreReader implements IStoreReader
+public class DBStoreAccessor implements IStoreReader, IStoreWriter
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreAccessor.class);
+
protected DBStore store;
+ protected Object context;
+
+ protected boolean reader;
+
protected Connection connection;
- public DBStoreReader(DBStore store) throws DBException
+ private DBStoreAccessor(DBStore store, Object context, boolean reader) throws DBException
{
this.store = store;
+ this.context = context;
+ this.reader = reader;
try
{
- connection = store.getDataSource().getConnection();
+ connection = store.getConnectionProvider().getConnection();
+ connection.setAutoCommit(reader);
}
catch (SQLException ex)
{
@@ -61,16 +78,33 @@ public class DBStoreReader implements IStoreReader
}
}
+ public DBStoreAccessor(DBStore store, ISession session) throws DBException
+ {
+ this(store, session, true);
+ }
+
+ public DBStoreAccessor(DBStore store, IView view) throws DBException
+ {
+ this(store, view, false);
+ }
+
public void release() throws DBException
{
try
{
- connection.close();
+ if (!reader)
+ {
+ connection.commit();
+ }
}
catch (SQLException ex)
{
throw new DBException(ex);
}
+ finally
+ {
+ DBUtil.close(connection);
+ }
}
public DBStore getStore()
@@ -78,11 +112,124 @@ public class DBStoreReader implements IStoreReader
return store;
}
+ public boolean isReader()
+ {
+ return reader;
+ }
+
+ public ISession getSession()
+ {
+ if (context instanceof IView)
+ {
+ return ((IView)context).getSession();
+ }
+
+ return (ISession)context;
+ }
+
+ public IView getView()
+ {
+ if (context instanceof IView)
+ {
+ return (IView)context;
+ }
+
+ return null;
+ }
+
public Connection getConnection()
{
return connection;
}
+ public void writePackages(CDOPackageImpl... cdoPackages)
+ {
+ for (CDOPackageImpl cdoPackage : cdoPackages)
+ {
+ if (!cdoPackage.isSystem())
+ {
+ int id = store.getNextPackageID();
+ cdoPackage.setServerInfo(new PackageServerInfo(id));
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
+ }
+
+ String packageURI = cdoPackage.getPackageURI();
+ String name = cdoPackage.getName();
+ String ecore = cdoPackage.getEcore();
+ boolean dynamic = cdoPackage.isDynamic();
+ CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
+ long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
+ DBUtil.insertRow(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
+
+ for (CDOClassImpl cdoClass : cdoPackage.getClasses())
+ {
+ writeClass(cdoClass);
+ }
+ }
+ }
+
+ IMappingStrategy mappingStrategy = store.getMappingStrategy();
+ Collection<IDBTable> affectedTables = mappingStrategy.map(cdoPackages);
+ store.getDBAdapter().createTables(affectedTables, connection);
+ }
+
+ public void writeClass(CDOClassImpl cdoClass)
+ {
+ int id = store.getNextClassID();
+ cdoClass.setServerInfo(new ClassServerInfo(id));
+
+ CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
+ int packageID = ServerInfo.getDBID(cdoPackage);
+ int classifierID = cdoClass.getClassifierID();
+ String name = cdoClass.getName();
+ boolean isAbstract = cdoClass.isAbstract();
+ DBUtil.insertRow(connection, CDODBSchema.CLASSES, id, packageID, classifierID, name, isAbstract);
+
+ for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
+ {
+ writeSuperType(id, superType);
+ }
+
+ for (CDOFeatureImpl feature : cdoClass.getFeatures())
+ {
+ writeFeature(feature);
+ }
+ }
+
+ public void writeSuperType(int type, CDOClassProxy superType)
+ {
+ String packageURI = superType.getPackageURI();
+ int classifierID = superType.getClassifierID();
+ DBUtil.insertRow(connection, CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
+ }
+
+ public void writeFeature(CDOFeatureImpl feature)
+ {
+ int id = store.getNextFeatureID();
+ feature.setServerInfo(new FeatureServerInfo(id));
+
+ int classID = ServerInfo.getDBID(feature.getContainingClass());
+ String name = feature.getName();
+ int featureID = feature.getFeatureID();
+ int type = feature.getType().getTypeID();
+ CDOClassProxy reference = feature.getReferenceTypeProxy();
+ String packageURI = reference == null ? null : reference.getPackageURI();
+ int classifierID = reference == null ? 0 : reference.getClassifierID();
+ boolean many = feature.isMany();
+ boolean containment = feature.isContainment();
+ int idx = feature.getFeatureIndex();
+ DBUtil.insertRow(connection, CDODBSchema.FEATURES, id, classID, featureID, name, type, packageURI, classifierID,
+ many, containment, idx);
+ }
+
+ public void writeRevision(CDORevisionImpl revision)
+ {
+ store.getMappingStrategy().writeRevision(connection, revision);
+ }
+
public Collection<CDOPackageInfo> readPackageInfos()
{
final Collection<CDOPackageInfo> result = new ArrayList(0);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index bc58490..7be55e0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.server.IStoreFactory;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.net4j.db.ConnectionProvider;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
@@ -48,7 +49,8 @@ public class DBStoreFactory implements IStoreFactory
IMappingStrategy mappingStrategy = getMappingStrategy(storeConfig);
IDBAdapter dbAdapter = getDBAdapter(storeConfig);
DataSource dataSource = getDataSource(storeConfig);
- DBStore store = new DBStore(mappingStrategy, dbAdapter, dataSource);
+ ConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
+ DBStore store = new DBStore(mappingStrategy, dbAdapter, connectionProvider);
mappingStrategy.setStore(store);
return store;
}
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
deleted file mode 100644
index 4cb0abf..0000000
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
- * 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.server.internal.db;
-
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
-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.emf.cdo.server.internal.db.info.ClassServerInfo;
-import org.eclipse.emf.cdo.server.internal.db.info.FeatureServerInfo;
-import org.eclipse.emf.cdo.server.internal.db.info.ServerInfo;
-import org.eclipse.emf.cdo.server.internal.db.info.PackageServerInfo;
-
-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;
-
-/**
- * @author Eike Stepper
- */
-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
- {
- super(store);
- this.view = view;
-
- try
- {
- connection.setAutoCommit(false);
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- }
-
- @Override
- public void release() throws DBException
- {
- try
- {
- connection.commit();
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
-
- super.release();
- }
-
- public IView getView()
- {
- return view;
- }
-
- public void writePackages(CDOPackageImpl... cdoPackages)
- {
- for (CDOPackageImpl cdoPackage : cdoPackages)
- {
- if (!cdoPackage.isSystem())
- {
- int id = store.getNextPackageID();
- cdoPackage.setServerInfo(new PackageServerInfo(id));
- if (TRACER.isEnabled())
- {
- TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
- }
-
- String packageURI = cdoPackage.getPackageURI();
- String name = cdoPackage.getName();
- String ecore = cdoPackage.getEcore();
- boolean dynamic = cdoPackage.isDynamic();
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
- long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
- long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
- DBUtil.insertRow(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
-
- for (CDOClassImpl cdoClass : cdoPackage.getClasses())
- {
- writeClass(cdoClass);
- }
- }
- }
-
- IMappingStrategy mappingStrategy = store.getMappingStrategy();
- Collection<IDBTable> affectedTables = mappingStrategy.map(cdoPackages);
- store.getDBAdapter().createTables(affectedTables, connection);
- }
-
- public void writeClass(CDOClassImpl cdoClass)
- {
- int id = store.getNextClassID();
- cdoClass.setServerInfo(new ClassServerInfo(id));
-
- CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
- int packageID = ServerInfo.getDBID(cdoPackage);
- int classifierID = cdoClass.getClassifierID();
- String name = cdoClass.getName();
- boolean isAbstract = cdoClass.isAbstract();
- DBUtil.insertRow(connection, CDODBSchema.CLASSES, id, packageID, classifierID, name, isAbstract);
-
- for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
- {
- writeSuperType(id, superType);
- }
-
- for (CDOFeatureImpl feature : cdoClass.getFeatures())
- {
- writeFeature(feature);
- }
- }
-
- public void writeSuperType(int type, CDOClassProxy superType)
- {
- String packageURI = superType.getPackageURI();
- int classifierID = superType.getClassifierID();
- DBUtil.insertRow(connection, CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
- }
-
- public void writeFeature(CDOFeatureImpl feature)
- {
- int id = store.getNextFeatureID();
- feature.setServerInfo(new FeatureServerInfo(id));
-
- int classID = ServerInfo.getDBID(feature.getContainingClass());
- String name = feature.getName();
- int featureID = feature.getFeatureID();
- int type = feature.getType().getTypeID();
- CDOClassProxy reference = feature.getReferenceTypeProxy();
- String packageURI = reference == null ? null : reference.getPackageURI();
- int classifierID = reference == null ? 0 : reference.getClassifierID();
- boolean many = feature.isMany();
- boolean containment = feature.isContainment();
- int idx = feature.getFeatureIndex();
- DBUtil.insertRow(connection, CDODBSchema.FEATURES, id, classID, featureID, name, type, packageURI, classifierID,
- many, containment, idx);
- }
-
- public void writeRevision(CDORevisionImpl revision)
- {
- store.getMappingStrategy().writeRevision(connection, revision);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java
index 080e314..07825c7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java
@@ -11,28 +11,27 @@
package org.eclipse.emf.cdo.server.internal.db.info;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
-
-import org.eclipse.net4j.db.IDBTable;
+import org.eclipse.emf.cdo.server.internal.db.mapping.ClassMapper;
/**
* @author Eike Stepper
*/
public final class ClassServerInfo extends ServerInfo
{
- private IDBTable table;
+ private ClassMapper mapper;
public ClassServerInfo(int id)
{
super(id);
}
- public static IDBTable getTable(CDOClass cdoClass)
+ public static ClassMapper getMapper(CDOClass cdoClass)
{
- return ((ClassServerInfo)cdoClass.getServerInfo()).table;
+ return ((ClassServerInfo)cdoClass.getServerInfo()).mapper;
}
- public static void setTable(CDOClass cdoClass, IDBTable table)
+ public static void setMapper(CDOClass cdoClass, ClassMapper mapper)
{
- ((ClassServerInfo)cdoClass.getServerInfo()).table = table;
+ ((ClassServerInfo)cdoClass.getServerInfo()).mapper = mapper;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AttributeMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AttributeMapper.java
new file mode 100644
index 0000000..f69e675
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AttributeMapper.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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.server.internal.db.mapping;
+
+/**
+ * @author Eike Stepper
+ */
+public final class AttributeMapper
+{
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/ClassMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/ClassMapper.java
new file mode 100644
index 0000000..f050ea7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/ClassMapper.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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.server.internal.db.mapping;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ClassMapper
+{
+ private List<AttributeMapper> attributeMappers;
+
+ public List<AttributeMapper> getAttributeMappers()
+ {
+ return attributeMappers;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java
index 11d99fc..eb87430 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java
@@ -22,7 +22,6 @@ import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.db.info.ClassServerInfo;
import org.eclipse.emf.cdo.server.internal.db.info.FeatureServerInfo;
import org.eclipse.emf.cdo.server.internal.db.info.PackageServerInfo;
import org.eclipse.emf.cdo.server.internal.db.info.ServerInfo;
@@ -141,21 +140,24 @@ public abstract class StandardMappingStrategy extends MappingStrategy
* @param affectedTables
* Can be used to indicate the creation or modification of additional
* tables. There is no need to add the table of the returned field to
- * this set of affected tables. The caller takes care of that.
+ * this set of affected tables. The framework takes care of that.
*/
protected abstract IDBField mapFeature(CDOClass cdoClass, CDOFeature cdoFeature, Set<IDBTable> affectedTables);
protected IDBField mapAttribute(CDOClass cdoClass, CDOFeature cdoFeature)
{
- IDBTable table = ClassServerInfo.getTable(cdoClass);
- if (table == null)
- {
- table = addTable(cdoClass);
- initTable(table, true);
- ClassServerInfo.setTable(cdoClass, table);
- }
-
- return addField(cdoFeature, table);
+ // IDBTable table = ClassServerInfo.getTable(cdoClass);
+ // if (table == null)
+ // {
+ // table = addTable(cdoClass);
+ // initTable(table, true);
+ // ClassServerInfo.setTable(cdoClass, table);
+ // }
+ //
+ // return addField(cdoFeature, table);
+
+ // TODO Implement method StandardMappingStrategy.mapAttribute()
+ throw new UnsupportedOperationException("Not yet implemented");
}
protected IDBField mapReference(CDOClass cdoClass, CDOFeature cdoFeature, ToMany mapping)
@@ -227,6 +229,12 @@ public abstract class StandardMappingStrategy extends MappingStrategy
}
CDOClassImpl cdoClass = revision.getCDOClass();
+ // ClassMapper classMapper = ClassServerInfo.getMapper(cdoClass);
+ // List<AttributeMapper> attributeMappers =
+ // classMapper.getAttributeMappers();
+ //
+ // Map<IDBTable, FeatureMapper[]> featureMappers = classMapping.getTables();
+
ClassMapping classMapping = getClassMapping(cdoClass);
Map<IDBTable, FeatureMapping[]> tables = classMapping.getTables();
Entry<IDBTable, FeatureMapping[]> entry = tables.entrySet().iterator().next();