use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class WorkflowInterpreter method handleDynamicComponent.
private void handleDynamicComponent(Node node) throws WorkflowException {
DynamicComponent dynamicComponent = (DynamicComponent) node.getComponent();
String className = dynamicComponent.getClassName();
String operationName = dynamicComponent.getOperationName();
URL implJarLocation = dynamicComponent.getImplJarLocation();
DynamicNode dynamicNode = (DynamicNode) node;
LinkedList<Object> inputs = new LinkedList<Object>();
List<DataPort> inputPorts = dynamicNode.getInputPorts();
for (DataPort dataPort : inputPorts) {
Object inputVal = InterpreterUtil.findInputFromPort(dataPort, this.invokerMap);
/*
* Set type after get input value, and override inputValue if output
* type is array
*/
Node fromNode = dataPort.getFromNode();
DataType type = null;
if (fromNode instanceof InputNode) {
type = DataType.STRING;
} else if (fromNode instanceof ConstantNode) {
type = ((ConstantNode) fromNode).getType();
} else if ((dataPort.getFromPort() instanceof WSPort) && BasicTypeMapping.isArrayType(((WSPort) dataPort.getFromPort()).getComponentPort().getElement())) {
Invoker fromInvoker = this.invokerMap.get(fromNode);
// inputVal = BasicTypeMapping.getOutputArray(XmlConstants.BUILDER.parseFragmentFromString(fromInvoker.getOutputs().toString()), dataPort
// .getFromPort().getName(), BasicTypeMapping.getSimpleTypeIndex(((DataPort) dataPort.getFromPort()).getType()));
type = ((DataPort) dataPort.getFromPort()).getType();
} else {
type = ((DataPort) dataPort.getFromPort()).getType();
}
if (null == inputVal) {
throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + node.getID());
}
// inputs.add(BasicTypeMapping.getObjectOfType(type, inputVal));
}
DynamicInvoker dynamicInvoker = new DynamicInvoker(className, implJarLocation, operationName, inputs.toArray());
this.invokerMap.put(node, dynamicInvoker);
dynamicInvoker.setup();
dynamicInvoker.invoke();
node.setState(NodeExecutionState.FINISHED);
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class GraphUtil method propagateTypes.
/**
* @param graph
* @throws GraphException
*/
public static void propagateTypes(Graph graph) throws GraphException {
List<WSPort> wsPorts = getPorts(graph, WSPort.class);
for (WSPort wsPort : wsPorts) {
List<DataEdge> edges = wsPort.getEdges();
for (DataEdge edge : edges) {
DataPort fromPort = edge.getFromPort();
DataPort toPort = edge.getToPort();
if (fromPort == wsPort) {
toPort.copyType(wsPort);
} else if (toPort == wsPort) {
fromPort.copyType(wsPort);
} else {
throw new WorkflowRuntimeException();
}
}
}
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class WorkflowModifier method getFinalOutputPorts.
/**
* @param originalGraph
* @param graph
* @return The final output ports.
*/
private Set<WSPort> getFinalOutputPorts(WSGraph originalGraph, WSGraph graph) {
Collection<Port> inputPorts = GraphUtil.getPorts(graph, Port.Kind.DATA_IN);
Set<WSPort> originalFromPorts = new HashSet<WSPort>();
for (Port inputPort : inputPorts) {
Port fromPort = inputPort.getFromPort();
if (fromPort == null) {
// This input port is not connected.
String inputPortID = inputPort.getID();
logger.debug("id: " + inputPortID);
Port originalInputPort = originalGraph.getPort(inputPortID);
// No duplicate in set.
Port originalFromPort = originalInputPort.getFromPort();
originalFromPorts.add((WSPort) originalFromPort);
}
}
return originalFromPorts;
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class InputNode method edgeWasRemoved.
/**
* Called whan an Edge was removed from the parameter port. Change the name of the node.
*
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
*/
@Override
protected void edgeWasRemoved(Edge removedEdge) {
super.edgeWasRemoved(removedEdge);
// TODO organize this.
List<DataEdge> edges = getEdges();
if (edges.size() == 0) {
setParameterType(null);
if (!isConfigured()) {
// Reset
setName(getComponent().getName());
setDescription("");
setDefaultValue(null);
setMetadata(null);
}
} else {
Edge edge = edges.get(0);
Port toPort = edge.getToPort();
WSPort toWsPort = (WSPort) toPort;
DataType toType = toWsPort.getType();
setParameterType(toType);
if (!isConfigured()) {
// Copy
copyDefaultConfiguration(toWsPort);
}
}
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class S3InputNode method edgeWasRemoved.
/**
* Called whan an Edge was removed from the parameter port. Change the name of the node.
*
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
*/
@Override
protected void edgeWasRemoved(Edge removedEdge) {
super.edgeWasRemoved(removedEdge);
// TODO organize this.
List<DataEdge> edges = getEdges();
if (edges.size() == 0) {
setParameterType(null);
if (!isConfigured()) {
// Reset
setName(getComponent().getName());
setDescription("");
setDefaultValue(null);
setMetadata(null);
}
} else {
Edge edge = edges.get(0);
Port toPort = edge.getToPort();
WSPort toWsPort = (WSPort) toPort;
DataType toType = toWsPort.getType();
setParameterType(toType);
if (!isConfigured()) {
// Copy
copyDefaultConfiguration(toWsPort);
}
}
}
Aggregations