use of org.apache.airavata.workflow.model.graph.ws.WSPort 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.ws.WSPort in project airavata by apache.
the class WorkflowInterpreter method setupNodeDetailsInput.
private void setupNodeDetailsInput(Node node, WorkflowNodeDetails nodeDetails) {
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort dataPort : inputPorts) {
Node fromNode = dataPort.getFromNode();
String portInputValue = null;
if (fromNode instanceof InputNode) {
portInputValue = (String) ((InputNode) fromNode).getDefaultValue();
} else if (fromNode instanceof WSNode) {
Map<String, String> outputData = nodeOutputData.get(fromNode);
portInputValue = outputData.get(dataPort.getName());
if (portInputValue == null) {
portInputValue = outputData.get(dataPort.getEdge(0).getFromPort().getName());
}
}
// 123456789
InputDataObjectType elem = new InputDataObjectType();
elem.setName(dataPort.getName());
elem.setValue(portInputValue);
if (dataPort instanceof WSPort) {
WSPort port = (WSPort) dataPort;
elem.setInputOrder(port.getComponentPort().getInputOrder());
elem.setApplicationArgument((port.getComponentPort().getApplicationArgument() != null ? port.getComponentPort().getApplicationArgument() : ""));
elem.setType(port.getType());
}
nodeDetails.addToNodeInputs(elem);
}
try {
getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
} catch (RegistryException e) {
log.error(e.getMessage(), e);
}
}
Aggregations