public Graph transform(RequestContext context, Graph graph)
throws TransformationException
{
if (mTypeChecker == null)
{
throw new TransformationException("Type checker must not be null.");
}
List<RequestNode> newNodes = new ArrayList<RequestNode>();
for (RequestNode requestNode : graph.getNodes())
{
if (!(requestNode instanceof ProcessingElementNode))
{
continue;
}
ProcessingElementNode pe = (ProcessingElementNode)requestNode;
ProcessingElementDescriptor descriptor =
pe.getProcessingElementDescriptor();
for (ProcessingElementInputDescriptor inputDescriptor : descriptor.getInputs())
{
Map<Integer, Connection> input =
requestNode.getAllInputs().get(inputDescriptor.getName());
if (input == null)
{
// we have an optional input that is not connected
// this is valid so we're just ignoring it
continue;
}
for (Entry<Integer, Connection> connection : input.entrySet())
{
RequestNode source = connection.getValue().getSource();
String name = connection.getValue().getSourceOutputName();
ProcessingElementOutputDescriptor outputDescriptor =
getOutputDescriptor(source, name);
try
{
RequestNode converter =
mTypeChecker.checkCompatibility(
outputDescriptor, inputDescriptor);
insertConverter(
newNodes,
requestNode,
connection.getValue(),
converter);
}
catch (Exception e)
{
throw new TransformationException(
"Types in output descriptor " + name
+ "[" + connection.getValue().getSourceOutputIndex()
+ "] of PE " + source.getName()
+ " are not compatible with input descriptor "
+ inputDescriptor.getName()