Search in sources :

Example 1 with Parameter

use of org.cristalise.kernel.scripting.Parameter in project kernel by cristal-ise.

the class AgentProxy method callScript.

@SuppressWarnings("rawtypes")
private ErrorInfo callScript(ItemProxy item, Job job) throws ScriptingEngineException, InvalidDataException, ObjectNotFoundException {
    Script script = job.getScript();
    if (script.getOutputParams().size() == 1) {
        Parameter p = script.getOutputParams().values().iterator().next();
        if (p.getType() == ErrorInfo.class) {
            script.setActExecEnvironment(item, this, job);
            Object returnVal = script.execute();
            if (returnVal instanceof Map)
                return (ErrorInfo) ((Map) returnVal).get(p.getName());
            else
                return (ErrorInfo) returnVal;
        }
    }
    throw new InvalidDataException("Script " + script.getName() + " must define single output of type org.cristalise.kernel.scripting.ErrorInfo");
}
Also used : Script(org.cristalise.kernel.scripting.Script) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) Parameter(org.cristalise.kernel.scripting.Parameter) C2KLocalObject(org.cristalise.kernel.entity.C2KLocalObject) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 C2KLocalObject (org.cristalise.kernel.entity.C2KLocalObject)1 Parameter (org.cristalise.kernel.scripting.Parameter)1 Script (org.cristalise.kernel.scripting.Script)1