incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1169896 - in /incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql: sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsyst...
Date Mon, 12 Sep 2011 19:44:20 GMT
Author: kevin
Date: Mon Sep 12 19:44:19 2011
New Revision: 1169896

URL: http://svn.apache.org/viewvc?rev=1169896&view=rev
Log:
ISIS-118: Collections can now handle polymorphic types, including classes. For real, this
time!

Modified:
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.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/auto/ForeignKeyCollectionMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyInChildCollectionMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ReversedAutoAssociationMapper.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolyBaseClass.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassOne.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassThree.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassTwo.java
    incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.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/AbstractAutoMapper.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/AbstractAutoMapper.java
Mon Sep 12 19:44:19 2011
@@ -66,6 +66,17 @@ public abstract class AbstractAutoMapper
         this.objectMapperLookup = objectMapperLookup;
     }
 
+    protected AbstractAutoMapper(final FieldMappingLookup lookup, final AbstractAutoMapper
abstractAutoMapper,
+        String className) {
+
+        this.className = className;
+        specification = IsisContext.getSpecificationLoader().loadSpecification(className);
+
+        this.parameterBase = null;
+        this.lookup = null;
+        this.objectMapperLookup = null;
+    }
+
     protected void setUpFieldMappers() {
         setUpFieldMappers(lookup, objectMapperLookup, className, parameterBase);
     }
@@ -98,7 +109,7 @@ public abstract class AbstractAutoMapper
             // setupSpecifiedMapping(specification, configParameters, parameterBase);
         }
 
-        LOG.info("table mapping: " + table + " (" + columnList() + ")");
+        LOG.info("table mapping: " + table + " (" + columnList(fieldMappings) + ")");
     }
 
     protected String getTableNameFromSpecification(ObjectSpecification objectSpecification)
{
@@ -171,9 +182,11 @@ public abstract class AbstractAutoMapper
                                     oneToManyProperties[collectionFieldNo], parameterBase,
lookup, objectMapperLookup,
                                     this, field);
                         } else {
-                            collectionMapper =
+                            ForeignKeyInChildCollectionMapper mapper =
                                 new ForeignKeyInChildCollectionMapper(oneToManyProperties[collectionFieldNo],
                                     parameterBase, lookup, objectMapperLookup, this, field);
+                            mapper.setUpFieldMappers();
+                            collectionMapper = mapper;
                         }
                     }
 
@@ -238,7 +251,7 @@ public abstract class AbstractAutoMapper
      * 
      * throw new NotYetImplementedException(); } } }
      */
