Re-establish old behaviour in addNode() that if an existing child element is present

with the given name it is deleted. Do not wrap addGroupbyNode-code in try/catch.
This commit is contained in:
hns 2004-01-28 15:56:53 +00:00
parent 2f2b0ae051
commit 13a9f914be

View file

@ -840,7 +840,6 @@ public final class Node implements INode, Serializable {
Relation srel = dbmap.getSubnodeRelation(); Relation srel = dbmap.getSubnodeRelation();
if ((srel != null) && (srel.groupby != null)) { if ((srel != null) && (srel.groupby != null)) {
try {
Relation groupbyRel = srel.otherType.columnNameToRelation(srel.groupby); Relation groupbyRel = srel.otherType.columnNameToRelation(srel.groupby);
String groupbyProp = (groupbyRel != null) ? groupbyRel.propName String groupbyProp = (groupbyRel != null) ? groupbyRel.propName
: srel.groupby; : srel.groupby;
@ -855,13 +854,7 @@ public final class Node implements INode, Serializable {
} }
groupbyNode.addNode(node); groupbyNode.addNode(node);
return node; return node;
} catch (Exception x) {
System.err.println("Error adding groupby: " + x);
return null;
}
} }
} }
@ -896,11 +889,14 @@ public final class Node implements INode, Serializable {
String prop = node.getString(propname); String prop = node.getString(propname);
if ((prop != null) && (prop.length() > 0)) { if ((prop != null) && (prop.length() > 0)) {
INode old = getNode(prop); INode old = (INode) getChildElement(prop);
if ((old != null) && (old != node)) { if ((old != null) && (old != node)) {
unset(prop); // FIXME: we delete the existing node here,
removeNode(old); // but actually the app developer should prevent this from
// happening, so it might be better to throw an exception.
old.remove();
this.removeNode(old);
} }
setNode(prop, node); setNode(prop, node);