Cumulative patch:
* Factor out invokeOnInit() method from Node.init() in order to implement onInit() invocation for the embedded database. * Make properties starting with an _underscore transient in the embedded database, mirroring the behaviour of the object relational storage. * Keep filter.additionalTables from being included in prefetchNode() queries, fixing bug 472. * Some minor code cleanup and simplification.
This commit is contained in:
parent
21be4d8651
commit
f5b90c23f1
4 changed files with 24 additions and 19 deletions
|
@ -163,9 +163,11 @@ public final class Node implements INode, Serializable {
|
|||
if (state != CLEAN) {
|
||||
markAs(CLEAN);
|
||||
}
|
||||
}
|
||||
|
||||
public void invokeOnInit() {
|
||||
// Invoke onInit() if it is defined by this Node's prototype
|
||||
if (dbm != null) {
|
||||
if (dbmap != null) {
|
||||
try {
|
||||
// We need to reach deap into helma.framework.core to invoke onInit(),
|
||||
// but the functionality is neat so we got to be strong here.
|
||||
|
@ -1971,7 +1973,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2082,7 +2084,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2119,7 +2121,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2156,7 +2158,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2193,7 +2195,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2230,7 +2232,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
@ -2267,7 +2269,7 @@ public final class Node implements INode, Serializable {
|
|||
|
||||
lastmodified = System.currentTimeMillis();
|
||||
|
||||
if (state == CLEAN) {
|
||||
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||
markAs(MODIFIED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -504,8 +504,8 @@ public final class NodeManager {
|
|||
if (!((rel != null) && (rel.isPrimitive() || rel.isReference())) &&
|
||||
!name.equalsIgnoreCase(nameField) &&
|
||||
!name.equalsIgnoreCase(prototypeField)) {
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
stmtNumber++;
|
||||
if (p!=null) {
|
||||
|
@ -585,11 +585,9 @@ public final class NodeManager {
|
|||
|
||||
// skip readonly, virtual and collection relations
|
||||
if ((rel == null) || rel.readonly || rel.virtual ||
|
||||
((rel.reftype != Relation.REFERENCE) &&
|
||||
(rel.reftype != Relation.PRIMITIVE))) {
|
||||
(!rel.isReference() && !rel.isPrimitive())) {
|
||||
// null out property so we don't consider it later
|
||||
props[i] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1253,7 +1251,7 @@ public final class NodeManager {
|
|||
long logTimeStart = logSql ? System.currentTimeMillis() : 0;
|
||||
|
||||
try {
|
||||
StringBuffer b = dbm.getSelect(rel);
|
||||
StringBuffer b = dbm.getSelect(null);
|
||||
|
||||
String idfield = (rel.groupby != null) ? rel.groupby : dbm.getIDField();
|
||||
boolean needsQuotes = dbm.needsQuotes(idfield);
|
||||
|
@ -1957,7 +1955,7 @@ public final class NodeManager {
|
|||
}
|
||||
|
||||
node.init(dbmap, id, name, protoName, propMap, safe);
|
||||
|
||||
node.invokeOnInit();
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -199,7 +198,9 @@ public final class XmlDatabaseReader extends DefaultHandler implements XmlConsta
|
|||
*/
|
||||
public void endElement(String namespaceURI, String localName, String qName)
|
||||
throws SAXException {
|
||||
if (elementType != null) {
|
||||
if ("hopobject".equals(qName) && currentNode != null) {
|
||||
currentNode.invokeOnInit();
|
||||
} else if (elementType != null) {
|
||||
Property prop = new Property(elementName, currentNode);
|
||||
String charValue = charBuffer.toString();
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
|||
throws IOException {
|
||||
Enumeration e = null;
|
||||
|
||||
if ((dbmode == true) && node instanceof helma.objectmodel.db.Node) {
|
||||
if (dbmode && node instanceof helma.objectmodel.db.Node) {
|
||||
// a newly constructed db.Node doesn't have a propMap,
|
||||
// but returns an enumeration of all it's db-mapped properties
|
||||
Hashtable props = ((Node) node).getPropMap();
|
||||
|
@ -284,6 +284,9 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
|||
|
||||
while (e.hasMoreElements()) {
|
||||
String key = (String) e.nextElement();
|
||||
if (dbmode && key.charAt(0) == '_') {
|
||||
continue;
|
||||
}
|
||||
IProperty prop = node.get(key);
|
||||
|
||||
if (prop != null) {
|
||||
|
@ -376,6 +379,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
|||
if (str != null) {
|
||||
write(str);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
write("</");
|
||||
|
@ -388,7 +392,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
|||
* loop through the children-array and print them as <hop:child>
|
||||
*/
|
||||
private void writeChildren(INode node, int level) throws IOException {
|
||||
if ((dbmode == true) && node instanceof helma.objectmodel.db.Node) {
|
||||
if (dbmode && node instanceof helma.objectmodel.db.Node) {
|
||||
Node dbNode = (Node) node;
|
||||
DbMapping smap = (dbNode.getDbMapping() == null) ? null
|
||||
: dbNode.getDbMapping()
|
||||
|
|
Loading…
Add table
Reference in a new issue