summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-21 02:25:32 (EDT)
committerEike Stepper2007-08-21 02:25:32 (EDT)
commit4d9a04c90bc80374604447d49e2c99fffed486b1 (patch)
tree0c84dd5538c3fefb99a4a92d698eb16c15e09b6c
parente9d2a37c209c8df489759155e9f3165cbb567681 (diff)
downloadcdo-4d9a04c90bc80374604447d49e2c99fffed486b1.zip
cdo-4d9a04c90bc80374604447d49e2c99fffed486b1.tar.gz
cdo-4d9a04c90bc80374604447d49e2c99fffed486b1.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ClassServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/PackageServerInfo.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ServerInfo.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/StandardMappingStrategy.java9
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java21
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java21
9 files changed, 46 insertions, 58 deletions
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 dd79905..ee8ba1b 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
@@ -138,7 +138,7 @@ public class DBStoreReader implements IStoreReader
}
};
- String where = CDODBSchema.CLASSES_PACKAGE.getName() + " = " + ServerInfo.getDBID(cdoPackage);
+ String where = CDODBSchema.CLASSES_PACKAGE.getName() + " = " + ServerInfo.getID(cdoPackage);
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 4cb0abf..e92e942 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
@@ -117,7 +117,7 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
cdoClass.setServerInfo(new ClassServerInfo(id));
CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
- int packageID = ServerInfo.getDBID(cdoPackage);
+ int packageID = ServerInfo.getID(cdoPackage);
int classifierID = cdoClass.getClassifierID();
String name = cdoClass.getName();
boolean isAbstract = cdoClass.isAbstract();
@@ -146,7 +146,7 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
int id = store.getNextFeatureID();
feature.setServerInfo(new FeatureServerInfo(id));
- int classID = ServerInfo.getDBID(feature.getContainingClass());
+ int classID = ServerInfo.getID(feature.getContainingClass());
String name = feature.getName();
int featureID = feature.getFeatureID();
int type = feature.getType().getTypeID();
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 0bfa2e3..080e314 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
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db.info;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
+
import org.eclipse.net4j.db.IDBTable;
/**
@@ -24,21 +26,13 @@ public final class ClassServerInfo extends ServerInfo
super(id);
}
- public IDBTable getTable()
+ public static IDBTable getTable(CDOClass cdoClass)
{
- return table;
+ return ((ClassServerInfo)cdoClass.getServerInfo()).table;
}
- public void setTable(IDBTable table)
+ public static void setTable(CDOClass cdoClass, IDBTable table)
{
- if (this.table != table)
- {
- if (this.table != null)
- {
- throw new IllegalStateException("Table is already set");
- }
-
- this.table = table;
- }
+ ((ClassServerInfo)cdoClass.getServerInfo()).table = table;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/PackageServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/PackageServerInfo.java
index fdf692e..6c0e451 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/PackageServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/PackageServerInfo.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db.info;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+
import org.eclipse.net4j.db.IDBSchema;
/**
@@ -24,21 +26,13 @@ public final class PackageServerInfo extends ServerInfo
super(id);
}
- public IDBSchema getSchema()
+ public static IDBSchema getSchema(CDOPackage cdoPackage)
{
- return schema;
+ return ((PackageServerInfo)cdoPackage.getServerInfo()).schema;
}
- public void setSchema(IDBSchema schema)
+ public static void setSchema(CDOPackage cdoPackage, IDBSchema schema)
{
- if (this.schema != schema)
- {
- if (this.schema != null)
- {
- throw new IllegalStateException("Schema " + schema + "is already set");
- }
-
- this.schema = schema;
- }
+ ((PackageServerInfo)cdoPackage.getServerInfo()).schema = schema;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ServerInfo.java
index 771aff9..ccf4615 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/info/ServerInfo.java
@@ -24,13 +24,8 @@ public abstract class ServerInfo
this.id = id;
}
- public int getID()
+ public static int getID(CDOModelElement modelElement)
{
- return id;
- }
-
- public static int getDBID(CDOModelElement modelElement)
- {
- return ((ServerInfo)modelElement.getServerInfo()).getID();
+ return ((ServerInfo)modelElement.getServerInfo()).id;
}
}
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 48d4d48..564b489 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
@@ -102,7 +102,7 @@ public abstract class StandardMappingStrategy extends MappingStrategy
Set<IDBTable> affectedTables = new HashSet();
for (CDOPackageImpl cdoPackage : cdoPackages)
{
- ((PackageServerInfo)cdoPackage.getServerInfo()).setSchema(getSchema());
+ PackageServerInfo.setSchema(cdoPackage, getSchema());
if (TRACER.isEnabled())
{
TRACER.format("Mapped package: {0} --> {1}", cdoPackage, getSchema());
@@ -147,13 +147,12 @@ public abstract class StandardMappingStrategy extends MappingStrategy
protected IDBField mapAttribute(CDOClass cdoClass, CDOFeature cdoFeature)
{
- ClassServerInfo classInfo = (ClassServerInfo)cdoClass.getServerInfo();
- IDBTable table = classInfo.getTable();
+ IDBTable table = ClassServerInfo.getTable(cdoClass);
if (table == null)
{
table = addTable(cdoClass);
initTable(table, true);
- classInfo.setTable(table);
+ ClassServerInfo.setTable(cdoClass, table);
}
return addField(cdoFeature, table);
@@ -236,7 +235,7 @@ public abstract class StandardMappingStrategy extends MappingStrategy
int i = 0;
Object[] values = new Object[table.getFieldCount()];
values[i++] = revision.getID().getValue();
- values[i++] = ServerInfo.getDBID(revision.getCDOClass());
+ values[i++] = ServerInfo.getID(revision.getCDOClass());
values[i++] = revision.getVersion();
values[i++] = new Date(revision.getCreated());
values[i++] = new Date(revision.getRevised());
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 7f446fc..bae9e34 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -178,27 +178,10 @@ public final class DBUtil
+ Arrays.asList(table.getFields()));
}
- StringBuilder builder = new StringBuilder();
- builder.append("INSERT INTO ");
- builder.append(table);
- builder.append(" VALUES (");
-
- for (int i = 0; i < fields.length; i++)
- {
- if (i > 0)
- {
- builder.append(", ");
- }
-
- builder.append("?");
- }
-
- builder.append(")");
-
- String sql = builder.toString();
+ String sql = table.sqlInsert();
if (TRACER.isEnabled())
{
- builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
builder.append("INSERT INTO ");
builder.append(table);
builder.append(" VALUES (");
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
index a9f7d88..9a7c736 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTable.java
@@ -46,4 +46,6 @@ public interface IDBTable extends IDBElement
public IDBIndex[] getIndices();
public IDBIndex getPrimaryKeyIndex();
+
+ public String sqlInsert();
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
index 6f27cd6..b658ce6 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
@@ -203,4 +203,25 @@ public class DBTable extends DBElement implements IDBTable
{
return name;
}
+
+ public String sqlInsert()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("INSERT INTO ");
+ builder.append(getName());
+ builder.append(" VALUES (");
+
+ for (int i = 0; i < fields.size(); i++)
+ {
+ if (i > 0)
+ {
+ builder.append(", ");
+ }
+
+ builder.append("?");
+ }
+
+ builder.append(")");
+ return builder.toString();
+ }
}