org.embl.ebi.escience.scuflworkers.java
Class XMLOutputSplitter

java.lang.Object
  extended by org.embl.ebi.escience.scuflworkers.java.XMLOutputSplitter
All Implemented Interfaces:
LocalWorker, LocalWorkerWithPorts, XMLExtensible

public class XMLOutputSplitter
extends java.lang.Object
implements LocalWorkerWithPorts, XMLExtensible

A LocalWorker that facilitates in extracting information from the inner elements of an XML output from a SOAP based service that returns a complex type. Information stored within deeper elements can be retreived by adding additional XMLOutputSplitters.

Author:
sowen

Field Summary
 
Fields inherited from interface org.embl.ebi.escience.scuflworkers.java.LocalWorker
BINARY, BINARY_ARRAY, HTML, HTML_ARRAY, PNG_IMAGE, PNG_IMAGE_ARRAY, STRING, STRING_ARRAY, UNTYPED, UNTYPED_ARRAY
 
Constructor Summary
XMLOutputSplitter()
           
 
Method Summary
 void consumeXML(org.jdom.Element element)
          Generates the TypeDescriptor structure, and then the relevant outputs from the XML element provided.
 boolean doesTypeContainCyclicReferences(OutputPort port)
          Returns true if the given port maps to a complex type whose data structure contains cyclic references
 java.util.Map execute(java.util.Map inputMap)
          Takes an XML input, and peels away the first layer and populates the outputs with the children of this layer.
 java.lang.String[] inputNames()
          Get an array of the names of input ports for this processor
 java.util.List<InputPort> inputPorts(LocalServiceProcessor processor)
          The InputPorts for this localworker, to be used by LocalServiceProcessor
 java.lang.String[] inputTypes()
          Get an array of the string types for the inputs defined by the inputNames() method, these should probably use the constants defined in this interface but may use any valid Baclava data type specifier.
static boolean isSplittable(OutputPort output)
          Determines whether the given output port supports being splitted
 java.lang.String[] outputNames()
          Names of the output ports
 java.util.List<OutputPort> outputPorts(LocalServiceProcessor processor)
          The OutputPorts for this localworker, to be used by LocalServiceProcessor
 java.lang.String[] outputTypes()
          Types of the output ports
 org.jdom.Element provideXML()
          Generates the XML that describes the TypeDescriptor, and therefore the outputs for this worker, to allow it to be reconstructed using consumeXML.
 void setUpOutputs(OutputPort portToSplit)
          Sets up the outputs for the worker based on the type descriptions of the OutputPort provided.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLOutputSplitter

public XMLOutputSplitter()
Method Detail

inputNames

public java.lang.String[] inputNames()
Description copied from interface: LocalWorker
Get an array of the names of input ports for this processor

Specified by:
inputNames in interface LocalWorker

inputTypes

public java.lang.String[] inputTypes()
Description copied from interface: LocalWorker
Get an array of the string types for the inputs defined by the inputNames() method, these should probably use the constants defined in this interface but may use any valid Baclava data type specifier.

Specified by:
inputTypes in interface LocalWorker

outputNames

public java.lang.String[] outputNames()
Description copied from interface: LocalWorker
Names of the output ports

Specified by:
outputNames in interface LocalWorker

outputTypes

public java.lang.String[] outputTypes()
Description copied from interface: LocalWorker
Types of the output ports

Specified by:
outputTypes in interface LocalWorker

doesTypeContainCyclicReferences

public boolean doesTypeContainCyclicReferences(OutputPort port)
Returns true if the given port maps to a complex type whose data structure contains cyclic references

Parameters:
port -
Returns:

isSplittable

public static boolean isSplittable(OutputPort output)
Determines whether the given output port supports being splitted

Parameters:
input -
Returns:

setUpOutputs

public void setUpOutputs(OutputPort portToSplit)
Sets up the outputs for the worker based on the type descriptions of the OutputPort provided.

Parameters:
portToSplit -

consumeXML

public void consumeXML(org.jdom.Element element)
Generates the TypeDescriptor structure, and then the relevant outputs from the XML element provided. This assumes that the root of the structure is . This will be the same xml generated by provideXML.

Specified by:
consumeXML in interface XMLExtensible

provideXML

public org.jdom.Element provideXML()
Generates the XML that describes the TypeDescriptor, and therefore the outputs for this worker, to allow it to be reconstructed using consumeXML.

Specified by:
provideXML in interface XMLExtensible

execute

public java.util.Map execute(java.util.Map inputMap)
                      throws TaskExecutionException
Takes an XML input, and peels away the first layer and populates the outputs with the children of this layer. If a child holds a primitive value then the output for this field is simply populated, for complex types the xml is passed forward to that output. For arrays, an ArrayList is populated. Outputs that are not present in the incoming XML are either populated with an empty text value, or an empty XML element for the output name if it is a complex type. Arrays are populated as an empty array.

Specified by:
execute in interface LocalWorker
Throws:
TaskExecutionException - thrown if there is an error during invocation of the task.

inputPorts

public java.util.List<InputPort> inputPorts(LocalServiceProcessor processor)
                                     throws DuplicatePortNameException,
                                            PortCreationException
Description copied from interface: LocalWorkerWithPorts
The InputPorts for this localworker, to be used by LocalServiceProcessor

Specified by:
inputPorts in interface LocalWorkerWithPorts
Throws:
DuplicatePortNameException
PortCreationException

outputPorts

public java.util.List<OutputPort> outputPorts(LocalServiceProcessor processor)
                                       throws DuplicatePortNameException,
                                              PortCreationException
Description copied from interface: LocalWorkerWithPorts
The OutputPorts for this localworker, to be used by LocalServiceProcessor

Specified by:
outputPorts in interface LocalWorkerWithPorts
Throws:
DuplicatePortNameException
PortCreationException