ResultProcessor

From GreenVulcano Wiki
Jump to: navigation, search

Description

Defines SubFlows output aggregation policy:

  • none  : return a java.util.List containig the SubFlows output
  • XMLAggregate  : aggregate the SubFlows output as XML
  • JavaScript  : use JavaScript to process a java.util.List containig the SubFlows output REMOVED in v3.5
  • OGNLScript  : use OGNL to process a java.util.List containig the SubFlows output REMOVED in v3.5
  • Script  : use a Script engine to process a java.util.List containig the SubFlows output

If isn't defined a processor the SubFlows output is intended as GVBuffer.output content or an Exception. The *Script processor receives as input a list of it.greenvulcano.gvesb.core.flow.parallel.Result instances that wrapps the SubFlows input and output.

VulCon / GV Console Configuration

The following table shows the ResultProcessor element's attributes:

Attribute Type Description
processor-input required Defines the input to pass to the specific processor:
   - XMLAggregate
       - only-object   : array of output valid GVBuffer.object content, in the order of instantiation of SubFlows
       - only-gvbuffer : same as above
       - gvbuffer-and-error : same as above
       - object-and-error   : same as above
   - *Script
       - only-object : java.util.List of output valid GVBuffer.object content, in the order of instantiation of SubFlows
       - only-gvbuffer : java.util.List of output valid GVBuffer (wrapped as Result object), in the order of instantiation of SubFlows
       - gvbuffer-and-error : java.util.List of output valid GVBuffer or Exception (wrapped as Result object), in the order of instantiation of SubFlows
       - object-and-error   : java.util.List of output valid GVBuffer.object content or Exception , in the order of instantiation of SubFlows

The number of elements in the array will depend on several factors related to parallel flow configuration and SubFlow execution.

If a processor is not defined, the output GVBuffer.object will contain the java.util.List as defined as input for *Script but unwrapped.

fail-on-error required If true and any of the SubFlows output contains an Exception then the ResultProcessor returns an error.

Default to true.

Might contain the following elements:

Follows an example that illustrate a input/output data manipulation through JavaScript:

<ResultProcessor fail-on-error="true"
                 processor-input="only-gvbuffer">
    <JavaScript><![CDATA[var str = "";
for (var i=0; i<results.size(); i++)
{
    var inV = results.get(i).getInput().getObject();
    var outV = results.get(i).getOutput().getObject();
    str += ";[" + inV + " -> " + outV + "]";
}

data.setObject(str.substring(1));]]>
    </JavaScript>
</ResultProcessor>

The same example using the generic Script engine:

<ResultProcessor fail-on-error="true"
                 processor-input="only-gvbuffer">
    <Script lang="js"><![CDATA[var str = "";
for (var i=0; i<results.size(); i++)
{
    var inV = results.get(i).getInput().getObject();
    var outV = results.get(i).getOutput().getObject();
    str += ";[" + inV + " -> " + outV + "]";
}

data.setObject(str.substring(1));]]>
    </Script>
</ResultProcessor>