summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 05:19:04 (EDT)
committerEike Stepper2007-08-25 05:19:04 (EDT)
commit364c16ae50b7c41c02d2b69814d63cc05fc23aea (patch)
tree6088153700b42de4c13e1464491266d0e4202aaa
parentaaeee6cd915be648a4d0c6a0befbd915fd1b9305 (diff)
downloadcdo-364c16ae50b7c41c02d2b69814d63cc05fc23aea.zip
cdo-364c16ae50b7c41c02d2b69814d63cc05fc23aea.tar.gz
cdo-364c16ae50b7c41c02d2b69814d63cc05fc23aea.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java38
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java18
3 files changed, 38 insertions, 28 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index 44863b1..ac1300e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -10,12 +10,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.server.IPackageManager;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IMapping;
import java.util.ArrayList;
@@ -40,11 +37,6 @@ public class HorizontalMappingStrategy extends MappingStrategy
return false;
}
- public CDOClassRef readObjectType(IDBStoreAccessor storeAccessor, CDOID id)
- {
- return null;
- }
-
@Override
protected IMapping createMapping(CDOClass cdoClass)
{
@@ -57,7 +49,7 @@ public class HorizontalMappingStrategy extends MappingStrategy
}
@Override
- protected List<CDOClass> getObjectIDClasses()
+ protected List<CDOClass> getClassesWithObjectInfo()
{
List<CDOClass> result = new ArrayList();
IPackageManager packageManager = getStore().getRepository().getPackageManager();
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 0b8eefe..df694ca 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
@@ -134,7 +134,7 @@ public abstract class MappingStrategy implements IMappingStrategy
public CloseableIterator<CDOID> readObjectIDs(final IDBStoreAccessor storeAccessor, final boolean withTypes)
{
- List<CDOClass> classes = getObjectIDClasses();
+ List<CDOClass> classes = getClassesWithObjectInfo();
final Iterator<CDOClass> classIt = classes.iterator();
return new ObjectIDIterator(this, storeAccessor, withTypes)
{
@@ -180,6 +180,40 @@ public abstract class MappingStrategy implements IMappingStrategy
};
}
+ public CDOClassRef readObjectType(IDBStoreAccessor storeAccessor, CDOID id)
+ {
+ String prefix = "SELECT DISTINCT " + Mapping.FIELD_NAME_CLASS + " FROM ";
+ String suffix = " WHERE " + Mapping.FIELD_NAME_ID + "=" + id;
+ for (CDOClass cdoClass : getClassesWithObjectInfo())
+ {
+ ValueMapping mapping = (ValueMapping)ClassServerInfo.getMapping(cdoClass);
+ if (mapping != null)
+ {
+ IDBTable table = mapping.getTable();
+ if (table != null)
+ {
+ String sql = prefix + table + suffix;
+
+ try
+ {
+ ResultSet resultSet = storeAccessor.getStatement().executeQuery(sql);
+ if (resultSet.next())
+ {
+ int classID = resultSet.getInt(1);
+ return getClassRef(storeAccessor, classID);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+ }
+ }
+
+ throw new DBException("No object with id " + id);
+ }
+
public CDOClassRef getClassRef(IDBStoreAccessor storeAccessor, int classID)
{
CDOClassRef classRef = classRefs.get(classID);
@@ -200,5 +234,5 @@ public abstract class MappingStrategy implements IMappingStrategy
protected abstract IMapping createMapping(CDOClass cdoClass);
- protected abstract List<CDOClass> getObjectIDClasses();
+ protected abstract List<CDOClass> getClassesWithObjectInfo();
} \ No newline at end of file
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 18c3999..ad52612 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
@@ -10,14 +10,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IMapping;
-import org.eclipse.net4j.util.io.CloseableIterator;
-
import java.util.Collections;
import java.util.List;
@@ -43,17 +38,6 @@ public class VerticalMappingStrategy extends MappingStrategy
return true;
}
- @Override
- public CloseableIterator<CDOID> readObjectIDs(IDBStoreAccessor storeAccessor, boolean withTypes)
- {
- return null;
- }
-
- public CDOClassRef readObjectType(IDBStoreAccessor storeAccessor, CDOID id)
- {
- return null;
- }
-
public RootMapping getRootMapping()
{
if (rootMapping == null)
@@ -71,7 +55,7 @@ public class VerticalMappingStrategy extends MappingStrategy
}
@Override
- protected List<CDOClass> getObjectIDClasses()
+ protected List<CDOClass> getClassesWithObjectInfo()
{
return Collections.singletonList(rootMapping.getCDOClass());
}