* Implement HopObject.onPersist() callback contributed by
Kris Leite on helma-user.
This commit is contained in:
parent
7ef2a3fcd0
commit
4b79e98a8b
1 changed files with 27 additions and 10 deletions
|
@ -349,7 +349,6 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
// New node is going ot be used, invoke onInit() on it
|
// New node is going ot be used, invoke onInit() on it
|
||||||
// Invoke onInit() if it is defined by this Node's prototype
|
// Invoke onInit() if it is defined by this Node's prototype
|
||||||
if (node.dbmap != null) {
|
|
||||||
try {
|
try {
|
||||||
// We need to reach deap into helma.framework.core to invoke onInit(),
|
// We need to reach deap into helma.framework.core to invoke onInit(),
|
||||||
// but the functionality is really worth it.
|
// but the functionality is really worth it.
|
||||||
|
@ -360,7 +359,6 @@ public final class NodeManager {
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
app.logError("Error invoking onInit()", x);
|
app.logError("Error invoking onInit()", x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,6 +419,7 @@ public final class NodeManager {
|
||||||
*/
|
*/
|
||||||
public void insertNode(IDatabase db, ITransaction txn, Node node)
|
public void insertNode(IDatabase db, ITransaction txn, Node node)
|
||||||
throws IOException, SQLException, ClassNotFoundException {
|
throws IOException, SQLException, ClassNotFoundException {
|
||||||
|
invokeOnPersist(node);
|
||||||
DbMapping dbm = node.getDbMapping();
|
DbMapping dbm = node.getDbMapping();
|
||||||
|
|
||||||
if ((dbm == null) || !dbm.isRelational()) {
|
if ((dbm == null) || !dbm.isRelational()) {
|
||||||
|
@ -530,6 +529,22 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls onPersist function for the HopObject
|
||||||
|
*/
|
||||||
|
private void invokeOnPersist(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, "onPersist", RequestEvaluator.EMPTY_ARGS);
|
||||||
|
}
|
||||||
|
} catch (Exception x) {
|
||||||
|
app.logError("Error invoking onPersist()", x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a modified node in the embedded db or an external relational database, depending
|
* Updates a modified node in the embedded db or an external relational database, depending
|
||||||
* on its database mapping.
|
* on its database mapping.
|
||||||
|
@ -539,6 +554,8 @@ public final class NodeManager {
|
||||||
*/
|
*/
|
||||||
public boolean updateNode(IDatabase db, ITransaction txn, Node node)
|
public boolean updateNode(IDatabase db, ITransaction txn, Node node)
|
||||||
throws IOException, SQLException, ClassNotFoundException {
|
throws IOException, SQLException, ClassNotFoundException {
|
||||||
|
|
||||||
|
invokeOnPersist(node);
|
||||||
DbMapping dbm = node.getDbMapping();
|
DbMapping dbm = node.getDbMapping();
|
||||||
boolean markMappingAsUpdated = false;
|
boolean markMappingAsUpdated = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue