From fc7f0721a0a0bfa6c780f064fea2161ee26656b3 Mon Sep 17 00:00:00 2001 From: hns Date: Sun, 28 Jan 2001 21:18:07 +0000 Subject: [PATCH] changed semantics of Node.properties(): Only the properties that are either explicitly defined in the type.properties.file or the actual properties are returned, but not the ones defined by a generic _properties rule. --- src/helma/objectmodel/Node.java | 12 ++++++----- src/helma/objectmodel/db/Node.java | 33 +++++++++++++++++------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/helma/objectmodel/Node.java b/src/helma/objectmodel/Node.java index 09dc6196..20cc6586 100644 --- a/src/helma/objectmodel/Node.java +++ b/src/helma/objectmodel/Node.java @@ -52,7 +52,7 @@ public class Node implements INode, Serializable { } /** - * Erstellt einen neuen Node. + * Make a new Node object with a given name */ public Node (String n) { id = generateID (); @@ -61,7 +61,7 @@ public class Node implements INode, Serializable { } /** - * Erstellt einen Clone eines Nodes in der "lokalen" Implementierung von INode. + * Create a clone of a given node that implements this class */ public Node (INode node, Hashtable ntable, boolean conversionRoot) { this.id = generateID (); @@ -79,7 +79,9 @@ public class Node implements INode, Serializable { addNode (nextc); } for (Enumeration e = node.properties (); e.hasMoreElements (); ) { - IProperty next = (IProperty) e.nextElement (); + IProperty next = node.get ((String) e.nextElement (), false); + if (next == null) + continue; int t = next.getType (); if (t == IProperty.NODE) { INode n = next.getNodeValue (); @@ -355,7 +357,7 @@ public class Node implements INode, Serializable { } for (Enumeration e2 = n.properties (); e2.hasMoreElements (); ) { // tell all nodes that are properties of n that they are no longer used as such - Property p = (Property) e2.nextElement (); + Property p = (Property) n.get ((String) e2.nextElement (), false); if (p != null && p.type == Property.NODE) p.unregisterNode (); } @@ -410,7 +412,7 @@ public class Node implements INode, Serializable { */ public Enumeration properties () { - return propMap == null ? new Vector ().elements () : propMap.elements (); + return propMap == null ? new EmptyEnumeration () : propMap.keys (); } diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 2ede190d..e4b7a290 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -126,10 +126,7 @@ public class Node implements INode, Serializable { this.id = Key.makeVirtualID (parentmap, parentID, propname); this.name = propname; this.anonymous = false; - if (prototype == null) - setPrototype (""); - else - setPrototype (prototype); + setPrototype (prototype); this.state = VIRTUAL; } @@ -289,7 +286,9 @@ public class Node implements INode, Serializable { addNode (nextc); } for (Enumeration e = node.properties (); e.hasMoreElements (); ) { - IProperty next = (IProperty) e.nextElement (); + IProperty next = node.get ((String) e.nextElement (), false); + if (next == null) + continue; int t = next.getType (); if (t == IProperty.NODE) { INode n = next.getNodeValue (); @@ -809,8 +808,10 @@ public class Node implements INode, Serializable { Relation gsrel = srel.getGroupbySubnodeRelation(); dbm.setSubnodeMapping (srel.other); dbm.setSubnodeRelation (gsrel); - dbm.setPropertyMapping (prel.other); - dbm.setPropertyRelation (prel.getGroupbyPropertyRelation()); + if (prel != null) { + dbm.setPropertyMapping (prel.other); + dbm.setPropertyRelation (prel.getGroupbyPropertyRelation()); + } node.setDbMapping (dbm); String snrel = "WHERE "+srel.groupby +"='"+sid+"'"; if (gsrel.direction == Relation.BACKWARD) @@ -819,7 +820,9 @@ public class Node implements INode, Serializable { snrel += " ORDER BY "+gsrel.order; node.setSubnodeRelation (snrel); return node; - } catch (Exception noluck) {} + } catch (Exception noluck) { + IServer.getLogger ().log ("Error creating group-by node for "+sid+": "+noluck); + } return null; } @@ -1047,7 +1050,7 @@ public class Node implements INode, Serializable { */ public Enumeration properties () { - final Relation prel = dbmap == null ? null : dbmap.getPropertyRelation (); + /* final Relation prel = dbmap == null ? null : dbmap.getPropertyRelation (); final DbMapping pmap = prel == null ? null : prel.other; if (pmap != null && pmap.isRelational ()) { class Enum implements Enumeration { @@ -1076,9 +1079,11 @@ public class Node implements INode, Serializable { } } return new Enum (); - } - - return propMap == null ? new Vector ().elements () : propMap.elements (); + } */ + if (dbmap != null && dbmap.prop2db.size() > 0) + return dbmap.prop2db.keys(); + else + return propMap == null ? new EmptyEnumeration () : propMap.keys (); // NOTE: we don't enumerate node properties here // return propMap == null ? new Vector ().elements () : propMap.elements (); @@ -1696,8 +1701,8 @@ public class Node implements INode, Serializable { n.makePersistentCapable (); } for (Enumeration e = properties (); e.hasMoreElements (); ) { - IProperty next = (IProperty) e.nextElement (); - if (next.getType () == IProperty.NODE) { + IProperty next = get ((String) e.nextElement (), false); + if (next != null && next.getType () == IProperty.NODE) { Node n = (Node) next.getNodeValue (); if (n != null && n.state == TRANSIENT) n.makePersistentCapable ();