isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1073104 - in /incubator/isis/trunk/alternatives/objectstore/sql: persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/ persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/ tests-served/src/test/config/...
Date Mon, 21 Feb 2011 18:18:50 GMT
Author: kevin
Date: Mon Feb 21 18:18:50 2011
New Revision: 1073104

URL: http://svn.apache.org/viewvc?rev=1073104&view=rev
Log:
Generalised the strings used to define the DATE, TIME and DATETIME SQL data types. Needed
so that PostgreSQL can over-ride DATETIME with TIMESTAMP. See postgresql.properties.

Modified:
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/VersionMapping.java
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcConnector.java
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateMapper.java
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateTimeMapper.java
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimeMapper.java
    incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimestampMapper.java
    incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/config/postgresql.properties
    incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/java/org/apache/isis/alternatives/objectstore/sql/PostgreSqlTest.java

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/VersionMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/VersionMapping.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/VersionMapping.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/VersionMapping.java
Mon Feb 21 18:18:50 2011
@@ -22,6 +22,7 @@ package org.apache.isis.alternatives.obj
 import java.sql.Timestamp;
 import java.util.Date;
 
+import org.apache.isis.alternatives.objectstore.sql.jdbc.JdbcConnector;
 import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
 import org.apache.isis.core.metamodel.adapter.version.Version;
 
@@ -83,7 +84,7 @@ public class VersionMapping {
 
         sql.append(",");
         sql.append(lastActivityDateColumn);
-        sql.append(" datetime");
+        sql.append(" "+JdbcConnector.timeStampType());
 
         return sql.toString();
     }

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcConnector.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcConnector.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcConnector.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcConnector.java
Mon Feb 21 18:18:50 2011
@@ -76,13 +76,14 @@ public class JdbcConnector extends Abstr
 	}
 
 	public void open() {
-		try {
-			IsisConfiguration params = IsisContext.getConfiguration();
-			String BASE = SqlObjectStore.BASE_NAME + ".jdbc.";
-			String driver = params.getString(BASE + "driver");
-			String url = params.getString(BASE + "connection");
-			String user = params.getString(BASE + "user");
-			String password = params.getString(BASE + "password");
+        String BASE = SqlObjectStore.BASE_NAME + ".jdbc.";
+        IsisConfiguration params = IsisContext.getConfiguration().getProperties(BASE);
+        
+		try {
+			String driver = params.getString(BASE+"driver");
+			String url = params.getString(BASE+"connection");
+			String user = params.getString(BASE+"user");
+			String password = params.getString(BASE+"password");
 
 			if (connection != null) {
 				throw new SqlObjectStoreException(
@@ -119,6 +120,10 @@ public class JdbcConnector extends Abstr
 			throw new SqlObjectStoreException("Could not find database driver",
 					e);
 		}
+		
+        String BASE_DATATYPE = SqlObjectStore.BASE_NAME+".datatypes.";
+        IsisConfiguration dataTypes = IsisContext.getConfiguration().getProperties(BASE_DATATYPE);
+		populateSqlDataTypes(dataTypes, BASE_DATATYPE);
 	}
 
 	/*
@@ -165,7 +170,24 @@ public class JdbcConnector extends Abstr
 	 * ObjectAdapterRuntimeException(e); } }
 	 */
 
-	@Override
+    //static String TYPE_BOOLEAN;
+	static String TYPE_TIMESTAMP;
+	static String TYPE_DATETIME;
+    static String TYPE_DATE;
+    static String TYPE_TIME;
+	
+	private void populateSqlDataTypes(IsisConfiguration dataTypes, String baseName) {
+	    //TYPE_BOOLEAN = dataTypes.getString("boolean" , "CHAR(1)");
+	    TYPE_TIMESTAMP = dataTypes.getString(baseName+"timestamp" , "DATETIME");
+	    TYPE_DATETIME = dataTypes.getString(baseName+"datetime" , "DATETIME");
+        TYPE_DATE = dataTypes.getString(baseName+"date" , "DATE");
+        TYPE_TIME = dataTypes.getString(baseName+"time" , "TIME");
+    }
+	public static String timeStampType(){
+	    return TYPE_TIMESTAMP;
+	}
+
+    @Override
 	public Results select(final String sql) {
 		LOG.debug("SQL: " + sql);
 		PreparedStatement statement;
@@ -346,8 +368,6 @@ public class JdbcConnector extends Abstr
 			debug.appendln("Keywords", metaData.getSQLKeywords());
 			debug.appendln("Date/Time functions",
 					metaData.getTimeDateFunctions());
-			debug.appendln("Date/Time functions",
-					metaData.getTimeDateFunctions());
 			debug.appendln("Mixed case identifiers",
 					metaData.supportsMixedCaseIdentifiers());
 			debug.appendln("Lower case identifiers",

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateMapper.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateMapper.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateMapper.java
Mon Feb 21 18:18:50 2011
@@ -79,7 +79,7 @@ public class JdbcDateMapper extends Abst
     }
 
     public String columnType() {
-        return "DATE";
+        return JdbcConnector.TYPE_DATE;
     }
 
 }

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateTimeMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateTimeMapper.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateTimeMapper.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcDateTimeMapper.java
Mon Feb 21 18:18:50 2011
@@ -72,9 +72,7 @@ public class JdbcDateTimeMapper extends 
     }
     
     public String columnType() {
-        // TODO MS-SQLServer chokes:
-        // return "TIMESTAMP";
-        return "DATETIME";
+        return JdbcConnector.TYPE_DATETIME;
     }
 
 }

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimeMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimeMapper.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimeMapper.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimeMapper.java
Mon Feb 21 18:18:50 2011
@@ -71,7 +71,7 @@ public class JdbcTimeMapper extends Abst
 
 	@Override
 	public String columnType() {
-		return "TIME";
+        return JdbcConnector.TYPE_TIME;
 	}
 
 }

