summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-16 12:05:52 (EDT)
committerEike Stepper2007-08-16 12:05:52 (EDT)
commitb7d75d9da3849842c5bf9fe508521bdcdafce9a4 (patch)
tree4154e74fb84ec8e477221b75d922ee7b4cb1d5dd
parent12519fe81c08ea733343dffc7d05f0e0281adb51 (diff)
downloadcdo-b7d75d9da3849842c5bf9fe508521bdcdafce9a4.zip
cdo-b7d75d9da3849842c5bf9fe508521bdcdafce9a4.tar.gz
cdo-b7d75d9da3849842c5bf9fe508521bdcdafce9a4.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java5
-rw-r--r--plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java3
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBType.java36
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBType.java61
7 files changed, 145 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
index 183c50b..b8d26de 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -82,7 +82,7 @@ public class DBStoreReader implements IStoreReader
public boolean handle(int row, final Object... values)
{
String packageURI = (String)values[0];
- boolean dynamic = values[1] != null;
+ boolean dynamic = getBoolean(values[1]);
long rangeLB = (Long)values[2];
long rangeUB = (Long)values[3];
CDOIDRange metaIDRange = CDOIDRangeImpl.create(rangeLB, rangeUB);
@@ -98,39 +98,39 @@ public class DBStoreReader implements IStoreReader
public void readPackage(final CDOPackageImpl cdoPackage)
{
- Object[] values = DBUtil.select(connection, "", CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
+ String where = CDODBSchema.PACKAGES_URI.toString() + " = '" + cdoPackage.getPackageURI() + "'";
+ Object[] values = DBUtil.select(connection, where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
CDODBSchema.PACKAGES_ECORE);
cdoPackage.setServerInfo(values[0]);
cdoPackage.setName((String)values[1]);
cdoPackage.setEcore((String)values[2]);
+ readClasses(cdoPackage);
+ }
+ public void readClasses(final CDOPackageImpl cdoPackage)
+ {
IDBRowHandler rowHandler = new IDBRowHandler()
{
public boolean handle(int row, Object... values)
{
+ int classID = (Integer)values[0];
int classifierID = (Integer)values[1];
String name = (String)values[2];
- boolean isAbstract = (Boolean)values[3];
+ boolean isAbstract = getBoolean(values[3]);
CDOClassImpl cdoClass = new CDOClassImpl(cdoPackage, classifierID, name, isAbstract);
- cdoClass.setServerInfo(values[0]);
+ cdoClass.setServerInfo(classID);
cdoPackage.addClass(cdoClass);
- readClass(cdoClass);
+ readSuperTypes(cdoClass, classID);
+ readFeatures(cdoClass, classID);
return true;
}
};
- String where = CDODBSchema.CLASSES_PACKAGE.toString() + " = '" + cdoPackage.getPackageURI() + "'";
+ String where = CDODBSchema.CLASSES_PACKAGE.toString() + " = " + cdoPackage.getServerInfo();
DBUtil.select(connection, rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
}
- public void readClass(final CDOClassImpl cdoClass)
- {
- int classID = (Integer)cdoClass.getServerInfo();
- readSuperTypes(cdoClass, classID);
- readFeatures(cdoClass, classID);
- }
-
public void readSuperTypes(final CDOClassImpl cdoClass, int classID)
{
IDBRowHandler rowHandler = new IDBRowHandler()
@@ -158,14 +158,14 @@ public class DBStoreReader implements IStoreReader
int featureID = (Integer)values[1];
String name = (String)values[2];
CDOTypeImpl type = CDOTypeImpl.getType((Integer)values[3]);
- boolean many = (Boolean)values[6];
+ boolean many = getBoolean(values[6]);
CDOFeatureImpl feature;
if (type == CDOType.OBJECT)
{
String packageURI = (String)values[4];
int classifierID = (Integer)values[5];
- boolean containment = (Boolean)values[7];
+ boolean containment = getBoolean(values[7]);
CDOClassRefImpl classRef = new CDOClassRefImpl(packageURI, classifierID);
CDOClassProxy referenceType = new CDOClassProxy(classRef, cdoClass.getPackageManager());
feature = new CDOFeatureImpl(cdoClass, featureID, name, referenceType, many, containment);
@@ -216,4 +216,24 @@ public class DBStoreReader implements IStoreReader
// TODO Implement method DBStoreReader.readObjectType()
throw new UnsupportedOperationException("Not yet implemented");
}
+
+ protected Boolean getBoolean(Object value)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+
+ if (value instanceof Boolean)
+ {
+ return (Boolean)value;
+ }
+
+ if (value instanceof Number)
+ {
+ return ((Number)value).intValue() != 0;
+ }
+
+ throw new IllegalArgumentException("Not a boolean value: " + value);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index dbf4b7a..d418f9d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -91,17 +91,17 @@ public class CommitTransactionIndication extends CDOServerIndication
throw new IllegalStateException("Illegal view: " + view);
}
- newPackages = readNewPackages(in);
- newResources = readNewResources(in);
- newObjects = readNewObjects(in);
- dirtyObjects = readDirtyObjects(in);
-
IStore store = getStore();
IStoreWriter storeWriter = store.getWriter(view);
try
{
StoreUtil.setReader(storeWriter);
+ newPackages = readNewPackages(in);
+ newResources = readNewResources(in);
+ newObjects = readNewObjects(in);
+ dirtyObjects = readDirtyObjects(in);
+
ITransaction<IStoreWriter> storeTransaction = new Transaction(storeWriter);
addPackages(storeTransaction, newPackages);
addRevisions(storeTransaction, newResources);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 81c976e..ab2cabe 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -356,6 +356,11 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
public Object convertObjectToID(Object potentialObject)
{
+ if (potentialObject instanceof CDOID)
+ {
+ return potentialObject;
+ }
+
if (potentialObject == null)
{
throw new ImplementationError();
diff --git a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
index 51e02a1..61ec168 100644
--- a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
+++ b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
@@ -40,7 +40,8 @@ public class DerbyAdapter extends DBAdapter
switch (type)
{
case BOOLEAN:
- return "CHAR(1)";
+ case BIT:
+ return "SMALLINT";
}
return super.getTypeName(field);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBType.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBType.java
new file mode 100644
index 0000000..79acfe4
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBType.java
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * 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.net4j.db;
+
+import org.eclipse.net4j.internal.db.DBType;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+@Deprecated
+public interface IDBType<JAVA>
+{
+ public static final IDBType<Boolean> BOOLEAN = DBType.BOOLEAN;
+
+ public String getName();
+
+ public int getCode();
+
+ public String format(JAVA value);
+
+ public JAVA get(ResultSet resultSet, int index) throws SQLException;
+
+ public void set(PreparedStatement statement, int index, JAVA value) throws SQLException;
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index dbcb729..bec99e6 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
@@ -58,7 +58,7 @@ public abstract class DBAdapter implements IDBAdapter
{
if (TRACER.isEnabled())
{
- TRACER.trace(ex.getMessage());
+ TRACER.trace("-- " + ex.getMessage());
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBType.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBType.java
new file mode 100644
index 0000000..6f1bf0e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBType.java
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * 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.net4j.internal.db;
+
+import org.eclipse.net4j.db.IDBType;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+@Deprecated
+public abstract class DBType<JAVA> implements IDBType<JAVA>
+{
+ public static final DBType<Boolean> BOOLEAN = new DBType<Boolean>()
+ {
+ public String getName()
+ {
+ return "BOOLEAN";
+ }
+
+ public int getCode()
+ {
+ return 0;
+ }
+
+ public Boolean get(ResultSet resultSet, int index) throws SQLException
+ {
+ return resultSet.getBoolean(index);
+ }
+
+ public void set(PreparedStatement statement, int index, Boolean value) throws SQLException
+ {
+ }
+ };
+
+ protected DBType()
+ {
+ }
+
+ public String format(JAVA value)
+ {
+ return value.toString();
+ }
+
+ @Override
+ public String toString()
+ {
+ return getName();
+ }
+}