Several smallish fixes:
* Check for group-by option in parent's child relation in getElementName(). This is necessary for embedded group nodes to operate as named objects. * Use specialized get code in getChildElement() if child relation is group-by. This is necessary to get group nodes after the change above. * Fix NullPointerException when name is null in setName() * Use the groupname as node name and also set an explicit "name" property in getGroupbySubnode().
This commit is contained in:
parent
4ec134c41f
commit
969ef70c93
1 changed files with 21 additions and 17 deletions
|
@ -427,18 +427,23 @@ public final class Node implements INode, Serializable {
|
||||||
DbMapping parentmap = p.getDbMapping();
|
DbMapping parentmap = p.getDbMapping();
|
||||||
Relation prel = parentmap.getSubnodeRelation();
|
Relation prel = parentmap.getSubnodeRelation();
|
||||||
|
|
||||||
if ((prel != null) && prel.hasAccessName()) {
|
if (prel != null) {
|
||||||
|
if (prel.groupby != null) {
|
||||||
|
setName(getString("groupname"));
|
||||||
|
anonymous = false;
|
||||||
|
} else if (prel.accessName != null) {
|
||||||
String propname = dbmap.columnNameToProperty(prel.accessName);
|
String propname = dbmap.columnNameToProperty(prel.accessName);
|
||||||
String propvalue = getString(propname);
|
String propvalue = getString(propname);
|
||||||
|
|
||||||
if ((propvalue != null) && (propvalue.length() > 0)) {
|
if ((propvalue != null) && (propvalue.length() > 0)) {
|
||||||
setName(propvalue);
|
setName(propvalue);
|
||||||
anonymous = false;
|
anonymous = false;
|
||||||
|
|
||||||
// nameProp = localrel.propName;
|
|
||||||
} else if (!anonymous && (p.contains(this) > -1)) {
|
} else if (!anonymous && (p.contains(this) > -1)) {
|
||||||
anonymous = true;
|
anonymous = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
anonymous = true;
|
||||||
|
}
|
||||||
} else if (!anonymous && (p.contains(this) > -1)) {
|
} else if (!anonymous && (p.contains(this) > -1)) {
|
||||||
anonymous = true;
|
anonymous = true;
|
||||||
}
|
}
|
||||||
|
@ -614,14 +619,12 @@ public final class Node implements INode, Serializable {
|
||||||
* @param name ...
|
* @param name ...
|
||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
// "/" is used as delimiter, so it's not a legal char
|
|
||||||
if (name.indexOf('/') > -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// throw new RuntimeException ("The name of the node must not contain \"/\".");
|
|
||||||
if ((name == null) || (name.trim().length() == 0)) {
|
if ((name == null) || (name.trim().length() == 0)) {
|
||||||
this.name = id; // use id as name
|
// use id as name
|
||||||
|
this.name = id;
|
||||||
|
} else if (name.indexOf('/') > -1) {
|
||||||
|
// "/" is used as delimiter, so it's not a legal char
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1009,7 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
rel = dbmap.getSubnodeRelation();
|
rel = dbmap.getSubnodeRelation();
|
||||||
|
|
||||||
if ((rel != null) && (rel.groupby == null) && (rel.accessName != null)) {
|
if ((rel != null) && (rel.groupby != null || rel.accessName != null)) {
|
||||||
if ((rel.otherType != null) && rel.otherType.isRelational()) {
|
if ((rel.otherType != null) && rel.otherType.isRelational()) {
|
||||||
return nmgr.getNode(this, name, rel);
|
return nmgr.getNode(this, name, rel);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1143,10 +1146,11 @@ public final class Node implements INode, Serializable {
|
||||||
|
|
||||||
if (relational || create) {
|
if (relational || create) {
|
||||||
Node node = relational ? new Node(this, sid, nmgr, null)
|
Node node = relational ? new Node(this, sid, nmgr, null)
|
||||||
: new Node("groupby-" + sid, null, nmgr);
|
: new Node(sid, null, nmgr);
|
||||||
|
|
||||||
// set "groupname" property to value of groupby field
|
// set "groupname" property to value of groupby field
|
||||||
node.setString("groupname", sid);
|
node.setString("groupname", sid);
|
||||||
|
node.setString("name", sid);
|
||||||
|
|
||||||
if (relational) {
|
if (relational) {
|
||||||
node.setDbMapping(groupbyMapping);
|
node.setDbMapping(groupbyMapping);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue