incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1081196 - in /incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql: ./ jdbc/
Date Sun, 13 Mar 2011 19:05:18 GMT
Author: kevin
Date: Sun Mar 13 19:05:18 2011
New Revision: 1081196

URL: http://svn.apache.org/viewvc?rev=1081196&view=rev
Log:
Cleanup completed. Removed valueAsDBString, replaced with preparedStatementObject.

Modified:
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcFieldMapping.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateTimeMapper.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimeMapper.java
    incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimestampMapper.java

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/IdMappingAbstract.java
Sun Mar 13 19:05:18 2011
@@ -43,8 +43,6 @@ public class IdMappingAbstract {
 		sql.append(column);
 		connector.addToQueryValues(primaryKeyAsObject(oid));
 		sql.append(" = ?");
-		// String id = primaryKey(oid);
-		// sql.append(id);
 	}
 
 	public void appendCreateColumnDefinitions(StringBuffer sql) {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcFieldMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcFieldMapping.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcFieldMapping.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/AbstractJdbcFieldMapping.java
Sun Mar 13 19:05:18 2011
@@ -54,7 +54,8 @@ public abstract class AbstractJdbcFieldM
         if (fieldValue == null) {
             sql.append("NULL");
         } else {
-        	sql.append(valueAsDBString(fieldValue, connector));
+        	sql.append("?");
+        	connector.addToQueryValues(preparedStatementObject(fieldValue));
         }
     }
 
@@ -70,7 +71,8 @@ public abstract class AbstractJdbcFieldM
         sql.append(Sql.sqlFieldName(field.getId()));
         sql.append(condition);
         ObjectAdapter fieldValue = field.get(object);
