use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class JythonScript method writeOutput.
private void writeOutput(OutputNode node, PrintWriter pw) throws GraphException {
String id = node.getID();
Port port = node.getPort();
Node fromNode = port.getFromNode();
if (fromNode == null) {
throw new GraphException("Output parameter has to be connected to some node.");
}
Port fromPort = port.getFromPort();
if (fromNode instanceof InputNode) {
// The OutputNode is directly connected to an InputNode.
pw.println(TAB + id + VALUE_SUFFIX + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')");
} else {
pw.println(TAB + "# Wait output " + id);
pw.println(TAB + id + VALUE_SUFFIX + " = " + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')");
}
pw.println(TAB + "print '" + id + " = ', " + id + VALUE_SUFFIX);
// This might try to remove a node that has been removed
// already, but it's OK.
this.executingNodes.remove(fromNode);
pw.println();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class JythonScript method writeParameters.
/**
* Handles parameters
*
* @param pw
*/
private void writeParameters(PrintWriter pw) {
pw.println(PROPERTIES_VARIABLE + " = Properties()");
pw.println();
pw.println("# Set up defaut parameter values.");
writeSetProperty(BROKER_URL_VARIABLE, XBayaConstants.DEFAULT_BROKER_URL, pw);
writeSetProperty(MESSAGE_BOX_URL_VARIABLE, this.configuration.getMessageBoxURL(), pw);
writeSetProperty(TOPIC_VARIABLE, XBayaConstants.DEFAULT_TOPIC, pw);
for (InputNode paramNode : this.inputNodes) {
writeParameter(paramNode, pw);
this.notYetInvokedNodes.remove(paramNode);
}
pw.println();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowModifier method createInputNodes.
/**
* @param graph
* @param originalFromPorts
* @throws GraphException
*/
private void createInputNodes(WSGraph graph, Set<WSPort> originalFromPorts) throws GraphException {
InputComponent inputComponent = new InputComponent();
for (WSPort originalFromPort : originalFromPorts) {
InputNode inputNode = inputComponent.createNode(graph);
List<Port> originalToPorts = originalFromPort.getToPorts();
boolean first = true;
for (Port originalToPort : originalToPorts) {
String toPortID = originalToPort.getID();
Port toPort = graph.getPort(toPortID);
graph.addEdge(inputNode.getPort(), toPort);
if (first) {
first = false;
Point position = NodeController.getGUI(originalToPort).getPosition();
Point inputNodePosition = new Point(0, position.y);
inputNode.setPosition(inputNodePosition);
}
}
}
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowModifier method createDifference.
/**
* @return The workflow that needs to be executed.
* @throws GraphException
* @throws MonitorException
*/
public Workflow createDifference() throws GraphException, MonitorException {
WSGraph originalGraph = this.modifiedWorkflow.getGraph();
Workflow workflow = this.modifiedWorkflow.clone();
String name = workflow.getName();
name += " (diff)";
workflow.setName(name);
WSGraph graph = workflow.getGraph();
// Remove the finished node.
removeFinishedNodes(originalGraph, graph);
Set<WSPort> originalFromPorts = getFinalOutputPorts(originalGraph, graph);
// Create input nodes for unconnected input ports.
createInputNodes(graph, originalFromPorts);
// Set default values.
for (WSPort originalFromPort : originalFromPorts) {
// TODO handle the case that node is not WSNode.
Node originalFromNode = originalFromPort.getNode();
String fromNodeID = originalFromNode.getID();
String output;
if (originalFromNode instanceof InputNode) {
// notification that includes the input of the workflow.
output = getWorkflowInput(fromNodeID);
} else if (originalFromNode instanceof WSNode) {
// Retrieve input value from notification.
WSComponent component = ((WSNode) originalFromNode).getComponent();
String messageName = component.getOutputTypeName();
String parameterName = originalFromPort.getComponentPort().getName();
output = getOutput(fromNodeID, messageName, parameterName);
} else {
// This should not happen.
throw new WorkflowRuntimeException(originalFromNode.getClass().getName());
}
Port originalToPort = originalFromPort.getToPorts().get(0);
PortImpl toPort = graph.getPort(originalToPort.getID());
InputNode inputNode = (InputNode) toPort.getFromNode();
inputNode.setDefaultValue(output);
}
return workflow;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowHarvester method cleanLeftOverInputNodes.
/**
* @param clone
*/
private void cleanLeftOverInputNodes(Workflow clone) {
List<NodeImpl> nodes = clone.getGraph().getNodes();
LinkedList<Node> removeList = new LinkedList<Node>();
for (Node nodeImpl : nodes) {
if (nodeImpl instanceof InputNode) {
if (nodeImpl.getOutputPort(0).getToNodes().size() == 0) {
removeList.add(nodeImpl);
}
}
}
for (Node node : removeList) {
try {
clone.removeNode(node);
} catch (GraphException e) {
throw new WorkflowRuntimeException(e);
}
}
}
Aggregations