use of org.apache.airavata.model.appcatalog.appinterface.DataType 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.model.appcatalog.appinterface.DataType in project airavata by apache.
the class DifferedInputConfigurationDialog method setInput.
private void setInput() {
DataType type = this.node.getParameterType();
XBayaTextComponent textComponent;
textComponent = this.valueTextField;
String name = this.nameTextField.getText();
String description = this.descriptionTextArea.getText();
String valueString = textComponent.getText();
String metadataText = this.metadataTextArea.getText();
if (name.length() == 0) {
String warning = "The name cannot be empty.";
this.xbayaGUI.getErrorWindow().error(warning);
return;
}
Object value = null;
if (valueString.length() > 0) {
if (!this.node.isInputValid(valueString)) {
String warning = "The defalut value is not valid for " + this.node.getParameterType() + ".";
this.xbayaGUI.getErrorWindow().error(warning);
}
value = valueString;
}
XmlElement metadata;
if (metadataText.length() == 0) {
metadata = null;
} else {
try {
metadata = XMLUtil.stringToXmlElement(metadataText);
} catch (RuntimeException e) {
String warning = "The metadata is ill-formed.";
this.xbayaGUI.getErrorWindow().error(warning, e);
return;
}
}
this.node.setConfigured(true);
this.node.setConfiguredName(name);
this.node.setDescription(description);
this.node.setDefaultValue(value);
this.node.setMetadata(metadata);
this.node.setState(NodeExecutionState.FINISHED);
hide();
this.xbayaGUI.getGraphCanvas().repaint();
}
use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.
the class ForEachNode method portTypeChanged.
/**
* @param port
* @throws GraphException
*/
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
super.portTypeChanged(port);
List<DataPort> inputPorts = getInputPorts();
List<DataPort> outputPorts = getOutputPorts();
Kind kind = port.getKind();
int index;
if (kind == Kind.DATA_IN) {
index = inputPorts.indexOf(port);
} else if (kind == Kind.DATA_OUT) {
index = outputPorts.indexOf(port);
} else {
throw new WorkflowRuntimeException();
}
SystemDataPort inputPort = (SystemDataPort) inputPorts.get(index);
SystemDataPort outputPort = (SystemDataPort) outputPorts.get(index);
DataType inputType = inputPort.getType();
DataType outputType = outputPort.getType();
DataType portType = port.getType();
if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
// Do nothing
return;
}
if (port == inputPort) {
// input -> output
if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
// outputPort.copyType(port, -1);
} else if (outputType.equals(portType)) {
// Do nothing.
} else {
// XXX cannot parse array from WSDL.
// String message = "The type of input " + index + " ("
// + inputType + ") of " + getID()
// + " must be same as the type of output " + index + " ("
// + outputType + ").";
// throw new GraphException(message);
}
} else if (port == outputPort) {
// output -> input1
if (inputType.equals(WSConstants.XSD_ANY_TYPE)) {
// inputPort.copyType(port, 1);
} else if (inputType.equals(portType)) {
// Do nothing.
} else {
// XXX cannot parse array from WSDL.
// String message = "The type of input " + index + " ("
// + inputType + ") of " + getID()
// + " must be same as the type of output " + index + " ("
// + outputType + ").";
// throw new GraphException(message);
}
} else {
throw new WorkflowRuntimeException();
}
}
use of org.apache.airavata.model.appcatalog.appinterface.DataType 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.model.appcatalog.appinterface.DataType 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