Repository: airavata Updated Branches: refs/heads/master 34cd927c3 -> 382b6c0e6
http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicNodeWindow.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicNodeWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicNodeWindow.java deleted file mode 100644 index c4d9790..0000000 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicNodeWindow.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.xbaya.ui.dialogs.graph.dynamic; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.xml.namespace.QName; - -import org.apache.airavata.model.appcatalog.appinterface.DataType; -import org.apache.airavata.workflow.model.component.url.URLComponentRegistry; -import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; -import org.apache.airavata.workflow.model.graph.DataPort; -import org.apache.airavata.workflow.model.graph.Graph; -import org.apache.airavata.workflow.model.graph.Node; -import org.apache.airavata.workflow.model.graph.Port; -import org.apache.airavata.workflow.model.graph.dynamic.BasicTypeMapping; -import org.apache.airavata.workflow.model.graph.dynamic.DynamicNode; -import org.apache.airavata.workflow.model.graph.dynamic.SchemaCompilerUtil; -import org.apache.airavata.workflow.model.graph.ws.WSNode; -import org.apache.airavata.workflow.model.graph.ws.WSPort; -import org.apache.airavata.xbaya.XBayaEngine; -import org.apache.airavata.xbaya.component.registry.ComponentController; -import org.apache.airavata.xbaya.component.registry.ComponentRegistryLoader; -import org.apache.airavata.xbaya.invoker.DynamicServiceCreator; -import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog; -import org.apache.airavata.xbaya.ui.widgets.GridPanel; -import org.apache.airavata.xbaya.ui.widgets.XBayaLabel; -import org.apache.airavata.xbaya.ui.widgets.XBayaTextArea; -import org.apache.airavata.xbaya.ui.widgets.component.ComponentTreeNode; -import org.apache.airavata.xbaya.util.RegistryConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xmlpull.infoset.XmlElement; -import org.xmlpull.infoset.XmlNamespace; -import org.xmlpull.v1.builder.XmlBuilderException; - -import xsul5.wsdl.WsdlDefinitions; - -public class DynamicNodeWindow { - - private static final Logger log = LoggerFactory.getLogger(DynamicNodeWindow.class); - - /** - * CLASSES_DIR - */ - private static final String CLASSES_DIR = "classes"; - - /** - * SRC_DIR - */ - private static final String SRC_DIR = "src"; - - - /** - * CLASS - */ - private static final String CLASS = "class"; - - /** - * PACKAGE - */ - private static final String PACKAGE = "package"; - - /** - * LINE - */ - private static final String LINE = "\n"; - - /** - * TAB - */ - private static final String TAB = "\t"; - - /** - * SPACE - */ - private static final String SPACE = " "; - - private XBayaEngine engine; - - private DynamicNode node; - - private XBayaDialog dialog; - - private XBayaTextArea javaCodeTxtArea; - - private String typesPath; - - private String functionStr; - - private JCheckBox checkBox; - - /** - * Constructs a WSNodeWindow. - * - * @param engine - * The XBayaEngine - * @param node - */ - public DynamicNodeWindow(XBayaEngine engine, DynamicNode node) { - this.engine = engine; - this.node = node; - initGUI(); - - } - - /** - * Shows the notification. - * - * @param event - * The notification to show - */ - public void show() { - - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int ret = fileChooser.showOpenDialog(this.engine.getGUI().getFrame()); - if (JFileChooser.APPROVE_OPTION != ret) { - throw new WorkflowRuntimeException("Cannot proceed without valid directory"); - } - File selectedDir = fileChooser.getSelectedFile(); - File rootDir = new File(selectedDir, "xbaya"); - deleteDir(rootDir); - rootDir.mkdir(); - File srcDir = new File(rootDir, SRC_DIR); - srcDir.mkdir(); - File classesDir = new File(rootDir, CLASSES_DIR); - classesDir.mkdir(); - initSchema(rootDir, srcDir, srcDir); - - this.javaCodeTxtArea.setText(generateClass()); - - this.dialog.show(); - if (this.checkBox.isSelected()) { - deployWebservice(); - } else { - this.compileAndRegisterJar(rootDir, srcDir, srcDir); - } - - } - - private void deployWebservice() { - try { - DynamicServiceCreator factory = new DynamicServiceCreator( - "http://129.79.246.108:8080/axis2/services/ServiceCreator?wsdl"); - String code = this.javaCodeTxtArea.getText(); - factory.createService(code); - URLComponentRegistry registry = null; - Thread.sleep(10000); - registry = new URLComponentRegistry(new URI("http://129.79.246.108:8080/axis2/services/" - + getClassName(code) + "?wsdl")); - ComponentRegistryLoader.getLoader(this.engine, RegistryConstants.REGISTRY_TYPE_URL).load(registry); - - Node newNode = this.engine - .getGUI() - .getGraphCanvas() - .addNode( - ((ComponentTreeNode) ComponentController.getComponentTree(registry).getFirstLeaf()).getComponentReference() - .getComponent(), this.node.getPosition()); - List<DataPort> inputPorts = newNode.getInputPorts(); - Graph graph = this.engine.getGUI().getGraphCanvas().getGraph(); - for (int i = 0; i < inputPorts.size(); ++i) { - graph.addEdge(this.node.getInputPort(i).getFromPort(), inputPorts.get(i)); - } - List<DataPort> outputPorts = newNode.getOutputPorts(); - - for (int i = 0; i < outputPorts.size(); ++i) { - List<Port> toPorts = this.node.getOutputPort(i).getToPorts(); - for (Port port : toPorts) { - graph.removeEdge(this.node.getOutputPort(i), port); - graph.addEdge(outputPorts.get(i), port); - } - - } - - this.engine.getGUI().getWorkflow().removeNode(this.node); - - } catch (Exception e) { - this.engine.getGUI().getErrorWindow().error(e); - } - - } - - private void hide() { - this.dialog.hide(); - } - - private void initGUI() { - BasicTypeMapping.reset(); - - this.javaCodeTxtArea = new XBayaTextArea(); - XBayaLabel operationLabel = new XBayaLabel("Operation", this.javaCodeTxtArea); - - GridPanel infoPanel = new GridPanel(); - infoPanel.add(operationLabel); - infoPanel.add(this.javaCodeTxtArea); - checkBox = new JCheckBox("Export as webservice"); - infoPanel.add(new XBayaLabel("", checkBox)); - - infoPanel.add(checkBox); - infoPanel.layout(2, 2, 0, 0); - - JButton okButton = new JButton("OK"); - okButton.addActionListener(new AbstractAction() { - public void actionPerformed(ActionEvent e) { - - hide(); - } - }); - JPanel buttonPanel = new JPanel(); - buttonPanel.add(okButton); - - this.dialog = new XBayaDialog(this.engine.getGUI(), this.node.getName(), infoPanel, buttonPanel); - this.dialog.setDefaultButton(okButton); - } - - private String generateClass() { - - String ret = "package org.apache.airavata.xbaya;"; - ret += LINE + LINE; - ret += "public class DefaultClassName{"; - ret += LINE + LINE + TAB + "public"; - String function = ""; - List<Port> toNodes = this.node.getOutputPort(0).getToPorts(); - XmlElement returnElement = null; - DataType returnType = null; - if (toNodes.size() == 0) { - function += SPACE + "void"; - } else { - - if (toNodes.size() == 1 && toNodes.get(0) instanceof WSPort) { - WSPort outPort = (WSPort) toNodes.get(0); - returnElement = outPort.getComponentPort().getElement(); - returnType = outPort.getType(); - } else { - throw new WorkflowRuntimeException("Unhandled port type for Dynamic component or to many outputs"); - } - for (Port port : toNodes) { - if (toNodes.get(0) instanceof DataPort) { - if (!returnType.equals(((DataPort) toNodes.get(0)).getType())) { - throw new WorkflowRuntimeException( - "Dynamic output port connected to input ports of different types."); - } - } else { - throw new WorkflowRuntimeException("Unhandled port type for Dynamic component"); - } - } - int index = BasicTypeMapping.getSimpleTypeIndex(returnElement); - if (-1 != index) { - function += SPACE + BasicTypeMapping.getTypeName(index); - } else { - throw new WorkflowRuntimeException("WIll be fixed with complex type mappign"); - } - } - - function += SPACE + "operationName("; - List<DataPort> inputPorts = this.node.getInputPorts(); - boolean first = true; - - // variable list in function prototype - for (DataPort inPort : inputPorts) { - Port fromPort = inPort.getFromPort(); - if (fromPort instanceof WSPort) { - WSPort wsPort = (WSPort) fromPort; - XmlElement element = wsPort.getComponentPort().getElement(); - - // QName inType = ((DataPort) fromPort).getType(); - int typeIndex = BasicTypeMapping.getSimpleTypeIndex(element); - if (-1 != typeIndex) { - if (first) { - first = false; - } else { - function += SPACE + ","; - } - function += BasicTypeMapping.getTypeName(typeIndex) + SPACE - + BasicTypeMapping.getTypeVariableName(typeIndex); - } else { - throw new WorkflowRuntimeException("Complex Type occured:This will be fixed!!!!!"); - } - } else { - throw new WorkflowRuntimeException("Dynamic Node connected to non data port"); - } - } - - function += ")"; - ret += function; - this.functionStr = function; - // body - ret += "{" + LINE + LINE; - if (null != returnElement) { - ret += TAB + TAB + "return" + SPACE - + BasicTypeMapping.getTypeDefault(BasicTypeMapping.getSimpleTypeIndex(returnElement)) + ";"; - } - ret += LINE; - ret += TAB + "}"; - ret += LINE + "}"; - return ret; - - } - - private void initSchema(File rootDir, File srcDir, File classesDir) { - - List<DataPort> inputPorts = node.getInputPorts(); - for (DataPort inPort : inputPorts) { - Port fromPort = inPort.getFromPort(); - Node fromNode = inPort.getFromNode(); - if (fromNode instanceof WSNode) { - WSNode fromWsNode = (WSNode) fromNode; - if (null != fromPort && fromPort instanceof DataPort) { - DataPort fromDataPort = (DataPort) fromPort; -// WsdlDefinitions wsdl = engine.getGUI().getWorkflow().getWSDLs().get(fromWsNode.getWSDLID()); -// Iterator<XmlNamespace> itr = wsdl.xml().namespaces().iterator(); -// try { -// XmlElement schema = wsdl.getTypes().element("schema").clone(); -// // do not change the following ordering of setting -// // namespaces. -// schema.setNamespace(xsul5.XmlConstants.BUILDER.newNamespace("http://www.w3.org/2001/XMLSchema")); -// while (itr.hasNext()) { -// XmlNamespace next = itr.next(); -// if (!"".equals(next.getPrefix()) && null != next.getPrefix()) { -// schema.setAttributeValue("xmlns:" + next.getPrefix(), next.getName()); -// } -// -// } -// -// try { -// xsul5.XmlConstants.BUILDER -// .serializeToOutputStream(schema, new FileOutputStream(rootDir.getCanonicalPath() -// + File.separatorChar + "types.xsd")); -// } catch (Exception e) { -// log.error(e.getMessage(), e); -// } -// -// typesPath = rootDir.getCanonicalPath() + File.separatorChar + "mytype.jar"; -// String[] args = new String[] { "-d", classesDir.getCanonicalPath(), "-src", -// srcDir.getCanonicalPath(), "-out", typesPath, -// rootDir.getCanonicalPath() + File.separatorChar + "types.xsd" }; -// SchemaCompilerUtil.compile(args); -// -// } catch (XmlBuilderException e) { -// this.engine.getGUI().getErrorWindow().error(e); -// } catch (CloneNotSupportedException e) { -// this.engine.getGUI().getErrorWindow().error(e); -// } catch (IOException e) { -// log.error(e.getMessage(), e); -// } - - } else { - throw new WorkflowRuntimeException("Unknown port for code generation" + fromPort); - } - } else { - throw new WorkflowRuntimeException("Unknown from node for code generation" + fromNode); - } - } - } - - private void compileAndRegisterJar(File rootDir, File srcDir, File classesDir) { - // String code = this.javaCodeTxtArea.getText(); - // String packageName = getPackageName(code); - // String className = getClassName(code); - // try { - // File classFile = new File(srcDir.getCanonicalPath()+ File.separator - // + packageName.replace('.', File.separatorChar) - // + File.separator + className+".java"); - // classFile.getParentFile().mkdirs(); - // - // FileWriter out = new FileWriter(classFile); - // out.write(code); - // out.flush(); - // out.close(); - // - // JarHelper jarHelper = new JarHelper(); - // jarHelper.unjarDir(new File(this.typesPath), classesDir); - // - // Main.compile(new String[]{classFile.getCanonicalPath(), "-d", classesDir.getCanonicalPath()}); - // File implJar = new File(rootDir, "impl.jar"); - // jarHelper.jarDir( classesDir, implJar); - // node.setImplURL(implJar.toURL()); - // node.setOperationName(getOperationName(code)); - // node.setClassName(getPackageName(code)+"."+getClassName(code)); - // } catch (IOException e) { - // this.engine.getGUI().getErrorWindow().error(e); - // } - - } - - private String getOperationName(String code) { - String[] publicSplit = code.split("public"); - String searchStr = this.functionStr.substring(this.functionStr.indexOf("("), this.functionStr.indexOf(")")); - int index = -1; - for (int i = 0; i < publicSplit.length; ++i) { - if (publicSplit[i].indexOf(searchStr) != -1) { - index = i; - break; - } - } - if (index == -1) { - throw new WorkflowRuntimeException("Operation name not found"); - } - return publicSplit[index].substring(0, publicSplit[index].indexOf(searchStr)).trim().split(" ")[1]; - } - - private String getPackageName(String code) { - return code.substring(code.indexOf(PACKAGE) + PACKAGE.length(), code.indexOf(";")).trim(); - } - - private String getClassName(String code) { - return code.substring(code.indexOf(CLASS) + CLASS.length(), code.indexOf("{")).trim().split(" ")[0].trim(); - - } - - private boolean hasComplexTypes() { - List<DataPort> inputPorts = node.getInputPorts(); - for (DataPort inPort : inputPorts) { - Port fromPort = inPort.getFromPort(); - Node fromNode = inPort.getFromNode(); - if (fromNode instanceof WSNode) { - if (null != fromPort && fromPort instanceof DataPort) { - - } else { - return false; - } - } else { - return false; - } - } - return false; - } - - public static boolean deleteDir(File dir) { - if (dir.isDirectory()) { - String[] children = dir.list(); - for (int i = 0; i < children.length; i++) { - boolean success = deleteDir(new File(dir, children[i])); - if (!success) { - return false; - } - } - } - - // The directory is now empty so delete it - return dir.delete(); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicWorkflowRunnerWindow.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicWorkflowRunnerWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicWorkflowRunnerWindow.java deleted file mode 100644 index 0de972a..0000000 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/dynamic/DynamicWorkflowRunnerWindow.java +++ /dev/null @@ -1,394 +0,0 @@ -///* -// * -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// * -// */ -// -//package org.apache.airavata.xbaya.ui.dialogs.graph.dynamic; -// -//import java.awt.event.ActionEvent; -//import java.net.URI; -//import java.net.URISyntaxException; -//import java.util.ArrayList; -//import java.util.Collection; -//import java.util.Iterator; -//import java.util.LinkedList; -//import java.util.List; -//import java.util.UUID; -// -//import javax.swing.AbstractAction; -//import javax.swing.JButton; -//import javax.swing.JCheckBox; -//import javax.swing.JComboBox; -//import javax.swing.JLabel; -//import javax.swing.JOptionPane; -//import javax.swing.JPanel; -//import javax.xml.namespace.QName; -// -//import org.apache.airavata.client.api.exception.AiravataAPIInvocationException; -//import org.apache.airavata.common.utils.StringUtil; -//import org.apache.airavata.common.utils.XMLUtil; -//import org.apache.airavata.workflow.model.exceptions.WorkflowException; -//import org.apache.airavata.workflow.model.graph.system.InputNode; -//import org.apache.airavata.workflow.model.graph.util.GraphUtil; -//import org.apache.airavata.workflow.model.graph.ws.WSNode; -//import org.apache.airavata.workflow.model.ode.ODEClient; -//import org.apache.airavata.workflow.model.wf.Workflow; -//import org.apache.airavata.ws.monitor.MonitorConfiguration; -//import org.apache.airavata.ws.monitor.MonitorException; -//import org.apache.airavata.xbaya.XBayaConfiguration; -//import org.apache.airavata.xbaya.XBayaEngine; -//import org.apache.airavata.xbaya.graph.controller.NodeController; -//import org.apache.airavata.xbaya.interpretor.GUIWorkflowInterpreterInteractorImpl; -//import org.apache.airavata.xbaya.interpretor.WorkflowInterpreter; -//import org.apache.airavata.xbaya.interpretor.WorkflowInterpreterConfiguration; -//import org.apache.airavata.xbaya.jython.script.JythonScript; -//import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog; -//import org.apache.airavata.xbaya.ui.graph.ws.WSNodeGUI; -//import org.apache.airavata.xbaya.ui.utils.ErrorMessages; -//import org.apache.airavata.xbaya.ui.widgets.GridPanel; -//import org.apache.airavata.xbaya.ui.widgets.XBayaLabel; -//import org.apache.airavata.xbaya.ui.widgets.XBayaTextField; -//import org.apache.airavata.xbaya.util.XBayaUtil; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -//import org.xmlpull.infoset.XmlElement; -//import org.xmlpull.v1.builder.XmlInfosetBuilder; -// -//import xsul.XmlConstants; -//import xsul.lead.LeadResourceMapping; -// -//public class DynamicWorkflowRunnerWindow { -// -// private static final Logger logger = LoggerFactory.getLogger(DynamicWorkflowRunnerWindow.class); -// -// private XBayaEngine engine; -// -// private Workflow workflow; -// -// private XBayaDialog dialog; -// -// private GridPanel parameterPanel; -// -// private XBayaTextField topicTextField; -// -// private List<XBayaTextField> parameterTextFields = new ArrayList<XBayaTextField>(); -// -// private XBayaLabel resourceSelectionLabel; -// -// // private XBayaComboBox resourceSelectionComboBox; -// -//// private JComboBox gfacUrlListField; -// -// private JCheckBox interactChkBox; -// -// private JCheckBox chkRunWithCrossProduct; -// -// private XBayaTextField instanceNameTextField; -// -// protected final static XmlInfosetBuilder builder = XmlConstants.BUILDER; -// -// /** -// * Constructs a TavernaRunnerWindow. -// * -// * @param engine -// * -// */ -// public DynamicWorkflowRunnerWindow(XBayaEngine engine) { -// this.engine = engine; -// if (XBayaUtil.acquireJCRRegistry(this.engine)) { -// initGUI(); -// } -// } -// -// /** -// * Shows the dialog. -// */ -// public void show() { -// this.workflow = this.engine.getGUI().getWorkflow(); -//// List<URI> urlList=null; -//// try { -//// urlList = this.engine.getConfiguration().getAiravataAPI().getAiravataManager().getGFaCURLs(); -//// } catch (AiravataAPIInvocationException e) { -//// e.printStackTrace(); -//// } -// // When run xbaya continously urls can be repeating, so first remove everything and then add -//// this.gfacUrlListField.removeAllItems(); -//// for (URI gfacUrl : urlList) { -//// if (XBayaUtil.isURLExists(gfacUrl + "?wsdl")) { -//// this.gfacUrlListField.addItem(gfacUrl); -//// } -//// } -//// this.gfacUrlListField.setEditable(true); -// MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration(); -// if (notifConfig.getBrokerURL() == null) { -// this.engine.getGUI().getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR); -// return; -// } -// -// // Create input fields -// List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph()); -// for (Iterator<InputNode> iterator = inputNodes.iterator(); iterator.hasNext();) { -// InputNode node = iterator.next(); -// String id = node.getID(); -// QName parameterType = node.getParameterType(); -// -// /* -// * If input node has no connection, skip it -// */ -// if (parameterType == null) { -// iterator.remove(); -// continue; -// } -// -// 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(); -// } -// } -// -// if (!node.isVisibility()) { -// paramField.setEditable(false); -// } -// paramField.setText(valueString); -// this.parameterPanel.add(nameLabel); -// this.parameterPanel.add(typeField); -// this.parameterPanel.add(paramField); -// this.parameterTextFields.add(paramField); -// } -// this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2); -// -//// this.instanceNameTextField.setText(workflow.getName()+"_"+Calendar.getInstance().getTime().toString()); -// -// this.topicTextField.setText(UUID.randomUUID().toString()); -// -// this.dialog.show(); -// } -// -// /** -// * Hides the dialog. -// */ -// public void hide() { -// this.dialog.hide(); -// -// this.parameterPanel.resetPanel(); -// this.parameterTextFields.clear(); -// } -// -// /** -// * ReInit Host Name ComboBox -// */ -// // public void reinitHostComboBox() { -// // if (this.resourceSelectionComboBox == null) -// // this.resourceSelectionComboBox = new XBayaComboBox(new DefaultComboBoxModel(initHostNameList())); -// // else -// // this.resourceSelectionComboBox.setModel(new DefaultComboBoxModel(initHostNameList())); -// // } -// -// private void initGUI() { -// this.parameterPanel = new GridPanel(true); -// -// // reinitHostComboBox(); -// // this.resourceSelectionLabel = new XBayaLabel("Select a Compute Resource", this.resourceSelectionComboBox); -// this.instanceNameTextField = new XBayaTextField(); -// XBayaLabel instanceNameLabel = new XBayaLabel("Experiment name", this.instanceNameTextField); -// -// this.topicTextField = new XBayaTextField(); -// XBayaLabel topicLabel = new XBayaLabel("Notification topic", this.topicTextField); -//// this.gfacUrlListField = new JComboBox(); -//// XBayaLabel gfacURLLabel = new XBayaLabel("GFac URL", this.gfacUrlListField); -// this.interactChkBox = new JCheckBox(); -// this.interactChkBox.setSelected(false); -// XBayaLabel interactLabel = new XBayaLabel("Enable Service Interactions", this.interactChkBox); -// -// chkRunWithCrossProduct=new JCheckBox(); -// XBayaLabel crossProductLabel = new XBayaLabel("Execute in cross product", chkRunWithCrossProduct); -// -// GridPanel infoPanel = new GridPanel(); -// // infoPanel.add(this.resourceSelectionLabel); -// // infoPanel.add(this.resourceSelectionComboBox); -// infoPanel.add(instanceNameLabel); -// infoPanel.add(this.instanceNameTextField); -// infoPanel.add(topicLabel); -// infoPanel.add(this.topicTextField); -//// infoPanel.add(gfacURLLabel); -//// infoPanel.add(this.gfacUrlListField); -// infoPanel.add(interactLabel); -// infoPanel.add(this.interactChkBox); -// infoPanel.add(crossProductLabel); -// infoPanel.add(chkRunWithCrossProduct); -// -// infoPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1); -// -// GridPanel mainPanel = new GridPanel(); -// mainPanel.add(this.parameterPanel); -// mainPanel.add(infoPanel); -// mainPanel.layout(2, 1, 0, 0); -// -// JButton okButton = new JButton("Run"); -// okButton.addActionListener(new AbstractAction() { -// public void actionPerformed(ActionEvent e) { -// execute(); -// } -// }); -// -// JButton cancelButton = new JButton("Cancel"); -// cancelButton.addActionListener(new AbstractAction() { -// public void actionPerformed(ActionEvent e) { -// hide(); -// } -// }); -// -// JPanel buttonPanel = new JPanel(); -// buttonPanel.add(okButton); -// buttonPanel.add(cancelButton); -// -// this.dialog = new XBayaDialog(this.engine.getGUI(), "Invoke workflow", mainPanel, buttonPanel); -// this.dialog.setDefaultButton(okButton); -// } -// -// private void execute() { -// final List<String> arguments = new ArrayList<String>(); -// String instanceName = this.instanceNameTextField.getText(); -// if (instanceName.trim().equals("")){ -// JOptionPane.showMessageDialog(engine.getGUI().getFrame(), -// "Experiment name cannot be empty", -// "Experiment Name", -// JOptionPane.ERROR_MESSAGE); -// return; -// } -//// if (instanceName.equals("")){ -//// instanceName=workflow.getName(); -//// } -// final String instanceNameFinal=instanceName; -// String topic = this.topicTextField.getText(); -// if (topic.length() == 0) { -// this.engine.getGUI().getErrorWindow().error(ErrorMessages.TOPIC_EMPTY_ERROR); -// return; -// } -// -// // Use topic as a base of workflow instance ID so that the monitor can -// // find it. -// URI workfowInstanceID = URI.create(StringUtil.convertToJavaIdentifier(topic)); -// this.workflow.setGPELInstanceID(workfowInstanceID); -// -// MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration(); -// notifConfig.setTopic(topic); -// arguments.add("-" + JythonScript.TOPIC_VARIABLE); -// arguments.add(topic); -// Collection<WSNode> wsNodes = GraphUtil.getWSNodes(this.engine.getGUI().getWorkflow().getGraph()); -// // This is to enable service interaction with the back end -// if (this.interactChkBox.isSelected()) { -// LinkedList<String> nodeIDs = new LinkedList<String>(); -// for (WSNode node : wsNodes) { -// nodeIDs.add(node.getID()); -// ((WSNodeGUI) NodeController.getGUI(node)).setInteractiveMode(true); -// } -// notifConfig.setInteractiveNodeIDs(nodeIDs); -// } else { -// for (WSNode node : wsNodes) { -// ((WSNodeGUI) NodeController.getGUI(node)).setInteractiveMode(false); -// } -// } -// -// final boolean isRunCrossProduct=chkRunWithCrossProduct.isSelected(); -// // TODO error check for user inputs -// -// final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph()); -// builder.newFragment("inputs"); -// new ODEClient(); -// for (int i = 0; i < inputNodes.size(); i++) { -// InputNode inputNode = inputNodes.get(i); -// XBayaTextField parameterTextField = this.parameterTextFields.get(i); -// inputNode.getID(); -// String value = parameterTextField.getText(); -// inputNode.setDefaultValue(value); -// } -// -//// final String gFacUrl = ((URI) this.gfacUrlListField.getSelectedItem()).toASCIIString(); -//// if (null != gFacUrl && !"".equals(gFacUrl)) { -//// try { -//// this.engine.getConfiguration().setGFacURL(new URI(gFacUrl)); -//// } catch (URISyntaxException e) { -//// this.engine.getGUI().getErrorWindow().error(e); -//// } -//// } -// this.engine.getConfiguration().setTopic(topic); -// -// /* -// * Load host description from xregistry and add to interpreter -// */ -// LeadResourceMapping mapping = null; -// -// final LeadResourceMapping resourceMapping = mapping; -// final String topicString = topic; -// new Thread() { -// /** -// * @see java.lang.Thread#run() -// */ -// @Override -// public void run() { -// XBayaConfiguration conf = DynamicWorkflowRunnerWindow.this.engine.getConfiguration(); -// WorkflowInterpreterConfiguration workflowInterpreterConfiguration = new WorkflowInterpreterConfiguration(engine.getGUI().getWorkflow(),topicString,conf.getMessageBoxURL(), conf.getBrokerURL(), conf.getAiravataAPI(), conf, DynamicWorkflowRunnerWindow.this.engine.getGUI(), DynamicWorkflowRunnerWindow.this.engine.getMonitor()); -// workflowInterpreterConfiguration.setRunWithCrossProduct(isRunCrossProduct); -// -// WorkflowInterpreter workflowInterpreter = new WorkflowInterpreter( -// workflowInterpreterConfiguration, new GUIWorkflowInterpreterInteractorImpl(engine, engine.getGUI().getWorkflow())); -// DynamicWorkflowRunnerWindow.this.engine.registerWorkflowInterpreter(workflowInterpreter); -// try { -// MonitorConfiguration notifConfig = DynamicWorkflowRunnerWindow.this.engine.getMonitor() -// .getConfiguration(); -// notifConfig.setTopic(topicString); -// DynamicWorkflowRunnerWindow.this.engine.getMonitor().start(); -// -// if (resourceMapping != null) -// workflowInterpreter.setResourceMapping(resourceMapping); -// -// workflowInterpreter.scheduleDynamically(); -//// try { -//// engine.getConfiguration().getJcrComponentRegistry().getRegistry().saveWorkflowExecutionName(topicString, instanceNameFinal); -//// } catch (RegistryException e) { -//// e.printStackTrace(); -//// } -// } catch (WorkflowException e) { -// try { -// workflowInterpreter.cleanup(); -// } catch (MonitorException e1) { -// DynamicWorkflowRunnerWindow.this.engine.getGUI().getErrorWindow().error(e1); -// } -// DynamicWorkflowRunnerWindow.this.engine.getGUI().getErrorWindow().error(e); -// } -// -// } -// }.start(); -// -// hide(); -// } -//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java index 13762ed..63b7850 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/ConstantConfigurationDialog.java @@ -31,7 +31,6 @@ import javax.xml.namespace.QName; import org.apache.airavata.common.utils.XMLUtil; import org.apache.airavata.model.appcatalog.appinterface.DataType; import org.apache.airavata.workflow.model.graph.system.ConstantNode; -import org.apache.airavata.xbaya.lead.LEADTypes; import org.apache.airavata.xbaya.ui.XBayaGUI; import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog; import org.apache.airavata.xbaya.ui.widgets.GridPanel; http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java index 665f1da..e81a033 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/DifferedInputConfigurationDialog.java @@ -34,7 +34,6 @@ import org.apache.airavata.model.appcatalog.appinterface.DataType; import org.apache.airavata.workflow.model.graph.Node.NodeExecutionState; import org.apache.airavata.workflow.model.graph.system.DifferedInputNode; import org.apache.airavata.xbaya.graph.controller.NodeController; -import org.apache.airavata.xbaya.lead.LEADTypes; import org.apache.airavata.xbaya.ui.XBayaGUI; import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog; import org.apache.airavata.xbaya.ui.graph.system.DifferedInputNodeGUI; http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java index 449c51d..b0c5f57 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/graph/system/InputConfigurationDialog.java @@ -31,7 +31,6 @@ import javax.xml.namespace.QName; import org.apache.airavata.common.utils.XMLUtil; import org.apache.airavata.model.appcatalog.appinterface.DataType; import org.apache.airavata.workflow.model.graph.system.InputNode; -import org.apache.airavata.xbaya.lead.LEADTypes; import org.apache.airavata.xbaya.ui.XBayaGUI; import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog; import org.apache.airavata.xbaya.ui.widgets.GridPanel; http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/dynamic/DynamicNodeGUI.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/dynamic/DynamicNodeGUI.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/dynamic/DynamicNodeGUI.java deleted file mode 100644 index 4229ba7..0000000 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/dynamic/DynamicNodeGUI.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.xbaya.ui.graph.dynamic; - -import java.awt.event.MouseEvent; - -import org.apache.airavata.workflow.model.graph.dynamic.DynamicNode; -import org.apache.airavata.xbaya.XBayaEngine; -import org.apache.airavata.xbaya.ui.dialogs.graph.dynamic.DynamicNodeWindow; -import org.apache.airavata.xbaya.ui.graph.NodeGUI; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DynamicNodeGUI extends NodeGUI { - - private final static Logger logger = LoggerFactory.getLogger(DynamicNodeGUI.class); - - private DynamicNode node; - - private DynamicNodeWindow window; - - /** - * Creates a WsNodeGui - * - * @param node - */ - public DynamicNodeGUI(DynamicNode node) { - super(node); - this.node = node; - } - - /** - * @see org.apache.airavata.xbaya.ui.graph.GraphPieceGUI#mouseClicked(java.awt.event.MouseEvent, - * org.apache.airavata.xbaya.XBayaEngine) - */ - @Override - public void mouseClicked(MouseEvent event, XBayaEngine engine) { - logger.debug(event.toString()); - if (event.getClickCount() >= 2) { - showWindow(engine); - } - } - - private void showWindow(XBayaEngine engine) { - if (this.window == null) { - this.window = new DynamicNodeWindow(engine, this.node); - } - try { - this.window.show(); - } catch (Throwable e) { - engine.getGUI().getErrorWindow().error(e); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java index db5628a..f468972 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java @@ -114,10 +114,10 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{ runMenu.add(launchXBayaInterpreterItem); // runMenu.add(launchDynamicWorkflowItem); - runMenu.addSeparator(); +// runMenu.addSeparator(); // runMenu.add(stopWorkflowItem); - runMenu.addSeparator(); +// runMenu.addSeparator(); // runMenu.add(this.resumeMonitoringItem); // runMenu.add(this.pauseMonitoringItem); @@ -249,7 +249,7 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{ } private void createLaunchXBayaInterpreterItem() { - this.launchXBayaInterpreterItem = new JMenuItem("Run on Interpreter Server...", MenuIcons.RUN_ICON); + this.launchXBayaInterpreterItem = new JMenuItem("Launch Workflow to Airavata Server...", MenuIcons.RUN_ICON); AbstractAction action = new AbstractAction() { private WorkflowInterpreterLaunchWindow window; public void actionPerformed(ActionEvent e) { http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java deleted file mode 100644 index 725a20f..0000000 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.xbaya.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.apache.airavata.common.utils.StringUtil; -import org.apache.airavata.workflow.model.exceptions.WorkflowException; -import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; -import org.apache.airavata.workflow.model.graph.DataPort; -import org.apache.airavata.workflow.model.graph.Node; -import org.apache.airavata.workflow.model.graph.Node.NodeExecutionState; -import org.apache.airavata.workflow.model.graph.amazon.InstanceNode; -import org.apache.airavata.workflow.model.graph.impl.NodeImpl; -import org.apache.airavata.workflow.model.graph.system.ConstantNode; -import org.apache.airavata.workflow.model.graph.system.DifferedInputNode; -import org.apache.airavata.workflow.model.graph.system.DoWhileNode; -import org.apache.airavata.workflow.model.graph.system.EndDoWhileNode; -import org.apache.airavata.workflow.model.graph.system.EndForEachNode; -import org.apache.airavata.workflow.model.graph.system.EndifNode; -import org.apache.airavata.workflow.model.graph.system.ForEachNode; -import org.apache.airavata.workflow.model.graph.system.InputNode; -import org.apache.airavata.workflow.model.graph.system.SystemDataPort; -import org.apache.airavata.workflow.model.graph.ws.WSGraph; -import org.apache.airavata.workflow.model.graph.ws.WSNode; -import org.apache.airavata.workflow.model.graph.ws.WSPort; -import org.apache.airavata.xbaya.interpretor.SystemComponentInvoker; -import org.apache.airavata.xbaya.interpretor.WorkFlowInterpreterException; -import org.apache.airavata.xbaya.invoker.GenericInvoker; -import org.apache.airavata.xbaya.invoker.Invoker; -import org.apache.airavata.xbaya.invoker.WorkflowInvokerWrapperForGFacInvoker; -import org.xmlpull.infoset.XmlElement; -import org.xmlpull.infoset.impl.XmlElementWithViewsImpl; - -import xsul5.XmlConstants; -import xsul5.wsdl.WsdlPort; -import xsul5.wsdl.WsdlService; -//import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler; -//import org.apache.airavata.xbaya.ui.monitor.MonitorEventHandler.NodeState; - -public class InterpreterUtil { - /** - * This method returns the input values for given foreach node - * - * @param forEachNode - * @param listOfValues - * @param invokerMap - * @return - * @throws WorkflowException - */ - public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) - throws WorkflowException { - List<DataPort> inputPorts = forEachNode.getInputPorts(); - - Object returnValForProvenance = null; - for (DataPort inputPort : inputPorts) { - - Node inputNode = inputPort.getFromNode(); - // if input node for for-each is WSNode - if (inputNode instanceof InputNode) { -// for (DataPort dataPort : forEachNode.getInputPorts()) { - returnValForProvenance = InterpreterUtil.findInputFromPort(inputPort, 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)); -// } - } else { - Invoker workflowInvoker = invokerMap.get(inputNode); - if (workflowInvoker != null) { - if (workflowInvoker instanceof GenericInvoker) { - - String outputName = inputNode.getOutputPort(0).getName(); - returnValForProvenance = workflowInvoker.getOutput(outputName); - Iterator children = null; - if (returnValForProvenance instanceof org.xmlpull.v1.builder.XmlElement) { - org.xmlpull.v1.builder.XmlElement msgElmt = (org.xmlpull.v1.builder.XmlElement) returnValForProvenance; - children = msgElmt.children(); - } else { - XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>"); - children = msgElmt.children().iterator(); - } - while (children.hasNext()) { - Object object = children.next(); - if (object instanceof org.xmlpull.v1.builder.XmlElement) { - org.xmlpull.v1.builder.XmlElement child = (org.xmlpull.v1.builder.XmlElement) object; - Iterator valItr = child.children(); - if (valItr.hasNext()) { - Object object2 = valItr.next(); - if (object2 instanceof String) { - listOfValues.add(object2.toString()); - } - } - } - if (object instanceof XmlElement) { - listOfValues.add(((XmlElement) object).children().iterator().next().toString()); - }if (object instanceof String){ - listOfValues.add(object.toString()); - } - } - } else if (workflowInvoker instanceof SystemComponentInvoker) { - int index = inputNode.getOutputPorts().indexOf(inputPort.getEdge(0).getFromPort()); - String outputName = ""; - if (inputNode.getInputPort(index) instanceof SystemDataPort) { - outputName = ((SystemDataPort) inputNode.getInputPort(index)).getWSComponentPort().getName(); - } else if (inputNode.getInputPort(index) instanceof WSPort) { - outputName = ((SystemDataPort) inputNode.getInputPort(inputNode.getOutputPorts().indexOf( - inputPort.getEdge(0).getFromPort()))).getWSComponentPort().getName(); - } - returnValForProvenance = workflowInvoker.getOutput(outputName); - XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>"); - Iterator valItr = msgElmt.children().iterator(); - while (valItr.hasNext()) { - Object object2 = valItr.next(); - if (object2 instanceof XmlElement) { - listOfValues.add(((XmlElement) object2).children().iterator().next().toString()); - } - } - } - } else { - throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach"); - } - } - } - return returnValForProvenance; - } - - /** - * - * @param inputPort - * @param invokerMap - * @return - * @throws WorkflowException - */ - public static Object findInputFromPort(DataPort inputPort, Map<Node, Invoker> invokerMap) 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; - - } - - /** - * @param node - * @return - */ - public static Node findEndForEachFor(ForEachNode node) { - - Collection<Node> toNodes = node.getOutputPort(0).getToNodes(); - if (toNodes.size() != 1) { - throw new WorkflowRuntimeException("ForEach output does not contain single out-edge"); - } - Node middleNode = toNodes.iterator().next(); - List<DataPort> outputPorts = middleNode.getOutputPorts(); - for (DataPort dataPort : outputPorts) { - if (dataPort.getToNodes().size() == 1) { - Node possibleEndForEachNode = dataPort.getToNodes().get(0); - if (possibleEndForEachNode instanceof EndForEachNode) { - return possibleEndForEachNode; - } - } - } - throw new WorkflowRuntimeException("EndForEachNode not found"); - } - - 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; - } else { - Invoker workflowInvoker = invokerMap.get(forEachInputNode); - if (workflowInvoker != null) { - if (workflowInvoker instanceof GenericInvoker) { - - returnValForProvenance = ((GenericInvoker) workflowInvoker).getOutputs(); - String message = returnValForProvenance.toString(); - - XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString(message); - Iterator children = msgElmt.children().iterator(); - while (children.hasNext()) { - Object object = children.next(); - // foreachWSNode.getInputPort(0).getType() - if (object instanceof XmlElement) { - index++; - } - } - } else if (workflowInvoker instanceof WorkflowInvokerWrapperForGFacInvoker) { - String outputName = forEachInputNode.getOutputPort(0).getName(); - returnValForProvenance = workflowInvoker.getOutput(outputName); - org.xmlpull.v1.builder.XmlElement msgElmt = (org.xmlpull.v1.builder.XmlElement) returnValForProvenance; - Iterator children = msgElmt.children(); - while (children.hasNext()) { - Object object = children.next(); - if (object instanceof org.xmlpull.v1.builder.XmlElement) { - org.xmlpull.v1.builder.XmlElement child = (org.xmlpull.v1.builder.XmlElement) object; - Iterator valItr = child.children(); - if (valItr.hasNext()) { - Object object2 = valItr.next(); - if (object2 instanceof String) { - index++; - } - } - } - } - inputNumbers[inputPorts.indexOf(forEachInputPort)] = index; - } else if (workflowInvoker instanceof SystemComponentInvoker) { - int portIndex = forEachInputNode.getOutputPorts().indexOf(forEachInputPort.getEdge(0).getFromPort()); - String outputName = ""; - if (forEachInputNode.getInputPort(portIndex) instanceof SystemDataPort) { - outputName = ((SystemDataPort) forEachInputNode.getInputPort(portIndex)).getWSComponentPort().getName(); - } else if (forEachInputNode.getInputPort(portIndex) instanceof WSPort) { - outputName = ((WSPort) forEachInputNode.getInputPort(portIndex)).getComponentPort().getName(); - } - returnValForProvenance = workflowInvoker.getOutput(outputName); - XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>"); - Iterator valItr = msgElmt.children().iterator(); - while (valItr.hasNext()) { - Object object2 = valItr.next(); - if (object2 instanceof XmlElement) { - index++; - } - } - inputNumbers[inputPorts.indexOf(forEachInputPort)] = index; - } - - } else { - throw new WorkFlowInterpreterException("Did not find inputs from WS to foreach"); - } - } - } - return inputNumbers; - } - - public static ArrayList<Node> getFinishedNodesDynamically(WSGraph graph) { - return getNodesWithBodyColor(NodeExecutionState.FINISHED, graph); - } - - public static ArrayList<Node> getFailedNodesDynamically(WSGraph graph) { - return getNodesWithBodyColor(NodeExecutionState.FAILED, graph); - } - - public static ArrayList<Node> getWaitingNodesDynamically(WSGraph graph) { - return getNodesWithBodyColor(NodeExecutionState.WAITING, graph); - } - - 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; - } - - public static int getRunningNodeCountDynamically(WSGraph graph) { - return getNodeCountWithBodyColor(NodeExecutionState.EXECUTING, graph); - } - - public static int getFailedNodeCountDynamically(WSGraph graph) { - return getFailedNodesDynamically(graph).size(); - } - - public static int getWaitingNodeCountDynamically(WSGraph graph) { - return getNodeCountWithBodyColor(NodeExecutionState.WAITING, graph); - } - - public static int getNodeCountWithBodyColor(NodeExecutionState state, WSGraph graph) { - int sum = 0; - List<NodeImpl> nodes = graph.getNodes(); - for (Node node : nodes) { - if (node.getState()==state) { - ++sum; - } - } - return sum; - } - -// public static String getEPR(WSNode wsNode) { -// Iterable<WsdlService> services = wsNode.getComponent().getWSDL().services(); -// Iterator<WsdlService> iterator = services.iterator(); -// if (iterator.hasNext()) { -// Iterable<WsdlPort> ports = iterator.next().ports(); -// Iterator<WsdlPort> portIterator = ports.iterator(); -// if (portIterator.hasNext()) { -// WsdlPort port = portIterator.next(); -// Iterable children = port.xml().children(); -// Iterator childIterator = children.iterator(); -// while (childIterator.hasNext()) { -// Object next = childIterator.next(); -// if (next instanceof XmlElementWithViewsImpl) { -// org.xmlpull.infoset.XmlAttribute epr = ((XmlElementWithViewsImpl) next).attribute("location"); -// return epr.getValue(); -// } -// } -// } -// } -// return null; -// } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/382b6c0e/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java index db25a1a..abb0b86 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/XBayaUtil.java @@ -50,8 +50,6 @@ import org.apache.airavata.xbaya.ThriftClientData; import org.apache.airavata.xbaya.ThriftServiceType; import org.apache.airavata.xbaya.XBayaConfiguration; import org.apache.airavata.xbaya.XBayaEngine; -import org.apache.airavata.xbaya.invoker.Invoker; -import org.apache.airavata.xbaya.lead.LeadContextHeaderHelper; import org.apache.airavata.xbaya.ui.dialogs.registry.RegistryWindow; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,52 +66,6 @@ public class XBayaUtil { public static final String JCR_PASS = "jcr.password"; public static final String JCR_URL = "jcr.url"; - public static LeadContextHeader buildLeadContextHeader(final XBayaEngine engine, - String nodeId, LeadResourceMapping resourceMapping) - throws URISyntaxException { - - XBayaConfiguration configuration = engine.getConfiguration(); - Workflow workflow = engine.getGUI().getWorkflow(); - - LeadContextHeader leadContext = buildLeadContextHeader(workflow, configuration, nodeId, - resourceMapping); - - return leadContext; - - } - - /** - * - * @param workflow - * @param configuration - * @param nodeId - * @param resourceMapping - * @return - * @throws URISyntaxException - */ - public static LeadContextHeader buildLeadContextHeader(Workflow workflow, XBayaConfiguration configuration, - String nodeId, LeadResourceMapping resourceMapping) - throws URISyntaxException { - LeadContextHeaderHelper leadContextHelper = new LeadContextHeaderHelper(); - leadContextHelper.setXBayaConfiguration(configuration); - - leadContextHelper.setWorkflowInstanceID(workflow.getGPELInstanceID()); - leadContextHelper.setWorkflowTemplateID(workflow.getUniqueWorkflowName()); - -// leadContextHelper.setMonitorConfiguration(monitorConfiguration); - - LeadContextHeader leadContext = leadContextHelper.getLeadContextHeader(); - - leadContext.setNodeId(nodeId); - - leadContext.setTimeStep("1"); - - if (resourceMapping != null) { - leadContext.setResourceMapping(resourceMapping); - } - return leadContext; - - } public static boolean isURLExists(String URLName) { try { @@ -149,65 +101,6 @@ public class XBayaUtil { RegistryWindow window = new RegistryWindow(xbayaEngine, ThriftServiceType.API_SERVICE); window.show(); } - - /** - * - * @param inputPort - * @param invokerMap - * @return - * @throws WorkflowException - */ - public static Object findInputFromPort(DataPort inputPort, Map<Node, Invoker> invokerMap) 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 EndifNode) { - 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 = fromNode.getOutputPort(0).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) { - outputVal = outputVal - + StringUtil.DELIMETER - + StringUtil.quoteString(((XmlElement) object2).children().iterator() - .next().toString()); - } - } - 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; - - } /** * @param node
