incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1098941 [5/8] - in /incubator/isis/trunk/runtimes/dflt/objectstores: nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ nosql/src/main/java/org/a...
Date Tue, 03 May 2011 06:52:55 GMT
Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/ObjectMappingLookup.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/ObjectMappingLookup.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/ObjectMappingLookup.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/ObjectMappingLookup.java Tue May  3 06:52:51 2011
@@ -17,14 +17,11 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.debug.DebuggableWithTitle;
@@ -35,7 +32,7 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
-
+import org.apache.log4j.Logger;
 
 public class ObjectMappingLookup implements DebuggableWithTitle {
     private static final Logger LOG = Logger.getLogger(ObjectMappingLookup.class);
@@ -44,12 +41,13 @@ public class ObjectMappingLookup impleme
     private ObjectMappingFactory objectMappingFactory;
     private FieldMappingLookup fieldMappingLookup;
 
-    public ObjectMapping getMapping(final ObjectSpecification spec, DatabaseConnector connection) {
+    public ObjectMapping getMapping(final ObjectSpecification spec, final DatabaseConnector connection) {
         ObjectMapping mapping = mappings.get(spec);
         if (mapping == null) {
-            String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper.default";
-            mapping = objectMappingFactory.createMapper(spec.getFullIdentifier(), propertiesBase, fieldMappingLookup, this);
-            add(spec, mapping, connection); 
+            final String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper.default";
+            mapping =
+                objectMappingFactory.createMapper(spec.getFullIdentifier(), propertiesBase, fieldMappingLookup, this);
+            add(spec, mapping, connection);
         }
         LOG.debug("  mapper for " + spec.getSingularName() + " -> " + mapping);
         if (mapping == null) {
@@ -58,7 +56,7 @@ public class ObjectMappingLookup impleme
         return mapping;
     }
 
-    public ObjectMapping getMapping(final ObjectAdapter object, DatabaseConnector connection) {
+    public ObjectMapping getMapping(final ObjectAdapter object, final DatabaseConnector connection) {
         return getMapping(object.getSpecification(), connection);
     }
 
@@ -71,12 +69,12 @@ public class ObjectMappingLookup impleme
         this.objectMappingFactory = mapperFactory;
     }
 
-    public void setValueMappingLookup(FieldMappingLookup fieldMappingLookup) {
+    public void setValueMappingLookup(final FieldMappingLookup fieldMappingLookup) {
         this.fieldMappingLookup = fieldMappingLookup;
     }
 
     private void add(final String className, final ObjectMapping mapper) {
-        ObjectSpecification spec = IsisContext.getSpecificationLoader().loadSpecification(className);
+        final ObjectSpecification spec = IsisContext.getSpecificationLoader().loadSpecification(className);
         if (spec.getProperties().size() == 0) {
             throw new SqlObjectStoreException(spec.getFullIdentifier() + " has no fields to persist: " + spec);
         }
@@ -85,8 +83,8 @@ public class ObjectMappingLookup impleme
 
     public void add(final ObjectSpecification specification, final ObjectMapping mapper, DatabaseConnector connection) {
         LOG.debug("add mapper " + mapper + " for " + specification);
-        if (connection == null){
-        	connection = connectionPool.acquire();
+        if (connection == null) {
+            connection = connectionPool.acquire();
         }
         mapper.startup(connection, this);
         connectionPool.release(connection);
@@ -95,24 +93,24 @@ public class ObjectMappingLookup impleme
 
     public void init() {
         fieldMappingLookup.init();
-        
-        String prefix = SqlObjectStore.BASE_NAME + ".mapper.";
-        IsisConfiguration subset = IsisContext.getConfiguration().createSubset(prefix);
-        for (String className : subset) {
-            String value = subset.getString(className);
-            
+
+        final String prefix = SqlObjectStore.BASE_NAME + ".mapper.";
+        final IsisConfiguration subset = IsisContext.getConfiguration().createSubset(prefix);
+        for (final String className : subset) {
+            final String value = subset.getString(className);
+
             if (value.startsWith("auto.")) {
-                String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper." + value.substring(5) + ".";
+                final String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper." + value.substring(5) + ".";
                 add(className, objectMappingFactory.createMapper(className, propertiesBase, fieldMappingLookup, this));
             } else if (value.trim().equals("auto")) {
-                String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper.default";
+                final String propertiesBase = SqlObjectStore.BASE_NAME + ".automapper.default";
                 add(className, objectMappingFactory.createMapper(className, propertiesBase, fieldMappingLookup, this));
             } else {
                 LOG.debug("mapper " + className + "=" + value);
-                
+
                 try {
                     add(className, InstanceUtil.createInstance(value, ObjectMapping.class));
-                } catch (ObjectPersistenceException ex) {
+                } catch (final ObjectPersistenceException ex) {
                     throw new InstanceCreationException("Failed to set up mapper for " + className, ex);
                 }
             }
@@ -120,28 +118,28 @@ public class ObjectMappingLookup impleme
     }
 
     public void shutdown() {
-        for (ObjectMapping mapping : mappings.values()) {
+        for (final ObjectMapping mapping : mappings.values()) {
             try {
                 mapping.shutdown();
-            } catch (ObjectPersistenceException ex) {
+            } catch (final ObjectPersistenceException ex) {
                 LOG.error("Shutdown mapper " + mapping, ex);
             }
         }
     }
 
     @Override
-    public void debugData(DebugBuilder debug) {
+    public void debugData(final DebugBuilder debug) {
         debug.appendln("field mapping lookup", fieldMappingLookup);
         debug.appendln("object mapping factory", objectMappingFactory);
         debug.appendTitle("Mappings");
         int i = 1;
-        for (ObjectSpecification specification : mappings.keySet()) {
+        for (final ObjectSpecification specification : mappings.keySet()) {
             debug.appendln(i++ + ". " + specification.getShortIdentifier());
-           ObjectMapping mapper = mappings.get(specification);
-           debug.indent();
-           debug.append(mapper);
-           debug.unindent();
-         }
+            final ObjectMapping mapper = mappings.get(specification);
+            debug.indent();
+            debug.append(mapper);
+            debug.unindent();
+        }
     }
 
     @Override

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Parameter.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/Parameter.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Parameter.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Parameter.java Tue May  3 06:52:51 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
-
 public interface Parameter {
     void setupParameter(int parameter, StoredProcedure procedure) throws ObjectPersistenceException;
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKey.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/PrimaryKey.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKey.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKey.java Tue May  3 06:52:51 2011
@@ -23,7 +23,7 @@ import java.io.Serializable;
 
 public interface PrimaryKey extends Serializable {
 
-	public String stringValue();
+    public String stringValue();
 
-	public Object naturalValue();
+    public Object naturalValue();
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKeyMapper.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/PrimaryKeyMapper.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKeyMapper.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/PrimaryKeyMapper.java Tue May  3 06:52:51 2011
@@ -17,8 +17,6 @@
  *  under the License.
  */
 
-
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 public interface PrimaryKeyMapper {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Sql.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/Sql.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Sql.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/Sql.java Tue May  3 06:52:51 2011
@@ -30,18 +30,18 @@ public class Sql {
 
     // public static String timestamp = "CURRENT_TIMESTAMP";
 
-    public static void setMetaData(SqlMetaData metadata) {
+    public static void setMetaData(final SqlMetaData metadata) {
         Sql.metadata = metadata;
     }
 
-    public static String escapeAndQuoteValue(String encodedString) {
+    public static String escapeAndQuoteValue(final String encodedString) {
         if (encodedString == null || encodedString.equals("NULL")) {
             return "NULL";
         }
         // StringBuffer buffer = new StringBuffer("'");
-        StringBuffer buffer = new StringBuffer(metadata.getQuoteString());
+        final StringBuffer buffer = new StringBuffer(metadata.getQuoteString());
         for (int i = 0; i < encodedString.length(); i++) {
-            char c = encodedString.charAt(i);
+            final char c = encodedString.charAt(i);
             if (c == '\'') {
                 buffer.append("\\'");
             } else if (c == '\\') {
@@ -52,11 +52,11 @@ public class Sql {
         }
         // buffer.append("'");
         buffer.append(metadata.getQuoteString());
-        String string = buffer.toString();
+        final String string = buffer.toString();
         return string;
     }
 
-    public static String sqlName(String name) {
+    public static String sqlName(final String name) {
         // TODO need to deal with non-ascii (ie unicode characters)
         return name.replace(' ', '_').toLowerCase();
 
@@ -67,12 +67,12 @@ public class Sql {
          */
     }
 
-    public static String sqlFieldName(String name) {
-        int length = name.length();
-        StringBuffer convertedName = new StringBuffer(length);
+    public static String sqlFieldName(final String name) {
+        final int length = name.length();
+        final StringBuffer convertedName = new StringBuffer(length);
         boolean lastWasLowerCase = false;
         for (int i = 0; i < length; i++) {
-            char ch = name.charAt(i);
+            final char ch = name.charAt(i);
             if (Character.isUpperCase(ch)) {
                 if (lastWasLowerCase) {
                     convertedName.append('_');
@@ -86,12 +86,12 @@ public class Sql {
         return sqlName(convertedName.toString());
     }
 
-    public static String identifier(String name) {
+    public static String identifier(final String name) {
         // return metadata.quoteIdentifier(name);
         return tableIdentifier(name);
     }
 
-    public static String tableIdentifier(String name) {
+    public static String tableIdentifier(final String name) {
         if (metadata.isStoresMixedCaseIdentifiers()) {
             return name;
         } else if (metadata.isStoresLowerCaseIdentifiers()) {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlExecutionContext.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/SqlExecutionContext.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlExecutionContext.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlExecutionContext.java Tue May  3 06:52:51 2011
@@ -17,29 +17,31 @@
  *  under the License.
  */
 
+package org.apache.isis.runtimes.dflt.objectstores.sql;
 
-package org.apache.isis.runtimes.dflt.objectstores.sql;
-
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
-
-
-
-public class SqlExecutionContext implements PersistenceCommandContext {
-    private final DatabaseConnector connection;
-
-    public SqlExecutionContext(final DatabaseConnector connection, IsisTransactionManager transactionManager, MessageBroker messageBroker, UpdateNotifier updateNotifier) {
-        this.connection = connection;
-    }
-
-    public DatabaseConnector getConnection() {
-        return connection;
-    }
-
-    public void start() {}
-
-    public void end() {}
-
+
+public class SqlExecutionContext implements PersistenceCommandContext {
+    private final DatabaseConnector connection;
+
+    public SqlExecutionContext(final DatabaseConnector connection, final IsisTransactionManager transactionManager,
+        final MessageBroker messageBroker, final UpdateNotifier updateNotifier) {
+        this.connection = connection;
+    }
+
+    public DatabaseConnector getConnection() {
+        return connection;
+    }
+
+    @Override
+    public void start() {
+    }
+
+    @Override
+    public void end() {
+    }
+
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStore.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/SqlObjectStore.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStore.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStore.java Tue May  3 06:52:51 2011
@@ -22,8 +22,6 @@ package org.apache.isis.runtimes.dflt.ob
 import java.util.List;
 import java.util.Vector;
 
-import org.apache.log4j.Logger;
-
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.debug.DebugString;
 import org.apache.isis.core.commons.exceptions.IsisException;
@@ -46,6 +44,7 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
 import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+import org.apache.log4j.Logger;
 
 public final class SqlObjectStore implements ObjectStore {
     private static final String TABLE_NAME = "isis_admin_services";
@@ -66,9 +65,9 @@ public final class SqlObjectStore implem
         return new CreateObjectCommand() {
             @Override
             public void execute(final PersistenceCommandContext context) {
-                DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
+                final DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
                 LOG.debug("  create object " + object);
-                ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
+                final ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
                 mapping.createObject(connection, object);
             }
 
@@ -89,9 +88,9 @@ public final class SqlObjectStore implem
         return new DestroyObjectCommand() {
             @Override
             public void execute(final PersistenceCommandContext context) {
-                DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
+                final DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
                 LOG.debug("  destroy object " + object);
-                ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
+                final ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
                 mapping.destroyObject(connection, object);
             }
 
@@ -112,7 +111,7 @@ public final class SqlObjectStore implem
         return new SaveObjectCommand() {
             @Override
             public void execute(final PersistenceCommandContext context) {
-                DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
+                final DatabaseConnector connection = ((SqlExecutionContext) context).getConnection();
                 LOG.debug("  save object " + object);
                 if (object.getSpecification().isCollectionOrIsAggregated()) {
                     /*
@@ -125,7 +124,7 @@ public final class SqlObjectStore implem
                      */
                     throw new NotYetImplementedException(object.toString());
                 } else {
-                    ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
+                    final ObjectMapping mapping = objectMappingLookup.getMapping(object, connection);
                     mapping.save(connection, object);
                     connectionPool.release(connection);
                 }
@@ -166,20 +165,20 @@ public final class SqlObjectStore implem
 
     @Override
     public void execute(final List<PersistenceCommand> commands) {
-        DatabaseConnector connector = connectionPool.acquire();
+        final DatabaseConnector connector = connectionPool.acquire();
         connector.begin();
 
-        IsisTransactionManager transactionManager = IsisContext.getTransactionManager();
-        MessageBroker messageBroker = IsisContext.getMessageBroker();
-        UpdateNotifier updateNotifier = IsisContext.getUpdateNotifier();
-        SqlExecutionContext context =
+        final IsisTransactionManager transactionManager = IsisContext.getTransactionManager();
+        final MessageBroker messageBroker = IsisContext.getMessageBroker();
+        final UpdateNotifier updateNotifier = IsisContext.getUpdateNotifier();
+        final SqlExecutionContext context =
             new SqlExecutionContext(connector, transactionManager, messageBroker, updateNotifier);
         try {
-            for (PersistenceCommand command : commands) {
+            for (final PersistenceCommand command : commands) {
                 command.execute(context);
             }
             connector.commit();
-        } catch (IsisException e) {
+        } catch (final IsisException e) {
             LOG.warn("Failure during execution", e);
             connector.rollback();
             throw e;
@@ -206,58 +205,58 @@ public final class SqlObjectStore implem
     }
 
     private ObjectAdapter[] findByPattern(final PersistenceQueryFindByPattern query) {
-        ObjectSpecification specification = query.getSpecification();
-        DatabaseConnector connector = connectionPool.acquire();
-        ObjectMapping mapper = objectMappingLookup.getMapping(specification, connector);
-        ObjectAdapter instances[] = mapper.getInstances(connector, specification, query);
+        final ObjectSpecification specification = query.getSpecification();
+        final DatabaseConnector connector = connectionPool.acquire();
+        final ObjectMapping mapper = objectMappingLookup.getMapping(specification, connector);
+        final ObjectAdapter instances[] = mapper.getInstances(connector, specification, query);
         connectionPool.release(connector);
         return instances;
     }
 
     private ObjectAdapter[] getAllInstances(final PersistenceQueryFindAllInstances criteria) {
-        ObjectSpecification spec = criteria.getSpecification();
+        final ObjectSpecification spec = criteria.getSpecification();
         return allInstances(spec);
     }
 
     // TODO: allInstances of should find all derived types, too.
-    private ObjectAdapter[] allInstances(ObjectSpecification spec) {
-        DatabaseConnector connector = connectionPool.acquire();
-        ObjectMapping mapper = objectMappingLookup.getMapping(spec, connector);
-        ObjectAdapter[] instances = mapper.getInstances(connector, spec);
-        Vector<ObjectAdapter> matchingInstances = new Vector<ObjectAdapter>();
-        for (int i = 0; i < instances.length; i++) {
-            matchingInstances.addElement(instances[i]);
+    private ObjectAdapter[] allInstances(final ObjectSpecification spec) {
+        final DatabaseConnector connector = connectionPool.acquire();
+        final ObjectMapping mapper = objectMappingLookup.getMapping(spec, connector);
+        final ObjectAdapter[] instances = mapper.getInstances(connector, spec);
+        final Vector<ObjectAdapter> matchingInstances = new Vector<ObjectAdapter>();
+        for (final ObjectAdapter instance : instances) {
+            matchingInstances.addElement(instance);
         }
         connectionPool.release(connector);
-        ObjectAdapter[] instanceArray = new ObjectAdapter[matchingInstances.size()];
+        final ObjectAdapter[] instanceArray = new ObjectAdapter[matchingInstances.size()];
         matchingInstances.copyInto(instanceArray);
         return instanceArray;
     }
 
     private ObjectAdapter[] findByTitle(final PersistenceQueryFindByTitle criteria) {
-        ObjectSpecification spec = criteria.getSpecification();
-        DatabaseConnector connector = connectionPool.acquire();
-        ObjectMapping mapper = objectMappingLookup.getMapping(spec, connector);
+        final ObjectSpecification spec = criteria.getSpecification();
+        final DatabaseConnector connector = connectionPool.acquire();
+        final ObjectMapping mapper = objectMappingLookup.getMapping(spec, connector);
 
-        ObjectAdapter[] instances = mapper.getInstances(connector, spec, criteria.getTitle());
+        final ObjectAdapter[] instances = mapper.getInstances(connector, spec, criteria.getTitle());
         connectionPool.release(connector);
         return instances;
     }
 
     @Override
     public ObjectAdapter getObject(final Oid oid, final ObjectSpecification hint) {
-        DatabaseConnector connection = connectionPool.acquire();
-        ObjectMapping mapper = objectMappingLookup.getMapping(hint, connection);
-        ObjectAdapter object = mapper.getObject(connection, oid, hint);
+        final DatabaseConnector connection = connectionPool.acquire();
+        final ObjectMapping mapper = objectMappingLookup.getMapping(hint, connection);
+        final ObjectAdapter object = mapper.getObject(connection, oid, hint);
         connectionPool.release(connection);
         return object;
     }
 
     @Override
-    public Oid getOidForService(String name) {
-        DatabaseConnector connector = connectionPool.acquire();
+    public Oid getOidForService(final String name) {
+        final DatabaseConnector connector = connectionPool.acquire();
 
-        StringBuffer sql = new StringBuffer();
+        final StringBuffer sql = new StringBuffer();
         sql.append("select ");
         sql.append(Sql.identifier(PRIMARYKEY_COLUMN));
         sql.append(" from ");
@@ -267,9 +266,9 @@ public final class SqlObjectStore implem
         sql.append(" = ?");
         connector.addToQueryValues(name);
 
-        Results results = connector.select(sql.toString());
+        final Results results = connector.select(sql.toString());
         if (results.next()) {
-            int key = results.getInt(PRIMARYKEY_COLUMN);
+            final int key = results.getInt(PRIMARYKEY_COLUMN);
             connectionPool.release(connector);
             return SqlOid.createPersistent(name, new IntegerPrimaryKey(key));
         } else {
@@ -280,9 +279,9 @@ public final class SqlObjectStore implem
 
     @Override
     public boolean hasInstances(final ObjectSpecification spec) {
-        DatabaseConnector connection = connectionPool.acquire();
-        ObjectMapping mapper = objectMappingLookup.getMapping(spec, connection);
-        boolean hasInstances = mapper.hasInstances(connection, spec);
+        final DatabaseConnector connection = connectionPool.acquire();
+        final ObjectMapping mapper = objectMappingLookup.getMapping(spec, connection);
+        final boolean hasInstances = mapper.hasInstances(connection, spec);
         connectionPool.release(connection);
         return hasInstances;
     }
@@ -296,19 +295,19 @@ public final class SqlObjectStore implem
     public void open() {
         Sql.setMetaData(connectionPool.acquire().getMetaData());
 
-        DebugBuilder debug = new DebugString();
+        final DebugBuilder debug = new DebugString();
         connectionPool.debug(debug);
         LOG.info("Database: " + debug);
 
         objectMappingLookup.init();
 
-        DatabaseConnector connector = connectionPool.acquire();
+        final DatabaseConnector connector = connectionPool.acquire();
         isInitialized = connector.hasTable(Sql.tableIdentifier(TABLE_NAME));
         if (!isInitialized) {
 
             Defaults.initialise();
 
-            StringBuffer sql = new StringBuffer();
+            final StringBuffer sql = new StringBuffer();
             sql.append("create table ");
             sql.append(Sql.tableIdentifier(TABLE_NAME));
             sql.append(" (");
@@ -328,9 +327,9 @@ public final class SqlObjectStore implem
 
     @Override
     public void registerService(final String name, final Oid oid) {
-        DatabaseConnector connector = connectionPool.acquire();
+        final DatabaseConnector connector = connectionPool.acquire();
 
-        StringBuffer sql = new StringBuffer();
+        final StringBuffer sql = new StringBuffer();
         sql.append("insert into ");
         sql.append(Sql.tableIdentifier(TABLE_NAME));
         sql.append(" (");
@@ -353,9 +352,9 @@ public final class SqlObjectStore implem
     @Override
     public void resolveField(final ObjectAdapter object, final ObjectAssociation field) {
         if (field.isOneToManyAssociation()) {
-            DatabaseConnector connection = connectionPool.acquire();
-            ObjectSpecification spec = object.getSpecification();
-            ObjectMapping mapper = objectMappingLookup.getMapping(spec, connection);
+            final DatabaseConnector connection = connectionPool.acquire();
+            final ObjectSpecification spec = object.getSpecification();
+            final ObjectMapping mapper = objectMappingLookup.getMapping(spec, connection);
             mapper.resolveCollection(connection, object, field);
             connectionPool.release(connection);
         } else {
@@ -365,8 +364,8 @@ public final class SqlObjectStore implem
 
     @Override
     public void resolveImmediately(final ObjectAdapter object) {
-        DatabaseConnector connector = connectionPool.acquire();
-        ObjectMapping mapping = objectMappingLookup.getMapping(object, connector);
+        final DatabaseConnector connector = connectionPool.acquire();
+        final ObjectMapping mapping = objectMappingLookup.getMapping(object, connector);
         mapping.resolve(connector, object);
         connectionPool.release(connector);
     }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStoreException.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/SqlObjectStoreException.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStoreException.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlObjectStoreException.java Tue May  3 06:52:51 2011
@@ -17,12 +17,10 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import org.apache.isis.runtimes.dflt.runtime.transaction.ObjectPersistenceException;
 
-
 public class SqlObjectStoreException extends ObjectPersistenceException {
     private static final long serialVersionUID = 1L;
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOid.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/SqlOid.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOid.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOid.java Tue May  3 06:52:51 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import java.io.IOException;
@@ -27,23 +26,20 @@ import org.apache.isis.core.commons.enco
 import org.apache.isis.core.commons.ensure.Assert;
 import org.apache.isis.core.metamodel.adapter.oid.Oid;
 
-
 public final class SqlOid implements Oid {
     private static final long serialVersionUID = 1L;
 
     public static enum State {
-        PERSISTENT,
-        TRANSIENT;
+        PERSISTENT, TRANSIENT;
         public boolean isTransient() {
             return this == TRANSIENT;
         }
     }
 
-    
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
     // Factory methods
-    ////////////////////////////////////////////////////
-    
+    // //////////////////////////////////////////////////
+
     public static SqlOid createPersistent(final String className, final PrimaryKey primaryKey) {
         return new SqlOid(className, primaryKey, State.PERSISTENT);
     }
@@ -52,10 +48,9 @@ public final class SqlOid implements Oid
         return new SqlOid(className, new TransientKey(serialNo), State.TRANSIENT);
     }
 
-    
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
     // Constructors, encode
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
 
     private String className;
     private SqlOid previous;
@@ -70,16 +65,17 @@ public final class SqlOid implements Oid
         initialized();
     }
 
-    public SqlOid(DataInputExtended input) throws IOException {
-    	this.className = input.readUTF();
-    	this.primaryKey = input.readSerializable(PrimaryKey.class);
-    	this.newPrimaryKey = input.readSerializable(PrimaryKey.class);
-    	this.previous = input.readEncodable(SqlOid.class);
-    	this.state = input.readSerializable(State.class);
-    	initialized();
+    public SqlOid(final DataInputExtended input) throws IOException {
+        this.className = input.readUTF();
+        this.primaryKey = input.readSerializable(PrimaryKey.class);
+        this.newPrimaryKey = input.readSerializable(PrimaryKey.class);
+        this.previous = input.readEncodable(SqlOid.class);
+        this.state = input.readSerializable(State.class);
+        initialized();
     }
 
-	public void encode(DataOutputExtended output) throws IOException {
+    @Override
+    public void encode(final DataOutputExtended output) throws IOException {
         output.writeUTF(className);
         output.writeSerializable(primaryKey);
         output.writeSerializable(newPrimaryKey);
@@ -87,19 +83,18 @@ public final class SqlOid implements Oid
         output.writeSerializable(state);
     }
 
-
     private void initialized() {
-		// nothing to do
-	}
-
+        // nothing to do
+    }
 
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
     // impl
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
 
+    @Override
     public void copyFrom(final Oid oid) {
         Assert.assertTrue(oid instanceof SqlOid);
-        SqlOid from = (SqlOid) oid;
+        final SqlOid from = (SqlOid) oid;
         this.primaryKey = from.primaryKey;
         this.className = from.className;
     }
@@ -109,14 +104,15 @@ public final class SqlOid implements Oid
     }
 
     public PrimaryKey getPrimaryKey() {
-    	return primaryKey;
+        return primaryKey;
     }
-    
+
+    @Override
     public boolean isTransient() {
-    	// TODO: why not look at the State?
-    	return primaryKey instanceof TransientKey;
+        // TODO: why not look at the State?
+        return primaryKey instanceof TransientKey;
     }
-    
+
     /**
      * Should be called prior to {@link #makePersistent()}
      */
@@ -125,30 +121,34 @@ public final class SqlOid implements Oid
         this.newPrimaryKey = primaryKey;
     }
 
+    @Override
     public void makePersistent() {
         Assert.assertTrue(state.isTransient());
         Assert.assertNotNull(newPrimaryKey);
         previous = new SqlOid(this.className, this.primaryKey, state);
         this.primaryKey = newPrimaryKey;
         this.state = State.PERSISTENT;
-        
+
     }
 
+    @Override
     public boolean hasPrevious() {
-    	return previous != null;
+        return previous != null;
     }
-    
+
+    @Override
     public Oid getPrevious() {
-    	return previous;
+        return previous;
     }
-    
+
+    @Override
     public void clearPrevious() {
         previous = null;
     }
 
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
     // equals, hashCode
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
 
     @Override
     public boolean equals(final Object obj) {
@@ -156,7 +156,7 @@ public final class SqlOid implements Oid
             return true;
         }
         if (obj instanceof SqlOid) {
-            SqlOid otherOid = ((SqlOid) obj);
+            final SqlOid otherOid = ((SqlOid) obj);
             return className.equals(otherOid.className) && primaryKey.equals(otherOid.primaryKey);
         }
         return false;
@@ -170,15 +170,14 @@ public final class SqlOid implements Oid
         return hashCode;
     }
 
-
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
     // toString
-    ////////////////////////////////////////////////////
+    // //////////////////////////////////////////////////
 
     @Override
     public String toString() {
-        return (isTransient() ? "T" : "") + "OID#" + primaryKey.stringValue() + "/" + className + (previous == null ? "" : "+");
+        return (isTransient() ? "T" : "") + "OID#" + primaryKey.stringValue() + "/" + className
+            + (previous == null ? "" : "+");
     }
 
-
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOidGenerator.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/SqlOidGenerator.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOidGenerator.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlOidGenerator.java Tue May  3 06:52:51 2011
@@ -41,7 +41,7 @@ public class SqlOidGenerator extends Oid
             return transientNumber++;
         }
 
-        public synchronized long nextPersistentId(DatabaseConnectorPool connectionPool) {
+        public synchronized long nextPersistentId(final DatabaseConnectorPool connectionPool) {
             if (lastId > newBatchAt) {
                 throw new SqlObjectStoreException("ID exception, last id (" + lastId + ") past new batch boundary ("
                     + newBatchAt + ")");
@@ -53,11 +53,11 @@ public class SqlOidGenerator extends Oid
             return lastId;
         }
 
-        private void prepareNewBatch(DatabaseConnectorPool connectionPool) {
-            DatabaseConnector db = connectionPool.acquire();
+        private void prepareNewBatch(final DatabaseConnectorPool connectionPool) {
+            final DatabaseConnector db = connectionPool.acquire();
             try {
-                String tableName = Sql.tableIdentifier(TABLE_NAME);
-                String numberColumn = Sql.identifier(NUMBER_COLUMN);
+                final String tableName = Sql.tableIdentifier(TABLE_NAME);
+                final String numberColumn = Sql.identifier(NUMBER_COLUMN);
                 if (!db.hasTable(tableName)) {
                     lastId = 1;
                     newBatchAt = BATCH_SIZE;
@@ -69,21 +69,21 @@ public class SqlOidGenerator extends Oid
                         + BATCH_SIZE) != 1) {
                         throw new SqlObjectStoreException("failed to update serial id table; no rows updated");
                     }
-                    Results rs = db.select("select " + numberColumn + " from " + tableName);
+                    final Results rs = db.select("select " + numberColumn + " from " + tableName);
                     rs.next();
                     newBatchAt = rs.getLong(NUMBER_COLUMN); // TODO here
                     lastId = newBatchAt - BATCH_SIZE;
                     LOG.debug("New ID batch created, from " + lastId + " to " + newBatchAt);
                     rs.close();
                 }
-            } catch (ObjectPersistenceException e) {
+            } catch (final ObjectPersistenceException e) {
                 throw e;
             } finally {
                 connectionPool.release(db);
             }
         }
 
-        public void debugData(DebugBuilder debug) {
+        public void debugData(final DebugBuilder debug) {
             debug.appendln("id", lastId);
             debug.appendln("transient id", transientNumber);
         }
@@ -103,18 +103,19 @@ public class SqlOidGenerator extends Oid
 
     @Override
     public SqlOid createTransientOid(final Object object) {
-        String className = object.getClass().getName();
+        final String className = object.getClass().getName();
         return SqlOid.createTransient(className, ids.nextTransientId());
     }
-    
-    public String createAggregateId(Object pojo) {
+
+    @Override
+    public String createAggregateId(final Object pojo) {
         throw new SqlObjectStoreException("Aggregated objects are not supported in this store");
     }
 
     @Override
     public void convertTransientToPersistentOid(final Oid oid) {
         Assert.assertNotNull("No connection set up", connectionPool);
-        IntegerPrimaryKey primaryKey = new IntegerPrimaryKey((int) ids.nextPersistentId(connectionPool));
+        final IntegerPrimaryKey primaryKey = new IntegerPrimaryKey((int) ids.nextPersistentId(connectionPool));
         ((SqlOid) oid).setId(primaryKey);
         ((SqlOid) oid).makePersistent();
     }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistenceSessionFactory.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/SqlPersistenceSessionFactory.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistenceSessionFactory.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistenceSessionFactory.java Tue May  3 06:52:51 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistenceSessionFactoryDelegating;
@@ -25,9 +24,8 @@ import org.apache.isis.runtimes.dflt.run
 
 public class SqlPersistenceSessionFactory extends PersistenceSessionFactoryDelegating {
 
-    public SqlPersistenceSessionFactory(DeploymentType deploymentType, SqlPersistorInstaller sqlPersistorInstaller) {
+    public SqlPersistenceSessionFactory(final DeploymentType deploymentType,
+        final SqlPersistorInstaller sqlPersistorInstaller) {
         super(deploymentType, sqlPersistorInstaller);
     }
 }
-
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.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/SqlPersistorInstaller.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/SqlPersistorInstaller.java Tue May  3 06:52:51 2011
@@ -17,14 +17,13 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 import org.apache.isis.runtimes.dflt.objectstores.sql.auto.AutoMapperFactory;
 import org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.JdbcConnectorFactory;
 import org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.installer.JdbcFieldMappingFactoryInstaller;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
 import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.ObjectStorePersistenceMechanismInstallerAbstract;
 import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStore;
 import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
@@ -32,7 +31,6 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
 
-
 public class SqlPersistorInstaller extends ObjectStorePersistenceMechanismInstallerAbstract {
 
     private SqlObjectStore objectStore;
@@ -43,25 +41,22 @@ public class SqlPersistorInstaller exten
     }
 
     @Override
-    protected ObjectStore createObjectStore(
-            IsisConfiguration configuration,
-            ObjectAdapterFactory objectFactory,
-            AdapterManager adapterManager) {
-        
-        
+    protected ObjectStore createObjectStore(final IsisConfiguration configuration,
+        final ObjectAdapterFactory objectFactory, final AdapterManager adapterManager) {
+
         if (objectStore == null) {
-            FieldMappingLookup fieldMappingLookup = new FieldMappingLookup();
-            JdbcFieldMappingFactoryInstaller installer = new JdbcFieldMappingFactoryInstaller();
+            final FieldMappingLookup fieldMappingLookup = new FieldMappingLookup();
+            final JdbcFieldMappingFactoryInstaller installer = new JdbcFieldMappingFactoryInstaller();
             installer.load(fieldMappingLookup);
             // fieldMappingLookup.setValueMappingFactory(new
             // JdbcFieldMappingFactoryInstaller());
 
-            ObjectMappingLookup objectMappingLookup = new ObjectMappingLookup();
+            final ObjectMappingLookup objectMappingLookup = new ObjectMappingLookup();
             objectMappingLookup.setValueMappingLookup(fieldMappingLookup);
             objectMappingLookup.setObjectMappingFactory(new AutoMapperFactory());
             objectMappingLookup.setConnectionPool(connectionPool);
 
-            SqlObjectStore objectStore = new SqlObjectStore();
+            final SqlObjectStore objectStore = new SqlObjectStore();
             objectStore.setMapperLookup(objectMappingLookup);
             objectStore.setConnectionPool(connectionPool);
             this.objectStore = objectStore;
@@ -70,26 +65,23 @@ public class SqlPersistorInstaller exten
     }
 
     @Override
-    protected OidGenerator createOidGenerator(IsisConfiguration configuration) {
-        DatabaseConnectorFactory connectorFactory = new JdbcConnectorFactory();
+    protected OidGenerator createOidGenerator(final IsisConfiguration configuration) {
+        final DatabaseConnectorFactory connectorFactory = new JdbcConnectorFactory();
         connectionPool = new DatabaseConnectorPool(connectorFactory, 1);
 
         return new SqlOidGenerator(connectionPool);
     }
 
+    @Override
     public PersistenceSessionFactory createPersistenceSessionFactory(final DeploymentType deploymentType) {
         return new SqlPersistenceSessionFactory(deploymentType, this);
     }
-    
-    
-    /*
-    
 
-    
-    @Override
-    protected AdapterManagerExtended createAdapterManager(final IsisConfiguration configuration) {
-        return new XmlAdapterManager();
-    }
-*/
+    /*
+     * 
+     * 
+     * 
+     * @Override protected AdapterManagerExtended createAdapterManager(final IsisConfiguration configuration) { return
+     * new XmlAdapterManager(); }
+     */
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StoredProcedure.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/StoredProcedure.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StoredProcedure.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StoredProcedure.java Tue May  3 06:52:51 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 public interface StoredProcedure {

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKey.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/StringPrimaryKey.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKey.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKey.java Tue May  3 06:52:51 2011
@@ -20,44 +20,44 @@
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 public class StringPrimaryKey implements PrimaryKey {
-	private static final long serialVersionUID = 1L;
-	private final String primaryKey;
+    private static final long serialVersionUID = 1L;
+    private final String primaryKey;
 
-	public StringPrimaryKey(final String primaryKey) {
-		this.primaryKey = primaryKey;
-	}
-
-	@Override
-	public boolean equals(final Object obj) {
-		if (obj == this) {
-			return true;
-		}
-		if (obj instanceof StringPrimaryKey) {
-			StringPrimaryKey o = ((StringPrimaryKey) obj);
-			return primaryKey == o.primaryKey;
-		}
-		return false;
-	}
-
-	@Override
-	public int hashCode() {
-		int hash = 17;
-		hash = 37 * hash + primaryKey.hashCode();
-		return hash;
-	}
-
-	@Override
-	public String stringValue() {
-		return "" + primaryKey;
-	}
-
-	@Override
-	public String toString() {
-		return "" + primaryKey;
-	}
-
-	@Override
-	public Object naturalValue() {
-		return stringValue();
-	}
+    public StringPrimaryKey(final String primaryKey) {
+        this.primaryKey = primaryKey;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (obj instanceof StringPrimaryKey) {
+            final StringPrimaryKey o = ((StringPrimaryKey) obj);
+            return primaryKey == o.primaryKey;
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 17;
+        hash = 37 * hash + primaryKey.hashCode();
+        return hash;
+    }
+
+    @Override
+    public String stringValue() {
+        return "" + primaryKey;
+    }
+
+    @Override
+    public String toString() {
+        return "" + primaryKey;
+    }
+
+    @Override
+    public Object naturalValue() {
+        return stringValue();
+    }
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKeyMapper.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/StringPrimaryKeyMapper.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKeyMapper.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/StringPrimaryKeyMapper.java Tue May  3 06:52:51 2011
@@ -17,13 +17,13 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 public class StringPrimaryKeyMapper implements PrimaryKeyMapper {
 
+    @Override
     public PrimaryKey generateKey(final Results rs, final String column) {
-        String id = rs.getString(column);
+        final String id = rs.getString(column);
         return new StringPrimaryKey(id);
     }
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TitleMapping.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/TitleMapping.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TitleMapping.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TitleMapping.java Tue May  3 06:52:51 2011
@@ -17,60 +17,58 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 
-
 public class TitleMapping {
-    private String column = Sql.identifier("NO_title");
+    private final String column = Sql.identifier("NO_title");
 
-     protected String getColumn() {
+    protected String getColumn() {
         return column;
     }
-     
-    public void appendWhereClause(StringBuffer sql, String title) {
+
+    public void appendWhereClause(final StringBuffer sql, final String title) {
         appendAssignment(sql, title);
     }
 
-    private void appendAssignment(StringBuffer sql, String title) {
+    private void appendAssignment(final StringBuffer sql, final String title) {
         sql.append(column);
         sql.append(" = ");
         appendTitle(sql, title);
     }
 
-    public void appendColumnDefinitions(StringBuffer sql) {
+    public void appendColumnDefinitions(final StringBuffer sql) {
         sql.append(column);
         sql.append(" ");
         sql.append("varchar(200)");
     }
 
-    public void appendColumnNames(StringBuffer sql) {
+    public void appendColumnNames(final StringBuffer sql) {
         sql.append(column);
     }
 
-    //TODO:KAM:here 
-    public void appendInsertValues(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object) {
+    // TODO:KAM:here
+    public void appendInsertValues(final DatabaseConnector connector, final StringBuffer sql, final ObjectAdapter object) {
         if (object == null) {
             sql.append("NULL");
         } else {
-            //appendTitle(sql, object.titleString());
-        	connector.addToQueryValues(object.titleString().toLowerCase());
+            // appendTitle(sql, object.titleString());
+            connector.addToQueryValues(object.titleString().toLowerCase());
         }
-    	sql.append("?");
+        sql.append("?");
     }
 
-    private void appendTitle(StringBuffer sql, String title) {
-        String titleString = title.toLowerCase();
+    private void appendTitle(final StringBuffer sql, final String title) {
+        final String titleString = title.toLowerCase();
         sql.append(Sql.escapeAndQuoteValue(titleString));
     }
 
-    public void appendUpdateAssignment(DatabaseConnector connector, StringBuffer sql, ObjectAdapter object) {
+    public void appendUpdateAssignment(final DatabaseConnector connector, final StringBuffer sql,
+        final ObjectAdapter object) {
         sql.append(column);
         sql.append(" = ");
         appendInsertValues(connector, sql, object);
-        
+
     }
 }
-

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TransientKey.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/TransientKey.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TransientKey.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/TransientKey.java Tue May  3 06:52:51 2011
@@ -20,20 +20,20 @@
 package org.apache.isis.runtimes.dflt.objectstores.sql;
 
 public class TransientKey implements PrimaryKey {
-	private static final long serialVersionUID = 1L;
-	private final long transientId;
+    private static final long serialVersionUID = 1L;
+    private final long transientId;
 
-	public TransientKey(final long id) {
-		transientId = id;
-	}
+    public TransientKey(final long id) {
+        transientId = id;
+    }
 
-	@Override
-	public String stringValue() {
-		return "" + transientId;
-	}
+    @Override
+    public String stringValue() {
+        return "" + transientId;
+    }
 
-	@Override
-	public Object naturalValue() {
-		return transientId;
-	}
+    @Override
+    public Object naturalValue() {
+        return transientId;
+    }
 }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/VersionMapping.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/VersionMapping.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/VersionMapping.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/VersionMapping.java Tue May  3 06:52:51 2011
@@ -41,7 +41,7 @@ public class VersionMapping {
         return versionColumn + ", " + lastActivityUserColumn + ", " + lastActivityDateColumn;
     }
 
-    public String insertValues(DatabaseConnector connector, SerialNumberVersion version) {
+    public String insertValues(final DatabaseConnector connector, final SerialNumberVersion version) {
         connector.addToQueryValues(version.getSequence());
         String user = version.getUser();
         if (user == "") {
@@ -52,18 +52,18 @@ public class VersionMapping {
         return "?,?,?";
     }
 
-    public String whereClause(DatabaseConnector connector, SerialNumberVersion version) {
+    public String whereClause(final DatabaseConnector connector, final SerialNumberVersion version) {
         connector.addToQueryValues(version.getSequence());
         return versionColumn + " = ?";
     }
 
-    public String updateAssigment(DatabaseConnector connector, long nextSequence) {
+    public String updateAssigment(final DatabaseConnector connector, final long nextSequence) {
         connector.addToQueryValues(nextSequence);
         return versionColumn + " = ?";
     }
 
     public String appendSelectColumns() {
-        StringBuffer sql = new StringBuffer();
+        final StringBuffer sql = new StringBuffer();
         sql.append(versionColumn);
         sql.append(",");
         sql.append(lastActivityUserColumn);
@@ -73,7 +73,7 @@ public class VersionMapping {
     }
 
     public String appendColumnDefinitions() {
-        StringBuffer sql = new StringBuffer();
+        final StringBuffer sql = new StringBuffer();
 
         sql.append(versionColumn);
         sql.append(" bigint");
@@ -89,16 +89,16 @@ public class VersionMapping {
         return sql.toString();
     }
 
-    public Object appendUpdateValues(DatabaseConnector connector, long versionSequence) {
+    public Object appendUpdateValues(final DatabaseConnector connector, final long versionSequence) {
         connector.addToQueryValues(versionSequence);
         return versionColumn + "= ?";
     }
 
-    public Version getLock(Results rs) {
-        long number = rs.getLong(versionColumn);
-        String user = rs.getString(lastActivityUserColumn);
-        Date time = rs.getJavaDateTime(lastActivityDateColumn, Defaults.getCalendar());
-        Version version = new SerialNumberVersion(number, user, time);
+    public Version getLock(final Results rs) {
+        final long number = rs.getLong(versionColumn);
+        final String user = rs.getString(lastActivityUserColumn);
+        final Date time = rs.getJavaDateTime(lastActivityDateColumn, Defaults.getCalendar());
+        final Version version = new SerialNumberVersion(number, user, time);
         return version;
     }
 

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.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/auto/AbstractAutoMapper.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.java Tue May  3 06:52:51 2011
@@ -24,6 +24,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.objectstores.sql.AbstractMapper;
 import org.apache.isis.runtimes.dflt.objectstores.sql.CollectionMapper;
 import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
@@ -32,12 +38,6 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.sql.Sql;
 import org.apache.isis.runtimes.dflt.objectstores.sql.SqlObjectStoreException;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
 import org.apache.log4j.Logger;
@@ -52,8 +52,8 @@ public abstract class AbstractAutoMapper
     protected List<FieldMapping> fieldMappings = new ArrayList<FieldMapping>();
     protected Map<ObjectAssociation, FieldMapping> fieldMappingLookup = new HashMap<ObjectAssociation, FieldMapping>();
 
-    protected AbstractAutoMapper(final String className, final String parameterBase, FieldMappingLookup lookup,
-        ObjectMappingLookup objectMapperLookup) {
+    protected AbstractAutoMapper(final String className, final String parameterBase, final FieldMappingLookup lookup,
+        final ObjectMappingLookup objectMapperLookup) {
         specification = IsisContext.getSpecificationLoader().loadSpecification(className);
         if (specification.getProperties() == null || specification.getProperties().size() == 0) {
             throw new SqlObjectStoreException(specification.getFullIdentifier() + " has no fields: " + specification);
@@ -61,12 +61,12 @@ public abstract class AbstractAutoMapper
         setUpFieldMappers(lookup, objectMapperLookup, className, parameterBase);
     }
 
-    private void setUpFieldMappers(FieldMappingLookup lookup, ObjectMappingLookup objectMapperLookup,
+    private void setUpFieldMappers(final FieldMappingLookup lookup, final ObjectMappingLookup objectMapperLookup,
         final String className, final String parameterBase) {
-        IsisConfiguration configParameters = IsisContext.getConfiguration();
+        final IsisConfiguration configParameters = IsisContext.getConfiguration();
         table = configParameters.getString(parameterBase + "table");
         if (table == null) {
-            String name = "isis_" + className.substring(className.lastIndexOf('.') + 1).toUpperCase();
+            final String name = "isis_" + className.substring(className.lastIndexOf('.') + 1).toUpperCase();
             table = Sql.sqlName(name);
         }
 
@@ -84,7 +84,7 @@ public abstract class AbstractAutoMapper
 
     private void setupFullMapping(final FieldMappingLookup lookup, final ObjectMappingLookup objectMapperLookup,
         final String className, final IsisConfiguration configParameters, final String parameterBase) {
-        List<? extends ObjectAssociation> fields = specification.getAssociations();
+        final List<? extends ObjectAssociation> fields = specification.getAssociations();
 
         int simpleFieldCount = 0;
         int collectionFieldCount = 0;
@@ -98,15 +98,15 @@ public abstract class AbstractAutoMapper
             }
         }
 
-        ObjectAssociation[] oneToOneProperties = new ObjectAssociation[simpleFieldCount];
-        ObjectAssociation[] oneToManyProperties = new ObjectAssociation[collectionFieldCount];
+        final ObjectAssociation[] oneToOneProperties = new ObjectAssociation[simpleFieldCount];
+        final ObjectAssociation[] oneToManyProperties = new ObjectAssociation[collectionFieldCount];
         collectionMappers = new CollectionMapper[collectionFieldCount];
         // Properties collectionMappings = configParameters.getPropertiesStrippingPrefix(parameterBase +
         // "collection");
-        IsisConfiguration subset = IsisContext.getConfiguration().createSubset(parameterBase + ".mapper.");
+        final IsisConfiguration subset = IsisContext.getConfiguration().createSubset(parameterBase + ".mapper.");
 
         for (int i = 0, simpleFieldNo = 0, collectionFieldNo = 0; i < fields.size(); i++) {
-            ObjectAssociation field = fields.get(i);
+            final ObjectAssociation field = fields.get(i);
             if (field.isNotPersisted()) {
                 continue;
             } else if (field.isOneToManyAssociation()) {
@@ -114,7 +114,7 @@ public abstract class AbstractAutoMapper
 
                 // TODO: Replace "new CombinedCollectionMapper" with a factory method(?) to allow a different
                 // default CollectionMapper
-                String type = subset.getString(field.getId());
+                final String type = subset.getString(field.getId());
                 if (type == null || type.equals("association-table")) {
                     // collectionMappers[collectionFieldNo] = new AutoCollectionMapper(specification,
                     // oneToManyProperties[collectionFieldNo], lookup);
@@ -126,8 +126,8 @@ public abstract class AbstractAutoMapper
                             lookup, objectMapperLookup);
 
                 } else if (type.equals("fk-table")) {
-                    String property = parameterBase + field.getId() + ".element-type";
-                    String elementType = configParameters.getString(property);
+                    final String property = parameterBase + field.getId() + ".element-type";
+                    final String elementType = configParameters.getString(property);
                     if (elementType == null) {
                         throw new SqlObjectStoreException("Expected property " + property);
                     }
@@ -150,9 +150,8 @@ public abstract class AbstractAutoMapper
             }
         }
 
-        for (int f = 0; f < oneToOneProperties.length; f++) {
-            ObjectAssociation field = oneToOneProperties[f];
-            FieldMapping mapping = lookup.createMapping(field);
+        for (final ObjectAssociation field : oneToOneProperties) {
+            final FieldMapping mapping = lookup.createMapping(field);
             fieldMappings.add(mapping);
             fieldMappingLookup.put(field, mapping);
         }
@@ -185,8 +184,8 @@ public abstract class AbstractAutoMapper
      * throw new NotYetImplementedException(); } } }
      */
     protected String columnList() {
-        StringBuffer sql = new StringBuffer();
-        for (FieldMapping mapping : fieldMappings) {
+        final StringBuffer sql = new StringBuffer();
+        for (final FieldMapping mapping : fieldMappings) {
             if (sql.length() > 0) {
                 sql.append(",");
             }
@@ -196,8 +195,8 @@ public abstract class AbstractAutoMapper
     }
 
     protected ObjectAdapter getAdapter(final ObjectSpecification specification, final Oid oid) {
-        AdapterManager objectLoader = IsisContext.getPersistenceSession().getAdapterManager();
-        ObjectAdapter adapter = objectLoader.getAdapterFor(oid);
+        final AdapterManager objectLoader = IsisContext.getPersistenceSession().getAdapterManager();
+        final ObjectAdapter adapter = objectLoader.getAdapterFor(oid);
         if (adapter != null) {
             return adapter;
         } else {
@@ -205,7 +204,7 @@ public abstract class AbstractAutoMapper
         }
     }
 
-    protected FieldMapping fieldMappingFor(ObjectAssociation field) {
+    protected FieldMapping fieldMappingFor(final ObjectAssociation field) {
         return fieldMappingLookup.get(field);
     }
 
@@ -225,9 +224,9 @@ public abstract class AbstractAutoMapper
             + specification.getFullIdentifier() + "]";
     }
 
-    protected String values(DatabaseConnector connector, final ObjectAdapter object) {
-        StringBuffer sql = new StringBuffer();
-        for (FieldMapping mapping : fieldMappings) {
+    protected String values(final DatabaseConnector connector, final ObjectAdapter object) {
+        final StringBuffer sql = new StringBuffer();
+        for (final FieldMapping mapping : fieldMappings) {
             mapping.appendInsertValues(connector, sql, object);
             sql.append(",");
         }

Modified: incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoCollectionMapper.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/auto/AutoCollectionMapper.java?rev=1098941&r1=1098940&r2=1098941&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoCollectionMapper.java (original)
+++ incubator/isis/trunk/runtimes/dflt/objectstores/sql/impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AutoCollectionMapper.java Tue May  3 06:52:51 2011
@@ -17,12 +17,18 @@
  *  under the License.
  */
 
-
 package org.apache.isis.runtimes.dflt.objectstores.sql.auto;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.objectstores.sql.AbstractMapper;
 import org.apache.isis.runtimes.dflt.objectstores.sql.CollectionMapper;
 import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
@@ -32,43 +38,34 @@ import org.apache.isis.runtimes.dflt.obj
 import org.apache.isis.runtimes.dflt.objectstores.sql.Sql;
 import org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.JdbcObjectReferenceMapping;
 import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.ObjectReferenceMapping;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.runtime.persistence.PersistorUtil;
 import org.apache.log4j.Logger;
 
-
 public class AutoCollectionMapper extends AbstractMapper implements CollectionMapper {
     private static final Logger LOG = Logger.getLogger(AutoCollectionMapper.class);
     private String tableName;
-    private ObjectAssociation field;
-    private ObjectReferenceMapping elementMapping;
-    private IdMapping idMapping;
-
-    public AutoCollectionMapper(
-            final ObjectSpecification specification,
-            final ObjectAssociation field,
-            final FieldMappingLookup lookup) {
+    private final ObjectAssociation field;
+    private final ObjectReferenceMapping elementMapping;
+    private final IdMapping idMapping;
+
+    public AutoCollectionMapper(final ObjectSpecification specification, final ObjectAssociation field,
+        final FieldMappingLookup lookup) {
         this.field = field;
 
-        ObjectSpecification spec = field.getFacet(TypeOfFacet.class).valueSpec();
+        final ObjectSpecification spec = field.getFacet(TypeOfFacet.class).valueSpec();
         idMapping = lookup.createIdMapping();
         elementMapping = lookup.createMapping(spec);
 
-        String className = specification.getShortIdentifier();
-        String columnName = field.getId();
+        final String className = specification.getShortIdentifier();
+        final String columnName = field.getId();
         tableName = Sql.sqlName(className) + "_" + asSqlName(columnName);
         tableName = Sql.identifier(tableName);
     }
 
+    @Override
     public void createTables(final DatabaseConnector connector) {
         if (!connector.hasTable(tableName)) {
-            StringBuffer sql = new StringBuffer();
+            final StringBuffer sql = new StringBuffer();
             sql.append("create table ");
             sql.append(tableName);
             sql.append(" (");
@@ -83,13 +80,14 @@ public class AutoCollectionMapper extend
         }
     }
 
+    @Override
     public void loadInternalCollection(final DatabaseConnector connector, final ObjectAdapter parent) {
-        ObjectAdapter collection = (ObjectAdapter) field.get(parent);
+        final ObjectAdapter collection = field.get(parent);
         if (collection.getResolveState().canChangeTo(ResolveState.RESOLVING)) {
             LOG.debug("loading internal collection " + field);
             collection.changeState(ResolveState.RESOLVING);
-            
-            StringBuffer sql = new StringBuffer();
+
+            final StringBuffer sql = new StringBuffer();
             sql.append("select ");
             idMapping.appendColumnNames(sql);
             sql.append(", ");
@@ -97,26 +95,28 @@ public class AutoCollectionMapper extend
             sql.append(" from ");
             sql.append(tableName);
 
-            Results rs = connector.select(sql.toString());
-            List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
+            final Results rs = connector.select(sql.toString());
+            final List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
             while (rs.next()) {
-                ObjectAdapter element = ((JdbcObjectReferenceMapping) elementMapping).initializeField(rs);
+                final ObjectAdapter element = ((JdbcObjectReferenceMapping) elementMapping).initializeField(rs);
                 LOG.debug("  element  " + element.getOid());
                 list.add(element);
             }
-            CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
+            final CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
             collectionFacet.init(collection, list.toArray(new ObjectAdapter[list.size()]));
             rs.close();
             PersistorUtil.end(collection);
         }
     }
 
+    @Override
     public boolean needsTables(final DatabaseConnector connector) {
         return !connector.hasTable(tableName);
     }
 
+    @Override
     public void saveInternalCollection(final DatabaseConnector connector, final ObjectAdapter parent) {
-        ObjectAdapter collection = (ObjectAdapter) field.get(parent);
+        final ObjectAdapter collection = field.get(parent);
         LOG.debug("saving internal collection " + collection);
 
         StringBuffer sql = new StringBuffer();
@@ -137,15 +137,16 @@ public class AutoCollectionMapper extend
         idMapping.appendInsertValues(connector, sql, parent);
         sql.append(", ");
 
-        CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
-        for (ObjectAdapter element : collectionFacet.iterable(collection)) {
-            StringBuffer values = new StringBuffer();
+        final CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
+        for (final ObjectAdapter element : collectionFacet.iterable(collection)) {
+            final StringBuffer values = new StringBuffer();
             elementMapping.appendInsertValues(connector, values, element);
             connector.update(sql.toString() + values + ")");
         }
     }
-     
-    public void debugData(DebugBuilder debug) {
+
+    @Override
+    public void debugData(final DebugBuilder debug) {
         debug.appendln(field.getName(), "collection");
         debug.indent();
         debug.appendln("Table", tableName);



Mime
View raw message