Skip to content

Instantly share code, notes, and snippets.

@grechaw
Created April 28, 2016 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grechaw/3ca6f520fd87026b9538ce6e104dcd29 to your computer and use it in GitHub Desktop.
Save grechaw/3ca6f520fd87026b9538ce6e104dcd29 to your computer and use it in GitHub Desktop.
eval one result
public static EvalResultIterator eval(String functionCall) throws TestEvalException {
String imports =
"import module namespace sem = 'http://marklogic.com/semantics' at '/MarkLogic/semantics.xqy';\n";
ServerEvaluationCall call =
client.newServerEval().xquery(entityServicesImport + functionCall);
EvalResultIterator results = null;
try {
results = call.eval();
} catch (FailedRequestException e) {
throw new TestEvalException(e);
}
return results;
}
protected static <T extends AbstractReadHandle> T evalOneResult(String functionCall, T handle) throws TestEvalException {
EvalResultIterator results = eval(functionCall);
EvalResult result = null;
if (results.hasNext()) {
result = results.next();
return result.get(handle);
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment