diff options
author | Eike Stepper | 2007-09-13 10:06:35 +0000 |
---|---|---|
committer | Eike Stepper | 2007-09-13 10:06:35 +0000 |
commit | 27c0d8fe3a6c9ec0f17717ce27e4a941ec9f3a9e (patch) | |
tree | 1f5bb4f9e9ddde3013ec0be942563c0ed8446dcc | |
parent | 0d120401b7c42c311a3f47f37fec4e699ff820ec (diff) | |
download | cdo-27c0d8fe3a6c9ec0f17717ce27e4a941ec9f3a9e.tar.gz cdo-27c0d8fe3a6c9ec0f17717ce27e4a941ec9f3a9e.tar.xz cdo-27c0d8fe3a6c9ec0f17717ce27e4a941ec9f3a9e.zip |
[202833] Horizontal Mapping Strategy
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202833
22 files changed, 343 insertions, 395 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IAttributeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IAttributeMapping.java index 9b7116918e..3e32ea2637 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IAttributeMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IAttributeMapping.java @@ -11,7 +11,6 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; -import org.eclipse.emf.cdo.protocol.model.CDOFeature; import org.eclipse.net4j.db.IDBField; @@ -20,12 +19,8 @@ import java.sql.ResultSet; /** * @author Eike Stepper */ -public interface IAttributeMapping +public interface IAttributeMapping extends IFeatureMapping { - public IValueMapping getValueMapping(); - - public CDOFeature getFeature(); - public IDBField getField(); public void appendValue(StringBuilder builder, CDORevisionImpl revision); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java index 9d886ac459..741b43f92e 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java @@ -12,22 +12,32 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.model.CDOFeature; import org.eclipse.net4j.db.IDBTable; +import java.util.List; import java.util.Set; /** * @author Eike Stepper */ -public interface IMapping +public interface IClassMapping { public IMappingStrategy getMappingStrategy(); public CDOClass getCDOClass(); + public IDBTable getTable(); + public Set<IDBTable> getAffectedTables(); + public List<IAttributeMapping> getAttributeMappings(); + + public List<IReferenceMapping> getReferenceMappings(); + + public IReferenceMapping getReferenceMapping(CDOFeature feature); + public void writeRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision); public void readRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IValueMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IFeatureMapping.java index 90f1a68e86..8b471ad3db 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IValueMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IFeatureMapping.java @@ -12,20 +12,12 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.protocol.model.CDOFeature; -import org.eclipse.net4j.db.IDBTable; - -import java.util.List; - /** * @author Eike Stepper */ -public interface IValueMapping extends IMapping +public interface IFeatureMapping { - public IDBTable getTable(); - - public List<IAttributeMapping> getAttributeMappings(); - - public List<IReferenceMapping> getReferenceMappings(); + public IClassMapping getClassMapping(); - public IReferenceMapping getReferenceMapping(CDOFeature feature); + public CDOFeature getFeature(); } 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 c7704798aa..9335dbe1a3 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 @@ -39,7 +39,7 @@ public interface IMappingStrategy public void setProperties(Map<String, String> properties); - public IMapping getMapping(CDOClass cdoClass); + public IClassMapping getClassMapping(CDOClass cdoClass); public CloseableIterator<CDOID> readObjectIDs(IDBStoreAccessor storeAccessor, boolean withTypes); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java index 6d3aeca92a..376e42f499 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java @@ -11,7 +11,6 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; -import org.eclipse.emf.cdo.protocol.model.CDOFeature; import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk; import org.eclipse.net4j.db.IDBTable; @@ -21,12 +20,8 @@ import java.util.List; /** * @author Eike Stepper */ -public interface IReferenceMapping +public interface IReferenceMapping extends IFeatureMapping { - public IValueMapping getValueMapping(); - - public CDOFeature getFeature(); - public IDBTable getTable(); public void writeReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java index 7331fef0a0..3d6811258b 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java @@ -20,10 +20,10 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib { private IDBField field; - public AttributeMapping(ValueMapping valueMapping, CDOFeature feature) + public AttributeMapping(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); - field = valueMapping.addField(feature, valueMapping.getTable()); + super(classMapping, feature); + field = classMapping.addField(feature, classMapping.getTable()); } public IDBField getField() @@ -74,9 +74,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMString extends AttributeMapping { - public AMString(ValueMapping valueMapping, CDOFeature feature) + public AMString(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -91,9 +91,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMShort extends AttributeMapping { - public AMShort(ValueMapping valueMapping, CDOFeature feature) + public AMShort(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -108,9 +108,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMObject extends AttributeMapping { - public AMObject(ValueMapping valueMapping, CDOFeature feature) + public AMObject(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -131,9 +131,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMLong extends AttributeMapping { - public AMLong(ValueMapping valueMapping, CDOFeature feature) + public AMLong(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -148,9 +148,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMInteger extends AttributeMapping { - public AMInteger(ValueMapping valueMapping, CDOFeature feature) + public AMInteger(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -165,9 +165,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMFloat extends AttributeMapping { - public AMFloat(ValueMapping valueMapping, CDOFeature feature) + public AMFloat(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -182,9 +182,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMDouble extends AttributeMapping { - public AMDouble(ValueMapping valueMapping, CDOFeature feature) + public AMDouble(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -199,9 +199,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMDate extends AttributeMapping { - public AMDate(ValueMapping valueMapping, CDOFeature feature) + public AMDate(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -217,9 +217,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMCharacter extends AttributeMapping { - public AMCharacter(ValueMapping valueMapping, CDOFeature feature) + public AMCharacter(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -240,9 +240,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMByte extends AttributeMapping { - public AMByte(ValueMapping valueMapping, CDOFeature feature) + public AMByte(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override @@ -257,9 +257,9 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib */ public static class AMBoolean extends AttributeMapping { - public AMBoolean(ValueMapping valueMapping, CDOFeature feature) + public AMBoolean(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java index 442904a61d..22f3a0b8a3 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java @@ -16,27 +16,43 @@ import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.protocol.model.CDOFeature; import org.eclipse.emf.cdo.protocol.model.CDOType; 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.IReferenceMapping; -import org.eclipse.emf.cdo.server.db.IValueMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.net4j.db.DBException; +import org.eclipse.net4j.db.DBType; import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.IDBField; +import org.eclipse.net4j.db.IDBTable; import org.eclipse.net4j.internal.util.om.trace.ContextTracer; import org.eclipse.net4j.util.ImplementationError; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * @author Eike Stepper */ -public abstract class ValueMapping extends Mapping implements IValueMapping +public abstract class ClassMapping implements IClassMapping { - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, ValueMapping.class); + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, ClassMapping.class); + + private MappingStrategy mappingStrategy; + + private CDOClass cdoClass; + + private IDBTable table; + + private Set<IDBTable> affectedTables = new HashSet<IDBTable>(); private List<IAttributeMapping> attributeMappings; @@ -46,17 +62,165 @@ public abstract class ValueMapping extends Mapping implements IValueMapping private String selectPrefixWithVersion; - public ValueMapping(MappingStrategy mappingStrategy, CDOClass cdoClass, CDOFeature[] features) + public ClassMapping(MappingStrategy mappingStrategy, CDOClass cdoClass, CDOFeature[] features) { - super(mappingStrategy, cdoClass); - initTable(getTable(), hasFullRevisionInfo()); - attributeMappings = createAttributeMappings(features); - referenceMappings = createReferenceMappings(features); + this.mappingStrategy = mappingStrategy; + this.cdoClass = cdoClass; + + table = addTable(cdoClass.getName()); + initTable(table, hasFullRevisionInfo()); + + if (features != null) + { + attributeMappings = createAttributeMappings(features); + referenceMappings = createReferenceMappings(features); + } selectPrefix = createSelectPrefix(false); selectPrefixWithVersion = createSelectPrefix(true); } + public MappingStrategy getMappingStrategy() + { + return mappingStrategy; + } + + public CDOClass getCDOClass() + { + return cdoClass; + } + + public IDBTable getTable() + { + return table; + } + + public Set<IDBTable> getAffectedTables() + { + return affectedTables; + } + + protected void initTable(IDBTable table, boolean full) + { + table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT); + table.addField(CDODBSchema.ATTRIBUTES_VERSION, DBType.INTEGER); + if (full) + { + table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.INTEGER); + table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT); + table.addField(CDODBSchema.ATTRIBUTES_REVISED, DBType.BIGINT); + table.addField(CDODBSchema.ATTRIBUTES_RESOURCE, DBType.BIGINT); + table.addField(CDODBSchema.ATTRIBUTES_CONTAINER, DBType.BIGINT); + table.addField(CDODBSchema.ATTRIBUTES_FEATURE, DBType.INTEGER); + } + } + + protected void appendRevisionInfos(StringBuilder builder, CDORevisionImpl revision, boolean full) + { + builder.append(revision.getID().getValue()); + builder.append(", "); + builder.append(revision.getVersion()); + if (full) + { + builder.append(", "); + builder.append(ServerInfo.getDBID(revision.getCDOClass())); + builder.append(", "); + builder.append(revision.getCreated()); + builder.append(", "); + builder.append(revision.getRevised()); + builder.append(", "); + builder.append(revision.getResourceID().getValue()); + builder.append(", "); + builder.append(revision.getContainerID().getValue()); + builder.append(", "); + builder.append(revision.getContainingFeatureID()); + } + } + + protected int sqlUpdate(IDBStoreAccessor storeAccessor, String sql) throws DBException + { + if (TRACER.isEnabled()) + { + TRACER.trace(sql); + } + + try + { + Statement statement = storeAccessor.getStatement(); + return statement.executeUpdate(sql); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + + protected String mangleTableName(String name, int attempt) + { + return getDBAdapter().mangleTableName(name, attempt); + } + + protected String mangleFieldName(String name, int attempt) + { + return getDBAdapter().mangleFieldName(name, attempt); + } + + protected IDBTable addTable(String name) + { + for (int attempt = 0;; ++attempt) + { + String tableName = mangleTableName(name, attempt); + + try + { + IDBTable table = mappingStrategy.getStore().getSchema().addTable(tableName); + affectedTables.add(table); + return table; + } + catch (DBException ex) + { + if (TRACER.isEnabled()) + { + TRACER.format("{0}. attempt to add table: {1} ({2})", attempt + 1, tableName, ex.getMessage()); + } + } + } + } + + protected IDBField addField(CDOFeature cdoFeature, IDBTable table) throws DBException + { + DBType fieldType = getDBType(cdoFeature.getType()); + for (int attempt = 0;; ++attempt) + { + String fieldName = mangleFieldName(cdoFeature.getName(), attempt); + + try + { + IDBField field = table.addField(fieldName, fieldType); + affectedTables.add(table); + return field; + } + catch (DBException ex) + { + if (TRACER.isEnabled()) + { + TRACER.format("{0}. attempt to add field: {1} ({2})", attempt + 1, fieldName, ex.getMessage()); + } + } + } + } + + protected DBType getDBType(CDOType type) + { + return DBStore.getDBType(type); + } + + protected IDBAdapter getDBAdapter() + { + IDBStore store = mappingStrategy.getStore(); + return store.getDBAdapter(); + } + protected String createSelectPrefix(boolean readVersion) { StringBuilder builder = new StringBuilder(); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java index 5693ffb71a..cbb44c219d 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java @@ -11,7 +11,7 @@ package org.eclipse.emf.cdo.server.internal.db; import org.eclipse.emf.cdo.protocol.model.CDOClass; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.net4j.util.ImplementationError; @@ -24,7 +24,7 @@ public final class ClassServerInfo extends ServerInfo public static final int CDO_RESOURCE_CLASS_DBID = -2; - private IMapping mapping; + private IClassMapping classMapping; private ClassServerInfo(int id) { @@ -38,13 +38,13 @@ public final class ClassServerInfo extends ServerInfo return serverInfo; } - public static IMapping getMapping(CDOClass cdoClass) + public static IClassMapping getClassMapping(CDOClass cdoClass) { ClassServerInfo serverInfo = getServerInfo(cdoClass); - return serverInfo == null ? null : serverInfo.mapping; + return serverInfo == null ? null : serverInfo.classMapping; } - public static void setMapping(CDOClass cdoClass, IMapping mapping) + public static void setClassMapping(CDOClass cdoClass, IClassMapping classMapping) { ClassServerInfo serverInfo = getServerInfo(cdoClass); if (serverInfo == null) @@ -52,7 +52,7 @@ public final class ClassServerInfo extends ServerInfo throw new ImplementationError("No serverInfo for class " + cdoClass); } - serverInfo.mapping = mapping; + serverInfo.classMapping = classMapping; } protected static ClassServerInfo getServerInfo(CDOClass cdoClass) 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 f903571ef1..3701df0af8 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 @@ -32,7 +32,7 @@ import org.eclipse.emf.cdo.server.ISession; import org.eclipse.emf.cdo.server.IStoreChunkReader; import org.eclipse.emf.cdo.server.IView; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; @@ -394,7 +394,7 @@ public class DBStoreAccessor implements IDBStoreAccessor } CDOClassImpl cdoClass = revision.getCDOClass(); - IMapping mapping = ClassServerInfo.getMapping(cdoClass); + IClassMapping mapping = ClassServerInfo.getClassMapping(cdoClass); mapping.writeRevision(this, revision); } @@ -429,7 +429,7 @@ public class DBStoreAccessor implements IDBStoreAccessor CDOClassImpl cdoClass = getObjectType(id); CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id); - IMapping mapping = ClassServerInfo.getMapping(cdoClass); + IClassMapping mapping = ClassServerInfo.getClassMapping(cdoClass); mapping.readRevision(this, revision, referenceChunk); return revision; } @@ -445,7 +445,7 @@ public class DBStoreAccessor implements IDBStoreAccessor CDOClassImpl cdoClass = getObjectType(id); CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id); - IMapping mapping = ClassServerInfo.getMapping(cdoClass); + IClassMapping mapping = ClassServerInfo.getClassMapping(cdoClass); mapping.readRevisionByTime(this, revision, timeStamp, referenceChunk); return revision; } @@ -461,13 +461,14 @@ public class DBStoreAccessor implements IDBStoreAccessor CDOClassImpl cdoClass = getObjectType(id); CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id); - IMapping mapping = ClassServerInfo.getMapping(cdoClass); + IClassMapping mapping = ClassServerInfo.getClassMapping(cdoClass); mapping.readRevisionByVersion(this, revision, version, referenceChunk); return revision; } public CDOID readResourceID(String path) { + IMappingStrategy mappingStrategy = getStore().getMappingStrategy(); // TODO Implement method DBStoreAccessor.readResourceID() throw new UnsupportedOperationException("Not yet implemented"); } @@ -537,7 +538,7 @@ public class DBStoreAccessor implements IDBStoreAccessor IMappingStrategy mappingStrategy = store.getMappingStrategy(); for (CDOClassImpl cdoClass : cdoClasses) { - IMapping mapping = mappingStrategy.getMapping(cdoClass); + IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass); if (mapping != null) { affectedTables.addAll(mapping.getAffectedTables()); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java index 610a9c4f12..6c99db4075 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java @@ -14,14 +14,12 @@ import org.eclipse.emf.cdo.internal.server.StoreChunkReader; import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.protocol.model.CDOFeature; import org.eclipse.emf.cdo.protocol.revision.CDORevision; +import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader; -import org.eclipse.emf.cdo.server.db.IMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.emf.cdo.server.db.IReferenceMapping; -import org.eclipse.net4j.util.ImplementationError; - import java.util.List; /** @@ -37,16 +35,8 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun { super(storeAccessor, revision, feature); IMappingStrategy mappingStrategy = storeAccessor.getStore().getMappingStrategy(); - CDOClass cdoClass = revision.getCDOClass(); - IMapping mapping = mappingStrategy.getMapping(cdoClass); - if (mapping instanceof ValueMapping) - { - referenceMapping = ((ValueMapping)mapping).getReferenceMapping(feature); - } - else - { - throw new ImplementationError(); - } + IClassMapping mapping = mappingStrategy.getClassMapping(revision.getCDOClass()); + referenceMapping = mapping.getReferenceMapping(feature); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java index 676a390b6e..cd595f89ba 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/FeatureMapping.java @@ -19,19 +19,19 @@ import org.eclipse.net4j.db.IDBAdapter; */ public class FeatureMapping { - private ValueMapping valueMapping; + private ClassMapping classMapping; private CDOFeature feature; - public FeatureMapping(ValueMapping valueMapping, CDOFeature feature) + public FeatureMapping(ClassMapping classMapping, CDOFeature feature) { - this.valueMapping = valueMapping; + this.classMapping = classMapping; this.feature = feature; } - public ValueMapping getValueMapping() + public ClassMapping getClassMapping() { - return valueMapping; + return classMapping; } public CDOFeature getFeature() @@ -41,6 +41,6 @@ public class FeatureMapping protected IDBAdapter getDBAdapter() { - return getValueMapping().getMappingStrategy().getStore().getDBAdapter(); + return getClassMapping().getMappingStrategy().getStore().getDBAdapter(); } } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java index 7e75541c7f..9734475716 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java @@ -15,9 +15,9 @@ import org.eclipse.emf.cdo.protocol.model.CDOClass; /** * @author Eike Stepper */ -public class HorizontalMapping extends ValueMapping +public class HorizontalClassMapping extends ClassMapping { - public HorizontalMapping(HorizontalMappingStrategy mappingStrategy, CDOClass cdoClass) + public HorizontalClassMapping(HorizontalMappingStrategy mappingStrategy, CDOClass cdoClass) { super(mappingStrategy, cdoClass, cdoClass.getAllFeatures()); } 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 b4174969b2..376514d778 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 @@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server.internal.db; import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.protocol.model.CDOPackage; import org.eclipse.emf.cdo.server.IPackageManager; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import java.util.ArrayList; import java.util.List; @@ -38,14 +38,14 @@ public class HorizontalMappingStrategy extends MappingStrategy } @Override - protected IMapping createMapping(CDOClass cdoClass) + protected IClassMapping createClassMapping(CDOClass cdoClass) { if (cdoClass.isAbstract()) { return null; } - return new HorizontalMapping(this, cdoClass); + return new HorizontalClassMapping(this, cdoClass); } @Override 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 deleted file mode 100644 index 1cae9ad4fd..0000000000 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/Mapping.java +++ /dev/null @@ -1,196 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.server.internal.db; - -import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; -import org.eclipse.emf.cdo.protocol.model.CDOClass; -import org.eclipse.emf.cdo.protocol.model.CDOFeature; -import org.eclipse.emf.cdo.protocol.model.CDOType; -import org.eclipse.emf.cdo.server.db.IDBStore; -import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; -import org.eclipse.emf.cdo.server.db.IMapping; -import org.eclipse.emf.cdo.server.internal.db.bundle.OM; - -import org.eclipse.net4j.db.DBException; -import org.eclipse.net4j.db.DBType; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.IDBField; -import org.eclipse.net4j.db.IDBTable; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; - -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class Mapping implements IMapping -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, Mapping.class); - - private MappingStrategy mappingStrategy; - - private CDOClass cdoClass; - - private IDBTable table; - - private Set<IDBTable> affectedTables = new HashSet<IDBTable>(); - - public Mapping(MappingStrategy mappingStrategy, CDOClass cdoClass) - { - this.mappingStrategy = mappingStrategy; - this.cdoClass = cdoClass; - table = addTable(cdoClass.getName()); - } - - public MappingStrategy getMappingStrategy() - { - return mappingStrategy; - } - - public CDOClass getCDOClass() - { - return cdoClass; - } - - public IDBTable getTable() - { - return table; - } - - public Set<IDBTable> getAffectedTables() - { - return affectedTables; - } - - protected void initTable(IDBTable table, boolean full) - { - table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT); - table.addField(CDODBSchema.ATTRIBUTES_VERSION, DBType.INTEGER); - if (full) - { - table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.INTEGER); - table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT); - table.addField(CDODBSchema.ATTRIBUTES_REVISED, DBType.BIGINT); - table.addField(CDODBSchema.ATTRIBUTES_RESOURCE, DBType.BIGINT); - table.addField(CDODBSchema.ATTRIBUTES_CONTAINER, DBType.BIGINT); - table.addField(CDODBSchema.ATTRIBUTES_FEATURE, DBType.INTEGER); - } - } - - protected void appendRevisionInfos(StringBuilder builder, CDORevisionImpl revision, boolean full) - { - builder.append(revision.getID().getValue()); - builder.append(", "); - builder.append(revision.getVersion()); - if (full) - { - builder.append(", "); - builder.append(ServerInfo.getDBID(revision.getCDOClass())); - builder.append(", "); - builder.append(revision.getCreated()); - builder.append(", "); - builder.append(revision.getRevised()); - builder.append(", "); - builder.append(revision.getResourceID().getValue()); - builder.append(", "); - builder.append(revision.getContainerID().getValue()); - builder.append(", "); - builder.append(revision.getContainingFeatureID()); - } - } - - protected int sqlUpdate(IDBStoreAccessor storeAccessor, String sql) throws DBException - { - if (TRACER.isEnabled()) - { - TRACER.trace(sql); - } - - try - { - Statement statement = storeAccessor.getStatement(); - return statement.executeUpdate(sql); - } - catch (SQLException ex) - { - throw new DBException(ex); - } - } - - protected String mangleTableName(String name, int attempt) - { - return getDBAdapter().mangleTableName(name, attempt); - } - - protected String mangleFieldName(String name, int attempt) - { - return getDBAdapter().mangleFieldName(name, attempt); - } - - protected IDBTable addTable(String name) - { - for (int attempt = 0;; ++attempt) - { - String tableName = mangleTableName(name, attempt); - - try - { - IDBTable table = mappingStrategy.getStore().getSchema().addTable(tableName); - affectedTables.add(table); - return table; - } - catch (DBException ex) - { - if (TRACER.isEnabled()) - { - TRACER.format("{0}. attempt to add table: {1} ({2})", attempt + 1, tableName, ex.getMessage()); - } - } - } - } - - protected IDBField addField(CDOFeature cdoFeature, IDBTable table) throws DBException - { - DBType fieldType = getDBType(cdoFeature.getType()); - for (int attempt = 0;; ++attempt) - { - String fieldName = mangleFieldName(cdoFeature.getName(), attempt); - - try - { - IDBField field = table.addField(fieldName, fieldType); - affectedTables.add(table); - return field; - } - catch (DBException ex) - { - if (TRACER.isEnabled()) - { - TRACER.format("{0}. attempt to add field: {1} ({2})", attempt + 1, fieldName, ex.getMessage()); - } - } - } - } - - protected DBType getDBType(CDOType type) - { - return DBStore.getDBType(type); - } - - protected IDBAdapter getDBAdapter() - { - IDBStore store = mappingStrategy.getStore(); - return store.getDBAdapter(); - } -} 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 c4f6c81f02..8d6d235dde 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 @@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.protocol.model.CDOClassRef; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.net4j.db.DBException; @@ -122,18 +122,18 @@ public abstract class MappingStrategy implements IMappingStrategy return referenceTables; } - public IMapping getMapping(CDOClass cdoClass) + public IClassMapping getClassMapping(CDOClass cdoClass) { - IMapping mapping = ClassServerInfo.getMapping(cdoClass); - if (mapping == NoMapping.INSTANCE) + IClassMapping mapping = ClassServerInfo.getClassMapping(cdoClass); + if (mapping == NoClassMapping.INSTANCE) { return null; } if (mapping == null) { - mapping = createMapping(cdoClass); - ClassServerInfo.setMapping(cdoClass, mapping == null ? NoMapping.INSTANCE : mapping); + mapping = createClassMapping(cdoClass); + ClassServerInfo.setClassMapping(cdoClass, mapping == null ? NoClassMapping.INSTANCE : mapping); } return mapping; @@ -151,7 +151,7 @@ public abstract class MappingStrategy implements IMappingStrategy while (classIt.hasNext()) { CDOClass cdoClass = classIt.next(); - ValueMapping mapping = (ValueMapping)ClassServerInfo.getMapping(cdoClass); + ClassMapping mapping = (ClassMapping)ClassServerInfo.getClassMapping(cdoClass); if (mapping != null) { IDBTable table = mapping.getTable(); @@ -193,7 +193,7 @@ public abstract class MappingStrategy implements IMappingStrategy String suffix = " WHERE " + CDODBSchema.ATTRIBUTES_ID + "=" + id; for (CDOClass cdoClass : getClassesWithObjectInfo()) { - ValueMapping mapping = (ValueMapping)ClassServerInfo.getMapping(cdoClass); + ClassMapping mapping = (ClassMapping)ClassServerInfo.getClassMapping(cdoClass); if (mapping != null) { IDBTable table = mapping.getTable(); @@ -244,7 +244,7 @@ public abstract class MappingStrategy implements IMappingStrategy return getType(); } - protected abstract IMapping createMapping(CDOClass cdoClass); + protected abstract IClassMapping createClassMapping(CDOClass cdoClass); 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/NoMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java index 51b22f5136..9a5d0230af 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java @@ -12,23 +12,27 @@ package org.eclipse.emf.cdo.server.internal.db; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.model.CDOFeature; +import org.eclipse.emf.cdo.server.db.IAttributeMapping; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; +import org.eclipse.emf.cdo.server.db.IReferenceMapping; import org.eclipse.net4j.db.IDBTable; import java.util.Collections; +import java.util.List; import java.util.Set; /** * @author Eike Stepper */ -public class NoMapping implements IMapping +public class NoClassMapping implements IClassMapping { - public static final IMapping INSTANCE = new NoMapping(); + public static final IClassMapping INSTANCE = new NoClassMapping(); - private NoMapping() + private NoClassMapping() { } @@ -42,11 +46,31 @@ public class NoMapping implements IMapping return null; } + public IDBTable getTable() + { + return null; + } + public Set<IDBTable> getAffectedTables() { return Collections.emptySet(); } + public List<IAttributeMapping> getAttributeMappings() + { + return null; + } + + public IReferenceMapping getReferenceMapping(CDOFeature feature) + { + return null; + } + + public List<IReferenceMapping> getReferenceMappings() + { + return null; + } + public void writeRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision) { } 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 b9b5e7c01c..00696bb78c 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 @@ -44,11 +44,11 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin private String selectPrefix; - public ReferenceMapping(ValueMapping valueMapping, CDOFeature feature, ToMany toMany) + public ReferenceMapping(ClassMapping classMapping, CDOFeature feature, ToMany toMany) { - super(valueMapping, feature); + super(classMapping, feature); this.toMany = toMany; - mapReference(valueMapping.getCDOClass(), feature); + mapReference(classMapping.getCDOClass(), feature); int dbFeatureID = withFeature ? FeatureServerInfo.getDBID(getFeature()) : 0; insertPrefix = createInsertPrefix(dbFeatureID); @@ -79,7 +79,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin builder.append(target); builder.append(")"); String sql = builder.toString(); - getValueMapping().sqlUpdate(storeAccessor, sql); + getClassMapping().sqlUpdate(storeAccessor, sql); } } @@ -237,7 +237,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin case PER_REPOSITORY: withFeature = true; - IRepository repository = getValueMapping().getMappingStrategy().getStore().getRepository(); + IRepository repository = getClassMapping().getMappingStrategy().getStore().getRepository(); table = mapReferenceTable(repository, repository.getName() + "_refs"); break; @@ -248,7 +248,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin protected IDBTable mapReferenceTable(Object key, String tableName) { - Map<Object, IDBTable> referenceTables = getValueMapping().getMappingStrategy().getReferenceTables(); + Map<Object, IDBTable> referenceTables = getClassMapping().getMappingStrategy().getReferenceTables(); IDBTable table = referenceTables.get(key); if (table == null) { @@ -261,7 +261,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin protected IDBTable addReferenceTable(String tableName) { - IDBTable table = getValueMapping().addTable(tableName); + IDBTable table = getClassMapping().addTable(tableName); if (withFeature) { table.addField(CDODBSchema.REFERENCES_FEATURE, DBType.INTEGER); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootClassMapping.java new file mode 100644 index 0000000000..3c09de2824 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootClassMapping.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.server.internal.db; + +import org.eclipse.emf.cdo.protocol.model.core.CDOObjectClass; + +/** + * @author Eike Stepper + */ +public class RootClassMapping extends ClassMapping +{ + public RootClassMapping(VerticalMappingStrategy mappingStrategy) + { + super(mappingStrategy, getRootClass(mappingStrategy), null); + initTable(getTable(), true); + } + + @Override + public VerticalMappingStrategy getMappingStrategy() + { + return (VerticalMappingStrategy)super.getMappingStrategy(); + } + + @Override + protected boolean hasFullRevisionInfo() + { + return true; + } + + private static CDOObjectClass getRootClass(VerticalMappingStrategy mappingStrategy) + { + return mappingStrategy.getStore().getRepository().getPackageManager().getCDOCorePackage().getCDOObjectClass(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootMapping.java deleted file mode 100644 index 7714b2ce6f..0000000000 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/RootMapping.java +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2007 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.emf.cdo.server.internal.db; - -import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; -import org.eclipse.emf.cdo.protocol.model.core.CDOObjectClass; -import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; - -/** - * @author Eike Stepper - */ -public class RootMapping extends Mapping -{ - public RootMapping(VerticalMappingStrategy mappingStrategy) - { - super(mappingStrategy, getRootClass(mappingStrategy)); - initTable(getTable(), true); - } - - @Override - public VerticalMappingStrategy getMappingStrategy() - { - return (VerticalMappingStrategy)super.getMappingStrategy(); - } - - public void writeRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision) - { - StringBuilder builder = new StringBuilder(); - builder.append("INSERT INTO "); - builder.append(getTable()); - builder.append(" VALUES ("); - appendRevisionInfos(builder, revision, true); - builder.append(")"); - sqlUpdate(storeAccessor, builder.toString()); - } - - public void readRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk) - { - // TODO Implement method RootMapping.readRevision() - throw new UnsupportedOperationException("Not yet implemented"); - } - - public void readRevisionByTime(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, long timeStamp, - int referenceChunk) - { - // TODO Implement method RootMapping.readRevisionByTime() - throw new UnsupportedOperationException("Not yet implemented"); - } - - public void readRevisionByVersion(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int version, - int referenceChunk) - { - // TODO Implement method RootMapping.readRevisionByVersion() - throw new UnsupportedOperationException("Not yet implemented"); - } - - private static CDOObjectClass getRootClass(VerticalMappingStrategy mappingStrategy) - { - return mappingStrategy.getStore().getRepository().getPackageManager().getCDOCorePackage().getCDOObjectClass(); - } -} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java index f8be13cae6..0a850b1c8b 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java @@ -19,9 +19,9 @@ import org.eclipse.emf.cdo.protocol.model.CDOFeature; */ public class ToOneReferenceMapping extends AttributeMapping.AMObject { - public ToOneReferenceMapping(ValueMapping valueMapping, CDOFeature feature) + public ToOneReferenceMapping(ClassMapping classMapping, CDOFeature feature) { - super(valueMapping, feature); + super(classMapping, feature); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java index 8f92f88daf..8bb3a3ea27 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalClassMapping.java @@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server.internal.db; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; import org.eclipse.emf.cdo.protocol.model.CDOClass; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import java.util.ArrayList; import java.util.List; @@ -21,21 +21,21 @@ import java.util.List; /** * @author Eike Stepper */ -public class VerticalMapping extends ValueMapping +public class VerticalClassMapping extends ClassMapping { - private List<IMapping> superMappings; + private List<IClassMapping> superMappings; - public VerticalMapping(VerticalMappingStrategy mappingStrategy, CDOClass cdoClass) + public VerticalClassMapping(VerticalMappingStrategy mappingStrategy, CDOClass cdoClass) { super(mappingStrategy, cdoClass, cdoClass.getFeatures()); for (CDOClass superType : cdoClass.getSuperTypes()) { - IMapping superMapping = mappingStrategy.getMapping(superType); + IClassMapping superMapping = mappingStrategy.getClassMapping(superType); if (superMapping != null) { if (superMappings == null) { - superMappings = new ArrayList<IMapping>(0); + superMappings = new ArrayList<IClassMapping>(0); } superMappings.add(superMapping); @@ -55,7 +55,7 @@ public class VerticalMapping extends ValueMapping return false; } - public List<IMapping> getSuperMappings() + public List<IClassMapping> getSuperMappings() { return superMappings; } @@ -66,7 +66,7 @@ public class VerticalMapping extends ValueMapping super.writeRevision(storeAccessor, revision); if (superMappings != null) { - for (IMapping superMapping : superMappings) + for (IClassMapping superMapping : superMappings) { superMapping.writeRevision(storeAccessor, revision); } 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 ad52612ca8..f9caac8b9f 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 @@ -11,7 +11,7 @@ package org.eclipse.emf.cdo.server.internal.db; import org.eclipse.emf.cdo.protocol.model.CDOClass; -import org.eclipse.emf.cdo.server.db.IMapping; +import org.eclipse.emf.cdo.server.db.IClassMapping; import java.util.Collections; import java.util.List; @@ -21,7 +21,7 @@ import java.util.List; */ public class VerticalMappingStrategy extends MappingStrategy { - private RootMapping rootMapping; + private RootClassMapping rootMapping; public VerticalMappingStrategy() { @@ -38,20 +38,20 @@ public class VerticalMappingStrategy extends MappingStrategy return true; } - public RootMapping getRootMapping() + public RootClassMapping getRootMapping() { if (rootMapping == null) { - rootMapping = new RootMapping(this); + rootMapping = new RootClassMapping(this); } return rootMapping; } @Override - protected IMapping createMapping(CDOClass cdoClass) + protected IClassMapping createClassMapping(CDOClass cdoClass) { - return new VerticalMapping(this, cdoClass); + return new VerticalClassMapping(this, cdoClass); } @Override |