use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class InterpreterUtil method findInputFromPort.
public static Object findInputFromPort(DataPort inputPort) throws WorkflowException {
Object outputVal = null;
Node fromNode = inputPort.getFromNode();
if (fromNode instanceof InputNode) {
outputVal = ((InputNode) fromNode).getDefaultValue();
// } else if (fromNode instanceof ConstantNode) {
// outputVal = ((ConstantNode) fromNode).getValue();
// } else if (fromNode instanceof DifferedInputNode && ((DifferedInputNode) fromNode).isConfigured()) {
// outputVal = ((DifferedInputNode) fromNode).getDefaultValue();
// } else if (fromNode instanceof EndifNode || fromNode instanceof DoWhileNode || fromNode instanceof EndDoWhileNode) {
// Invoker fromInvoker = invokerMap.get(fromNode);
// outputVal = fromInvoker.getOutput(inputPort.getFromPort().getID());
// } else if (fromNode instanceof InstanceNode) {
// return ((InstanceNode) fromNode).getOutputInstanceId();
// } else if (fromNode instanceof EndForEachNode) {
// outputVal = "";
// Invoker workflowInvoker = invokerMap.get(fromNode);
// String outputName = "";
// if (inputPort instanceof SystemDataPort) {
// outputName = ((SystemDataPort) inputPort).getWSComponentPort().getName();
//
// } else if (inputPort instanceof WSPort) {
// outputName = ((SystemDataPort) fromNode.getInputPort(fromNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort())))
// .getWSComponentPort().getName();
// }
// XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + workflowInvoker.getOutput(outputName) + "</temp>");
// Iterator valItr = msgElmt.children().iterator();
// while (valItr.hasNext()) {
// Object object2 = valItr.next();
// if (object2 instanceof XmlElement) {
//
// if (((XmlElement) object2).children().iterator().hasNext()) {
// outputVal = outputVal + StringUtil.DELIMETER + StringUtil.quoteString(((XmlElement) object2).children().iterator().next().toString());
// }
// }
// }
//
// if (((String) outputVal).length() == 0) {
// throw new WorkflowException("Empty Output Generated");
// }
// outputVal = ((String) outputVal).substring(1, ((String) outputVal).length());
// } else {
// Invoker fromInvoker = invokerMap.get(fromNode);
// try {
// if (fromInvoker != null)
// outputVal = fromInvoker.getOutput(inputPort.getFromPort().getName());
//
// } catch (Exception e) {
// // if the value is still null look it up from the inputport name
// // because the value is set to the input port name at some point
// // there is no harm in doing this
// if (null == outputVal) {
// outputVal = fromInvoker.getOutput(inputPort.getName());
// }
// }
}
return outputVal;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class InterpreterUtil method getNumberOfInputsForForEachNode.
public static Integer[] getNumberOfInputsForForEachNode(final ForEachNode forEachNode, Map<Node, Invoker> invokerMap) throws WorkflowException {
List<DataPort> inputPorts = forEachNode.getInputPorts();
Integer[] inputNumbers = new Integer[inputPorts.size()];
for (DataPort forEachInputPort : inputPorts) {
// if input node for for-each is WSNode
Node forEachInputNode = forEachInputPort.getFromNode();
int index = 0;
Object returnValForProvenance = null;
if (forEachInputNode instanceof InputNode) {
returnValForProvenance = InterpreterUtil.findInputFromPort(forEachInputPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
inputNumbers[inputPorts.indexOf(forEachInputPort)] = vals.length;
}
}
return inputNumbers;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class Workflow method getInputs.
/**
* Returns the inputs of the workflow.
*
* @return The inputs of the workflow.
* @throws ComponentException
*/
public List<WSComponentPort> getInputs() throws ComponentException {
List<InputNode> nodes = GraphUtil.getNodes(this.graph, InputNode.class);
List<WSComponentPort> ports = new ArrayList<WSComponentPort>();
for (InputNode inputNode : nodes) {
ports.add(new WSComponentPort(inputNode.getName(), inputNode.getOutputPorts().get(0).getType(), null));
}
return ports;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowWSDL method addParameter.
/**
* Adds the parameter element.
*
* @param node
* @param sequence
* @param schema
* @return The parameter element
*/
private XmlElement addParameter(ParameterNode node, XmlElement sequence, XmlElement schema) {
XmlElement element;
SystemDataPort port = node.getPort();
element = addParameter(node, port, sequence, schema);
//
// Annotation
//
String description = node.getDescription();
XmlElement appinfo = node.getMetadata();
// description
if (description != null && description.trim().length() != 0) {
XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
XmlElement documentation = annotation.addElement(WSConstants.DOCUMENTATION_TAG);
documentation.setText(node.getDescription());
}
// appinfo
if (appinfo != null) {
XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
try {
annotation.addElement(XMLUtil.deepClone(appinfo));
} catch (AiravataException e) {
log.error(e.getMessage(), e);
}
}
//
if (node instanceof InputNode) {
InputNode inputNode = (InputNode) node;
Object value = inputNode.getDefaultValue();
if (value instanceof String) {
element.setAttributeValue(WSConstants.DEFAULT_ATTRIBUTE, (String) value);
} else if (value instanceof XmlElement) {
// Add the default value in <annotation><default> because there
// is no standard way.
XmlElement valueElement = null;
try {
valueElement = XMLUtil.deepClone((XmlElement) value);
} catch (AiravataException e) {
log.error(e.getMessage(), e);
}
XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
XmlElement defaultElement = annotation.addElement(WSComponentPort.DEFAULT);
defaultElement.addElement(valueElement);
}
}
return element;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class XBayaUtil method getInputsForForEachNode.
public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
Node forEachInputNode = forEachNode.getInputPort(0).getFromNode();
// if input node for for-each is WSNode
Object returnValForProvenance = null;
if (forEachInputNode instanceof InputNode) {
for (DataPort dataPort : forEachNode.getInputPorts()) {
returnValForProvenance = XBayaUtil.findInputFromPort(dataPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
listOfValues.addAll(Arrays.asList(vals));
}
}
return returnValForProvenance;
}
Aggregations