-        sql.append(valueAsDBString(fieldValue, connector));
+        sql.append("?");
+        connector.addToQueryValues(preparedStatementObject(fieldValue));
     }
     
     public void initializeField(ObjectAdapter object, Results rs) {
@@ -92,8 +94,6 @@ public abstract class AbstractJdbcFieldM
 
     protected abstract String columnType();
 
-    //TODO: replace valueAsDBString with preparedStatementObject
-    protected abstract String valueAsDBString(ObjectAdapter value, DatabaseConnector connector);
     protected abstract Object preparedStatementObject(ObjectAdapter value);
 
     protected abstract ObjectAdapter setFromDBColumn(String encodeValue, ObjectAssociation
field);

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateMapper.java
Sun Mar 13 19:05:18 2011
@@ -20,13 +20,12 @@
 
 package org.apache.isis.runtimes.dflt.objectstores.sql.jdbc;
 
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 import org.apache.isis.applib.value.Date;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 
 
 public class JdbcDateMapper extends AbstractJdbcFieldMapping {
@@ -41,21 +40,6 @@ public class JdbcDateMapper extends Abst
         super(field);
     }
 
-    //TODO:KAM:here XYZ
-    public String valueAsDBString(final ObjectAdapter value, DatabaseConnector connector)
{
-    	connector.addToQueryValues(preparedStatementObject(value));
-    	return "?";
-    	/*
-        EncodableFacet encodeableFacet = value.getSpecification().getFacet(EncodableFacet.class);
-        String encodedString = encodeableFacet.toEncodedString(value);
-        String year = encodedString.substring(0, 4);
-        String month = encodedString.substring(4, 6);
-        String day = encodedString.substring(6, 8);
-        String encodedWithAdaptions = year + "-" + month + "-" + day;
-        return "'" + encodedWithAdaptions + "'";
-        */
-    }
-    
     @Override
     protected Object preparedStatementObject(ObjectAdapter value){
         java.sql.Date date; 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateTimeMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateTimeMapper.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateTimeMapper.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcDateTimeMapper.java
Sun Mar 13 19:05:18 2011
@@ -20,13 +20,12 @@
 
 package org.apache.isis.runtimes.dflt.objectstores.sql.jdbc;
 
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 import org.apache.isis.applib.value.DateTime;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 
 
 public class JdbcDateTimeMapper extends AbstractJdbcFieldMapping {
@@ -41,22 +40,6 @@ public class JdbcDateTimeMapper extends 
         super(field);
     }
 
-    //TODO:KAM:here XYZ
-    public String valueAsDBString(final ObjectAdapter value, DatabaseConnector connector)
{
-        connector.addToQueryValues(preparedStatementObject(value));
-    	return "?";
-    	/*
-        EncodableFacet encodeableFacet = value.getSpecification().getFacet(EncodableFacet.class);
-        String encodedString = encodeableFacet.toEncodedString(value);
-        String year = encodedString.substring(0, 4);
-        String month = encodedString.substring(4, 6);
-        String day = encodedString.substring(6, 8);
-        String hour = encodedString.substring(9, 11);
-        String minute = encodedString.substring(11, 13);
-        String encodedWithAdaptions = year + "-" + month + "-" + day + " " + hour + ":" +
minute+ ":00000";
-        return "'" + encodedWithAdaptions + "'";
-        */
-    }
     @Override
     protected Object preparedStatementObject(ObjectAdapter value){
         DateTime asDate = (DateTime) value.getObject();

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
Sun Mar 13 19:05:18 2011
@@ -19,9 +19,6 @@
 
 package org.apache.isis.runtimes.dflt.objectstores.sql.jdbc;
 
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 import org.apache.isis.applib.value.Color;
 import org.apache.isis.applib.value.Money;
 import org.apache.isis.applib.value.Password;
@@ -29,6 +26,8 @@ import org.apache.isis.applib.value.Perc
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 
 public class JdbcGeneralValueMapper extends AbstractJdbcFieldMapping {
 
@@ -54,45 +53,11 @@ public class JdbcGeneralValueMapper exte
 	}
 
 	// TODO:KAM: here X
-	@Override
-	public String valueAsDBString(final ObjectAdapter value,
-			DatabaseConnector connector) {
-		if (value == null) {
-			return "null";
-		} else {
-			Object valueObject = value.getObject();
-			if (valueObject == null){
-				return "null";
-			}
-			
-			valueObject = preparedStatementObject(value);
-			if (valueObject != null){
-                connector.addToQueryValues(valueObject);
-			} else {
-				if (columnType().contains("CHAR")){
-					EncodableFacet facet = value.getSpecification().getFacet(
-							EncodableFacet.class);
-					String encodedString = facet.toEncodedString(value);
-					connector.addToQueryValues(encodedString);
-				} else {
-					connector.addToQueryValues(valueObject);
-				}
-			}
-			/*
-			 * EncodableFacet facet =
-			 * value.getSpecification().getFacet(EncodableFacet.class); String
-			 * encodedString = facet.toEncodedString(value);
-			 * 
-			 * if (this.columnType().startsWith("VARCHAR")){ return
-			 * Sql.escapeAndQuoteValue(encodedString); } else { return
-			 * encodedString; }
-			 */
-		}
-		return "?";
-
-	}
 	
+	@Override
     protected Object preparedStatementObject(ObjectAdapter value){
+        if (value == null) return null;
+        
         Object o = value.getObject();
         
         if (o instanceof Money) {
@@ -106,7 +71,14 @@ public class JdbcGeneralValueMapper exte
         } else if (o instanceof String) {
             return o;
         } else {
-            return null;
+            if (columnType().contains("CHAR")){
+                EncodableFacet facet = value.getSpecification().getFacet(
+                        EncodableFacet.class);
+                String encodedString = facet.toEncodedString(value);
+                return encodedString;
+            } else {
+                return o;
+            }
         }
     }
 	

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimeMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimeMapper.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimeMapper.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimeMapper.java
Sun Mar 13 19:05:18 2011
@@ -19,13 +19,12 @@
 
 package org.apache.isis.runtimes.dflt.objectstores.sql.jdbc;
 
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
-import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 import org.apache.isis.applib.value.Time;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 
 public class JdbcTimeMapper extends AbstractJdbcFieldMapping {
 
@@ -40,21 +39,6 @@ public class JdbcTimeMapper extends Abst
 		super(field);
 	}
 
-	// TODO:KAM:here XY
-	@Override
-	public String valueAsDBString(final ObjectAdapter value,
-			DatabaseConnector connector) {
-        connector.addToQueryValues(preparedStatementObject(value));
-		return "?";
-		/*
-		 * EncodableFacet encodeableFacet =
-		 * value.getSpecification().getFacet(EncodableFacet.class); String
-		 * encodedString = encodeableFacet.toEncodedString(value); String minute
-		 * = encodedString.substring(2, 4); String hour =
-		 * encodedString.substring(0, 2); String encodedWithAdaptions = hour +
-		 * ":" + minute + ":00"; return "'" + encodedWithAdaptions + "'";
-		 */
-	}
     @Override
 	protected Object preparedStatementObject(ObjectAdapter value){
         Time asDate = (Time) value.getObject();

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimestampMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimestampMapper.java?rev=1081196&r1=1081195&r2=1081196&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimestampMapper.java
(original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcTimestampMapper.java
Sun Mar 13 19:05:18 2011
@@ -23,7 +23,6 @@ import org.apache.isis.applib.value.Time
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
 
@@ -40,21 +39,6 @@ public class JdbcTimestampMapper extends
         super(field);
     }
 
-    // TODO:KAM:here XYZ
-    @Override
-    public String valueAsDBString(final ObjectAdapter value, DatabaseConnector connector)
{
-        connector.addToQueryValues(preparedStatementObject(value));
-        return "?";
-        /*
-         * EncodableFacet encodeableFacet = value.getSpecification().getFacet(EncodableFacet.class);
String
-         * encodedString = encodeableFacet.toEncodedString(value); String year = encodedString.substring(0,
4); String
-         * month = encodedString.substring(4, 6); String day = encodedString.substring(6,
8); String hour =
-         * encodedString.substring(8+1, 10+1); String minute = encodedString.substring(10+1,
12+1); String second =
-         * encodedString.substring(12+1, 14+1); String millisecond = encodedString.substring(14+1,
17+1); String
-         * encodedWithAdaptions = year + "-" + month + "-" + day + " " + hour + ":" + minute
+ ":" + second + "." +
-         * millisecond; return "'" + encodedWithAdaptions + "'";
-         */
-    }
     @Override
     protected Object preparedStatementObject(ObjectAdapter value){
         TimeStamp asDate = (TimeStamp) value.getObject();



Mime
View raw message