summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-21 01:05:00 (EDT)
committerEike Stepper2007-08-21 01:05:00 (EDT)
commit680d09deb0f3bced6ffc174a795552dbf3230d30 (patch)
treed4d89b73b3aeeb849a051cd2e03b029e0f55467f
parentbe8dd3c2554eb6c3d7940494964ec544b47b1eee (diff)
downloadcdo-680d09deb0f3bced6ffc174a795552dbf3230d30.zip
cdo-680d09deb0f3bced6ffc174a795552dbf3230d30.tar.gz
cdo-680d09deb0f3bced6ffc174a795552dbf3230d30.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java68
1 files changed, 17 insertions, 51 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 3de0709..b164d7f 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
@@ -72,7 +72,7 @@ public class HorizontalMappingStrategy extends MappingStrategy
{
if (cdoFeature.isMany())
{
- return mapReferenceMany(cdoClass, cdoFeature, getToManyReferenceMapping());
+ return mapReference(cdoClass, cdoFeature, getToManyReferenceMapping());
}
else
{
@@ -81,7 +81,7 @@ public class HorizontalMappingStrategy extends MappingStrategy
case LIKE_ATTRIBUTES:
return mapAttribute(cdoClass, cdoFeature);
case LIKE_TO_MANY_REFERENCES:
- return mapReferenceMany(cdoClass, cdoFeature, getToManyReferenceMapping());
+ return mapReference(cdoClass, cdoFeature, getToManyReferenceMapping());
default:
throw new IllegalArgumentException("Invalid mapping: " + getToOneReferenceMapping());
}
@@ -112,18 +112,20 @@ public class HorizontalMappingStrategy extends MappingStrategy
return addField(cdoFeature, table);
}
- protected IDBField mapReferenceMany(CDOClass cdoClass, CDOFeature cdoFeature, ToManyReferenceMapping mapping)
+ protected IDBField mapReference(CDOClass cdoClass, CDOFeature cdoFeature, ToManyReferenceMapping mapping)
{
switch (mapping)
{
case ONE_TABLE_PER_REFERENCE:
- return mapReference(cdoClass, cdoFeature);
+ return mapReferenceTable(cdoFeature, cdoClass.getName() + "_" + cdoFeature.getName() + "_refs", false);
case ONE_TABLE_PER_CLASS:
- return mapReferencePerClass(cdoClass);
+ return mapReferenceTable(cdoClass, cdoClass.getName() + "_refs", true);
case ONE_TABLE_PER_PACKAGE:
- return mapReferencePerPackage(cdoClass.getContainingPackage());
+ CDOPackage cdoPackage = cdoClass.getContainingPackage();
+ return mapReferenceTable(cdoPackage, cdoPackage.getName() + "_refs", true);
case ONE_TABLE_PER_REPOSITORY:
- return mapReferencePerRepository(getStore().getRepository());
+ IRepository repository = getStore().getRepository();
+ return mapReferenceTable(repository, repository.getName() + "_refs", true);
case LIKE_ATTRIBUTES:
return mapReferenceSerialized(cdoClass, cdoFeature);
default:
@@ -131,60 +133,24 @@ public class HorizontalMappingStrategy extends MappingStrategy
}
}
- protected IDBField mapReference(CDOClass cdoClass, CDOFeature cdoFeature)
- {
- IDBTable table = referenceTables.get(cdoFeature);
- if (table == null)
- {
- table = addReferenceTable(cdoClass.getName() + "_" + cdoFeature.getName() + "_refs", false);
- referenceTables.put(cdoFeature, table);
- }
-
- return table.getField(0);
- }
-
- protected IDBField mapReferencePerClass(CDOClass cdoClass)
- {
- IDBTable table = referenceTables.get(cdoClass);
- if (table == null)
- {
- table = addReferenceTable(cdoClass.getName() + "_refs", true);
- referenceTables.put(cdoClass, table);
- }
-
- return table.getField(0);
- }
-
- protected IDBField mapReferencePerPackage(CDOPackage cdoPackage)
+ protected IDBField mapReferenceSerialized(CDOClass cdoClass, CDOFeature cdoFeature)
{
- IDBTable table = referenceTables.get(cdoPackage);
- if (table == null)
- {
- table = addReferenceTable(cdoPackage.getName() + "_refs", true);
- referenceTables.put(cdoPackage, table);
- }
-
- return table.getField(0);
+ // TODO Implement method HorizontalMappingStrategy.mapReferenceSerialized()
+ throw new UnsupportedOperationException("Not yet implemented");
}
- protected IDBField mapReferencePerRepository(IRepository repository)
+ protected IDBField mapReferenceTable(Object key, String tableName, boolean withFeature)
{
- IDBTable table = referenceTables.get(repository);
+ IDBTable table = referenceTables.get(key);
if (table == null)
{
- table = addReferenceTable(repository.getName() + "_refs", true);
- referenceTables.put(repository, table);
+ table = addReferenceTable(tableName, withFeature);
+ referenceTables.put(key, table);
}
return table.getField(0);
}
- protected IDBField mapReferenceSerialized(CDOClass cdoClass, CDOFeature cdoFeature)
- {
- // TODO Implement method HorizontalMappingStrategy.mapReferenceSerialized()
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
protected IDBTable addReferenceTable(String tableName, boolean withFeature)
{
IDBTable table = addTable(tableName);
@@ -193,9 +159,9 @@ public class HorizontalMappingStrategy extends MappingStrategy
table.addField("cdo_feature", DBType.INTEGER);
}
+ table.addField("cdo_idx", DBType.INTEGER);
table.addField("cdo_source", DBType.BIGINT);
table.addField("cdo_target", DBType.BIGINT);
- table.addField("cdo_idx", DBType.INTEGER);
return table;
}