// try named node definitions first
QItemDefinition[] defs = getNamedItemDefs(name);
for (QItemDefinition def : defs) {
if (def.definesNode()) {
QNodeDefinition nd = (QNodeDefinition) def;
Name[] types = nd.getRequiredPrimaryTypes();
// node definition with that name exists
if (entTarget != null && types != null) {
// check 'required primary types' constraint
if (entTarget.includesNodeTypes(types)) {
// found named node definition
return nd;
}
} else if (nd.getDefaultPrimaryType() != null) {
// found node definition with default node type
return nd;
}
}
}
// no item with that name defined;
// try residual node definitions
QNodeDefinition[] nda = getUnnamedNodeDefs();
for (QNodeDefinition nd : nda) {
if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
// check 'required primary types' constraint
if (!entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
continue;
}
// found residual node definition
return nd;
} else {
// since no node type has been specified for the new node,
// it must be determined from the default node type;
if (nd.getDefaultPrimaryType() != null) {
// found residual node definition with default node type
return nd;
}
}
}