Modified: incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimestampMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimestampMapper.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimestampMapper.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/persistor/src/main/java/org/apache/isis/alternatives/objectstore/sql/jdbc/JdbcTimestampMapper.java
Mon Feb 21 18:18:50 2011
@@ -87,9 +87,7 @@ public class JdbcTimestampMapper extends
 
     @Override
     public String columnType() {
-        // TODO MS-SQLServer chokes:
-        // return "TIMESTAMP";
-        return "DATETIME";
+        return JdbcConnector.TYPE_TIMESTAMP;
     }
 
 }

Modified: incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/config/postgresql.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/config/postgresql.properties?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/config/postgresql.properties
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/config/postgresql.properties
Mon Feb 21 18:18:50 2011
@@ -4,3 +4,6 @@ isis.persistor.sql.jdbc.driver=org.postg
 isis.persistor.sql.jdbc.connection=jdbc:postgresql://abacus/noftest
 isis.persistor.sql.jdbc.user=nof
 isis.persistor.sql.jdbc.password=
+
+isis.persistor.sql.datatypes.timestamp=TIMESTAMP
+isis.persistor.sql.datatypes.datetime=TIMESTAMP
\ No newline at end of file

Modified: incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/java/org/apache/isis/alternatives/objectstore/sql/PostgreSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/java/org/apache/isis/alternatives/objectstore/sql/PostgreSqlTest.java?rev=1073104&r1=1073103&r2=1073104&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/java/org/apache/isis/alternatives/objectstore/sql/PostgreSqlTest.java
(original)
+++ incubator/isis/trunk/alternatives/objectstore/sql/tests-served/src/test/java/org/apache/isis/alternatives/objectstore/sql/PostgreSqlTest.java
Mon Feb 21 18:18:50 2011
@@ -41,6 +41,9 @@ public class PostgreSqlTest extends SqlI
 			properties.put(SqlObjectStore.BASE_NAME + ".jdbc.connection", "jdbc:postgresql://abacus/noftest");
 			properties.put(SqlObjectStore.BASE_NAME + ".jdbc.user", "nof");
 			properties.put(SqlObjectStore.BASE_NAME + ".jdbc.password", "");
+			
+            properties.put(SqlObjectStore.BASE_NAME + ".datatypes.timestamp", "TIMESTAMP");
+            properties.put(SqlObjectStore.BASE_NAME + ".datetime", "TIMESTAMP");        
   
 		}
 		return properties;
 	}



Mime
View raw message