use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowInterpreterLaunchWindow method show.
/**
* Shows the dialog.
*/
public void show() {
this.workflow = this.engine.getGUI().getWorkflow();
// Create input fields
Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
for (InputNode node : inputNodes) {
String id = node.getID();
DataType parameterType = node.getParameterType();
JLabel nameLabel = new JLabel(id);
JLabel typeField = new JLabel(parameterType.toString());
XBayaTextField paramField = new XBayaTextField();
Object value = node.getDefaultValue();
String valueString;
if (value == null) {
valueString = "";
} else {
if (value instanceof XmlElement) {
XmlElement valueElement = (XmlElement) value;
valueString = XMLUtil.xmlElementToString(valueElement);
} else {
// Only string comes here for now.
valueString = value.toString();
}
}
paramField.setText(valueString);
this.parameterPanel.add(nameLabel);
this.parameterPanel.add(typeField);
this.parameterPanel.add(paramField);
this.parameterTextFields.add(paramField);
}
Map<String, String> hosts = null;
try {
hosts = airavataClient.getAllComputeResourceNames();
if (hosts.isEmpty()) {
JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "No Compute Resources found", "Compute Resources", JOptionPane.ERROR_MESSAGE);
return;
}
} catch (InvalidRequestException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (AiravataClientException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (AiravataSystemException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (TException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
hostNames = new HashMap<String, String>();
Iterator it = hosts.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
String key = (String) pairs.getKey();
String value = (String) pairs.getValue();
if (!hostNames.containsKey(value)) {
hostNames.put(value, key);
}
}
host = new JComboBox();
it = hostNames.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
String key = (String) pairs.getKey();
host.addItem(key);
}
host.setSelectedIndex(0);
XBayaLabel hostLabel = new XBayaLabel("Host", host);
this.parameterPanel.add(hostLabel);
this.parameterPanel.add(host);
this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2);
this.dialog.show();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class GraphCanvas method mouseReleased.
private void mouseReleased(MouseEvent event) {
Point point = event.getPoint();
if (this.draggedNode != null) {
NodeController.getGUI(this.draggedNode).setDraggedFlag(false);
this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
// Check if it s stream grouping
if (draggedNode instanceof InputNode) {
StreamSourceNode streamNode = NodeController.getGUI(this.graph).getStreamSourceAt(point);
if (streamNode != null) {
streamNode.addInputNode((InputNode) draggedNode);
}
}
this.draggedNode = null;
}
if (this.draggedPort != null) {
GraphPiece graphPiece = NodeController.getGUI(this.graph).getGraphPieceAt(point);
if (graphPiece instanceof DynamicNode) {
if (this.draggedPort.getKind() == Kind.DATA_OUT && draggedPort instanceof DataPort) {
this.panel.setCursor(SwingUtil.CROSSHAIR_CURSOR);
DynamicNode dynamicNode = (DynamicNode) graphPiece;
dynamicNode.getComponent();
DataPort freePort = dynamicNode.getFreeInPort();
try {
freePort.copyType((DataPort) draggedPort);
} catch (GraphException e) {
engine.getGUI().getErrorWindow().error(e);
return;
}
// selectInputPort(freePort);
connect(this.draggedPort, freePort);
this.dynamicNodeWithFreePort = null;
}
} else if (graphPiece instanceof Port) {
Port port = (Port) graphPiece;
if (this.draggedPort.getKind() == Kind.DATA_OUT && port.getKind() == Kind.DATA_IN) {
connect(this.draggedPort, port);
} else if (port.getKind() == Kind.DATA_OUT && this.draggedPort.getKind() == Kind.DATA_IN) {
connect(port, this.draggedPort);
} else if (this.draggedPort.getKind() == Kind.CONTROL_OUT && port.getKind() == Kind.CONTROL_IN) {
connect(this.draggedPort, port);
} else if (this.draggedPort.getKind() == Kind.CONTROL_IN && port.getKind() == Kind.CONTROL_OUT) {
connect(port, this.draggedPort);
} else if (this.draggedPort.getKind() == Kind.EPR && port.getKind() == Kind.DATA_IN) {
connect(this.draggedPort, port);
} else if (this.draggedPort.getKind() == Kind.DATA_IN && port.getKind() == Kind.EPR) {
connect(port, this.draggedPort);
}
}
this.draggedPort = null;
}
if (this.dynamicNodeWithFreePort != null) {
try {
this.dynamicNodeWithFreePort.removeLastDynamicallyAddedInPort();
} catch (GraphException e) {
this.engine.getGUI().getErrorWindow().error(e);
}
}
/*
* Multiple selected
*/
if (this.mousePointForSelection != null) {
double width = Math.abs(this.mousePoint.getX() - this.mousePointForSelection.getX());
double height = Math.abs(this.mousePoint.getY() - this.mousePointForSelection.getY());
int x = (int) (this.mousePoint.getX() > this.mousePointForSelection.getX() ? this.mousePointForSelection.getX() : this.mousePoint.getX());
int y = (int) (this.mousePoint.getY() > this.mousePointForSelection.getY() ? this.mousePointForSelection.getY() : this.mousePoint.getY());
this.multipleSelectedNodes = NodeController.getGUI(this.graph).getNodesIn(new Rectangle(x, y, (int) width, (int) height));
selectNodes(this.multipleSelectedNodes);
// clear mousepoint
this.mousePointForSelection = null;
}
if (this.multipleSelectedNodes != null) {
this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
}
maybeShowPopup(event);
updateSize();
this.panel.repaint();
event.consume();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class ParameterPropertyWindow method ok.
private void ok() {
String inputMetadataText = this.inputPanel.getMetadata();
XmlElement inputMetadata;
if (inputMetadataText.length() == 0) {
inputMetadata = null;
} else {
try {
inputMetadata = XMLUtil.stringToXmlElement(inputMetadataText);
} catch (RuntimeException e) {
String warning = "The input metadata is ill-formed.";
this.engine.getGUI().getErrorWindow().error(warning, e);
return;
}
}
String outputMetadataText = this.outputPanel.getMetadata();
XmlElement outputMetadata;
if (outputMetadataText.length() == 0) {
outputMetadata = null;
} else {
try {
outputMetadata = XMLUtil.stringToXmlElement(outputMetadataText);
} catch (RuntimeException e) {
String warning = "The output metadata is ill-formed.";
this.engine.getGUI().getErrorWindow().error(warning, e);
return;
}
}
// outputs, and the rest.
for (int i = 0; i < this.inputNodes.size(); i++) {
InputNode inputNode = this.inputNodes.get(i);
Collections.swap(this.nodes, i, this.nodes.indexOf(inputNode));
}
for (int i = 0; i < this.outputNodes.size(); i++) {
OutputNode outputNode = this.outputNodes.get(i);
Collections.swap(this.nodes, this.inputNodes.size() + i, this.nodes.indexOf(outputNode));
}
hide();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class JythonScript method writeSetup.
/**
* @param pw
*/
private void writeSetup(PrintWriter pw) {
// Initialize some variables.
pw.println(GFAC_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + GFAC_VARIABLE + "')");
pw.println(TOPIC_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + TOPIC_VARIABLE + "')");
pw.println(BROKER_URL_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + BROKER_URL_VARIABLE + "')");
pw.println(MESSAGE_BOX_URL_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + MESSAGE_BOX_URL_VARIABLE + "')");
// Initialize a notification sender.
// pw.println(NOTIFICATION_VARIABLE + " = " + NOTIFICATION_CLASS + "(" + BROKER_URL_VARIABLE + ", "
// + TOPIC_VARIABLE + ")");
// Send a START_WORKFLOW notification.
pw.println(NOTIFICATION_VARIABLE + "." + WORKFLOW_STARTED_METHOD + "(");
boolean first = true;
for (InputNode inputNode : this.inputNodes) {
String id = inputNode.getID();
if (first) {
first = false;
} else {
pw.println(",");
}
pw.print(TAB + id + "=" + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + id + "')");
}
pw.println(")");
pw.println();
// The biggining of try
pw.println("try:");
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class JythonScript method writeInvocation.
/**
* @param node
* @param thread
* @param pw
*/
private void writeInvocation(WSNode node, boolean thread, PrintWriter pw) {
String id = node.getID();
String wsdlID = getWSDLID(node);
WSComponent component = node.getComponent();
QName portTypeQName = component.getPortTypeQName();
String operation = component.getOperationName();
pw.println(TAB + "# Invoke " + id + ".");
pw.println(TAB + id + QNAME_SUFFIX + " = QName('" + portTypeQName.getNamespaceURI() + "', '" + portTypeQName.getLocalPart() + "')");
pw.println(TAB + wsdlID + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + wsdlID + "')");
pw.println(TAB + id + INVOKER_SUFFIX + " = " + "(" + id + QNAME_SUFFIX + ", " + wsdlID + ", '" + id + "',");
pw.println(TAB + TAB + MESSAGE_BOX_URL_VARIABLE + ", " + GFAC_VARIABLE + ", " + NOTIFICATION_VARIABLE + ")");
pw.println(TAB + "def " + INVOKE_METHOD + id + "():");
pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SETUP_METHOD + "()");
pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_OPERATION_METHOD + "('" + operation + "')");
// Ports
for (Port port : node.getInputPorts()) {
String portName = port.getName();
String value;
Node fromNode = port.getFromNode();
if (fromNode instanceof InputNode) {
value = PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')";
} else {
Port fromPort = port.getFromPort();
value = "" + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')";
// This might try to remove a node that has been removed
// already, but it's OK.
this.executingNodes.remove(fromNode);
}
pw.println(TAB + TAB + portName + VALUE_SUFFIX + " = " + value);
pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_INPUT_METHOD + "('" + portName + "', " + portName + VALUE_SUFFIX + ")");
}
pw.println(TAB + TAB + "print 'Invoking " + id + ".'");
pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + INVOKE_METHOD + "()");
if (thread) {
pw.println(TAB + "thread.start_new_thread(" + INVOKE_METHOD + id + ", ())");
} else {
pw.println(TAB + INVOKE_METHOD + id + "()");
}
pw.println();
this.executingNodes.add(node);
}
Aggregations