From bf72cbe440ed9fc16aa3caa5a6d913cbc1232c19 Mon Sep 17 00:00:00 2001 From: hns Date: Sun, 11 Mar 2001 18:51:29 +0000 Subject: [PATCH] getNameOrID now dares to set anonymous, depending on whether the parent has propertiesAreSubnodes set and it makes sense in the context of the current object. --- src/helma/objectmodel/db/Node.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 0a7e9fc3..d79c4029 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -415,6 +415,7 @@ public class Node implements INode, Serializable { public String getNameOrID () { // if subnodes are also mounted as properties, try to get the "nice" prop value // instead of the id by turning the anonymous flag off. + if (parentmap != null) { Relation prel = parentmap.getPropertyRelation(); if (prel != null && prel.subnodesAreProperties && !prel.usesPrimaryKey ()) try { @@ -422,11 +423,13 @@ public class Node implements INode, Serializable { String propvalue = getString (localrel.propname, false); if (propvalue != null && propvalue.length() > 0) { setName (propvalue); - // anonymous = false; + anonymous = false; // nameProp = localrel.propname; + } else { + anonymous = true; } } catch (Exception ignore) { - // just fall back to ID + // just fall back to default method } } return anonymous || name == null || name.length() == 0 ? id : name; @@ -1535,6 +1538,7 @@ public class Node implements INode, Serializable { prop.setNodeValue (n); Relation rel = dbmap == null ? null : dbmap.getPropertyRelation (propname); + if (rel == null || rel.direction == Relation.FORWARD || rel.virtual || rel.other == null || !rel.other.isRelational()) { // the node must be stored as explicit property propMap.put (p2, prop);