Remove unregisterNode() because it is doing silly things, like deleting

nodes when it shouldn't.
This commit is contained in:
hns 2004-01-14 16:52:54 +00:00
parent 5b9fe8fbfc
commit 237b785fa9

View file

@ -208,9 +208,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* Directly set the value of this property. * Directly set the value of this property.
*/ */
protected void setValue(Object value, int type) { protected void setValue(Object value, int type) {
if (type == NODE) {
unregisterNode();
}
this.value = value; this.value = value;
this.type = type; this.type = type;
dirty = true; dirty = true;
@ -222,10 +219,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param str ... * @param str ...
*/ */
public void setStringValue(String str) { public void setStringValue(String str) {
if (type == NODE) {
unregisterNode();
}
type = STRING; type = STRING;
value = str; value = str;
dirty = true; dirty = true;
@ -237,10 +230,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param l ... * @param l ...
*/ */
public void setIntegerValue(long l) { public void setIntegerValue(long l) {
if (type == NODE) {
unregisterNode();
}
type = INTEGER; type = INTEGER;
value = new Long(l); value = new Long(l);
dirty = true; dirty = true;
@ -252,10 +241,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param d ... * @param d ...
*/ */
public void setFloatValue(double d) { public void setFloatValue(double d) {
if (type == NODE) {
unregisterNode();
}
type = FLOAT; type = FLOAT;
value = new Double(d); value = new Double(d);
dirty = true; dirty = true;
@ -267,10 +252,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param date ... * @param date ...
*/ */
public void setDateValue(Date date) { public void setDateValue(Date date) {
if (type == NODE) {
unregisterNode();
}
type = DATE; type = DATE;
value = date; value = date;
dirty = true; dirty = true;
@ -282,10 +263,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param bool ... * @param bool ...
*/ */
public void setBooleanValue(boolean bool) { public void setBooleanValue(boolean bool) {
if (type == NODE) {
unregisterNode();
}
type = BOOLEAN; type = BOOLEAN;
value = bool ? Boolean.TRUE : Boolean.FALSE; value = bool ? Boolean.TRUE : Boolean.FALSE;
dirty = true; dirty = true;
@ -297,14 +274,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param node ... * @param node ...
*/ */
public void setNodeValue(Node node) { public void setNodeValue(Node node) {
// value.checkWriteLock ();
if (type == NODE) {
unregisterNode();
}
// registerNode (value);
type = NODE; type = NODE;
value = (node == null) ? null : node.getHandle(); value = (node == null) ? null : node.getHandle();
dirty = true; dirty = true;
} }
@ -315,11 +285,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param handle ... * @param handle ...
*/ */
public void setNodeHandle(NodeHandle handle) { public void setNodeHandle(NodeHandle handle) {
if (type == NODE) {
unregisterNode();
}
// registerNode (value);
type = NODE; type = NODE;
value = handle; value = handle;
dirty = true; dirty = true;
@ -357,58 +322,10 @@ public final class Property implements IProperty, Serializable, Cloneable {
* @param obj ... * @param obj ...
*/ */
public void setJavaObjectValue(Object obj) { public void setJavaObjectValue(Object obj) {
if (type == NODE) {
unregisterNode();
}
type = JAVAOBJECT; type = JAVAOBJECT;
value = obj; value = obj;
} }
/**
* tell a the value node that it is no longer used as a property.
* If this was the "main" property for the node, also remove all other references.
*/
protected void unregisterNode() {
if ((value == null) || !(value instanceof NodeHandle)) {
return;
}
NodeHandle nhandle = (NodeHandle) value;
Node nvalue = nhandle.getNode(node.nmgr);
DbMapping nvmap = null;
Relation nvrel = null;
if (node.dbmap != null) {
nvmap = node.dbmap.getPropertyMapping(propname);
nvrel = node.dbmap.getPropertyRelation(propname);
}
if (nvalue == null) {
return;
}
nvalue.checkWriteLock();
// check if the property node is also a subnode
// BUG: this doesn't work because properties for subnode/properties are never stored
// and therefore never reused.
if ((nvrel != null) && nvrel.hasAccessName()) {
node.removeNode(nvalue);
}
// only need to call unregisterPropLink if the value node is not stored in a relational db
// also, getParent is heuristical/implicit for relational nodes, so we don't do deepRemoveNode
// based on that for relational nodes.
if ((nvmap == null) || !nvmap.isRelational()) {
if (!nvalue.isAnonymous() && propname.equals(nvalue.getName()) &&
(this.node == nvalue.getParent())) {
// this is the "main" property of a named node, so handle this as a cascading delete.
nvalue.deepRemoveNode();
}
}
}
/** /**
* *