summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-20 02:32:37 (EDT)
committerEike Stepper2007-08-20 02:32:37 (EDT)
commitbe5d9a1ef236432aff0ffcd96b52f1e4d0b2f9f6 (patch)
tree2be1675bd08f6d1884130b2a51867b936c4c0a51
parentb39e7f42221bd11f483d9d629089feba4f290e42 (diff)
downloadcdo-be5d9a1ef236432aff0ffcd96b52f1e4d0b2f9f6.zip
cdo-be5d9a1ef236432aff0ffcd96b52f1e4d0b2f9f6.tar.gz
cdo-be5d9a1ef236432aff0ffcd96b52f1e4d0b2f9f6.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/MappingPrecedence.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToManyReferenceMapping.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToOneReferenceMapping.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java75
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java9
8 files changed, 147 insertions, 15 deletions
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 645dd33..735319d 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
@@ -20,7 +20,7 @@ import org.eclipse.net4j.db.IDBSchema;
import org.eclipse.net4j.db.IDBTable;
import java.sql.Connection;
-import java.util.Properties;
+import java.util.Map;
import java.util.Set;
/**
@@ -36,9 +36,15 @@ public interface IMappingStrategy
public void setStore(IDBStore store);
- public Properties getProperties();
+ public Map<String, String> getProperties();
- public void setProperties(Properties properties);
+ public void setProperties(Map<String, String> properties);
+
+ public ToManyReferenceMapping getToManyReferenceMapping();
+
+ public ToOneReferenceMapping getToOneReferenceMapping();
+
+ public MappingPrecedence getMappingPrecedence();
/**
* @return A collection of the affected tables.
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/MappingPrecedence.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/MappingPrecedence.java
new file mode 100644
index 0000000..8a0359f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/MappingPrecedence.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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.db;
+
+/**
+ * @author Eike Stepper
+ */
+public enum MappingPrecedence
+{
+ MODEL, STRATEGY
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToManyReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToManyReferenceMapping.java
new file mode 100644
index 0000000..07aeab0
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToManyReferenceMapping.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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.db;
+
+/**
+ * @author Eike Stepper
+ */
+public enum ToManyReferenceMapping
+{
+ ONE_TABLE_PER_REFERENCE, ONE_TABLE_PER_CLASS, ONE_TABLE_PER_PACKAGE, ONE_TABLE_PER_REPOSITORY, LIKE_ATTRIBUTES
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToOneReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToOneReferenceMapping.java
new file mode 100644
index 0000000..a9627a1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/ToOneReferenceMapping.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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.db;
+
+/**
+ * @author Eike Stepper
+ */
+public enum ToOneReferenceMapping
+{
+ LIKE_ATTRIBUTES, LIKE_TO_MANY_REFERENCES
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index 1586b0f..bc58490 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -26,6 +26,7 @@ import org.w3c.dom.NodeList;
import javax.sql.DataSource;
+import java.util.Map;
import java.util.Properties;
/**
@@ -63,7 +64,7 @@ public class DBStoreFactory implements IStoreFactory
Element mappingStrategyConfig = (Element)mappingStrategyConfigs.item(0);
String mappingStrategyType = mappingStrategyConfig.getAttribute("type");
IMappingStrategy mappingStrategy = CDODBUtil.createMappingStrategy(mappingStrategyType);
- Properties properties = RepositoryConfigurator.getProperties(mappingStrategyConfig);
+ Map<String, String> properties = RepositoryConfigurator.getProperties(mappingStrategyConfig);
mappingStrategy.setProperties(properties);
return mappingStrategy;
}
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 0fea91f..b90f2bc 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
@@ -87,13 +87,13 @@ public class HorizontalMappingStrategy extends MappingStrategy
IDBTable table = entry.getKey();
Object[] values = new Object[table.getFieldCount()];
- values[0] = revision.getID();
+ values[0] = revision.getID().getValue();
values[1] = ((DBClassInfo)revision.getCDOClass().getServerInfo()).getID();
values[2] = revision.getVersion();
values[3] = new Date(revision.getCreated());
values[4] = new Date(revision.getRevised());
- values[5] = revision.getResourceID();
- values[6] = revision.getContainerID();
+ values[5] = revision.getResourceID().getValue();
+ values[6] = revision.getContainerID().getValue();
values[7] = revision.getContainingFeatureID();
int i = 8;
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 c15dd97..713258d 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
@@ -16,6 +16,9 @@ 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.IMappingStrategy;
+import org.eclipse.emf.cdo.server.db.MappingPrecedence;
+import org.eclipse.emf.cdo.server.db.ToManyReferenceMapping;
+import org.eclipse.emf.cdo.server.db.ToOneReferenceMapping;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBException;
@@ -35,7 +38,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
@@ -50,10 +52,16 @@ public abstract class MappingStrategy implements IMappingStrategy
private IDBStore store;
- private Properties properties;
+ private Map<String, String> properties;
private IDBSchema schema;
+ private MappingPrecedence mappingPrecedence;
+
+ private ToManyReferenceMapping toManyReferenceMapping;
+
+ private ToOneReferenceMapping toOneReferenceMapping;
+
private Map<CDOClass, ClassMapping> classMappings = new HashMap();
public MappingStrategy()
@@ -70,12 +78,17 @@ public abstract class MappingStrategy implements IMappingStrategy
this.store = store;
}
- public Properties getProperties()
+ public Map<String, String> getProperties()
{
+ if (properties == null)
+ {
+ properties = new HashMap();
+ }
+
return properties;
}
- public void setProperties(Properties properties)
+ public void setProperties(Map<String, String> properties)
{
this.properties = properties;
}
@@ -85,6 +98,60 @@ public abstract class MappingStrategy implements IMappingStrategy
return schema;
}
+ public MappingPrecedence getMappingPrecedence()
+ {
+ if (mappingPrecedence == null)
+ {
+ mappingPrecedence = MappingPrecedence.STRATEGY;
+ if (properties != null)
+ {
+ String value = properties.get("mappingPrecedence");
+ if (value != null)
+ {
+ mappingPrecedence = MappingPrecedence.valueOf(value);
+ }
+ }
+ }
+
+ return mappingPrecedence;
+ }
+
+ public ToManyReferenceMapping getToManyReferenceMapping()
+ {
+ if (toManyReferenceMapping == null)
+ {
+ toManyReferenceMapping = ToManyReferenceMapping.ONE_TABLE_PER_REFERENCE;
+ if (properties != null)
+ {
+ String value = properties.get("toManyReferenceMapping");
+ if (value != null)
+ {
+ toManyReferenceMapping = ToManyReferenceMapping.valueOf(value);
+ }
+ }
+ }
+
+ return toManyReferenceMapping;
+ }
+
+ public ToOneReferenceMapping getToOneReferenceMapping()
+ {
+ if (toOneReferenceMapping == null)
+ {
+ toOneReferenceMapping = ToOneReferenceMapping.LIKE_ATTRIBUTES;
+ if (properties != null)
+ {
+ String value = properties.get("toOneReferenceMapping");
+ if (value != null)
+ {
+ toOneReferenceMapping = ToOneReferenceMapping.valueOf(value);
+ }
+ }
+ }
+
+ return toOneReferenceMapping;
+ }
+
@Override
public String toString()
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
index 89fa562..47b70b4 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
@@ -35,8 +35,9 @@ import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
-import java.util.Properties;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -113,14 +114,14 @@ public class RepositoryConfigurator
return document;
}
- public static Properties getProperties(Element element)
+ public static Map<String, String> getProperties(Element element)
{
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap();
collectProperties(element, "", properties);
return properties;
}
- private static void collectProperties(Element element, String prefix, Properties properties)
+ private static void collectProperties(Element element, String prefix, Map<String, String> properties)
{
if ("property".equals(element.getNodeName()))
{