use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class InterpreterUtil method getNodesWithBodyColor.
public static ArrayList<Node> getNodesWithBodyColor(NodeExecutionState state, WSGraph graph) {
ArrayList<Node> list = new ArrayList<Node>();
List<NodeImpl> nodes = graph.getNodes();
for (Node node : nodes) {
if (node.getState() == state) {
list.add(node);
}
}
return list;
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class LaunchApplicationWindow 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();
// QName parameterType = node.getParameterType();
// JLabel nameLabel = new JLabel(id);
// JLabel typeField = new JLabel(parameterType.getLocalPart());
// 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);
List<NodeImpl> nodes = workflow.getGraph().getNodes();
NodeImpl node = null;
for (int i = 0; i < nodes.size(); i++) {
node = nodes.get(i);
String html = node.getComponent().toHTML();
String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
if (nodeType.equals("Application")) {
break;
}
}
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort port : inputPorts) {
String id = port.getName();
DataType parameterType = port.getType();
JLabel nameLabel = new JLabel(id);
JLabel typeField = new JLabel(parameterType.toString());
XBayaTextField paramField = new XBayaTextField();
paramField.setText("");
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();
} catch (InvalidRequestException e) {
logger.error(e.getMessage(), e);
} catch (AiravataClientException e) {
logger.error(e.getMessage(), e);
} catch (AiravataSystemException e) {
logger.error(e.getMessage(), e);
} catch (TException e) {
logger.error(e.getMessage(), e);
}
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(1);
XBayaLabel hostLabel = new XBayaLabel("Host", this.host);
this.parameterPanel.add(hostLabel);
this.parameterPanel.add(host);
// this.parameterPanel.layout(inputNodes.size()+1, 2, GridPanel.WEIGHT_NONE, 2);
this.dialog.show();
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class WorkflowHarvester method cleanLeftOverInputNodes.
/**
* @param clone
*/
private void cleanLeftOverInputNodes(Workflow clone) {
List<NodeImpl> nodes = clone.getGraph().getNodes();
LinkedList<Node> removeList = new LinkedList<Node>();
for (Node nodeImpl : nodes) {
if (nodeImpl instanceof InputNode) {
if (nodeImpl.getOutputPort(0).getToNodes().size() == 0) {
removeList.add(nodeImpl);
}
}
}
for (Node node : removeList) {
try {
clone.removeNode(node);
} catch (GraphException e) {
throw new WorkflowRuntimeException(e);
}
}
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class WorkflowHarvester method harvest.
public Workflow[] harvest(Workflow workflow, QName dataType) {
LinkedList<Workflow> harvest = new LinkedList<Workflow>();
LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
for (Pair<String, String> pair : candidates) {
Workflow clone = workflow.clone();
NodeImpl node = clone.getGraph().getNode(pair.getLeft());
if (null == node) {
throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
}
Port candidatePort = null;
List<DataPort> inPorts = node.getInputPorts();
for (DataPort dataPort : inPorts) {
if (pair.getRight().equals(dataPort.getID())) {
candidatePort = dataPort;
break;
}
}
if (null == candidatePort) {
throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
}
if (!(candidatePort.getFromNode() instanceof InputNode)) {
removeUnnecessaryNodes(node, candidatePort, clone);
Node input = clone.addNode(new InputComponent());
input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
// original
if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
!isWorkflowAlreadyHarvested(harvest, clone)) {
try {
clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
cleanLeftOverInputNodes(clone);
} catch (GraphException e) {
throw new RuntimeException(e);
}
harvest.add(clone);
}
}
}
return harvest.toArray(new Workflow[0]);
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class Workflow method getWorkflowServiceNodeIDs.
public List<String> getWorkflowServiceNodeIDs() {
List<NodeImpl> nodes = getGraph().getNodes();
ArrayList<String> nodeIDs = new ArrayList<String>();
for (Node node : nodes) {
if (node instanceof WSNode) {
nodeIDs.add(node.getID());
}
}
return nodeIDs;
}
Aggregations