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.
This commit is contained in:
hns 2001-03-11 18:51:29 +00:00
parent 9eb575ea16
commit bf72cbe440

View file

@ -415,6 +415,7 @@ public class Node implements INode, Serializable {
public String getNameOrID () { public String getNameOrID () {
// if subnodes are also mounted as properties, try to get the "nice" prop value // if subnodes are also mounted as properties, try to get the "nice" prop value
// instead of the id by turning the anonymous flag off. // instead of the id by turning the anonymous flag off.
if (parentmap != null) { if (parentmap != null) {
Relation prel = parentmap.getPropertyRelation(); Relation prel = parentmap.getPropertyRelation();
if (prel != null && prel.subnodesAreProperties && !prel.usesPrimaryKey ()) try { if (prel != null && prel.subnodesAreProperties && !prel.usesPrimaryKey ()) try {
@ -422,11 +423,13 @@ public class Node implements INode, Serializable {
String propvalue = getString (localrel.propname, false); String propvalue = getString (localrel.propname, false);
if (propvalue != null && propvalue.length() > 0) { if (propvalue != null && propvalue.length() > 0) {
setName (propvalue); setName (propvalue);
// anonymous = false; anonymous = false;
// nameProp = localrel.propname; // nameProp = localrel.propname;
} else {
anonymous = true;
} }
} catch (Exception ignore) { } catch (Exception ignore) {
// just fall back to ID // just fall back to default method
} }
} }
return anonymous || name == null || name.length() == 0 ? id : name; return anonymous || name == null || name.length() == 0 ? id : name;
@ -1535,6 +1538,7 @@ public class Node implements INode, Serializable {
prop.setNodeValue (n); prop.setNodeValue (n);
Relation rel = dbmap == null ? null : dbmap.getPropertyRelation (propname); Relation rel = dbmap == null ? null : dbmap.getPropertyRelation (propname);
if (rel == null || rel.direction == Relation.FORWARD || rel.virtual || rel.other == null || !rel.other.isRelational()) { if (rel == null || rel.direction == Relation.FORWARD || rel.virtual || rel.other == null || !rel.other.isRelational()) {
// the node must be stored as explicit property // the node must be stored as explicit property
propMap.put (p2, prop); propMap.put (p2, prop);