// - get uuid for each parameter; ordered by sequence (l to r)
// - (x) if no match, attempt non-equivalence query
// - find kam node by term signature / uuids
// parse the bel term
Term term = null;
try {
term = BELParser.parseTerm(belTerm);
if (term == null) return null;
} catch (Exception e) {
// unrecognized BEL structure
return null;
}
// get all parameters; remap to kam namespace by prefix
List<Parameter> params = term.getAllParametersLeftToRight();
remapNamespace(params, nsmap);
// convert bel term to signature
String termSignature = term.toTermSignature();
// find uuids for all parameters; bucket both the mapped and
// unmapped namespace values
SkinnyUUID[] uuids = new SkinnyUUID[params.size()];
Parameter[] parray = params.toArray(new Parameter[params.size()]);
boolean missing = false;
for (int i = 0; i < parray.length; i++) {
Parameter param = parray[i];
Namespace ns = param.getNamespace();
if (ns == null) {
missing = true;
break;
}
String value = clean(param.getValue());
SkinnyUUID uuid = null;
try {
uuid = equivalencer.getUUID(ns, value);
} catch (EquivalencerException e) {
throw new ResolverException(e);
}
if (uuid != null && !kAMStore.getKamNodes(kam, uuid).isEmpty()) {
uuids[i] = uuid;
} else {
missing = true;
break;
}
}
// TODO Handle terms that may not have UUID parameters!
if (missing) {
KamNode kamNode = kAMStore.getKamNode(kam, belTerm);
return kamNode;
}
// find kam node by term signature / uuids
return kAMStore.getKamNodeForTerm(kam, termSignature,
term.getFunctionEnum(), uuids);
} catch (KAMStoreException e) {
throw new ResolverException(e);
}
}