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) {
|
if (state != CLEAN) {
|
||||||
markAs(CLEAN);
|
markAs(CLEAN);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invokeOnInit() {
|
||||||
// Invoke onInit() if it is defined by this Node's prototype
|
// Invoke onInit() if it is defined by this Node's prototype
|
||||||
if (dbm != null) {
|
if (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 neat so we got to be strong here.
|
// 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();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2082,7 +2084,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2119,7 +2121,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2156,7 +2158,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2193,7 +2195,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2230,7 +2232,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2267,7 +2269,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
lastmodified = System.currentTimeMillis();
|
lastmodified = System.currentTimeMillis();
|
||||||
|
|
||||||
if (state == CLEAN) {
|
if (state == CLEAN && propname.charAt(0) != '_') {
|
||||||
markAs(MODIFIED);
|
markAs(MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,11 +585,9 @@ public final class NodeManager {
|
||||||
|
|
||||||
// skip readonly, virtual and collection relations
|
// skip readonly, virtual and collection relations
|
||||||
if ((rel == null) || rel.readonly || rel.virtual ||
|
if ((rel == null) || rel.readonly || rel.virtual ||
|
||||||
((rel.reftype != Relation.REFERENCE) &&
|
(!rel.isReference() && !rel.isPrimitive())) {
|
||||||
(rel.reftype != Relation.PRIMITIVE))) {
|
|
||||||
// null out property so we don't consider it later
|
// null out property so we don't consider it later
|
||||||
props[i] = null;
|
props[i] = null;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1253,7 +1251,7 @@ public final class NodeManager {
|
||||||
long logTimeStart = logSql ? System.currentTimeMillis() : 0;
|
long logTimeStart = logSql ? System.currentTimeMillis() : 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StringBuffer b = dbm.getSelect(rel);
|
StringBuffer b = dbm.getSelect(null);
|
||||||
|
|
||||||
String idfield = (rel.groupby != null) ? rel.groupby : dbm.getIDField();
|
String idfield = (rel.groupby != null) ? rel.groupby : dbm.getIDField();
|
||||||
boolean needsQuotes = dbm.needsQuotes(idfield);
|
boolean needsQuotes = dbm.needsQuotes(idfield);
|
||||||
|
@ -1957,7 +1955,7 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
node.init(dbmap, id, name, protoName, propMap, safe);
|
node.init(dbmap, id, name, protoName, propMap, safe);
|
||||||
|
node.invokeOnInit();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Hashtable;
|
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)
|
public void endElement(String namespaceURI, String localName, String qName)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
if (elementType != null) {
|
if ("hopobject".equals(qName) && currentNode != null) {
|
||||||
|
currentNode.invokeOnInit();
|
||||||
|
} else if (elementType != null) {
|
||||||
Property prop = new Property(elementName, currentNode);
|
Property prop = new Property(elementName, currentNode);
|
||||||
String charValue = charBuffer.toString();
|
String charValue = charBuffer.toString();
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Enumeration e = null;
|
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,
|
// a newly constructed db.Node doesn't have a propMap,
|
||||||
// but returns an enumeration of all it's db-mapped properties
|
// but returns an enumeration of all it's db-mapped properties
|
||||||
Hashtable props = ((Node) node).getPropMap();
|
Hashtable props = ((Node) node).getPropMap();
|
||||||
|
@ -284,6 +284,9 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
||||||
|
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
String key = (String) e.nextElement();
|
String key = (String) e.nextElement();
|
||||||
|
if (dbmode && key.charAt(0) == '_') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
IProperty prop = node.get(key);
|
IProperty prop = node.get(key);
|
||||||
|
|
||||||
if (prop != null) {
|
if (prop != null) {
|
||||||
|
@ -376,6 +379,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
write(str);
|
write(str);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
write("</");
|
write("</");
|
||||||
|
@ -388,7 +392,7 @@ public class XmlWriter extends OutputStreamWriter implements XmlConstants {
|
||||||
* loop through the children-array and print them as <hop:child>
|
* loop through the children-array and print them as <hop:child>
|
||||||
*/
|
*/
|
||||||
private void writeChildren(INode node, int level) throws IOException {
|
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;
|
Node dbNode = (Node) node;
|
||||||
DbMapping smap = (dbNode.getDbMapping() == null) ? null
|
DbMapping smap = (dbNode.getDbMapping() == null) ? null
|
||||||
: dbNode.getDbMapping()
|
: dbNode.getDbMapping()
|
||||||
|
|
Loading…
Add table
Reference in a new issue