mikeh 01/07/02 12:10:54
Modified: src/java/org/apache/turbine/torque/engine/database/model
ForeignKey.java
Log:
support for onUpdate, onDelete attributes
Revision Changes Path
1.7 +44 -1
jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/ForeignKey.java
Index: ForeignKey.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/ForeignKey.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ForeignKey.java 2001/05/10 23:03:21 1.6
+++ ForeignKey.java 2001/07/02 19:10:52 1.7
@@ -63,15 +63,19 @@
* A Class for information about foreign keys of a table
*
* @author <a href="mailto:[EMAIL PROTECTED]">Fedor</a>
- * @version $Id: ForeignKey.java,v 1.6 2001/05/10 23:03:21 jon Exp $
+ * @version $Id: ForeignKey.java,v 1.7 2001/07/02 19:10:52 mikeh Exp $
*/
public class ForeignKey
{
private String foreignTableName;
+ private String onUpdate;
+ private String onDelete;
private Table parentTable;
private List localColumns = new ArrayList(3);
private List foreignColumns = new ArrayList(3);
+ private final String NONE = "NONE";
+
/**
* Default Constructor
*/
@@ -85,6 +89,45 @@
public void loadFromXML (Attributes attrib)
{
foreignTableName = attrib.getValue("foreignTable");
+ onUpdate = attrib.getValue("onUpdate");
+ onDelete = attrib.getValue("onDelete");
+ onUpdate = normalizeFKey(onUpdate);
+ onDelete = normalizeFKey(onDelete);
+ }
+
+ private String normalizeFKey(String attrib)
+ {
+ if (attrib == null)
+ {
+ attrib = NONE;
+ }
+
+ attrib = attrib.toUpperCase();
+ if (attrib.equals("SETNULL"))
+ {
+ attrib = "SET NULL";
+ }
+ return attrib;
+ }
+
+ public boolean hasOnUpdate()
+ {
+ return ! onUpdate.equals(NONE);
+ }
+
+ public boolean hasOnDelete()
+ {
+ return ! onDelete.equals(NONE);
+ }
+
+ public String getOnUpdate()
+ {
+ return onUpdate;
+ }
+
+ public String getOnDelete()
+ {
+ return onDelete;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]