summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-17 03:53:17 (EDT)
committerEike Stepper2007-08-17 03:53:17 (EDT)
commit32683980457cb6f968899da134718d2f65e5e1c3 (patch)
treeedf06f8b65880b50f9f2a52b0ec15abcf0b52ec8
parent9aea5261ada37350d1445e95273dab5dd371f961 (diff)
downloadcdo-32683980457cb6f968899da134718d2f65e5e1c3.zip
cdo-32683980457cb6f968899da134718d2f65e5e1c3.tar.gz
cdo-32683980457cb6f968899da134718d2f65e5e1c3.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java36
-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/src/org/eclipse/emf/cdo/internal/server/PackageManager.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java3
9 files changed, 63 insertions, 47 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 6f47b65..6aeef54 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
@@ -10,13 +10,14 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.db;
-import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.db.IDBSchema;
import org.eclipse.net4j.db.IDBTable;
import java.util.Properties;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -35,5 +36,8 @@ public interface IMappingStrategy
public IDBSchema getSchema();
- public IDBTable[] map(CDOPackage cdoPackage);
+ /**
+ * @return A collection of the affected tables.
+ */
+ public Set<IDBTable> map(CDOPackageImpl[] cdoPackages);
}
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 8a8f9f2..ffe4f0b 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,7 +105,9 @@ public class DBStoreReader implements IStoreReader
cdoPackage.setName((String)values[1]);
cdoPackage.setEcore((String)values[2]);
readClasses(cdoPackage);
- store.getMappingStrategy().map(cdoPackage);
+
+ CDOPackageImpl[] cdoPackages = { cdoPackage };
+ store.getMappingStrategy().map(cdoPackages);
}
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 1e4d1c7..eb5edd7 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
@@ -25,6 +25,7 @@ import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBTable;
import java.sql.SQLException;
+import java.util.Collection;
/**
* @author Eike Stepper
@@ -68,27 +69,30 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
return view;
}
- public void writePackage(CDOPackageImpl cdoPackage)
+ public void writePackages(CDOPackageImpl[] cdoPackages)
{
- int id = store.getNextPackageID();
- cdoPackage.setServerInfo(new DBPackageInfo(id));
-
- String packageURI = cdoPackage.getPackageURI();
- String name = cdoPackage.getName();
- String ecore = cdoPackage.getEcore();
- boolean dynamic = cdoPackage.isDynamic();
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
- long lb = metaIDRange.getLowerBound().getValue();
- long ub = metaIDRange.getUpperBound().getValue();
- DBUtil.insertRow(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
-
- for (CDOClassImpl cdoClass : cdoPackage.getClasses())
+ for (CDOPackageImpl cdoPackage : cdoPackages)
{
- writeClass(cdoClass);
+ int id = store.getNextPackageID();
+ cdoPackage.setServerInfo(new DBPackageInfo(id));
+
+ String packageURI = cdoPackage.getPackageURI();
+ String name = cdoPackage.getName();
+ String ecore = cdoPackage.getEcore();
+ boolean dynamic = cdoPackage.isDynamic();
+ CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ long lb = metaIDRange.getLowerBound().getValue();
+ long ub = 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();
- IDBTable[] affectedTables = mappingStrategy.map(cdoPackage);
+ Collection<IDBTable> affectedTables = mappingStrategy.map(cdoPackages);
store.getDBAdapter().createTables(affectedTables, connection);
}
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 88624fc..0347f33 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
@@ -10,9 +10,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
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.IStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
@@ -74,7 +74,7 @@ public abstract class MappingStrategy implements IMappingStrategy
return getType();
}
- public IDBTable[] map(CDOPackage cdoPackage)
+ public Set<IDBTable> map(CDOPackageImpl[] cdoPackages)
{
if (schema == null)
{
@@ -82,28 +82,31 @@ public abstract class MappingStrategy implements IMappingStrategy
}
Set<IDBTable> affectedTables = new HashSet();
- ((DBPackageInfo)cdoPackage.getServerInfo()).setSchema(schema);
- for (CDOClass cdoClass : cdoPackage.getClasses())
+ for (CDOPackageImpl cdoPackage : cdoPackages)
{
- IDBTable table = map(schema, cdoClass, affectedTables);
- if (table != null)
+ ((DBPackageInfo)cdoPackage.getServerInfo()).setSchema(schema);
+ for (CDOClass cdoClass : cdoPackage.getClasses())
{
- ((DBClassInfo)cdoClass.getServerInfo()).setTable(table);
- affectedTables.add(table);
- }
-
- for (CDOFeature cdoFeature : cdoClass.getAllFeatures())
- {
- IDBField field = map(schema, cdoClass, cdoFeature, affectedTables);
+ IDBTable table = map(schema, cdoClass, affectedTables);
if (table != null)
{
- ((DBFeatureInfo)cdoFeature.getServerInfo()).setField(field);
- affectedTables.add(field.getTable());
+ ((DBClassInfo)cdoClass.getServerInfo()).setTable(table);
+ affectedTables.add(table);
+ }
+
+ for (CDOFeature cdoFeature : cdoClass.getAllFeatures())
+ {
+ IDBField field = map(schema, cdoClass, cdoFeature, affectedTables);
+ if (table != null)
+ {
+ ((DBFeatureInfo)cdoFeature.getServerInfo()).setField(field);
+ affectedTables.add(field.getTable());
+ }
}
}
}
- return affectedTables.toArray(new IDBTable[affectedTables.size()]);
+ return affectedTables;
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
index 6f3de93..678d0c2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -44,8 +44,9 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
for (CDOPackageImpl cdoPackage : cdoPackages)
{
cdoPackage.setPackageManager(this);
- storeTransaction.execute(new AddPackageOperation(cdoPackage));
}
+
+ storeTransaction.execute(new AddPackagesOperation(cdoPackages));
}
@Override
@@ -80,23 +81,26 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
/**
* @author Eike Stepper
*/
- private final class AddPackageOperation implements ITransactionalOperation<IStoreWriter>
+ private final class AddPackagesOperation implements ITransactionalOperation<IStoreWriter>
{
- private CDOPackageImpl cdoPackage;
+ private CDOPackageImpl[] cdoPackages;
- private AddPackageOperation(CDOPackageImpl cdoPackage)
+ private AddPackagesOperation(CDOPackageImpl[] cdoPackages)
{
- this.cdoPackage = cdoPackage;
+ this.cdoPackages = cdoPackages;
}
public void phase1(IStoreWriter storeWriter) throws Exception
{
- storeWriter.writePackage(cdoPackage);
+ storeWriter.writePackages(cdoPackages);
}
public void phase2(IStoreWriter storeWriter)
{
- addPackage(cdoPackage);
+ for (CDOPackageImpl cdoPackage : cdoPackages)
+ {
+ addPackage(cdoPackage);
+ }
}
public void undoPhase1(IStoreWriter storeWriter)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
index 516dddd..69a7e16 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
@@ -42,7 +42,7 @@ public interface IStoreWriter extends IStoreReader
* @see CDOClassProxy#getPackageURI()
* @see CDOClassProxy#getClassifierID()
*/
- public void writePackage(CDOPackageImpl cdoPackage);
+ public void writePackages(CDOPackageImpl[] cdoPackages);
public void writeRevision(CDORevisionImpl revision);
}
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 f8ac2af..d203601 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
@@ -30,7 +30,7 @@ public interface IDBAdapter
public Driver getJDBCDriver();
- public void createTables(IDBTable[] tables, Connection connection) throws DBException;
+ public void createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException;
public void createTable(IDBTable table, Statement statement) throws DBException;
}
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 b00a56a..4f267f9 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
@@ -51,7 +51,7 @@ public abstract class DBAdapter implements IDBAdapter
return version;
}
- public void createTables(IDBTable[] tables, Connection connection) throws DBException
+ public void createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException
{
Statement statement = null;
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 a2ca7c6..861c2b0 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
@@ -14,7 +14,6 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBSchema;
-import org.eclipse.net4j.db.IDBTable;
import javax.sql.DataSource;
@@ -98,7 +97,7 @@ public class DBSchema implements IDBSchema
public void create(IDBAdapter dbAdapter, Connection connection)
{
- dbAdapter.createTables(tables.values().toArray(new IDBTable[tables.size()]), connection);
+ dbAdapter.createTables(tables.values(), connection);
}
@Override