Only do anonymous/named check in getElementName() for relational objects.

Also check if child is relational before doing Relation.checkConstraints in isParentOf().
This commit is contained in:
hns 2004-03-02 15:03:05 +00:00
parent 08c443ce6a
commit 83d29f6a60

View file

@ -413,13 +413,9 @@ public final class Node implements INode, Serializable {
* and a property value for named properties. * and a property value for named properties.
*/ */
public String getElementName() { public String getElementName() {
// if subnodes are also mounted as properties, try to get the "nice" prop value // for relational nodes we need to consult parent mapping to find element name
// instead of the id by turning the anonymous flag off. if (isRelational()) {
long lastmod = lastmodified; long lastmod = Math.max(lastmodified, dbmap.getLastTypeChange());
if (dbmap != null) {
lastmod = Math.max(lastmod, dbmap.getLastTypeChange());
}
if ((parentHandle != null) && (lastNameCheck < lastmod)) { if ((parentHandle != null) && (lastNameCheck < lastmod)) {
try { try {
@ -454,6 +450,7 @@ public final class Node implements INode, Serializable {
lastNameCheck = System.currentTimeMillis(); lastNameCheck = System.currentTimeMillis();
} }
}
return (anonymous || (name == null) || (name.length() == 0)) ? id : name; return (anonymous || (name == null) || (name.length() == 0)) ? id : name;
} }
@ -1354,7 +1351,7 @@ public final class Node implements INode, Serializable {
* @return true if the given node is contained in this node's child list * @return true if the given node is contained in this node's child list
*/ */
public boolean isParentOf(Node n) { public boolean isParentOf(Node n) {
if (dbmap != null) { if (dbmap != null && n.isRelational()) {
Relation subrel = dbmap.getSubnodeRelation(); Relation subrel = dbmap.getSubnodeRelation();
// if we're dealing with relational child nodes use // if we're dealing with relational child nodes use
// Relation.checkConstraints to avoid loading the child index. // Relation.checkConstraints to avoid loading the child index.