-    protected String columnList() {
+    protected String columnList(List<FieldMapping> fieldMappings) {
         final StringBuffer sql = new StringBuffer();
         for (final FieldMapping mapping : fieldMappings) {
             if (sql.length() > 0) {

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=1169896&r1=1169895&r2=1169896&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 Sep 12 19:44:19 2011
@@ -71,6 +71,14 @@ public class AutoMapper extends Abstract
         setUpFieldMappers();
     }
 
+    protected VersionMapping getVersionMapping() {
+        return versionMapping;
+    }
+
+    protected IdMapping getIdMapping() {
+        return idMapping;
+    }
+
     @Override
     public void createTables(final DatabaseConnector connection) {
         if (!connection.hasTable(table)) {
@@ -106,7 +114,7 @@ public class AutoMapper extends Abstract
         sql.append("insert into " + table + " (");
         idMapping.appendColumnNames(sql);
         sql.append(", ");
-        final String columnList = columnList();
+        final String columnList = columnList(fieldMappings);
         if (columnList.length() > 0) {
             sql.append(columnList);
             sql.append(", ");
@@ -257,7 +265,7 @@ public class AutoMapper extends Abstract
         sql.append("select ");
         idMapping.appendColumnNames(sql);
         sql.append(", ");
-        final String columnList = columnList();
+        final String columnList = columnList(fieldMappings);
         if (columnList.length() > 0) {
             sql.append(columnList);
             sql.append(", ");
@@ -334,7 +342,7 @@ public class AutoMapper extends Abstract
         LOG.debug("loading data from SQL " + table + " for " + object);
         final StringBuffer sql = new StringBuffer();
         sql.append("select ");
-        sql.append(columnList());
+        sql.append(columnList(fieldMappings));
         sql.append(",");
         sql.append(versionMapping.appendSelectColumns());
         sql.append(" from " + table + " WHERE ");

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyCollectionMapper.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/ForeignKeyCollectionMapper.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyCollectionMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyCollectionMapper.java
Mon Sep 12 19:44:19 2011
@@ -81,6 +81,23 @@ public class ForeignKeyCollectionMapper 
         foreignKeyMapping = lookup.createMapping(columnName, specification);
     }
 
+    protected ForeignKeyCollectionMapper(final FieldMappingLookup lookup, final AbstractAutoMapper
abstractAutoMapper,
+        final ObjectAssociation field) {
+        super(lookup, abstractAutoMapper, field.getSpecification().getFullIdentifier());
+
+        this.field = field;
+        objectMapperLookup2 = null;
+
+        idMapping = lookup.createIdMapping();
+        versionMapping = lookup.createVersionMapping();
+
+        setColumnName(determineColumnName(field));
+        foreignKeyName = Sql.sqlName("fk_" + getColumnName());
+
+        foreignKeyName = Sql.identifier(foreignKeyName);
+        foreignKeyMapping = lookup.createMapping(columnName, specification);
+    }
+
     protected String determineColumnName(final ObjectAssociation objectAssociation) {
         return objectAssociation.getSpecification().getShortIdentifier();
     }
@@ -150,7 +167,7 @@ public class ForeignKeyCollectionMapper 
 
             final List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
 
-            loadCollectionIntoList(connector, parent, makeResolved, list);
+            loadCollectionIntoList(connector, parent, makeResolved, idMapping, fieldMappings,
versionMapping, list);
 
             final CollectionFacet collectionFacet = collection.getSpecification().getFacet(CollectionFacet.class);
             collectionFacet.init(collection, list.toArray(new ObjectAdapter[list.size()]));
@@ -170,13 +187,14 @@ public class ForeignKeyCollectionMapper 
     }
 
     protected void loadCollectionIntoList(final DatabaseConnector connector, final ObjectAdapter
parent,
-        final boolean makeResolved, final List<ObjectAdapter> list) {
+        final boolean makeResolved, final IdMapping idMapping, final List<FieldMapping>
fieldMappings,
+        final VersionMapping versionMapping, final List<ObjectAdapter> list) {
         final StringBuffer sql = new StringBuffer();
         sql.append("select ");
         idMapping.appendColumnNames(sql);
 
         sql.append(", ");
-        final String columnList = columnList();
+        final String columnList = columnList(fieldMappings);
         if (columnList.length() > 0) {
             sql.append(columnList);
             sql.append(", ");
@@ -191,14 +209,15 @@ public class ForeignKeyCollectionMapper 
         while (rs.next()) {
             final Oid oid = idMapping.recreateOid(rs, specification);
             final ObjectAdapter element = getAdapter(specification, oid);
-            loadFields(element, rs, makeResolved);
+            loadFields(element, rs, makeResolved, fieldMappings);
             LOG.debug("  element  " + element.getOid());
             list.add(element);
         }
         rs.close();
     }
 
-    protected void loadFields(final ObjectAdapter object, final Results rs, final boolean
makeResolved) {
+    protected void loadFields(final ObjectAdapter object, final Results rs, final boolean
makeResolved,
+        final List<FieldMapping> fieldMappings) {
         if (object.getResolveState().canChangeTo(ResolveState.RESOLVING)) {
             PersistorUtil.start(object, ResolveState.RESOLVING);
             for (final FieldMapping mapping : fieldMappings) {

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyInChildCollectionMapper.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/ForeignKeyInChildCollectionMapper.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyInChildCollectionMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ForeignKeyInChildCollectionMapper.java
Mon Sep 12 19:44:19 2011
@@ -41,7 +41,8 @@ import org.apache.isis.runtimes.dflt.obj
 public class ForeignKeyInChildCollectionMapper extends ForeignKeyCollectionMapper {
     private static final Logger LOG = Logger.getLogger(ForeignKeyCollectionMapper.class);
 
-    // TODO: Needs to detect if field has subclasses, and to add FK_* column to *all* non-abstract
subclasses.
+    protected final ObjectAssociation priorField; // prevents recursion
+    protected final List<ObjectAssociation> priorFields;
 
     public ForeignKeyInChildCollectionMapper(final ObjectAssociation objectAssociation, final
String parameterBase,
         final FieldMappingLookup lookup, final ObjectMappingLookup objectMapperLookup,
@@ -54,9 +55,12 @@ public class ForeignKeyInChildCollection
         setUpFieldMappers();
     }
 
-    protected final ObjectAssociation priorField; // prevents recursion
-
-    protected final List<ObjectAssociation> priorFields;
+    protected ForeignKeyInChildCollectionMapper(final FieldMappingLookup lookup,
+        final AbstractAutoMapper abstractAutoMapper, final ObjectAssociation field) {
+        super(lookup, abstractAutoMapper, field);
+        priorFields = null;
+        priorField = null;
+    }
 
     @Override
     protected void getExtraFields(List<ObjectAssociation> existingFields) {

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionMapper.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/PolymorphicForeignKeyInChildCollectionMapper.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/PolymorphicForeignKeyInChildCollectionMapper.java
Mon Sep 12 19:44:19 2011
@@ -33,7 +33,10 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.runtimes.dflt.objectstores.sql.DatabaseConnector;
 import org.apache.isis.runtimes.dflt.objectstores.sql.FieldMappingLookup;
+import org.apache.isis.runtimes.dflt.objectstores.sql.IdMapping;
 import org.apache.isis.runtimes.dflt.objectstores.sql.ObjectMappingLookup;
+import org.apache.isis.runtimes.dflt.objectstores.sql.VersionMapping;
+import org.apache.isis.runtimes.dflt.objectstores.sql.mapping.FieldMapping;
 
 /**
  * Used to map 1-to-many collections by creating, in the child table, 1 column per parent
collection. The column is
@@ -49,6 +52,7 @@ public class PolymorphicForeignKeyInChil
     private final ObjectAssociation baseField;
     private final List<String> tables;
     private final List<ObjectSpecification> tableSpecifications;
+    private final List<AutoMapper> subClassMappers;
     // private final String classColumnName;
 
     // For iterating through the subclasses
@@ -58,28 +62,53 @@ public class PolymorphicForeignKeyInChil
     private int currentIndexStart;
     private int currentIndex;
 
+    // Store for passing on to other mappers
+    final String parameterBase;
+    final FieldMappingLookup lookup;
+    final ObjectMappingLookup objectMapperLookup;
+    // final AbstractAutoMapper abstractAutoMapper;
+    // final ObjectAssociation field;
+    final String fieldClassName;
+
     public PolymorphicForeignKeyInChildCollectionMapper(final ObjectAssociation objectAssociation,
         final String parameterBase, final FieldMappingLookup lookup, final ObjectMappingLookup
objectMapperLookup,
-        AbstractAutoMapper abstractAutoMapper, ObjectAssociation field) {
-        super(objectAssociation, parameterBase, lookup, objectMapperLookup, abstractAutoMapper,
field);
+        final AbstractAutoMapper abstractAutoMapper, final ObjectAssociation field) {
 
-        this.baseField = objectAssociation;
-        // classColumnName = Sql.identifier(getForeignKeyName() + "_cls");
+        super(lookup, abstractAutoMapper, field);
+
+        // super(objectAssociation, parameterBase, lookup, objectMapperLookup, abstractAutoMapper,
field);
+        fieldClassName = className;
 
+        baseField = objectAssociation;
         tables = new ArrayList<String>();
         tableSpecifications = new ArrayList<ObjectSpecification>();
+        subClassMappers = new ArrayList<AutoMapper>();
+
+        // Capture for use in creating subclass mappers.
+        this.parameterBase = parameterBase;
+        this.lookup = lookup;
+        this.objectMapperLookup = objectMapperLookup;
+        // this.abstractAutoMapper = abstractAutoMapper;
+        // this.field = field;
+
         addSubSpecificationsToTable(specification);
 
+        // classColumnName = Sql.identifier(getForeignKeyName() + "_cls");
     }
 
     protected void addSubSpecificationsToTable(ObjectSpecification objectSpecification) {
-        for (ObjectSpecification subSpecification : objectSpecification.subclasses()) {
-            if (subSpecification.isAbstract() == false) {
-                final String tableNameFromSpecification = getTableNameFromSpecification(subSpecification);
-                tables.add(tableNameFromSpecification);
-                tableSpecifications.add(subSpecification);
-            }
-            if (subSpecification.hasSubclasses()) {
+        if (objectSpecification.isAbstract() == false) {
+            final String tableNameFromSpecification = getTableNameFromSpecification(objectSpecification);
+            tables.add(tableNameFromSpecification);
+            tableSpecifications.add(objectSpecification);
+
+            // setUpFieldMappers();
+            AutoMapper autoMapper =
+                new AutoMapper(objectSpecification.getFullIdentifier(), parameterBase, lookup,
objectMapperLookup);
+            subClassMappers.add(autoMapper);
+        }
+        if (objectSpecification.hasSubclasses()) {
+            for (ObjectSpecification subSpecification : objectSpecification.subclasses())
{
                 addSubSpecificationsToTable(subSpecification);
             }
         }
@@ -199,15 +228,20 @@ public class PolymorphicForeignKeyInChil
 
     @Override
     protected void loadCollectionIntoList(final DatabaseConnector connector, final ObjectAdapter
parent,
-        final boolean makeResolved, final List<ObjectAdapter> superList) {
+        final boolean makeResolved, final IdMapping idMapping, final List<FieldMapping>
fieldMappings,
+        final VersionMapping versionMapping, final List<ObjectAdapter> superList) {
         // TODO: Polymorphism: save instances to appropriate subclass tables
         final List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
         for (int i = 0; i < tables.size(); i++) {
             currentTableSpecification = tableSpecifications.get(i);
+
+            AutoMapper mapper = subClassMappers.get(i);
+
             specification = currentTableSpecification;
 
             table = tables.get(i);
-            super.loadCollectionIntoList(connector, parent, makeResolved, list);
+            super.loadCollectionIntoList(connector, parent, makeResolved, mapper.getIdMapping(),
mapper.fieldMappings,
+                mapper.getVersionMapping(), list);
 
             superList.addAll(list);
             list.clear();

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ReversedAutoAssociationMapper.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/ReversedAutoAssociationMapper.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ReversedAutoAssociationMapper.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-impl/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/auto/ReversedAutoAssociationMapper.java
Mon Sep 12 19:44:19 2011
@@ -96,7 +96,7 @@ public class ReversedAutoAssociationMapp
             sql.append("select ");
             idMapping.appendColumnNames(sql);
             sql.append(", ");
-            sql.append(columnList());
+            sql.append(columnList(fieldMappings));
             sql.append(" from ");
             sql.append(table);
             sql.append(" where ");
@@ -154,7 +154,7 @@ public class ReversedAutoAssociationMapp
         sql.append("insert into " + table + " (");
         idMapping.appendColumnNames(sql);
         sql.append(", ");
-        final String columnList = columnList();
+        final String columnList = columnList(fieldMappings);
         if (columnList.length() > 0) {
             sql.append(columnList);
             sql.append(", ");

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolyBaseClass.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolyBaseClass.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolyBaseClass.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolyBaseClass.java
Mon Sep 12 19:44:19 2011
@@ -30,18 +30,18 @@ import org.apache.isis.applib.AbstractDo
  */
 public abstract class PolyBaseClass extends AbstractDomainObject {
     public String title() {
-        return string;
+        return stringBase;
     }
 
     // {{ String type
-    private String string;
+    private String stringBase;
 
-    public String getString() {
-        return string;
+    public String getStringBase() {
+        return stringBase;
     }
 
-    public void setString(final String string) {
-        this.string = string;
+    public void setStringBase(final String string) {
+        this.stringBase = string;
     }
 
     // }}

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassOne.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassOne.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassOne.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassOne.java
Mon Sep 12 19:44:19 2011
@@ -22,7 +22,6 @@
  */
 package org.apache.isis.runtimes.dflt.objectstores.sql.testsystem.dataclasses.polymorphism;
 
-
 /**
  * @author Kevin
  * 
@@ -30,20 +29,18 @@ package org.apache.isis.runtimes.dflt.ob
 public class PolySubClassOne extends PolyBaseClass {
     @Override
     public String title() {
-        return string;
+        return stringOne;
     }
 
     // {{ String type
-    private String string;
+    private String stringOne;
 
-    @Override
-    public String getString() {
-        return string;
+    public String getStringClassOne() {
+        return stringOne;
     }
 
-    @Override
-    public void setString(final String string) {
-        this.string = string;
+    public void setStringClassOne(final String string) {
+        this.stringOne = string;
     }
 
     // }}

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassThree.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassThree.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassThree.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassThree.java
Mon Sep 12 19:44:19 2011
@@ -31,11 +31,11 @@ public class PolySubClassThree extends P
     // {{ String type
     private String string;
 
-    public String getAnotherString() {
+    public String getStringClassThree() {
         return string;
     }
 
-    public void setAnotherString(final String string) {
+    public void setStringClassThree(final String string) {
         this.string = string;
     }
 

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassTwo.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassTwo.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassTwo.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/main/java/org/apache/isis/runtimes/dflt/objectstores/sql/testsystem/dataclasses/polymorphism/PolySubClassTwo.java
Mon Sep 12 19:44:19 2011
@@ -29,22 +29,19 @@ package org.apache.isis.runtimes.dflt.ob
 public class PolySubClassTwo extends PolyBaseClass {
     @Override
     public String title() {
-        return string;
+        return stringClassTwo;
     }
 
     // {{ String type
-    private String string;
+    private String stringClassTwo;
 
-    @Override
-    public String getString() {
-        return string;
+    public String getStringClassTwo() {
+        return stringClassTwo;
     }
 
-    @Override
-    public void setString(final String string) {
-        this.string = string;
+    public void setStringClassTwo(final String string) {
+        this.stringClassTwo = string;
     }
-
     // }}
 
 }

Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java?rev=1169896&r1=1169895&r2=1169896&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java
(original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/sql/sql-tests-common/src/test/java/org/apache/isis/runtimes/dflt/objectstores/sql/PolymorphismTest.java
Mon Sep 12 19:44:19 2011
@@ -126,14 +126,17 @@ public class PolymorphismTest extends Sq
 
         // setup the polyTestClass
         PolySubClassOne polySubClassOne = factory.newPolySubClassOne();
-        polySubClassOne.setString("PolySubClassOne 1");
+        polySubClassOne.setStringBase("PolySubClassOne 1");
+        polySubClassOne.setStringClassOne("Class 1");
 
         PolySubClassTwo polySubClassTwo = factory.newPolySubClassTwo();
-        polySubClassTwo.setString("PolySubClassTwo 1");
+        polySubClassTwo.setStringBase("PolySubClassTwo 1");
+        polySubClassTwo.setStringClassTwo("Class 2");
 
         PolySubClassThree polySubClassThree = factory.newPolySubClassThree();
-        polySubClassThree.setString("PolySubClassThree 1");
-        polySubClassThree.setAnotherString("Another String");
+        polySubClassThree.setStringBase("PolySubClassThree 1");
+        polySubClassThree.setStringClassThree("Another String");
+        polySubClassThree.setStringClassTwo("Class 3");
 
         polyTestClass.getPolyBaseClasses().add(polySubClassOne);
         polyTestClass.getPolyBaseClasses().add(polySubClassTwo);
@@ -169,15 +172,29 @@ public class PolymorphismTest extends Sq
         final PolyTestClass polyTestClass = SqlIntegrationTestSingleton.getStaticPolyTestClass();
 
         List<PolyBaseClass> polyBaseClasses = polyTestClass.getPolyBaseClasses();
-        // TODO Polymorphism test temporary disabled
         assertEquals(3, polyBaseClasses.size());
 
+        PolyBaseClass polyClassBase = polyBaseClasses.get(0);
+        assertTrue(polyClassBase instanceof PolySubClassOne);
+        assertEquals("PolySubClassOne 1", polyClassBase.getStringBase());
+        final PolySubClassOne polySubClassOne = (PolySubClassOne) polyClassBase;
+        assertEquals("Class 1", polySubClassOne.getStringClassOne());
+
+        polyClassBase = polyBaseClasses.get(1);
+        assertTrue(polyClassBase instanceof PolySubClassTwo);
+        final PolySubClassTwo polySubClassTwo = (PolySubClassTwo) polyClassBase;
+        assertEquals("Class 2", polySubClassTwo.getStringClassTwo());
+
+        polyClassBase = polyBaseClasses.get(2);
+        assertTrue(polyClassBase instanceof PolySubClassThree);
+        final PolySubClassThree polySubClassThree = (PolySubClassThree) polyClassBase;
+        assertEquals("Class 3", polySubClassThree.getStringClassTwo());
+        assertEquals("Another String", polySubClassThree.getStringClassThree());
     }
 
     public void testInterfaceLoad() {
         final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
         final PolyTestClass polyTestClass = SqlIntegrationTestSingleton.getStaticPolyTestClass();
-        // assertEquals(polyTestClass.getClass(), polyTestClass.getPolyTestInterface().getClass());
 
         PolyInterface loaded = polyTestClass.getPolyInterfaceType();
         factory.resolve(loaded);



Mime
View raw message