tomdz 2005/06/19 06:53:34
Modified: src/xdoclet/test/xdoclet/modules/ojb/tests
AnonymousFieldTagTests.java
ReferenceTagClassRefAttributeTests.java
CollectionTagElementClassRefAttributeTests.java
ClassTagSimpleTests.java
CollectionTagAttributesAttributeTests.java
src/xdoclet/java/src/xdoclet/modules/ojb/constraints
ReferenceDescriptorConstraints.java
CollectionDescriptorConstraints.java
FieldDescriptorConstraints.java
InheritanceHelper.java
ClassDescriptorConstraints.java
ModelConstraints.java
src/xdoclet/java/src/xdoclet/modules/ojb/model ModelDef.java
TorqueModelDef.java ClassDescriptorDef.java
CollectionDescriptorDef.java
lib xdoclet-ojb-module-1.2.3.jar
Log:
Fixed handling of inner/nested classes
Revision Changes Path
1.6 +2 -1
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/AnonymousFieldTagTests.java
Index: AnonymousFieldTagTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/AnonymousFieldTagTests.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AnonymousFieldTagTests.java 17 Nov 2004 21:20:36 -0000 1.5
+++ AnonymousFieldTagTests.java 19 Jun 2005 13:53:33 -0000 1.6
@@ -37,7 +37,8 @@
"package test;\n"+
"/** @ojb.class\n" +
" * @ojb.field name=\"attr\"\n"+
- " * jdbc-type=\"INTEGER\""+
" */\n"+
+ " * jdbc-type=\"INTEGER\"\n"+
+ " */\n"+
"public class A {}\n");
assertEqualsOjbDescriptorFile(
1.8 +153 -0
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ReferenceTagClassRefAttributeTests.java 22 Mar 2005 21:30:39 -0000
1.7
+++ ReferenceTagClassRefAttributeTests.java 19 Jun 2005 13:53:33 -0000
1.8
@@ -1069,4 +1069,157 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
+
+ // Test: no class-ref attribute specified, type of variable is nested
class with ojb.class tag
+ public void testClassRef19()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {\n"+
+ "/** @ojb.field */\n"+
+ " private int attrKey;\n"+
+ "/** @ojb.reference foreignkey=\"attrKey\" */\n"+
+ " private test.B.Inner attr;\n"+
+ "}\n");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public static class Inner {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"attrKey\"\n"+
+ " column=\"attrKey\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <reference-descriptor\n"+
+ " name=\"attr\"\n"+
+ " class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <foreignkey field-ref=\"attrKey\"/>\n"+
+ " </reference-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\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=\"attrKey\"\n"+
+ " javaName=\"attrKey\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"Inner\">\n"+
+ " <reference local=\"attrKey\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\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"));
+ }
+
+ // Test: class-ref attribute points to a persistent inner class and uses
"$"
+ public void testClassRef20()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " }\n"+
+ " /** @ojb.field */\n"+
+ " private int attrKey;\n"+
+ " /** @ojb.reference foreignkey=\"attrKey\"\n"+
+ " * class-ref=\"test.A$Inner\"\n"+
+ " */\n"+
+ " private Object attr;\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"attrKey\"\n"+
+ " column=\"attrKey\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ " <reference-descriptor\n"+
+ " name=\"attr\"\n"+
+ " class-ref=\"test.A$Inner\"\n"+
+ " >\n"+
+ " <foreignkey field-ref=\"attrKey\"/>\n"+
+ " </reference-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.A$Inner\"\n"+
+ " table=\"Inner\"\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=\"attrKey\"\n"+
+ " javaName=\"attrKey\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"Inner\">\n"+
+ " <reference local=\"attrKey\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\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"));
+ }
}
1.7 +160 -0
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagElementClassRefAttributeTests.java
Index: CollectionTagElementClassRefAttributeTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagElementClassRefAttributeTests.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CollectionTagElementClassRefAttributeTests.java 22 Mar 2005 21:30:39
-0000 1.6
+++ CollectionTagElementClassRefAttributeTests.java 19 Jun 2005 13:53:33
-0000 1.7
@@ -758,4 +758,164 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, taskProps,
torqueSubTaskProps));
}
+
+ // Test: value points to a persistent nested class
+ public void testElementClassRef15()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n" +
+ "public class A {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " /** @ojb.collection element-class-ref=\"test.B.Inner\"\n"+
+ " * foreignkey=\"aid\"\n"+
+ " */\n"+
+ " private java.util.List attr;\n"+
+ "}");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field */\n"+
+ " private int aid;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\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"+
+ " <collection-descriptor\n"+
+ " name=\"attr\"\n"+
+ " element-class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <inverse-foreignkey field-ref=\"aid\"/>\n"+
+ " </collection-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"aid\"\n"+
+ " column=\"aid\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"aid\"\n"+
+ " javaName=\"aid\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"A\">\n"+
+ " <reference local=\"aid\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
+
+ // Test: value points to a persistent nested class where the reference
uses "$"
+ public void testElementClassRef16()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n" +
+ "public class A {\n"+
+ " /** @ojb.field primarykey=\"true\" */\n"+
+ " private int id;\n"+
+ " /** @ojb.collection element-class-ref=\"test.B$Inner\"\n"+
+ " * foreignkey=\"aid\"\n"+
+ " */\n"+
+ " private java.util.List attr;\n"+
+ "}");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public class Inner {\n"+
+ " /** @ojb.field */\n"+
+ " private int aid;\n"+
+ " }\n"+
+ "}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\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"+
+ " <collection-descriptor\n"+
+ " name=\"attr\"\n"+
+ " element-class-ref=\"test.B$Inner\"\n"+
+ " >\n"+
+ " <inverse-foreignkey field-ref=\"aid\"/>\n"+
+ " </collection-descriptor>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Inner\"\n"+
+ " table=\"Inner\"\n"+
+ ">\n"+
+ " <field-descriptor\n"+
+ " name=\"aid\"\n"+
+ " column=\"aid\"\n"+
+ " jdbc-type=\"INTEGER\"\n"+
+ " >\n"+
+ " </field-descriptor>\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " <column name=\"id\"\n"+
+ " javaName=\"id\"\n"+
+ " type=\"INTEGER\"\n"+
+ " primaryKey=\"true\"\n"+
+ " required=\"true\"\n"+
+ " />\n"+
+ " </table>\n"+
+ " <table name=\"Inner\">\n"+
+ " <column name=\"aid\"\n"+
+ " javaName=\"aid\"\n"+
+ " type=\"INTEGER\"\n"+
+ " />\n"+
+ " <foreign-key foreignTable=\"A\">\n"+
+ " <reference local=\"aid\" foreign=\"id\"/>\n"+
+ " </foreign-key>\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
}
1.4 +74 -15
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ClassTagSimpleTests.java
Index: ClassTagSimpleTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/ClassTagSimpleTests.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClassTagSimpleTests.java 5 Apr 2004 12:16:17 -0000 1.3
+++ ClassTagSimpleTests.java 19 Jun 2005 13:53:33 -0000 1.4
@@ -55,23 +55,25 @@
public void testSimple2()
{
addClass(
- "A",
+ "test.A",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class A {}\n");
addClass(
- "B",
+ "test.B",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class B extends A {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
- " class=\"A\"\n"+
+ " class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
- " <extent-class class-ref=\"B\"/>\n"+
+ " <extent-class class-ref=\"test.B\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"B\"\n"+
+ " class=\"test.B\"\n"+
" table=\"B\"\n"+
">\n"+
"</class-descriptor>",
@@ -90,39 +92,44 @@
public void testSimple3()
{
addClass(
- "A",
+ "test.A",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class A {}\n");
addClass(
- "B",
+ "test.B",
+ "package test;\n"+
"public class B extends A {}\n");
addClass(
- "C",
+ "test.C",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class C extends B {}\n");
addClass(
- "D",
+ "test.D",
+ "package test;\n"+
"public class D extends C {}\n");
addClass(
- "E",
+ "test.E",
+ "package test;\n"+
"/** @ojb.class */\n"+
"public class E extends D {}\n");
assertEqualsOjbDescriptorFile(
"<class-descriptor\n"+
- " class=\"A\"\n"+
+ " class=\"test.A\"\n"+
" table=\"A\"\n"+
">\n"+
- " <extent-class class-ref=\"C\"/>\n"+
+ " <extent-class class-ref=\"test.C\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"C\"\n"+
+ " class=\"test.C\"\n"+
" table=\"C\"\n"+
">\n"+
- " <extent-class class-ref=\"E\"/>\n"+
+ " <extent-class class-ref=\"test.E\"/>\n"+
"</class-descriptor>\n"+
"<class-descriptor\n"+
- " class=\"E\"\n"+
+ " class=\"test.E\"\n"+
" table=\"E\"\n"+
">\n"+
"</class-descriptor>",
@@ -138,4 +145,56 @@
"</database>",
runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
}
+
+ // Basic test: no attributes, three classes with one a nested class
+ public void testSimple4()
+ {
+ addClass(
+ "test.A",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class A {}\n");
+ addClass(
+ "test.B",
+ "package test;\n"+
+ "public class B {\n"+
+ " /** @ojb.class */\n"+
+ " public static class Nested extends A {}\n"+
+ "}\n");
+ addClass(
+ "test.C",
+ "package test;\n"+
+ "/** @ojb.class */\n"+
+ "public class C extends test.B.Nested {}\n");
+
+ assertEqualsOjbDescriptorFile(
+ "<class-descriptor\n"+
+ " class=\"test.A\"\n"+
+ " table=\"A\"\n"+
+ ">\n"+
+ " <extent-class class-ref=\"test.B$Nested\"/>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.B$Nested\"\n"+
+ " table=\"Nested\"\n"+
+ ">\n"+
+ " <extent-class class-ref=\"test.C\"/>\n"+
+ "</class-descriptor>\n"+
+ "<class-descriptor\n"+
+ " class=\"test.C\"\n"+
+ " table=\"C\"\n"+
+ ">\n"+
+ "</class-descriptor>",
+ runOjbXDoclet(OJB_DEST_FILE));
+ assertEqualsTorqueSchemaFile(
+ "<database name=\"ojbtest\">\n"+
+ " <table name=\"A\">\n"+
+ " </table>\n"+
+ " <table name=\"C\">\n"+
+ " </table>\n"+
+ " <table name=\"Nested\">\n"+
+ " </table>\n"+
+ "</database>",
+ runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
+ }
}
1.4 +1 -1
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagAttributesAttributeTests.java
Index: CollectionTagAttributesAttributeTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagAttributesAttributeTests.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CollectionTagAttributesAttributeTests.java 22 Mar 2005 21:30:39
-0000 1.3
+++ CollectionTagAttributesAttributeTests.java 19 Jun 2005 13:53:33
-0000 1.4
@@ -198,7 +198,7 @@
" private int id;\n"+
"/** @ojb.collection element-class-ref=\"test.B\"\n"+
" * foreignkey=\"aid\"\n"+
- " * attributes=\"a,b=c,d=e\"\n"+
+ " * attributes=\"a,b=c,d=e\"\n"+
" */\n"+
" private java.util.List objs;\n"+
"}\n");
1.5 +3 -1
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java
Index: ReferenceDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ReferenceDescriptorConstraints.java 5 Apr 2004 00:32:30 -0000
1.4
+++ ReferenceDescriptorConstraints.java 19 Jun 2005 13:53:33 -0000
1.5
@@ -73,7 +73,7 @@
ModelDef model =
(ModelDef)ownerClassDef.getOwner();
String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
ClassDescriptorDef targetClassDef = model.getClass(targetClassName);
-
+
if (targetClassDef == null)
{
throw new ConstraintException("The class "+targetClassName+"
referenced by "+refDef.getName()+" in class "+ownerClassDef.getName()+" is
unknown or not persistent");
@@ -113,5 +113,7 @@
throw new ConstraintException("Could not find the class
"+ex.getMessage()+" on the classpath while checking the reference
"+refDef.getName()+" in class "+refDef.getOwner().getName());
}
}
+ // we're adjusting the property to use the classloader-compatible
form
+ refDef.setProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF,
targetClassDef.getName());
}
}
1.6 +4 -1
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java
Index: CollectionDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CollectionDescriptorConstraints.java 22 Mar 2005 21:30:42 -0000
1.5
+++ CollectionDescriptorConstraints.java 19 Jun 2005 13:53:33 -0000
1.6
@@ -113,6 +113,8 @@
throw new ConstraintException("Could not find the class
"+ex.getMessage()+" on the classpath while checking the collection
"+collDef.getName()+" in class "+collDef.getOwner().getName());
}
}
+ // we're adjusting the property to use the classloader-compatible
form
+ collDef.setProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF,
elementClassDef.getName());
}
/**
@@ -237,7 +239,8 @@
}
ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
- ClassDescriptorDef elementClass =
((ModelDef)ownerClass.getOwner()).getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF).replace('$',
'.');
+ ClassDescriptorDef elementClass =
((ModelDef)ownerClass.getOwner()).getClass(elementClassName);
FieldDescriptorDef fieldDef;
String token;
String fieldName;
1.10 +12 -12
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java
Index: FieldDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FieldDescriptorConstraints.java 17 Nov 2004 21:20:36 -0000 1.9
+++ FieldDescriptorConstraints.java 19 Jun 2005 13:53:33 -0000 1.10
@@ -246,9 +246,9 @@
if (defaultLength != null)
{
LogHelper.warn(true,
- FieldDescriptorConstraints.class,
- "ensureLength",
- "The field
"+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no length
setting though its jdbc type requires it (in most databases); using default
length of "+defaultLength);
+ FieldDescriptorConstraints.class,
+ "ensureLength",
+ "The field "+fieldDef.getName()+" in class
"+fieldDef.getOwner().getName()+" has no length setting though its jdbc type
requires it (in most databases); using default length of "+defaultLength);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_LENGTH,
defaultLength);
}
}
@@ -271,9 +271,9 @@
if (defaultPrecision != null)
{
LogHelper.warn(true,
- FieldDescriptorConstraints.class,
- "ensureLength",
- "The field
"+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no
precision setting though its jdbc type requires it (in most databases); using
default precision of "+defaultPrecision);
+ FieldDescriptorConstraints.class,
+ "ensureLength",
+ "The field "+fieldDef.getName()+" in class
"+fieldDef.getOwner().getName()+" has no precision setting though its jdbc type
requires it (in most databases); using default precision of "+defaultPrecision);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION,
defaultPrecision);
}
else if (fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_SCALE))
@@ -288,9 +288,9 @@
if (defaultScale != null)
{
LogHelper.warn(true,
- FieldDescriptorConstraints.class,
- "ensureLength",
- "The field
"+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no scale
setting though its jdbc type requires it (in most databases); using default
scale of "+defaultScale);
+ FieldDescriptorConstraints.class,
+ "ensureLength",
+ "The field "+fieldDef.getName()+" in class
"+fieldDef.getOwner().getName()+" has no scale setting though its jdbc type
requires it (in most databases); using default scale of "+defaultScale);
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_SCALE, defaultScale);
}
else if
(fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_PRECISION) ||
fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_PRECISION))
@@ -403,9 +403,9 @@
if ("database".equals(autoInc) && !"readonly".equals(access))
{
LogHelper.warn(true,
- FieldDescriptorConstraints.class,
- "checkAccess",
- "The field
"+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" is set to
database auto-increment. Therefore the field's access is set to 'readonly'.");
+ FieldDescriptorConstraints.class,
+ "checkAccess",
+ "The field "+fieldDef.getName()+" in class
"+fieldDef.getOwner().getName()+" is set to database auto-increment. Therefore
the field's access is set to 'readonly'.");
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_ACCESS,
"readonly");
}
}
1.4 +8 -6
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/InheritanceHelper.java
Index: InheritanceHelper.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/InheritanceHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InheritanceHelper.java 5 Apr 2004 00:32:30 -0000 1.3
+++ InheritanceHelper.java 19 Jun 2005 13:53:33 -0000 1.4
@@ -57,7 +57,9 @@
*/
public boolean isSameOrSubTypeOf(XClass type, String baseType, boolean
checkActualClasses) throws ClassNotFoundException
{
- if (type.getQualifiedName().equals(baseType))
+ String qualifiedBaseType = baseType.replace('$', '.');
+
+ if (type.getQualifiedName().equals(qualifiedBaseType))
{
return true;
}
@@ -72,7 +74,7 @@
{
curType = (XClass)queue.get(0);
queue.remove(0);
- if (baseType.equals(curType.getQualifiedName()))
+ if (qualifiedBaseType.equals(curType.getQualifiedName()))
{
return true;
}
@@ -93,7 +95,7 @@
}
// if not found, we try via actual classes
- return checkActualClasses ? isSameOrSubTypeOf(type.getName(),
baseType) : false;
+ return checkActualClasses ? isSameOrSubTypeOf(type.getName(),
qualifiedBaseType) : false;
}
/**
@@ -107,7 +109,7 @@
*/
public boolean isSameOrSubTypeOf(ClassDescriptorDef type, String
baseType, boolean checkActualClasses) throws ClassNotFoundException
{
- if (type.getName().equals(baseType))
+ if (type.getQualifiedName().equals(baseType.replace('$', '.')))
{
return true;
}
@@ -131,7 +133,7 @@
*/
public boolean isSameOrSubTypeOf(String type, String baseType) throws
ClassNotFoundException
{
- return type.equals(baseType) ? true :
isSameOrSubTypeOf(getClass(type), baseType);
+ return type.replace('$', '.').equals(baseType.replace('$', '.')) ?
true : isSameOrSubTypeOf(getClass(type), baseType);
}
/**
@@ -144,6 +146,6 @@
*/
public boolean isSameOrSubTypeOf(Class type, String baseType) throws
ClassNotFoundException
{
- return type.getName().equals(baseType) ? true :
getClass(baseType).isAssignableFrom(type);
+ return type.getName().equals(baseType.replace('$', '.')) ? true :
getClass(baseType).isAssignableFrom(type);
}
}
1.8 +1 -3
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java
Index: ClassDescriptorConstraints.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ClassDescriptorConstraints.java 22 Mar 2005 21:30:42 -0000 1.7
+++ ClassDescriptorConstraints.java 19 Jun 2005 13:53:33 -0000 1.8
@@ -209,9 +209,7 @@
{
if (!classDef.hasProperty(PropertyHelper.OJB_PROPERTY_TABLE))
{
- String name = classDef.getName();
-
- classDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE,
name.substring(name.lastIndexOf('.') + 1));
+ classDef.setProperty(PropertyHelper.OJB_PROPERTY_TABLE,
classDef.getDefaultTableName());
}
}
}
1.10 +32 -21
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ModelConstraints.java 22 Mar 2005 21:30:42 -0000 1.9
+++ ModelConstraints.java 19 Jun 2005 13:53:33 -0000 1.10
@@ -107,7 +107,8 @@
*/
private void ensureReferencedPKs(ModelDef modelDef,
ReferenceDescriptorDef refDef) throws ConstraintException
{
- ClassDescriptorDef targetClassDef =
modelDef.getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF));
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ClassDescriptorDef targetClassDef =
modelDef.getClass(targetClassName);
ensurePKsFromHierarchy(targetClassDef);
}
@@ -122,7 +123,8 @@
*/
private void ensureReferencedPKs(ModelDef modelDef,
CollectionDescriptorDef collDef) throws ConstraintException
{
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
String indirTable =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
String localKey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String remoteKey =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
@@ -195,10 +197,11 @@
*/
private void ensureReferencedFKs(ModelDef modelDef,
CollectionDescriptorDef collDef) throws ConstraintException
{
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- String fkFieldNames =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
- ArrayList missingFields = new ArrayList();
- SequencedHashMap fkFields = new SequencedHashMap();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
+ String fkFieldNames =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
+ ArrayList missingFields = new ArrayList();
+ SequencedHashMap fkFields = new SequencedHashMap();
// first we gather all field names
for (CommaListIterator it = new CommaListIterator(fkFieldNames);
it.hasNext();)
@@ -412,8 +415,9 @@
// we know that the class is present because the collection
constraints have been checked already
// TODO: we must check whether there is a collection at the other
side; if the type does not map to a
// table then we have to check its subtypes
- ClassDescriptorDef elementClass =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- CollectionDescriptorDef remoteCollDef =
collDef.getRemoteCollection();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClass =
modelDef.getClass(elementClassName);
+ CollectionDescriptorDef remoteCollDef =
collDef.getRemoteCollection();
if (remoteCollDef == null)
{
@@ -497,9 +501,10 @@
throw new ConstraintException("The collection
"+collDef.getName()+" in class "+collDef.getOwner().getName()+" has no
foreignkeys");
}
- ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
- ArrayList primFields = ownerClass.getPrimaryKeys();
- ArrayList queue = new ArrayList();
+ ClassDescriptorDef ownerClass =
(ClassDescriptorDef)collDef.getOwner();
+ ArrayList primFields = ownerClass.getPrimaryKeys();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ArrayList queue = new ArrayList();
ClassDescriptorDef elementClass;
ArrayList keyFields;
FieldDescriptorDef keyField;
@@ -508,7 +513,7 @@
String keyType;
// we know that the class is present because the collection
constraints have been checked already
-
queue.add(modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF)));
+ queue.add(modelDef.getClass(elementClassName));
while (!queue.isEmpty())
{
elementClass = (ClassDescriptorDef)queue.get(0);
@@ -633,14 +638,15 @@
// for the referenced class and any subtype that is instantiable
(i.e. not an interface or abstract class)
// there must be the same number of primary keys and the jdbc types
of the primary keys must
// match the jdbc types of the foreignkeys (in the correct order)
- ArrayList queue = new ArrayList();
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ArrayList queue = new ArrayList();
ClassDescriptorDef referencedClass;
ArrayList primFields;
FieldDescriptorDef primField;
String primType;
String keyType;
-
queue.add(modelDef.getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF)));
+ queue.add(modelDef.getClass(targetClassName));
while (!queue.isEmpty())
{
@@ -800,20 +806,23 @@
*/
private CollectionDescriptorDef usedByCollection(ModelDef modelDef,
FieldDescriptorDef fieldDef, boolean elementClassSuffices)
{
- ClassDescriptorDef ownerClass =
(ClassDescriptorDef)fieldDef.getOwner();
- String name = fieldDef.getName();
+ ClassDescriptorDef ownerClass =
(ClassDescriptorDef)fieldDef.getOwner();
+ String ownerClassName =
ownerClass.getQualifiedName();
+ String name = fieldDef.getName();
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
+ String elementClassName;
for (Iterator classIt = modelDef.getClasses(); classIt.hasNext();)
{
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator collIt = classDef.getCollections();
collIt.hasNext();)
{
- collDef = (CollectionDescriptorDef)collIt.next();
+ collDef = (CollectionDescriptorDef)collIt.next();
+ elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF).replace('$',
'.');
// if the owner class of the field is the element class of a
normal collection
// and the field is a foreignkey of this collection
- if
(ownerClass.getName().equals(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF)))
+ if (ownerClassName.equals(elementClassName))
{
if
(collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
@@ -843,9 +852,10 @@
*/
private ReferenceDescriptorDef usedByReference(ModelDef modelDef,
FieldDescriptorDef fieldDef)
{
- String ownerClassName =
fieldDef.getOwner().getName();
+ String ownerClassName =
((ClassDescriptorDef)fieldDef.getOwner()).getQualifiedName();
ClassDescriptorDef classDef;
ReferenceDescriptorDef refDef;
+ String targetClassName;
// only relevant for primarykey fields
if
(PropertyHelper.toBoolean(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY),
false))
@@ -855,8 +865,9 @@
classDef = (ClassDescriptorDef)classIt.next();
for (Iterator refIt = classDef.getReferences();
refIt.hasNext();)
{
- refDef = (ReferenceDescriptorDef)refIt.next();
- if
(ownerClassName.equals(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF)))
+ refDef = (ReferenceDescriptorDef)refIt.next();
+ targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF).replace('$', '.');
+ if (ownerClassName.equals(targetClassName))
{
// the field is a primary key of the class
referenced by this reference descriptor
return refDef;
1.6 +8 -4
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ModelDef.java
Index: ModelDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/ModelDef.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ModelDef.java 5 Apr 2004 00:32:31 -0000 1.5
+++ ModelDef.java 19 Jun 2005 13:53:34 -0000 1.6
@@ -47,18 +47,20 @@
*/
public boolean hasClass(String qualifiedName)
{
- return _classDefs.containsKey(qualifiedName);
+ return _classDefs.containsKey(qualifiedName.replace('$', '.'));
}
/**
- * Returns the class descriptor of the given name contained in this
model.
+ * Returns the class descriptor of the given name contained in this
model. The name can be both
+ * a fully qualified name as per java spec or a classloader-compatible
full name (which uses
+ * '$' for inner/nested classes).
*
* @param qualifiedName The qualified name
* @return The class descriptor or <code>null</code> if there is no such
class in this model
*/
public ClassDescriptorDef getClass(String qualifiedName)
{
- return (ClassDescriptorDef)_classDefs.get(qualifiedName);
+ return (ClassDescriptorDef)_classDefs.get(qualifiedName.replace('$',
'.'));
}
/**
@@ -70,7 +72,9 @@
public void addClass(ClassDescriptorDef classDef)
{
classDef.setOwner(this);
- _classDefs.put(classDef.getName(), classDef);
+ // Regardless of the format of the class name, we're using the fully
qualified format
+ // This is safe because of the package & class naming constraints of
the Java language
+ _classDefs.put(classDef.getQualifiedName(), classDef);
}
/**
1.8 +18 -15
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/TorqueModelDef.java
Index: TorqueModelDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/TorqueModelDef.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TorqueModelDef.java 22 Mar 2005 21:30:42 -0000 1.7
+++ TorqueModelDef.java 19 Jun 2005 13:53:34 -0000 1.8
@@ -210,7 +210,8 @@
// local fields = foreignkey fields of the reference
// remote fields = primarykeys of the referenced type
ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)refDef.getOwner();
- ClassDescriptorDef referencedClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF));
+ String targetClassName =
refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
+ ClassDescriptorDef referencedClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(targetClassName);
// we can add a foreignkey only if the target type and all its
subtypes either
// map to the same table or do not map to a table at all
@@ -223,12 +224,12 @@
try
{
- String name = refDef.getName();
- ArrayList localFields =
ownerClassDef.getFields(refDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
- ArrayList remoteFields =
referencedClassDef.getPrimaryKeys();
+ String name = refDef.getName();
+ ArrayList localFields =
ownerClassDef.getFields(refDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
+ ArrayList remoteFields = referencedClassDef.getPrimaryKeys();
tableDef.addForeignkey(name, tableName, getColumns(localFields),
getColumns(remoteFields));
- }
+ }
catch (NoSuchFieldException ex)
{
// won't happen if we already checked the constraints
@@ -255,8 +256,9 @@
// remote table = table of collection owner
// local fields = foreignkey fields in the element type
// remote fields = primarykeys of the collection owner type
- ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
- ClassDescriptorDef elementClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
((ModelDef)ownerClassDef.getOwner()).getClass(elementClassName);
// we can only generate foreignkeys if the collection itself is not
shared by
// several classes in the hierarchy
@@ -319,9 +321,9 @@
elementTableDef.addForeignkey(name, tableDef.getName(),
getColumns(localFields), getColumns(remoteFields));
processedTables.put(elementTableName, null);
}
- }
- catch (NoSuchFieldException ex)
- {
+ }
+ catch (NoSuchFieldException ex)
+ {
// Shouldn't happen, but even if, then we're ignoring it and
simply don't add the fk
}
}
@@ -543,7 +545,8 @@
// remote columns = columns of corresponding primarykeys in
ownerclass/elementclass
ClassDescriptorDef ownerClassDef =
(ClassDescriptorDef)collDef.getOwner();
ModelDef modelDef =
(ModelDef)ownerClassDef.getOwner();
- ClassDescriptorDef elementClassDef =
modelDef.getClass(collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
+ String elementClassName =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClassDef =
modelDef.getClass(elementClassName);
ArrayList localPrimFields = ownerClassDef.getPrimaryKeys();
ArrayList remotePrimFields =
elementClassDef.getPrimaryKeys();
String localKeyList =
collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
@@ -567,7 +570,6 @@
{
fieldDef = (FieldDescriptorDef)localPrimFields.get(idx);
name = localKeys.getNext();
-
columnDef = tableDef.getColumn(name);
if (columnDef == null)
{
@@ -581,14 +583,14 @@
columnDef.setProperty(PropertyHelper.TORQUE_PROPERTY_PRIMARYKEY, "true");
}
if (localKeyDocs.hasNext())
- {
+ {
columnDef.setProperty(PropertyHelper.OJB_PROPERTY_COLUMN_DOCUMENTATION,
localKeyDocs.getNext());
}
localColumns.add(name);
remoteColumns.add(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN));
}
if
(collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY,
true))
- {
+ {
relationName =
collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_RELATION_NAME);
if ((relationName != null) && (ownerTable != null))
{
@@ -624,12 +626,13 @@
}
CollectionDescriptorDef elementCollDef =
collDef.getRemoteCollection();
+
if (((elementCollDef != null) &&
elementCollDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY,
true)) ||
((elementCollDef == null) &&
collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY,
true)))
{
relationName =
collDef.getProperty(PropertyHelper.TORQUE_PROPERTY_INV_RELATION_NAME);
if ((relationName != null) && (elementTable != null))
- {
+ {
tableDef.addForeignkey(relationName, elementTable,
localColumns, remoteColumns);
}
}
1.9 +26 -2
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ClassDescriptorDef.java 22 Mar 2005 21:30:41 -0000 1.8
+++ ClassDescriptorDef.java 19 Jun 2005 13:53:34 -0000 1.9
@@ -25,7 +25,7 @@
/**
* Definition of a class for the ojb repository file.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Dudziak ([EMAIL
PROTECTED])</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Thomas Dudziak</a>
*/
public class ClassDescriptorDef extends DefBase
{
@@ -64,7 +64,7 @@
*/
public ClassDescriptorDef(XClass origin)
{
- super(origin.getQualifiedName());
+ super(origin.getTransformedQualifiedName());
_origin = origin;
}
@@ -79,6 +79,30 @@
}
/**
+ * Returns the qualified name of this class as per Java spec.
+ *
+ * @return The qualified name
+ */
+ public String getQualifiedName()
+ {
+ return getName().replace('$', '.');
+ }
+
+ /**
+ * Returns the default table name for this class which is the
unqualified class name.
+ *
+ * @return The default table name
+ */
+ public String getDefaultTableName()
+ {
+ String name = getName();
+ int lastDotPos = name.lastIndexOf('.');
+ int lastDollarPos = name.lastIndexOf('$');
+
+ return lastDollarPos > lastDotPos ? name.substring(lastDollarPos +
1) : name.substring(lastDotPos + 1);
+ }
+
+ /**
* Determines whether this class descriptor has been processed.
*
* @return <code>true</code> if this class descriptor has been processed
1.7 +7 -6
db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/CollectionDescriptorDef.java
Index: CollectionDescriptorDef.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/java/src/xdoclet/modules/ojb/model/CollectionDescriptorDef.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CollectionDescriptorDef.java 22 Mar 2005 21:30:42 -0000 1.6
+++ CollectionDescriptorDef.java 19 Jun 2005 13:53:34 -0000 1.7
@@ -58,12 +58,13 @@
{
return null;
}
- ModelDef modelDef =
(ModelDef)getOwner().getOwner();
- ClassDescriptorDef elementClass =
modelDef.getClass(getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF));
- String indirTable =
getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
- boolean hasRemoteKey =
hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
- String remoteKey =
getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
- CollectionDescriptorDef remoteCollDef = null;
+ ModelDef modelDef =
(ModelDef)getOwner().getOwner();
+ String elementClassName =
getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
+ ClassDescriptorDef elementClass =
modelDef.getClass(elementClassName);
+ String indirTable =
getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
+ boolean hasRemoteKey =
hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+ String remoteKey =
getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
+ CollectionDescriptorDef remoteCollDef = null;
// find the collection in the element class that has the same
indirection table
for (Iterator it = elementClass.getCollections(); it.hasNext();)
1.2 +421 -249 db-ojb/lib/xdoclet-ojb-module-1.2.3.jar
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]