Patches
Kris Leite <kleite <at> imcsoftware.com>
2007-07-06 20:00:05 GMT
Hi Hannes,
The attached patches provide the following features:
* NodeManger - Invoke javascript 'onRemove' when a node is being deleted.
* NodeManager - Change the SQL string to use ' around the node id to allow
the node id to be non-numeric.
* Transactor - Enhance Transactor to process additional dirtyNodes created
when processing nodes that call onPersist, onInit, and on Remove functions.
Sorry for waiting so long to submit these patches.
Thanks,
Kris
Index: NodeManager.java
*** D:\jRTsrc\helma-1.6.0\hop\helma\src\helma\objectmodel\db\NodeManager.java Base (1.157)
--- D:\jRTsrc\helma-1.6.0\hop\helma\src\helma\objectmodel\db\NodeManager.java Locally
Modified (Based On 1.157)
***************
*** 546,551 ****
--- 546,567 ----
}
/**
+ * calls onRemove function for the HopObject
+ */
+ private void invokeOnRemove(Node node) {
+ try {
+ // We need to reach deap into helma.framework.core to invoke onPersist(),
+ // but the functionality is really worth it.
+ RequestEvaluator reval = app.getCurrentRequestEvaluator();
+ if (reval != null) {
+ reval.invokeDirectFunction(node, "onRemove", RequestEvaluator.EMPTY_ARGS);
+ }
+ } catch (Exception x) {
+ app.logError("Error invoking onRemove()", x);
+ }
+ }
+
+ /**
* Updates a modified node in the embedded db or an external relational database, depending
* on its database mapping.
*
***************
*** 681,686 ****
--- 697,704 ----
*/
public void deleteNode(IDatabase db, ITransaction txn, Node node)
throws Exception {
+ invokeOnRemove(node);
+
DbMapping dbm = node.getDbMapping();
if ((dbm == null) || !dbm.isRelational()) {
***************
*** 691,701 ****
String str = new StringBuffer("DELETE FROM ").append(dbm.getTableName())
.append(" WHERE ")
.append(dbm.getIDField())
! .append(" = ")
.append(node.getID())
.toString();
--- 709,717 ----
String str = new StringBuffer("DELETE FROM ").append(dbm.getTableName())
.append(" WHERE ")
.append(dbm.getIDField())
! .append(" = '")
.append(node.getID())
+ .append("'")
.toString();
try {
Index: Transactor.java
*** D:\jRTsrc\helma-1.6.0\hop\helma\src\helma\objectmodel\db\Transactor.java Base (1.34)
--- D:\jRTsrc\helma-1.6.0\hop\helma\src\helma\objectmodel\db\Transactor.java Locally Modified
(Based On 1.34)
***************
*** 257,268 ****
modifiedParentNodes = new ArrayList();
}
! if (!dirtyNodes.isEmpty()) {
Object[] dirty = dirtyNodes.values().toArray();
// the set to collect DbMappings to be marked as changed
HashSet dirtyDbMappings = new HashSet();
--- 257,268 ----
modifiedParentNodes = new ArrayList();
}
! while (!dirtyNodes.isEmpty()) {
Object[] dirty = dirtyNodes.values().toArray();
+ // reset dirty node list
+ dirtyNodes = new HashMap();
+
// the set to collect DbMappings to be marked as changed
HashSet dirtyDbMappings = new HashSet();
_______________________________________________
Helma-user mailing list
Helma-user <at> helma.org
http://helma.org/mailman/listinfo/helma-user