summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 04:45:41 (EDT)
committerEike Stepper2007-08-25 04:45:41 (EDT)
commit2181d6279e8e68aa18478ff16d2aa947c900cb4b (patch)
tree4daf83218d3629fc06d165fbb1f3de4b2292ce6e
parent3f092a0374378e09f54a35fe21abf5d4e8721ea2 (diff)
downloadcdo-2181d6279e8e68aa18478ff16d2aa947c900cb4b.zip
cdo-2181d6279e8e68aa18478ff16d2aa947c900cb4b.tar.gz
cdo-2181d6279e8e68aa18478ff16d2aa947c900cb4b.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java20
3 files changed, 63 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java
index 3b6d3dd..e544c5a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java
@@ -35,6 +35,22 @@ import java.util.Set;
*/
public abstract class Mapping implements IMapping
{
+ public static final String FIELD_NAME_ID = "cdo_id";
+
+ public static final String FIELD_NAME_VERSION = "cdo_version";
+
+ public static final String FIELD_NAME_CLASS = "cdo_class";
+
+ public static final String FIELD_NAME_CREATED = "cdo_created";
+
+ public static final String FIELD_NAME_REVISED = "cdo_revised";
+
+ public static final String FIELD_NAME_RESOURCE = "cdo_resource";
+
+ public static final String FIELD_NAME_CONTAINER = "cdo_container";
+
+ public static final String FIELD_NAME_FEATURE = "cdo_feature";
+
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, Mapping.class);
private MappingStrategy mappingStrategy;
@@ -74,16 +90,16 @@ public abstract class Mapping implements IMapping
protected void initTable(IDBTable table, boolean full)
{
- table.addField("cdo_id", DBType.BIGINT);
- table.addField("cdo_version", DBType.INTEGER);
+ table.addField(FIELD_NAME_ID, DBType.BIGINT);
+ table.addField(FIELD_NAME_VERSION, DBType.INTEGER);
if (full)
{
- table.addField("cdo_class", DBType.INTEGER);
- table.addField("cdo_created", DBType.BIGINT);
- table.addField("cdo_revised", DBType.BIGINT);
- table.addField("cdo_resource", DBType.BIGINT);
- table.addField("cdo_container", DBType.BIGINT);
- table.addField("cdo_feature", DBType.INTEGER);
+ table.addField(FIELD_NAME_CLASS, DBType.INTEGER);
+ table.addField(FIELD_NAME_CREATED, DBType.BIGINT);
+ table.addField(FIELD_NAME_REVISED, DBType.BIGINT);
+ table.addField(FIELD_NAME_RESOURCE, DBType.BIGINT);
+ table.addField(FIELD_NAME_CONTAINER, DBType.BIGINT);
+ table.addField(FIELD_NAME_FEATURE, DBType.INTEGER);
}
}
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 167b21e..fefb25b 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
@@ -18,9 +18,11 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IMapping;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.IDBTable;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -129,7 +131,7 @@ public abstract class MappingStrategy implements IMappingStrategy
return mapping;
}
- public Iterator<CDOID> readObjectIDs(IDBStoreAccessor storeAccessor, boolean withTypes)
+ public Iterator<CDOID> readObjectIDs(final IDBStoreAccessor storeAccessor, final boolean withTypes)
{
List<CDOClass> classes = getObjectIDClasses();
final Iterator<CDOClass> classIt = classes.iterator();
@@ -147,8 +149,27 @@ public abstract class MappingStrategy implements IMappingStrategy
IDBTable table = mapping.getTable();
if (table != null)
{
-
- return null;
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT DISTINCT ");
+ builder.append(Mapping.FIELD_NAME_ID);
+ if (withTypes)
+ {
+ builder.append(", ");
+ builder.append(Mapping.FIELD_NAME_CLASS);
+ }
+
+ builder.append(" FROM ");
+ builder.append(table);
+ String sql = builder.toString();
+
+ try
+ {
+ return storeAccessor.getStatement().executeQuery(sql);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index aac3ba4..d7ce3e3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -19,6 +19,16 @@ import java.util.Map;
*/
public class ReferenceMapping extends FeatureMapping implements IReferenceMapping
{
+ public static final String FIELD_NAME_FEATURE = "cdo_feature";
+
+ public static final String FIELD_NAME_SOURCE = "cdo_source";
+
+ public static final String FIELD_NAME_VERSION = "cdo_version";
+
+ public static final String FIELD_NAME_IDX = "cdo_idx";
+
+ public static final String FIELD_NAME_TARGET = "cdo_target";
+
private IDBTable table;
private ToMany toMany;
@@ -122,13 +132,13 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
IDBTable table = getValueMapping().addTable(tableName);
if (withFeature)
{
- table.addField("cdo_feature", DBType.INTEGER);
+ table.addField(FIELD_NAME_FEATURE, DBType.INTEGER);
}
- table.addField("cdo_source", DBType.BIGINT);
- table.addField("cdo_version", DBType.INTEGER);
- table.addField("cdo_idx", DBType.INTEGER);
- table.addField("cdo_target", DBType.BIGINT);
+ table.addField(FIELD_NAME_SOURCE, DBType.BIGINT);
+ table.addField(FIELD_NAME_VERSION, DBType.INTEGER);
+ table.addField(FIELD_NAME_IDX, DBType.INTEGER);
+ table.addField(FIELD_NAME_TARGET, DBType.BIGINT);
return table;
}