Make sure nodes created by HopObject.getCollection have a valid id. Fixes bug 663.
This commit is contained in:
parent
507da18a8b
commit
66eb754564
3 changed files with 18 additions and 2 deletions
|
@ -45,6 +45,9 @@ public final class DbKey implements Key, Serializable {
|
||||||
* make a key for a persistent Object, describing its datasource and id.
|
* make a key for a persistent Object, describing its datasource and id.
|
||||||
*/
|
*/
|
||||||
public DbKey(DbMapping dbmap, String id) {
|
public DbKey(DbMapping dbmap, String id) {
|
||||||
|
if (id == null) {
|
||||||
|
throw new IllegalArgumentException("id null in DbKey");
|
||||||
|
}
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.storageName = (dbmap == null) ? null : dbmap.getStorageTypeName();
|
this.storageName = (dbmap == null) ? null : dbmap.getStorageTypeName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,14 @@ public final class DbMapping {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DbMapping from a type.properties property file
|
||||||
|
*/
|
||||||
|
public DbMapping(Application app, String typename, Properties props, boolean virtual) {
|
||||||
|
this(app, typename, props);
|
||||||
|
isVirtual = virtual;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a DbMapping from a type.properties property file
|
* Create a DbMapping from a type.properties property file
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@ import helma.objectmodel.INode;
|
||||||
import helma.objectmodel.db.DbMapping;
|
import helma.objectmodel.db.DbMapping;
|
||||||
import helma.objectmodel.db.DbKey;
|
import helma.objectmodel.db.DbKey;
|
||||||
import helma.objectmodel.db.Node;
|
import helma.objectmodel.db.Node;
|
||||||
|
import helma.objectmodel.db.WrappedNodeManager;
|
||||||
|
|
||||||
import org.mozilla.javascript.*;
|
import org.mozilla.javascript.*;
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@ public class HopObjectCtor extends FunctionObject {
|
||||||
|
|
||||||
static Method hopObjCtor;
|
static Method hopObjCtor;
|
||||||
|
|
||||||
|
static long collectionId = 0;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
hopObjCtor = HopObjectCtor.class.getMethod("jsConstructor", new Class[] {
|
hopObjCtor = HopObjectCtor.class.getMethod("jsConstructor", new Class[] {
|
||||||
|
@ -203,11 +206,13 @@ public class HopObjectCtor extends FunctionObject {
|
||||||
childmapping.put("collection", HopObjectCtor.this.getFunctionName());
|
childmapping.put("collection", HopObjectCtor.this.getFunctionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Node node = new Node("HopQuery", null, core.app.getWrappedNodeManager());
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("_children", childmapping);
|
props.put("_children", childmapping);
|
||||||
DbMapping dbmap = new DbMapping(core.app, null, props);
|
DbMapping dbmap = new DbMapping(core.app, null, props, true);
|
||||||
dbmap.update();
|
dbmap.update();
|
||||||
|
|
||||||
|
WrappedNodeManager nmgr = core.app.getWrappedNodeManager();
|
||||||
|
Node node = new Node("HopQuery", Long.toString(collectionId++), null, nmgr);
|
||||||
node.setDbMapping(dbmap);
|
node.setDbMapping(dbmap);
|
||||||
node.setState(Node.VIRTUAL);
|
node.setState(Node.VIRTUAL);
|
||||||
return new HopObject("HopQuery", core, node, core.hopObjectProto);
|
return new HopObject("HopQuery", core, node, core.hopObjectProto);
|
||||||
|
|
Loading…
Add table
Reference in a new issue