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/lib xdoclet-ojb-module-1.2.1.jar
Date Tue, 29 Jun 2004 17:00:45 GMT
tomdz       2004/06/29 10:00:45

  Modified:    src/xdoclet/java/src/xdoclet/modules/ojb/model
                        ClassDescriptorDef.java
               src/xdoclet/test/xdoclet/modules/ojb/tests
                        ReferenceTagClassRefAttributeTests.java
               lib      xdoclet-ojb-module-1.2.1.jar
  Log:
  Fixed bug where the same persistent feature was inherited from multiple direct base types
(a side-effect of the last bug-fix)
  
  Revision  Changes    Path
  1.7       +49 -11    db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java
  
  Index: ClassDescriptorDef.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ClassDescriptorDef.java	5 Apr 2004 00:32:30 -0000	1.6
  +++ ClassDescriptorDef.java	29 Jun 2004 17:00:45 -0000	1.7
  @@ -284,7 +284,26 @@
               baseTypes.add(baseDef);
           }
       }
  -    
  +
  +    /**
  +     * Determines whether the given list contains a descriptor with the same name.
  +     * 
  +     * @param defs The list to search
  +     * @param obj  The object that is searched for
  +     * @return <code>true</code> if the list contains a descriptor with the
same name
  +     */
  +    private boolean contains(ArrayList defs, DefBase obj)
  +    {
  +        for (Iterator it = defs.iterator(); it.hasNext();)
  +        {
  +            if (obj.getName().equals(((DefBase)it.next()).getName()))
  +            {
  +                return true;
  +            }
  +        }
  +        return false;
  +    }
  +
       /**
        * Clones the features of the given base class (using modifications if available) and
puts them into
        * the given lists.
  @@ -305,20 +324,29 @@
           for (Iterator fieldIt = baseDef.getFields(); fieldIt.hasNext();)
           {
               copyFieldDef = cloneField((FieldDescriptorDef)fieldIt.next(), null);
  -            copyFieldDef.setInherited();
  -            newFields.add(copyFieldDef);
  +            if (!contains(newFields, copyFieldDef))
  +            {
  +                copyFieldDef.setInherited();
  +                newFields.add(copyFieldDef);
  +            }
           }
           for (Iterator refIt = baseDef.getReferences(); refIt.hasNext();)
           {
               copyRefDef = cloneReference((ReferenceDescriptorDef)refIt.next(), null);
  -            copyRefDef.setInherited();
  -            newReferences.add(copyRefDef);
  +            if (!contains(newReferences, copyRefDef))
  +            {
  +                copyRefDef.setInherited();
  +                newReferences.add(copyRefDef);
  +            }
           }
           for (Iterator collIt = baseDef.getCollections(); collIt.hasNext();)
           {
               copyCollDef = cloneCollection((CollectionDescriptorDef)collIt.next(), null);
  -            copyCollDef.setInherited();
  -            newCollections.add(copyCollDef);
  +            if (!contains(newCollections, copyCollDef))
  +            {
  +                copyCollDef.setInherited();
  +                newCollections.add(copyCollDef);
  +            }
           }
       }
   
  @@ -343,12 +371,19 @@
           for (Iterator fieldIt = nestedClassDef.getFields(); fieldIt.hasNext();)
           {
               copyFieldDef = cloneField((FieldDescriptorDef)fieldIt.next(), prefix);
  -            copyFieldDef.setNested();
  -            newFields.add(copyFieldDef);
  +            if (!contains(newFields, copyFieldDef))
  +            {
  +                copyFieldDef.setNested();
  +                newFields.add(copyFieldDef);
  +            }
           }
           for (Iterator refIt = nestedClassDef.getReferences(); refIt.hasNext();)
           {
               copyRefDef = cloneReference((ReferenceDescriptorDef)refIt.next(), prefix);
  +            if (contains(newReferences, copyRefDef))
  +            {
  +                continue;
  +            }
               copyRefDef.setNested();
   
               // we have to modify the foreignkey setting as it specifies a field of the
same (nested) class
  @@ -369,8 +404,11 @@
           for (Iterator collIt = nestedClassDef.getCollections(); collIt.hasNext();)
           {
               copyCollDef = cloneCollection((CollectionDescriptorDef)collIt.next(), prefix);
  -            copyCollDef.setNested();
  -            newCollections.add(copyCollDef);
  +            if (!contains(newCollections, copyCollDef))
  +            {
  +                copyCollDef.setNested();
  +                newCollections.add(copyCollDef);
  +            }
           }
       }
   
  
  
  
  1.6       +44 -4     db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ReferenceTagClassRefAttributeTests.java
  
  Index: ReferenceTagClassRefAttributeTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ReferenceTagClassRefAttributeTests.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReferenceTagClassRefAttributeTests.java	28 Jun 2004 20:42:19 -0000	1.5
  +++ ReferenceTagClassRefAttributeTests.java	29 Jun 2004 17:00:45 -0000	1.6
  @@ -894,7 +894,7 @@
               "test.B",
               "package test;\n"+
               "/** @ojb.class table=\"A\" */\n"+
  -            "public class B implements A {\n"+
  +            "public abstract class B implements A {\n"+
               "  private Integer id;\n"+
               "  private String ojbConcreteClass;\n"+
               "  public Integer getId() {\n"+
  @@ -907,8 +907,16 @@
           addClass(
               "test.C",
               "package test;\n"+
  +            "/** @ojb.class table=\"A\" */\n"+
  +            "public class C extends B {\n"+
  +            "  /** @ojb.field length=\"254\" */\n"+
  +            "  private String value;\n"+
  +            "}\n");
  +        addClass(
  +            "test.D",
  +            "package test;\n"+
               "/** @ojb.class */\n"+
  -            "public class C {\n"+
  +            "public class D {\n"+
               "  /** @ojb.field primarykey=\"true\" */\n"+
               "  private Integer id;\n"+
               "  /** @ojb.field */\n"+
  @@ -942,6 +950,7 @@
               "    class=\"test.B\"\n"+
               "    table=\"A\"\n"+
               ">\n"+
  +            "    <extent-class class-ref=\"test.C\"/>\n"+
               "    <field-descriptor\n"+
               "        name=\"id\"\n"+
               "        column=\"id\"\n"+
  @@ -959,7 +968,33 @@
               "</class-descriptor>\n"+
               "<class-descriptor\n"+
               "    class=\"test.C\"\n"+
  -            "    table=\"C\"\n"+
  +            "    table=\"A\"\n"+
  +            ">\n"+
  +            "    <field-descriptor\n"+
  +            "        name=\"id\"\n"+
  +            "        column=\"id\"\n"+
  +            "        jdbc-type=\"INTEGER\"\n"+
  +            "        primarykey=\"true\"\n"+
  +            "    >\n"+
  +            "    </field-descriptor>\n"+
  +            "    <field-descriptor\n"+
  +            "        name=\"ojbConcreteClass\"\n"+
  +            "        column=\"ojbConcreteClass\"\n"+
  +            "        jdbc-type=\"VARCHAR\"\n"+
  +            "        length=\"254\"\n"+
  +            "    >\n"+
  +            "    </field-descriptor>\n"+
  +            "    <field-descriptor\n"+
  +            "        name=\"value\"\n"+
  +            "        column=\"value\"\n"+
  +            "        jdbc-type=\"VARCHAR\"\n"+
  +            "        length=\"254\"\n"+
  +            "    >\n"+
  +            "    </field-descriptor>\n"+
  +            "</class-descriptor>\n"+
  +            "<class-descriptor\n"+
  +            "    class=\"test.D\"\n"+
  +            "    table=\"D\"\n"+
               ">\n"+
               "    <field-descriptor\n"+
               "        name=\"id\"\n"+
  @@ -996,8 +1031,13 @@
               "                type=\"VARCHAR\"\n"+
               "                size=\"254\"\n"+
               "        />\n"+
  +            "        <column name=\"value\"\n"+
  +            "                javaName=\"value\"\n"+
  +            "                type=\"VARCHAR\"\n"+
  +            "                size=\"254\"\n"+
  +            "        />\n"+
               "    </table>\n"+
  -            "    <table name=\"C\">\n"+
  +            "    <table name=\"D\">\n"+
               "        <column name=\"id\"\n"+
               "                javaName=\"id\"\n"+
               "                type=\"INTEGER\"\n"+
  
  
  
  1.3       +72 -62    db-ojb/lib/xdoclet-ojb-module-1.2.1.jar
  
  	<<Binary file>>
  
  

---------------------------------------------------------------------
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