db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests ModifyInheritedTagIgnoreAttributeTests.java
Date Fri, 17 Sep 2004 20:36:52 GMT
tomdz       2004/09/17 13:36:52

  Modified:    src/xdoclet/java/src/xdoclet/modules/ojb/constraints
                        ModelConstraints.java
               lib      xdoclet-ojb-module-1.2.1.jar
               src/xdoclet/test/xdoclet/modules/ojb/tests
                        ModifyInheritedTagIgnoreAttributeTests.java
  Log:
  Fixed bug that resulted in constraints checking for references/collections in classes where
they are ignored
  
  Revision  Changes    Path
  1.8       +16 -8     db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java
  
  Index: ModelConstraints.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ModelConstraints.java	8 Jul 2004 23:05:41 -0000	1.7
  +++ ModelConstraints.java	17 Sep 2004 20:36:52 -0000	1.8
  @@ -72,13 +72,16 @@
               for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
               {
                   collDef = (CollectionDescriptorDef)collIt.next();
  -                if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
  +                if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
                   {
  -                    checkIndirectionTable(modelDef, collDef);
  -                }
  -                else
  -                {    
  -                    checkCollectionForeignkeys(modelDef, collDef);
  +                    if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
  +                    {
  +                        checkIndirectionTable(modelDef, collDef);
  +                    }
  +                    else
  +                    {    
  +                        checkCollectionForeignkeys(modelDef, collDef);
  +                    }
                   }
               }
           }
  @@ -294,14 +297,19 @@
               return;
           }
   
  -        ClassDescriptorDef classDef;
  +        ClassDescriptorDef     classDef;
  +        ReferenceDescriptorDef refDef;
   
           for (Iterator it = modelDef.getClasses(); it.hasNext();)
           {
               classDef = (ClassDescriptorDef)it.next();
               for (Iterator refIt = classDef.getReferences(); refIt.hasNext();)
               {
  -                checkReferenceForeignkeys(modelDef, (ReferenceDescriptorDef)refIt.next());
  +                refDef = (ReferenceDescriptorDef)refIt.next();
  +                if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
  +                {
  +                    checkReferenceForeignkeys(modelDef, refDef);
  +                }
               }
           }
       }
  
  
  
  1.5       +117 -125  db-ojb/lib/xdoclet-ojb-module-1.2.1.jar
  
  	<<Binary file>>
  
  
  1.5       +94 -0     db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ModifyInheritedTagIgnoreAttributeTests.java
  
  Index: ModifyInheritedTagIgnoreAttributeTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ModifyInheritedTagIgnoreAttributeTests.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ModifyInheritedTagIgnoreAttributeTests.java	5 Apr 2004 12:16:16 -0000	1.4
  +++ ModifyInheritedTagIgnoreAttributeTests.java	17 Sep 2004 20:36:52 -0000	1.5
  @@ -533,4 +533,98 @@
               "</database>",
               runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
       }
  +
  +    // Test: ignoring a reference and its foreignkey field from a direct base class
  +    public void testIgnore9()
  +    {
  +        addClass(
  +            "test.A",
  +            "package test;\n"+
  +            "/** @ojb.class */\n" +
  +            "public class A {\n"+
  +            "  /** @ojb.field */\n"+
  +            "  private int cid;\n"+
  +            "  /** @ojb.reference foreignkey=\"cid\" */\n"+
  +            "  private C c;\n"+
  +            "}");
  +        addClass(
  +            "test.B",
  +            "package test;\n"+
  +            "/** @ojb.class\n" +
  +            "  * @ojb.modify-inherited name=\"c\"\n"+
  +            "  *                       ignore=\"true\"\n"+
  +            "  * @ojb.modify-inherited name=\"cid\"\n"+
  +            "  *                       ignore=\"true\"\n"+
  +            "  */\n"+
  +            "public class B extends A {}\n");
  +        addClass(
  +            "test.C",
  +            "package test;\n"+
  +            "/** @ojb.class */\n" +
  +            "public class C {\n"+
  +            "  /** @ojb.field primarykey=\"true\" */\n"+
  +            "  private int id;\n"+
  +            "}");
  +
  +        assertEqualsOjbDescriptorFile(
  +            "<class-descriptor\n"+
  +            "    class=\"test.A\"\n"+
  +            "    table=\"A\"\n"+
  +            ">\n"+
  +            "    <extent-class class-ref=\"test.B\"/>\n"+
  +            "    <field-descriptor\n"+
  +            "        name=\"cid\"\n"+
  +            "        column=\"cid\"\n"+
  +            "        jdbc-type=\"INTEGER\"\n"+
  +            "    >\n"+
  +            "    </field-descriptor>\n"+
  +            "    <reference-descriptor\n"+
  +            "        name=\"c\"\n"+
  +            "        class-ref=\"test.C\"\n"+
  +            "    >\n"+
  +            "        <foreignkey field-ref=\"cid\"/>\n"+
  +            "    </reference-descriptor>\n"+
  +            "</class-descriptor>\n"+
  +            "<class-descriptor\n"+
  +            "    class=\"test.B\"\n"+
  +            "    table=\"B\"\n"+
  +            ">\n"+
  +            "</class-descriptor>\n"+
  +            "<class-descriptor\n"+
  +            "    class=\"test.C\"\n"+
  +            "    table=\"C\"\n"+
  +            ">\n"+
  +            "    <field-descriptor\n"+
  +            "        name=\"id\"\n"+
  +            "        column=\"id\"\n"+
  +            "        jdbc-type=\"INTEGER\"\n"+
  +            "        primarykey=\"true\"\n"+
  +            "    >\n"+
  +            "    </field-descriptor>\n"+
  +            "</class-descriptor>",
  +            runOjbXDoclet(OJB_DEST_FILE));
  +        assertEqualsTorqueSchemaFile(
  +            "<database name=\"ojbtest\">\n"+
  +            "    <table name=\"A\">\n"+
  +            "        <column name=\"cid\"\n"+
  +            "                javaName=\"cid\"\n"+
  +            "                type=\"INTEGER\"\n"+
  +            "        />\n"+
  +            "        <foreign-key foreignTable=\"C\">\n"+
  +            "            <reference local=\"cid\" foreign=\"id\"/>\n"+
  +            "        </foreign-key>\n"+
  +            "    </table>\n"+
  +            "    <table name=\"B\">\n"+
  +            "    </table>\n"+
  +            "    <table name=\"C\">\n"+
  +            "        <column name=\"id\"\n"+
  +            "                javaName=\"id\"\n"+
  +            "                type=\"INTEGER\"\n"+
  +            "                primaryKey=\"true\"\n"+
  +            "                required=\"true\"\n"+
  +            "        />\n"+
  +            "    </table>\n"+
  +            "</database>",
  +            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message