summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-19 19:08:35 (EDT)
committerEike Stepper2007-08-19 19:08:35 (EDT)
commitfc2a3e906b9e73a56a83211b485f57046f58cc49 (patch)
tree3d55863e505ae856640fd3ff9ed0321ee9090353
parent1ed81906b6ff849f25d67524dfcb93aa5f86aafa (diff)
downloadcdo-fc2a3e906b9e73a56a83211b485f57046f58cc49.zip
cdo-fc2a3e906b9e73a56a83211b485f57046f58cc49.tar.gz
cdo-fc2a3e906b9e73a56a83211b485f57046f58cc49.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java2
3 files changed, 23 insertions, 7 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 9c97ca5..840d1b3 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
@@ -10,10 +10,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.server.PackageManager;
import org.eclipse.emf.cdo.internal.server.Store;
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.IDBStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
@@ -78,12 +77,12 @@ public class DBStore extends Store implements IDBStore
return dataSource;
}
- public IStoreReader getReader(ISession session) throws DBException
+ public DBStoreReader getReader(ISession session) throws DBException
{
return new DBStoreReader(this);
}
- public IStoreWriter getWriter(IView view) throws DBException
+ public DBStoreWriter getWriter(IView view) throws DBException
{
return new DBStoreWriter(this, view);
}
@@ -108,14 +107,23 @@ public class DBStore extends Store implements IDBStore
{
super.doActivate();
CDODBSchema.INSTANCE.create(dbAdapter, dataSource);
- Connection connection = null;
+ DBStoreWriter writer = getWriter(null);
+ Connection connection = writer.getConnection();
try
{
- connection = dataSource.getConnection();
+
nextPackageID = DBUtil.selectMaximum(connection, CDODBSchema.PACKAGES_ID) + 1;
nextClassID = DBUtil.selectMaximum(connection, CDODBSchema.CLASSES_ID) + 1;
nextFeatureID = DBUtil.selectMaximum(connection, CDODBSchema.FEATURES_ID) + 1;
+
+ if (nextPackageID == 1)
+ {
+ PackageManager packageManager = (PackageManager)getRepository().getPackageManager();
+ writer.writePackages(packageManager.getCDOResourcePackage());
+ }
+
+ writer.release();
}
finally
{
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 e9a3790..6d06a77 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
@@ -29,6 +29,8 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
{
private Repository repository;
+ private boolean resourcePackageStored;
+
public PackageManager(Repository repository)
{
this.repository = repository;
@@ -92,6 +94,12 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
public void phase1(IStoreWriter storeWriter) throws Exception
{
+ if (!resourcePackageStored)
+ {
+ storeWriter.writePackages(getCDOResourcePackage());
+ resourcePackageStored = true;
+ }
+
storeWriter.writePackages(cdoPackages);
}
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 69a7e16..dee2197 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 writePackages(CDOPackageImpl[] cdoPackages);
+ public void writePackages(CDOPackageImpl... cdoPackages);
public void writeRevision(CDORevisionImpl revision);
}