summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-16 15:29:27 (EDT)
committerEike Stepper2007-08-16 15:29:27 (EDT)
commit18f8c4427355e1b2a0782be90a4a674c555cd4c1 (patch)
treea318d70cae9c834dbea6d5371a8aa8283c9fcb5e
parent20de13c6b109f77ba7995324f5e953ccbb3cd12f (diff)
downloadcdo-18f8c4427355e1b2a0782be90a4a674c555cd4c1.zip
cdo-18f8c4427355e1b2a0782be90a4a674c555cd4c1.tar.gz
cdo-18f8c4427355e1b2a0782be90a4a674c555cd4c1.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryFactory.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java3
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java7
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java1
12 files changed, 90 insertions, 21 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
index c74cabf..6f47b65 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
@@ -11,7 +11,7 @@
package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
-import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.db.IDBSchema;
import org.eclipse.net4j.db.IDBTable;
@@ -25,11 +25,15 @@ public interface IMappingStrategy
{
public String getType();
+ public IStore getStore();
+
+ public void setStore(IStore store);
+
public Properties getProperties();
public void setProperties(Properties properties);
- public IDBSchema createSchema(IRepository repository);
+ public IDBSchema getSchema();
- public IDBTable[] map(IDBSchema schema, CDOPackage cdoPackage);
+ public IDBTable[] map(CDOPackage cdoPackage);
}
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 83fee5d..8a8f9f2 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
@@ -105,6 +105,7 @@ public class DBStoreReader implements IStoreReader
cdoPackage.setName((String)values[1]);
cdoPackage.setEcore((String)values[2]);
readClasses(cdoPackage);
+ store.getMappingStrategy().map(cdoPackage);
}
public void readClasses(final CDOPackageImpl cdoPackage)
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 eabb3c8..49afdbb 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
@@ -18,11 +18,14 @@ 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.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBTable;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* @author Eike Stepper
@@ -84,6 +87,27 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
{
writeClass(cdoClass);
}
+
+ IMappingStrategy mappingStrategy = store.getMappingStrategy();
+ IDBTable[] affectedTables = mappingStrategy.map(cdoPackage);
+ Statement statement = null;
+
+ try
+ {
+ statement = connection.createStatement();
+ for (IDBTable table : affectedTables)
+ {
+ store.getDBAdapter().createTable(table, statement);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ }
}
public void writeClass(CDOClassImpl cdoClass)
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 aedcc0e..b0a51d7 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
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.model.CDOType;
-import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.net4j.db.DBType;
@@ -33,12 +33,27 @@ import java.util.Set;
*/
public abstract class MappingStrategy implements IMappingStrategy
{
+ private IStore store;
+
private Properties properties;
+ private IDBSchema schema;
+
public MappingStrategy()
{
}
+ public IStore getStore()
+ {
+ return store;
+ }
+
+ public void setStore(IStore store)
+ {
+ this.store = store;
+ schema = createSchema();
+ }
+
public Properties getProperties()
{
return properties;
@@ -49,18 +64,18 @@ public abstract class MappingStrategy implements IMappingStrategy
this.properties = properties;
}
- @Override
- public String toString()
+ public IDBSchema getSchema()
{
- return getType();
+ return schema;
}
- public IDBSchema createSchema(IRepository repository)
+ @Override
+ public String toString()
{
- return new DBSchema(repository.getName());
+ return getType();
}
- public IDBTable[] map(IDBSchema schema, CDOPackage cdoPackage)
+ public IDBTable[] map(CDOPackage cdoPackage)
{
Set<IDBTable> affectedTables = new HashSet();
((DBPackageInfo)cdoPackage.getServerInfo()).setSchema(schema);
@@ -104,6 +119,12 @@ public abstract class MappingStrategy implements IMappingStrategy
protected abstract IDBField map(IDBSchema schema, CDOClass cdoClass, CDOFeature cdoFeature,
Set<IDBTable> affectedTables);
+ protected IDBSchema createSchema()
+ {
+ String name = store.getRepository().getName();
+ return new DBSchema(name);
+ }
+
protected void initTable(IDBTable table, boolean full)
{
table.addField("cdo_id", DBType.BIGINT);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
index 7e5ce3d..829c618 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
@@ -12,7 +12,6 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
-import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBSchema;
@@ -35,9 +34,9 @@ public class VerticalMappingStrategy extends MappingStrategy
}
@Override
- public IDBSchema createSchema(IRepository repository)
+ protected IDBSchema createSchema()
{
- IDBSchema schema = super.createSchema(repository);
+ IDBSchema schema = super.createSchema();
IDBTable table = schema.addTable("CDO_REVISIONS");
initTable(table, true);
return schema;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
index ffe3a72..89fa562 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
@@ -74,7 +74,9 @@ public class RepositoryConfigurator
Element storeConfig = (Element)storeConfigs.item(0);
IStore store = configureStore(storeConfig);
- return new Repository(repositoryName, store);
+ Repository repository = new Repository(repositoryName, store);
+ store.setRepository(repository);
+ return repository;
}
protected IStore configureStore(Element storeConfig) throws CoreException
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryFactory.java
index b04d3d0..c96a7e1 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryFactory.java
@@ -41,7 +41,9 @@ public class RepositoryFactory extends Factory<Repository>
public Repository create(String name)
{
IStore store = storeProvider.getStore(name);
- return new Repository(name, store);
+ Repository repository = new Repository(name, store);
+ store.setRepository(repository);
+ return repository;
}
public static Repository get(IManagedContainer container, String name)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
index 1682812..c6d0c6d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
@@ -21,6 +22,8 @@ public abstract class Store extends Lifecycle implements IStore
{
private String type;
+ private IRepository repository;
+
public Store(String type)
{
this.type = type;
@@ -30,4 +33,14 @@ public abstract class Store extends Lifecycle implements IStore
{
return type;
}
+
+ public IRepository getRepository()
+ {
+ return repository;
+ }
+
+ public void setRepository(IRepository repository)
+ {
+ this.repository = repository;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index c3a7a69..f99159d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -13,10 +13,12 @@ package org.eclipse.emf.cdo.server;
/**
* @author Eike Stepper
*/
-public interface IStore
+public interface IStore extends IRepositoryElement
{
public String getStoreType();
+ public void setRepository(IRepository repository);
+
public IStoreReader getReader();
public IStoreWriter getWriter(IView view);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
index 0fd3ce7..f9d6c14 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
@@ -11,7 +11,6 @@
package org.eclipse.net4j.db;
import org.eclipse.net4j.internal.db.DBAdapterRegistry;
-import org.eclipse.net4j.internal.db.DBTable;
import org.eclipse.net4j.util.registry.IRegistry;
import java.sql.Driver;
@@ -30,5 +29,5 @@ public interface IDBAdapter
public Driver getJDBCDriver();
- public void createTable(DBTable table, Statement statement);
+ public void createTable(IDBTable table, Statement statement);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index 4352fd7..4fdcaa4 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
@@ -13,6 +13,7 @@ package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBTable;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -48,11 +49,11 @@ public abstract class DBAdapter implements IDBAdapter
return version;
}
- public void createTable(DBTable table, Statement statement)
+ public void createTable(IDBTable table, Statement statement)
{
try
{
- doCreateTable(table, statement);
+ doCreateTable((DBTable)table, statement);
}
catch (SQLException ex)
{
@@ -62,7 +63,7 @@ public abstract class DBAdapter implements IDBAdapter
}
}
- validateTable(table, statement);
+ validateTable((DBTable)table, statement);
}
@Override
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
index 9d94722..d259590 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
@@ -81,6 +81,7 @@ public class DBSchema implements IDBSchema
{
Connection connection = null;
Statement statement = null;
+
try
{
connection = dataSource.getConnection();