use of com.inova8.intelligentgraph.exceptions.ScriptFailedException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class SEEQSource method getSEEQSignal.
/**
* Gets the SEEQ signal.
*
* @param thing the thing
* @param signal the signal
* @param customQueryOptions the custom query options
* @return the SEEQ signal
* @throws ScriptFailedException the script failed exception
*/
public static Resource getSEEQSignal(Thing thing, String signal, CustomQueryOptions customQueryOptions) throws ScriptFailedException {
signal = Utilities.trimIRIString(signal);
String[] elements = signal.split("/");
Object result;
SEEQSource seeqSource = null;
try {
if (elements.length < 6) {
thing.getEvaluationContext().getTracer().decrementLevel();
String error = String.format("Unsupported signal source: %s", signal);
logger.error(error);
thing.getEvaluationContext().getTracer().traceSignalError(error);
throw new ScriptFailedException(error);
} else {
thing.getEvaluationContext().getTracer().traceSEEQ(elements[5], customQueryOptions);
seeqSource = thing.getSource().seeqSourceFactory(elements[2]);
result = seeqSource.getSignal(elements[5], customQueryOptions);
thing.getEvaluationContext().getTracer().decrementLevel();
return Resource.create(thing.getSource(), literal((Double) result), thing.getEvaluationContext());
}
} catch (ScriptException e) {
throw new ScriptFailedException(e);
} catch (HandledException e) {
throw new ScriptFailedException(e);
}
}
Aggregations