tomdz 2005/03/22 13:38:17
Modified: src/xdoclet/java/src/xdoclet/modules/ojb/constraints Tag:
OJB_1_0_RELEASE ClassDescriptorConstraints.java
src/xdoclet/test/xdoclet/modules/ojb/tests Tag:
OJB_1_0_RELEASE
CollectionTagCollectionClassAttributeTests.java
Log:
Added PK-check to the XDoclet module
Fixed XDoclet module test case
Revision Changes Path
No revision
No revision
1.5.2.2 +26 -0
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.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- ClassDescriptorConstraints.java 15 Mar 2005 23:58:29 -0000 1.5.2.1
+++ ClassDescriptorConstraints.java 22 Mar 2005 21:38:17 -0000 1.5.2.2
@@ -20,6 +20,7 @@
import java.util.*;
import xdoclet.modules.ojb.CommaListIterator;
+import xdoclet.modules.ojb.LogHelper;
import xdoclet.modules.ojb.model.*;
/**
@@ -49,6 +50,7 @@
ensureTableIfNecessary(classDef, checkLevel);
checkFactoryClassAndMethod(classDef, checkLevel);
checkInitializationMethod(classDef, checkLevel);
+ checkPrimaryKey(classDef, checkLevel);
checkProxyPrefetchingLimit(classDef, checkLevel);
checkRowReader(classDef, checkLevel);
checkObjectCache(classDef, checkLevel);
@@ -381,6 +383,30 @@
}
/**
+ * Checks whether given class descriptor has a primary key.
+ *
+ * @param classDef The class descriptor
+ * @param checkLevel The current check level (this constraint is only
checked in strict)
+ * @exception ConstraintException If the constraint has been violated
+ */
+ private void checkPrimaryKey(ClassDescriptorDef classDef, String
checkLevel) throws ConstraintException
+ {
+ if (CHECKLEVEL_NONE.equals(checkLevel))
+ {
+ return;
+ }
+
+ if
(classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO,
true) &&
+ classDef.getPrimaryKeys().isEmpty())
+ {
+ LogHelper.warn(true,
+ getClass(),
+ "checkPrimaryKey",
+ "The class "+classDef.getName()+" has no primary
key");
+ }
+ }
+
+ /**
* Checks the given class descriptor for correct row-reader setting.
*
* @param classDef The class descriptor
No revision
No revision
1.5.2.2 +1 -1
db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagCollectionClassAttributeTests.java
Index: CollectionTagCollectionClassAttributeTests.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/xdoclet/test/xdoclet/modules/ojb/tests/CollectionTagCollectionClassAttributeTests.java,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- CollectionTagCollectionClassAttributeTests.java 1 Mar 2005 21:54:06
-0000 1.5.2.1
+++ CollectionTagCollectionClassAttributeTests.java 22 Mar 2005 21:38:17
-0000 1.5.2.2
@@ -773,7 +773,7 @@
" *
collection-class=\"org.apache.ojb.broker.util.collections.ManageableHashMap\"\n"+
" * database-foreignkey=\"false\"\n"+
" */\n"+
- " private java.util.HashMap attr;\n"+
+ " private java.util.Map attr;\n"+
"}");
addClass(
"test.B",
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]