Guest

Untitled

By: a guest on May 28th, 2009  |  syntax: None  |  size: 3.01 KB  |  hits: 130  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. a Tag points to two generic objects. In this testcase source = AudioInstance and destination = ImageInstance.
  2.  
  3. Tag.properties
  4. ----------------------------------
  5. src           = object(HopObject)
  6. ....
  7. dst           = object(HopObject)
  8. ...
  9.  
  10.  
  11. Image has a collection of tags sorted by tag_name with the accessname being the ID of the source-object. if i remove the accessname, my problems go away.
  12.  
  13.  
  14. Image.properties
  15. -----------------------------------
  16. tagsByName           = collection(Tag)
  17. tagsByName.accessname = tag_f_source_id
  18. tagsByName.local.1   = $id
  19. tagsByName.foreign.1 = tag_f_target_id
  20. tagsByName.local.2   = $prototype
  21. tagsByName.foreign.2 = tag_f_target_prototype
  22. tagsByName.group     = tag_name
  23.  
  24.  
  25.  
  26. reproduce the problem:
  27.    // get Image & Audio instances and attach them to Tag.
  28.    // then add the Tag to the grouped collection of Image
  29.    var img = Image.getById(1);
  30.    var audio = Audio.getById(1);
  31.    var tag = new Tag("viet");
  32.    tag.src = img;
  33.    tag.dst = audio;
  34.    img.tagsByName.add(tag);
  35.    
  36.    // remove the tag = undo the above
  37.    img.tagsByName.get(tag.title).removeChild(tag);
  38.    img.tagsByName.removeChild(tag);
  39.    tag.remove();
  40.  
  41.    // doing ONE of the following makes the last line of this action work
  42.    // res.commit();
  43.    // img.outboundRelations.get(rel.type).invalidate();
  44.    
  45.    var otherTag = new Tag("viet");
  46.    otherTag.target = img;
  47.    otherTag.src = audio;
  48.    img.tagsByName.add(otherTag); // NPE error retrieving node exception  
  49.  
  50.  
  51.  
  52.  
  53. ---------------
  54. gives  me
  55.  
  56. [2009/05/28 13:00:33] [ERROR] [dgr-1] Error retrieving Node "1" from HopObject#viet
  57. java.lang.NullPointerException
  58.         at helma.objectmodel.db.Relation$Constraint.addToQuery(Relation.java:1414)
  59.         at helma.objectmodel.db.Relation.renderConstraints(Relation.java:1042)
  60.         at helma.objectmodel.db.Relation.buildQuery(Relation.java:906)
  61.         at helma.objectmodel.db.NodeManager.getNodeByRelation(NodeManager.java:1625)
  62.         at helma.objectmodel.db.NodeManager.getNode(NodeManager.java:278)
  63.         at helma.objectmodel.db.WrappedNodeManager.getNode(WrappedNodeManager.java:87)
  64.         at helma.objectmodel.db.Node.getChildElement(Node.java:1054)
  65.         at helma.objectmodel.db.Node.addNode(Node.java:910)
  66.         at helma.objectmodel.db.Node.addNode(Node.java:813)
  67.         at helma.objectmodel.db.Node.addNode(Node.java:872)
  68.         at helma.objectmodel.db.Node.addNode(Node.java:813)
  69.         at helma.scripting.rhino.HopObject.jsFunction_add(HopObject.java:535)
  70.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  71.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  72.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  73.         at java.lang.reflect.Method.invoke(Method.java:585)
  74.         at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
  75.         at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:476)
  76.         at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
  77.         at org.mozilla.javascript.gen.c258._c2(/home/oberhams/experiments/demo-generic-reference/Root/actions.js:27)