basically removed all special case handling for node properties.

just hold a handle and return its node when asked.
This commit is contained in:
hns 2001-08-03 14:50:40 +00:00
parent af4c3fa861
commit 7310deaae6

View file

@ -23,8 +23,8 @@ public final class Property implements IProperty, Serializable, Cloneable {
protected boolean bvalue; protected boolean bvalue;
protected long lvalue; protected long lvalue;
protected double dvalue; protected double dvalue;
protected String nvalueID; // protected String nvalueID;
private transient NodeHandle nhandle; protected NodeHandle nhandle;
protected Object jvalue; protected Object jvalue;
protected int type; protected int type;
@ -53,7 +53,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
dvalue = in.readDouble (); dvalue = in.readDouble ();
break; break;
case NODE: case NODE:
nvalueID = in.readUTF (); nhandle = (NodeHandle) in.readObject ();
break; break;
case JAVAOBJECT: case JAVAOBJECT:
jvalue = in.readObject (); jvalue = in.readObject ();
@ -83,7 +83,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
out.writeDouble (dvalue); out.writeDouble (dvalue);
break; break;
case NODE: case NODE:
out.writeUTF (nvalueID); out.writeObject (nhandle);
break; break;
case JAVAOBJECT: case JAVAOBJECT:
if (jvalue != null && !(jvalue instanceof Serializable)) if (jvalue != null && !(jvalue instanceof Serializable))
@ -109,7 +109,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
public Property (String propname, Node node, Node value) { public Property (String propname, Node node, Node value) {
this (propname, node); this (propname, node);
type = NODE; type = NODE;
nvalueID = value == null ? null : value.getID (); nhandle = value == null ? null : value.getHandle ();
dirty = true; dirty = true;
} }
@ -198,7 +198,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
registerNode (value); registerNode (value);
type = NODE; type = NODE;
if (node.dbmap != null) { /* if (node.dbmap != null) {
Relation rel = node.dbmap.getPropertyRelation (propname); Relation rel = node.dbmap.getPropertyRelation (propname);
if (rel != null && rel.other != null) { if (rel != null && rel.other != null) {
DbMapping vmap = value.getDbMapping (); DbMapping vmap = value.getDbMapping ();
@ -222,10 +222,10 @@ public final class Property implements IProperty, Serializable, Cloneable {
return; return;
} }
} }
} } */
nhandle = new NodeHandle (value); nhandle = value.getHandle ();
this.nvalueID = value == null ? null : value.getID (); // this.nvalueID = value == null ? null : value.getID ();
dirty = true; dirty = true;
} }
@ -244,7 +244,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
protected void unregisterNode () { protected void unregisterNode () {
Node nvalue = null; Node nvalue = null;
if (nhandle != null) if (nhandle != null)
nvalue = nhandle.getNode (); nvalue = nhandle.getNode (node.nmgr);
DbMapping nvmap = null; DbMapping nvmap = null;
Relation nvrel = null; Relation nvrel = null;
@ -252,8 +252,8 @@ public final class Property implements IProperty, Serializable, Cloneable {
nvmap = node.dbmap.getPropertyMapping (propname); nvmap = node.dbmap.getPropertyMapping (propname);
nvrel = node.dbmap.getPropertyRelation (propname); nvrel = node.dbmap.getPropertyRelation (propname);
} }
if (nvalue == null) // if (nvalue == null)
nvalue = node.nmgr.getNode (nvalueID, nvmap); // nvalue = node.nmgr.getNode (nvalueID, nvmap);
if (nvalue == null) if (nvalue == null)
return; return;
@ -273,7 +273,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
// this is the "main" property of a named node, so handle this as a cascading delete. // this is the "main" property of a named node, so handle this as a cascading delete.
nvalue.deepRemoveNode (); nvalue.deepRemoveNode ();
} else { } else {
nvalue.unregisterPropLink (this.node); nvalue.unregisterPropLinkFrom (this.node);
} }
} }
} }
@ -285,7 +285,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
protected void registerNode (Node n) { protected void registerNode (Node n) {
// only need to call registerPropLink if the value node is not stored in a relational db // only need to call registerPropLink if the value node is not stored in a relational db
if (n != null && (n.dbmap == null || !n.dbmap.isRelational())) { if (n != null && (n.dbmap == null || !n.dbmap.isRelational())) {
n.registerPropLink (this.node); n.registerPropLinkFrom (this.node);
} }
} }
@ -303,7 +303,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
case FLOAT: case FLOAT:
return Double.toString (dvalue); return Double.toString (dvalue);
case NODE: case NODE:
return nvalueID; return nhandle.toString ();
case JAVAOBJECT: case JAVAOBJECT:
return jvalue.toString (); return jvalue.toString ();
} }
@ -342,10 +342,10 @@ public final class Property implements IProperty, Serializable, Cloneable {
public INode getNodeValue () { public INode getNodeValue () {
if (nhandle != null) { if (nhandle != null) {
Node n = nhandle.getNode (); Node n = nhandle.getNode (node.nmgr);
if (n != null) return n; if (n != null) return n;
} }
DbMapping dbm = null; /* DbMapping dbm = null;
//// PROVISIONAL //// PROVISIONAL
if (type == NODE && nvalueID != null) { if (type == NODE && nvalueID != null) {
Relation rel = null; Relation rel = null;
@ -368,7 +368,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
// we have what we need, now get the node from the node manager // we have what we need, now get the node from the node manager
Node retval = node.nmgr.getNode (nvalueID, dbm); Node retval = node.nmgr.getNode (nvalueID, dbm);
if (retval != null && retval.parentID == null && !"root".equalsIgnoreCase (retval.getPrototype ())) { if (retval != null && retval.parentHandle == null && !"root".equalsIgnoreCase (retval.getPrototype ())) {
retval.setParent (node); retval.setParent (node);
retval.setName (propname); retval.setName (propname);
retval.anonymous = false; retval.anonymous = false;
@ -386,7 +386,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
} }
return retval; return retval;
} } */
return null; return null;
} }
@ -412,11 +412,6 @@ public final class Property implements IProperty, Serializable, Cloneable {
SimpleDateFormat format = new SimpleDateFormat ("dd.MM.yy hh:mm"); SimpleDateFormat format = new SimpleDateFormat ("dd.MM.yy hh:mm");
String date = format.format (new Date (lvalue)); String date = format.format (new Date (lvalue));
return "<input type=text name=\""+propname+"\" value=\""+date+"\">"; return "<input type=text name=\""+propname+"\" value=\""+date+"\">";
case NODE:
DbMapping nvmap = null;
if (node.dbmap != null)
nvmap = node.dbmap.getPropertyMapping (propname);
return "<input type=text size=25 name="+propname+" value='"+ node.nmgr.getNode (nvalueID, nvmap).getName () +"'>";
} }
return ""; return "";
} }
@ -474,7 +469,7 @@ public final class Property implements IProperty, Serializable, Cloneable {
c.bvalue = this.bvalue; c.bvalue = this.bvalue;
c.lvalue = this.lvalue; c.lvalue = this.lvalue;
c.dvalue = this.dvalue; c.dvalue = this.dvalue;
c.nvalueID = this.nvalueID; c.nhandle = this.nhandle;
c.type = this.type; c.type = this.type;
return c; return c;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {