incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1210377 - in /incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql: ./ auto/ jdbc/ jdbc/installer/
Date Mon, 05 Dec 2011 09:36:13 GMT
Author: kevin
Date: Mon Dec  5 09:36:13 2011
New Revision: 1210377

URL: http://svn.apache.org/viewvc?rev=1210377&view=rev
Log:
ISIS-147: Several updates to improve fine-tuning or minor bugfixes:
* Provide several changes to current behaviour via the properties files (defaults shown):

** Determine the maximum number of instances returned by a query
isis.persistor.sql.maxinstances=100

** Ability to disable version checking
isis.persistor.sql.versioning=true

** Ability to disable version checking on certain tables
isis.persistor.sql.versioning.<tablename>=true

* Cleanup on JdbcBinaryValueMapper failing when the value was null

* Ability to override the default SQL storage type on a field
isis.persistor.sql.automapper.type.<fieldname>=<new type>

* Added more FieldMapping lookups to the installer. (e.g. both double.class and Double.class)
** if only one is specified, the other is handled by JdbcGeneralValueMapper as a VARCHAR(65)!


Modified:
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Defaults.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcBinaryValueMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Defaults.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Defaults.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Defaults.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Defaults.java
Mon Dec  5 09:36:13 2011
@@ -23,7 +23,6 @@ import java.util.Calendar;
 
 import org.joda.time.DateTimeZone;
 
