Provides simple java classes to generate an IWIR workflow.
The package encourages a top-down approach.
Attributes are assigned using the constructors.
If there can exist more than one child nodes of the same type (e.g.InputPort,UnionPort) the nodes are added using a add* method.
If there can exist only a single child node (e.g Loopcounter, IWIR-Task) the node is set using a set* method.
Consider the following complete example for a cross product:
{@code
IWIR i = new IWIR("crossProduct");
ParallelForEachTask forEach1 = new ParallelForEachTask("foreach1");
forEach1.addInputPort(new InputPort("collB",new CollectionType(SimpleType.FILE)));
forEach1.addLoopElement(new LoopElement("collA", new CollectionType(SimpleType.FILE)));
ParallelForEachTask forEach2 = new ParallelForEachTask("foreach2");
forEach2.addInputPort(new InputPort("elementA",SimpleType.FILE));
forEach2.addLoopElement(new LoopElement("collB",new CollectionType(SimpleType.FILE)));
Task a = new Task("A","consumer");
a.addInputPort(new InputPort("elementA",SimpleType.FILE));
a.addInputPort(new InputPort("elementB", SimpleType.FILE));
a.addOutputPort(new OutputPort("res",SimpleType.FILE));
forEach2.addTask(a);
forEach2.addOutputPort(new OutputPort("res",new CollectionType(SimpleType.FILE)));
forEach2.addLink(forEach2.getPort("elementA"), a.getPort("elementA"));
forEach2.addLink(forEach2.getPort("collB"), a.getPort("elementB"));
forEach2.addLink(a.getPort("res"), forEach2.getPort("res"));
forEach1.addTask(forEach2);
forEach1.addOutputPort(new OutputPort("res",new CollectionType(new CollectionType(SimpleType.FILE))));
forEach1.addLink(forEach1.getPort("collA"), forEach2.getPort("elementA"));
forEach1.addLink(forEach1.getPort("collB"), forEach2.getPort("collB"));
forEach1.addLink(forEach2.getPort("res"), forEach1.getPort("res"));
i.setTask(forEach1);
}
We can print out the result or write it into a file using following commands:
i.asXMLString();
and
i.asXMLFile();
and
An IWIR object can be generated from a given file using a constructor:
IWIR i = new IWIR(file);
Following lines depict the XML representation of our example:
<IWIR version="1.0" wfname="crossProduct" xmlns="http://shiwa-workflow.eu/IWIR">
<parallelForEach name="foreach1">
<inputPorts>
<inputPort name="collB" type="collection/file"/>
<loopElements>
<loopElement name="collA" type="collection/file"/>
</loopElements>
</inputPorts>
<body>
<parallelForEach name="foreach2">
<inputPorts>
<inputPort name="elementA" type="file"/>
<loopElements>
<loopElement name="collB" type="collection/file"/>
</loopElements>
</inputPorts>
<body>
<task name="A" tasktype="consumer">
<inputPorts>
<inputPort name="elementA" type="file"/>
<inputPort name="elementB" type="file"/>
</inputPorts>
<outputPorts>
<outputPort name="res" type="file"/>
</outputPorts>
</task>
</body>
<outputPorts>
<outputPort name="res" type="collection/file"/>
</outputPorts>
<links>
<links from="forEach2/elementA" to="A/elementA"/>
<links from="forEach2/collB" to="A/elementB"/>
<links from="A/res" to="forEach2/res"/>
</links>
</parallelForEach>
</body>
<outputPorts>
<outputPort name="res" type="collection/collection/file"/>
</outputPorts>
<links>
<links from="forEach1/collA" to="forEach2/elementA"/>
<links from="forEach1/collB" to="forEach2/collB"/>
<links from="forEach2/res" to="forEach1/res"/>
</links>
</parallelForEach>
</IWIR>