fixed getGroupbySubnode to use both subnode and property Relations

This commit is contained in:
hns 2001-01-04 12:48:29 +00:00
parent 18478e9bf6
commit 0c85da040c

View file

@ -763,22 +763,24 @@ public class Node implements INode, Serializable {
return retval; return retval;
} }
public Node getGroupbySubnode (String sid, Relation rel) { public Node getGroupbySubnode (String sid) {
loadNodes (); loadNodes ();
if (subnodes.contains (sid)) { if (subnodes.contains (sid)) try {
Node node = new Node (this, sid, nmgr, null); Node node = new Node (this, sid, nmgr, null);
Relation srel = dbmap.getSubnodeRelation ();
Relation prel = dbmap.getPropertyRelation ();
DbMapping dbm = new DbMapping (); DbMapping dbm = new DbMapping ();
dbm.setSubnodeMapping (rel.other); dbm.setSubnodeMapping (srel.other);
dbm.setSubnodeRelation (rel.getGroupbySubnodeRelation()); dbm.setSubnodeRelation (srel.getGroupbySubnodeRelation());
dbm.setPropertyMapping (rel.other); dbm.setPropertyMapping (prel.other);
dbm.setPropertyRelation (rel.getGroupbyPropertyRelation()); dbm.setPropertyRelation (prel.getGroupbyPropertyRelation());
node.setDbMapping (dbm); node.setDbMapping (dbm);
String snrel = "WHERE "+rel.groupby +"='"+sid+"'"; String snrel = "WHERE "+srel.groupby +"='"+sid+"'";
if (dbm.getSubnodeRelation().direction == Relation.BACKWARD) if (dbm.getSubnodeRelation().direction == Relation.BACKWARD)
snrel += " AND "+dbm.getSubnodeRelation().remoteField+"='"+getNonVirtualHomeID()+"'"; snrel += " AND "+dbm.getSubnodeRelation().remoteField+"='"+getNonVirtualHomeID()+"'";
node.setSubnodeRelation (snrel); node.setSubnodeRelation (snrel);
return node; return node;
} } catch (Exception noluck) {}
return null; return null;
} }