-import org.apache.isis.applib.annotation.MemberOrder;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 
@@ -35,7 +34,10 @@ import org.apache.isis.runtimes.dflt.run
  * @version $Rev$ $Date$
  */
 public class Defaults {
+    private static String propertiesBase;
+
     public static void initialise(String propertiesBase) {
+        Defaults.propertiesBase = propertiesBase;
         setTimeZone(DateTimeZone.UTC);
 
         final IsisConfiguration configParameters = IsisContext.getConfiguration();
@@ -43,6 +45,9 @@ public class Defaults {
         setPkIdLabel(getStringProperty(propertiesBase, configParameters, "pk_id"));
         setIdColumn(getStringProperty(propertiesBase, configParameters, "id"));
         setMaxInstances(getIntProperty(propertiesBase, configParameters, "maxinstances",
100));
+        final String useVersioningProperty = getStringProperty(propertiesBase, configParameters,
"versioning", "true");
+        final int isTrue = useVersioningProperty.compareToIgnoreCase("true");
+        useVersioning(isTrue == 0);
 
         final String BASE_DATATYPE = propertiesBase + ".datatypes.";
         final IsisConfiguration dataTypes = IsisContext.getConfiguration().getProperties(BASE_DATATYPE);
@@ -55,6 +60,11 @@ public class Defaults {
         return configParameters.getString(propertiesBase + ".default." + property, property);
     }
 
+    protected static String getStringProperty(String propertiesBase, final IsisConfiguration
configParameters,
+        String property, String defaultValue) {
+        return configParameters.getString(propertiesBase + ".default." + property, defaultValue);
+    }
+
     protected static int getIntProperty(String propertiesBase, final IsisConfiguration configParameters,
         String property, int defaultValue) {
         return configParameters.getInteger(propertiesBase + ".default." + property, defaultValue);
@@ -112,7 +122,6 @@ public class Defaults {
     // {{ MaxInstances
     private static int maxInstances;
 
-    @MemberOrder(sequence = "1")
     public static int getMaxInstances() {
         return maxInstances;
     }
@@ -225,5 +234,29 @@ public class Defaults {
     public static String TYPE_TIME() {
         return TYPE_TIME;
     }
+
     // }}
+
+    // {{ Versioning
+    private static boolean useVersioning;
+
+    public static void useVersioning(boolean useVersioning) {
+        Defaults.useVersioning = useVersioning;
+    }
+
+    public static boolean useVersioning() {
+        return useVersioning;
+    }
+
+    public static boolean useVersioning(String shortIdentifier) {
+        if (useVersioning() == false) {
+            return false;
+        }
+        final IsisConfiguration configParameters = IsisContext.getConfiguration();
+        final String useVersioningProperty =
+            getStringProperty(propertiesBase, configParameters, "versioning." + shortIdentifier,
"true");
+        return (useVersioningProperty.compareToIgnoreCase("true") == 0);
+    }
+    // }}
+
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java
Mon Dec  5 09:36:13 2011
@@ -67,6 +67,10 @@ public class SqlPersistorInstaller exten
         return objectStore;
     }
 
+    public SqlObjectStore getObjectStore() {
+        return objectStore;
+    }
+
     @Override
     protected OidGenerator createOidGenerator(final IsisConfiguration configuration) {
         final DatabaseConnectorFactory connectorFactory = new JdbcConnectorFactory();

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoMapper.java
Mon Dec  5 09:36:13 2011
@@ -57,10 +57,10 @@ import org.apache.isis.runtimes.dflt.run
 
 public class AutoMapper extends AbstractAutoMapper implements ObjectMapping, DebuggableWithTitle
{
     private static final Logger LOG = Logger.getLogger(AutoMapper.class);
-    // private static final int MAX_INSTANCES = 100;
     private final IdMapping idMapping;
     private final VersionMapping versionMapping;
     private final TitleMapping titleMapping;
+    private final boolean useVersioning;
     final AdapterManager adapterManager;
 
     public AutoMapper(final String className, final String parameterBase, final FieldMappingLookup
lookup,
@@ -71,6 +71,7 @@ public class AutoMapper extends Abstract
         titleMapping = lookup.createTitleMapping();
 
         adapterManager = IsisContext.getPersistenceSession().getAdapterManager();
+        useVersioning = Defaults.useVersioning(specification.getShortIdentifier());
 
         setUpFieldMappers();
     }
@@ -393,7 +394,12 @@ public class AutoMapper extends Abstract
     @Override
     public void save(final DatabaseConnector connector, final ObjectAdapter object) {
         final SerialNumberVersion version = (SerialNumberVersion) object.getVersion();
-        final long nextSequence = version.getSequence() + 1;
+        final long nextSequence;
+        if (useVersioning) {
+            nextSequence = version.getSequence() + 1;
+        } else {
+            nextSequence = version.getSequence();
+        }
 
         final StringBuffer sql = new StringBuffer();
         sql.append("UPDATE " + table + " SET ");
@@ -406,8 +412,10 @@ public class AutoMapper extends Abstract
         titleMapping.appendUpdateAssignment(connector, sql, object);
         sql.append(" WHERE ");
         idMapping.appendWhereClause(connector, sql, object.getOid());
-        sql.append(" AND ");
-        sql.append(versionMapping.whereClause(connector, (SerialNumberVersion) object.getVersion()));
+        if (useVersioning) {
+            sql.append(" AND ");
+            sql.append(versionMapping.whereClause(connector, (SerialNumberVersion) object.getVersion()));
+        }
 
         final int updateCount = connector.update(sql.toString());
         if (updateCount == 0) {

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcBinaryValueMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcBinaryValueMapper.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcBinaryValueMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcBinaryValueMapper.java
Mon Dec  5 09:36:13 2011
@@ -70,6 +70,9 @@ public class JdbcBinaryValueMapper exten
      */
     @Override
     protected Object preparedStatementObject(final ObjectAdapter value) {
+        if (value == null) {
+            return null;
+        }
         final Object o = value.getObject();
         return o;
     }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/JdbcGeneralValueMapper.java
Mon Dec  5 09:36:13 2011
@@ -22,12 +22,15 @@ package org.apache.isis.runtimes.dflt.ob
 import org.apache.isis.applib.value.Money;
 import org.apache.isis.applib.value.Password;
 import org.apache.isis.applib.value.Percentage;
+import org.apache.isis.core.commons.config.IsisConfiguration;
 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.Results;
+import org.apache.isis.runtimes.dflt.objectstores.sql.SqlObjectStore;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMappingFactory;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 
 public class JdbcGeneralValueMapper extends AbstractJdbcFieldMapping {
 
@@ -40,7 +43,11 @@ public class JdbcGeneralValueMapper exte
 
         @Override
         public FieldMapping createFieldMapping(final ObjectAssociation field) {
-            return new JdbcGeneralValueMapper(field, type);
+            // isis.persistor.sql.automapper.default
+            final IsisConfiguration configParameters = IsisContext.getConfiguration();
+            final String property = SqlObjectStore.BASE_NAME + ".automapper.type." + field.getId();
+            String dataType = configParameters.getString(property, type);
+            return new JdbcGeneralValueMapper(field, dataType);
         }
     }
 

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java?rev=1210377&r1=1210376&r2=1210377&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/jdbc/installer/JdbcFieldMappingFactoryInstaller.java
Mon Dec  5 09:36:13 2011
@@ -46,11 +46,11 @@ public class JdbcFieldMappingFactoryInst
     @Override
     public void load(final FieldMappingLookup lookup) {
         lookup.addFieldMappingFactory(Boolean.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_BOOLEAN()));
-        lookup.addFieldMappingFactory(short.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_SHORT()));
-        lookup.addFieldMappingFactory(int.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_INT()));
-        lookup.addFieldMappingFactory(long.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_LONG()));
+        lookup.addFieldMappingFactory(Short.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_SHORT()));
+        lookup.addFieldMappingFactory(Integer.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_INT()));
+        lookup.addFieldMappingFactory(Long.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_LONG()));
         lookup.addFieldMappingFactory(Float.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_FLOAT()));
-        lookup.addFieldMappingFactory(double.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_DOUBLE()));
+        lookup.addFieldMappingFactory(Double.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_DOUBLE()));
         lookup.addFieldMappingFactory(char.class, new JdbcGeneralValueMapper.Factory("CHAR(2)"));
 
         lookup.addFieldMappingFactory(Money.class, new JdbcMoneyValueMapper.Factory("FLOAT",
"VARCHAR(3)"));
@@ -69,6 +69,13 @@ public class JdbcFieldMappingFactoryInst
         lookup.addFieldMappingFactory(java.util.Date.class, new JdbcDateTimeMapper.Factory());
         lookup.addFieldMappingFactory(java.sql.Timestamp.class, new JdbcTimestampMapper.Factory());
 
+        lookup.addFieldMappingFactory(boolean.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_BOOLEAN()));
+        lookup.addFieldMappingFactory(short.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_SHORT()));
+        lookup.addFieldMappingFactory(int.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_INT()));
+        lookup.addFieldMappingFactory(long.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_LONG()));
+        lookup.addFieldMappingFactory(float.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_FLOAT()));
+        lookup.addFieldMappingFactory(double.class, new JdbcBinaryValueMapper.Factory(Defaults.TYPE_DOUBLE()));
+
         lookup.setReferenceFieldMappingFactory(new JdbcObjectReferenceFieldMapping.Factory());
 
         lookup.setObjectReferenceMappingfactory(new JdbcObjectReferenceMappingFactory());



Mime
View raw message