summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-13 06:29:16 (EDT)
committerEike Stepper2007-09-13 06:29:16 (EDT)
commit9521cc3ca7349320a52e074a94ce0fab3a3c22dc (patch)
tree5299dbd0fe7b9f6ab4104a40d704c73969dfa4f6
parent27c0d8fe3a6c9ec0f17717ce27e4a941ec9f3a9e (diff)
downloadcdo-9521cc3ca7349320a52e074a94ce0fab3a3c22dc.zip
cdo-9521cc3ca7349320a52e074a94ce0fab3a3c22dc.tar.gz
cdo-9521cc3ca7349320a52e074a94ce0fab3a3c22dc.tar.bz2
[202833] Horizontal Mapping Strategy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202833
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java12
8 files changed, 91 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
index 741b43f..299e095 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java
@@ -36,6 +36,8 @@ public interface IClassMapping
public List<IReferenceMapping> getReferenceMappings();
+ public IAttributeMapping getAttributeMapping(CDOFeature feature);
+
public IReferenceMapping getReferenceMapping(CDOFeature feature);
public void writeRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision);
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 9335dbe..413fac1 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
@@ -44,4 +44,8 @@ public interface IMappingStrategy
public CloseableIterator<CDOID> readObjectIDs(IDBStoreAccessor storeAccessor, boolean withTypes);
public CDOClassRef readObjectType(IDBStoreAccessor storeAccessor, CDOID id);
+
+ public CDOID readResourceID(String path);
+
+ public String readResourcePath(CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index 22f3a0b..399870b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -282,6 +282,7 @@ public abstract class ClassMapping implements IClassMapping
public IReferenceMapping getReferenceMapping(CDOFeature feature)
{
+ // TODO Optimize this?
for (IReferenceMapping referenceMapping : referenceMappings)
{
if (referenceMapping.getFeature() == feature)
@@ -293,6 +294,20 @@ public abstract class ClassMapping implements IClassMapping
return null;
}
+ public IAttributeMapping getAttributeMapping(CDOFeature feature)
+ {
+ // TODO Optimize this?
+ for (IAttributeMapping attributeMapping : attributeMappings)
+ {
+ if (attributeMapping.getFeature() == feature)
+ {
+ return attributeMapping;
+ }
+ }
+
+ return null;
+ }
+
protected List<IAttributeMapping> createAttributeMappings(CDOFeature[] features)
{
List<IAttributeMapping> attributeMappings = new ArrayList<IAttributeMapping>();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 3701df0..3cb6e62 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -469,14 +469,13 @@ public class DBStoreAccessor implements IDBStoreAccessor
public CDOID readResourceID(String path)
{
IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- // TODO Implement method DBStoreAccessor.readResourceID()
- throw new UnsupportedOperationException("Not yet implemented");
+ return mappingStrategy.readResourceID(path);
}
public String readResourcePath(CDOID id)
{
- // TODO Implement method DBStoreAccessor.readResourcePath()
- throw new UnsupportedOperationException("Not yet implemented");
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ return mappingStrategy.readResourcePath(id);
}
public CDORevisionImpl verifyRevision(CDORevisionImpl revision)
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 8d6d235..191e9a7 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
@@ -13,13 +13,18 @@ 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.resource.CDOPathFeature;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOResourceClass;
+import org.eclipse.emf.cdo.server.IPackageManager;
+import org.eclipse.emf.cdo.server.db.IAttributeMapping;
+import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBTable;
import org.eclipse.net4j.util.io.CloseableIterator;
@@ -55,6 +60,10 @@ public abstract class MappingStrategy implements IMappingStrategy
private Map<Integer, CDOClassRef> classRefs = new HashMap<Integer, CDOClassRef>();
+ private IClassMapping resourceClassMapping;
+
+ private IAttributeMapping resourcePathMapping;
+
public MappingStrategy()
{
}
@@ -139,6 +148,32 @@ public abstract class MappingStrategy implements IMappingStrategy
return mapping;
}
+ public IClassMapping getResourceClassMapping()
+ {
+ if (resourceClassMapping == null)
+ {
+ IPackageManager packageManager = getStore().getRepository().getPackageManager();
+ CDOResourceClass resourceClass = packageManager.getCDOResourcePackage().getCDOResourceClass();
+ resourceClassMapping = getClassMapping(resourceClass);
+ }
+
+ return resourceClassMapping;
+ }
+
+ public IAttributeMapping getResourcePathMapping()
+ {
+ if (resourcePathMapping == null)
+ {
+ IPackageManager packageManager = getStore().getRepository().getPackageManager();
+ CDOPathFeature pathFeature = packageManager.getCDOResourcePackage().getCDOResourceClass().getCDOPathFeature();
+
+ IClassMapping resourceMapping = getResourceClassMapping();
+ resourcePathMapping = resourceMapping.getAttributeMapping(pathFeature);
+ }
+
+ return resourcePathMapping;
+ }
+
public CloseableIterator<CDOID> readObjectIDs(final IDBStoreAccessor storeAccessor, final boolean withTypes)
{
List<CDOClass> classes = getClassesWithObjectInfo();
@@ -238,6 +273,23 @@ public abstract class MappingStrategy implements IMappingStrategy
return classRef;
}
+ public CDOID readResourceID(String path)
+ {
+ IClassMapping resourceClassMapping = getResourceClassMapping();
+ IAttributeMapping resourcePathMapping = getResourcePathMapping();
+
+ IDBTable resourceTable = resourceClassMapping.getTable();
+ IDBField idField = resourceTable.getField(CDODBSchema.ATTRIBUTES_ID);
+ IDBField pathField = resourcePathMapping.getField();
+
+ return null;
+ }
+
+ public String readResourcePath(CDOID id)
+ {
+ return null;
+ }
+
@Override
public String toString()
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
index 9a5d023..1802f20 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
@@ -61,12 +61,17 @@ public class NoClassMapping implements IClassMapping
return null;
}
- public IReferenceMapping getReferenceMapping(CDOFeature feature)
+ public List<IReferenceMapping> getReferenceMappings()
{
return null;
}
- public List<IReferenceMapping> getReferenceMappings()
+ public IAttributeMapping getAttributeMapping(CDOFeature feature)
+ {
+ return null;
+ }
+
+ public IReferenceMapping getReferenceMapping(CDOFeature feature)
{
return null;
}
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 00696bb..bbc46a5 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
@@ -102,6 +102,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
list.add(CDOIDImpl.create(target));
}
+ // TODO Optimize this?
while (resultSet.next())
{
list.add(CDORevisionImpl.UNINITIALIZED);
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 f9caac8..2d5683e 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
@@ -21,7 +21,7 @@ import java.util.List;
*/
public class VerticalMappingStrategy extends MappingStrategy
{
- private RootClassMapping rootMapping;
+ private RootClassMapping rootClassMapping;
public VerticalMappingStrategy()
{
@@ -38,14 +38,14 @@ public class VerticalMappingStrategy extends MappingStrategy
return true;
}
- public RootClassMapping getRootMapping()
+ public RootClassMapping getRootClassMapping()
{
- if (rootMapping == null)
+ if (rootClassMapping == null)
{
- rootMapping = new RootClassMapping(this);
+ rootClassMapping = new RootClassMapping(this);
}
- return rootMapping;
+ return rootClassMapping;
}
@Override
@@ -57,6 +57,6 @@ public class VerticalMappingStrategy extends MappingStrategy
@Override
protected List<CDOClass> getClassesWithObjectInfo()
{
- return Collections.singletonList(rootMapping.getCDOClass());
+ return Collections.singletonList(rootClassMapping.getCDOClass());
}
}