airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [2/4] git commit: Added a menu item for executing applications, restored previous workflow launching menu action, made composing workflows for executing single applciations optional
Date Tue, 09 Sep 2014 20:39:08 GMT
Added a menu item for executing applications, restored previous workflow launching menu action,
made composing workflows for executing single applciations optional


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4056bb91
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4056bb91
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4056bb91

Branch: refs/heads/master
Commit: 4056bb916e4de9acafbf3a8740c28152ea9b5ef4
Parents: 6b519e2
Author: Nadeem Anjum <nadeem.cs.iit@gmail.com>
Authored: Wed Aug 20 02:57:48 2014 +0530
Committer: Nadeem Anjum <nadeem.cs.iit@gmail.com>
Committed: Wed Aug 20 02:57:48 2014 +0530

----------------------------------------------------------------------
 .../ui/experiment/LaunchApplicationWindow.java  | 136 ++++++++++++-------
 .../xbaya/ui/menues/ApplicationMenuItem.java    |  59 ++++++++
 .../airavata/xbaya/ui/menues/RunMenuItem.java   |   9 +-
 .../airavata/xbaya/ui/menues/XBayaMenu.java     |   5 +-
 4 files changed, 150 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
index 18daea0..e99a6f3 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
@@ -51,6 +51,7 @@ import org.apache.airavata.model.workspace.experiment.DataObjectType;
 import org.apache.airavata.model.workspace.experiment.DataType;
 import org.apache.airavata.model.workspace.experiment.Experiment;
 import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
+import org.apache.airavata.workflow.model.graph.DataPort;
 import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
 import org.apache.airavata.workflow.model.graph.system.InputNode;
 import org.apache.airavata.workflow.model.graph.system.OutputNode;
@@ -127,33 +128,30 @@ public class LaunchApplicationWindow {
         }
 
         // 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);
+        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();
+    		QName parameterType = port.getType();
+    		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);            
+            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;
 		        
@@ -268,13 +266,14 @@ public class LaunchApplicationWindow {
     private void execute() throws AiravataClientConnectException, InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
     	List<NodeImpl> nodes = workflow.getGraph().getNodes();
     	String appId = null;
+    	NodeImpl node = null;
     	for(int i=0; i<nodes.size(); i++){
-    		NodeImpl node = nodes.get(i);
-    		String html = node.getComponent().toHTML();
+    		node = nodes.get(i);
+    		String html = node.getComponent().toHTML();     		
     		String nodeType =html.substring(html.indexOf("<h1>")+4, html.indexOf(":")).trim();
   		
     		if(nodeType.equals("Application")){
     			appId=html.substring(html.indexOf("</h2>")+6, html.indexOf("<br")).trim();
-    			break;
+    			break;    			
     		}
     	}
     	
@@ -301,7 +300,7 @@ public class LaunchApplicationWindow {
         if(owner.equals(""))owner="NotKnown";              
         project.setOwner(owner);
         project.setProjectID(airavataClient.createProject(project));
-        final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
+        final List<DataPort> inputPorts = node.getInputPorts();
         final Experiment experiment = new Experiment();
         experiment.setApplicationId(appId);
         ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
@@ -325,24 +324,57 @@ public class LaunchApplicationWindow {
         experiment.setName(instanceName);
         experiment.setProjectID(project.getProjectID());
         experiment.setUserName(thriftClientData.getUsername());
-        for (int i = 0; i < inputNodes.size(); i++) {
-            InputNode inputNode = inputNodes.get(i);
-            XBayaTextField parameterTextField = this.parameterTextFields.get(i);
-            inputNode.getID();
+        for (int i = 0; i < inputPorts.size(); i++) {
+            DataPort inputPort = inputPorts.get(i);
+            XBayaTextField parameterTextField = this.parameterTextFields.get(i);        
  
             String value = parameterTextField.getText();
             DataObjectType elem = new DataObjectType();
-            elem.setKey(inputNode.getID());
-            elem.setType(DataType.STRING);
+            elem.setKey(inputPort.getName());
+            String type = inputPort.getType().getLocalPart().trim();
+            DataType inpType = DataType.STRING;
+            if(type.equalsIgnoreCase("string")){
+            	inpType=DataType.STRING;
+            }
+            else if(type.equalsIgnoreCase("integer")){
+            	inpType=DataType.INTEGER;
+            }
+            else if(type.equalsIgnoreCase("uri")){
+            	inpType=DataType.URI;
+            }
+            else if(type.equalsIgnoreCase("stdour")){
+            	inpType=DataType.STDOUT;
+            }
+            else if(type.equalsIgnoreCase("stderr")){
+            	inpType=DataType.STDERR;
+            }
+            elem.setType(inpType);
             elem.setValue(value);
 			experiment.addToExperimentInputs(elem );
         }
-        final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
+        final List<DataPort> outputPorts = node.getOutputPorts();
         
-        for (int i = 0; i < outputNodes.size(); i++) {
-            OutputNode outputNode = outputNodes.get(i);
+        for (int i = 0; i < outputPorts.size(); i++) {
+            DataPort outputPort = outputPorts.get(i);
             DataObjectType elem = new DataObjectType();
-            elem.setKey(outputNode.getID());
-            elem.setType(DataType.STRING);
+            elem.setKey(outputPort.getName());
+            String type = outputPort.getType().getLocalPart().trim();
+            DataType outType = DataType.STRING;
+            if(type.equalsIgnoreCase("string")){
+            	outType=DataType.STRING;
+            }
+            else if(type.equalsIgnoreCase("integer")){
+            	outType=DataType.INTEGER;
+            }
+            else if(type.equalsIgnoreCase("uri")){
+            	outType=DataType.URI;
+            }
+            else if(type.equalsIgnoreCase("stdour")){
+            	outType=DataType.STDOUT;
+            }
+            else if(type.equalsIgnoreCase("stderr")){
+            	outType=DataType.STDERR;
+            }
+            elem.setType(outType);
             elem.setValue("");
 			experiment.addToExperimentOutputs(elem );
         }
@@ -368,25 +400,26 @@ public class LaunchApplicationWindow {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-        String output = "";
-        while(output.equals("")){
-        	String fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
-        	if(status.equals("COMPLETED")){
+        
+        if(status.equals("COMPLETED")){
+        	String output="";;
+        	String fullOutput="";
+        	while(output.equals("")){
+        		output = "";
+        		fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
             	List<DataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
             	for(int i1=0; i1<outputs.size(); i1++){
             		output = outputs.get(i1).getValue();
             		fullOutput+= outputs.get(i1).getKey()+": "+output+"\n";
             		
-            	}
-            	JOptionPane.showMessageDialog(null, fullOutput);
-            }
-            else{
-            	JOptionPane.showMessageDialog(null, "Experiment Failed");
-            	return;
-            }
+            	}            	
+            } 
+        	JOptionPane.showMessageDialog(null, fullOutput);
+        }
+        else{
+        	JOptionPane.showMessageDialog(null, "Experiment Failed");
+        	return;
         }
-
-
         new Thread() {
             @Override
             public void run() {
@@ -395,6 +428,5 @@ public class LaunchApplicationWindow {
         }.start();
 
         hide();
-    } 
-	
+    }       
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
new file mode 100644
index 0000000..1787c06
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
@@ -0,0 +1,59 @@
+package org.apache.airavata.xbaya.ui.menues;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.experiment.LaunchApplicationWindow;
+
+public class ApplicationMenuItem {
+	
+	private JMenu applicationMenu;
+
+    private JMenuItem executeApplicationItem;
+    
+	private XBayaEngine engine;
+
+	public ApplicationMenuItem(XBayaEngine engine) {
+		this.engine = engine;
+
+        createApplicationMenu();
+	}
+
+	private void createApplicationMenu() {
+		createExecuteApplicationItem();
+		this.applicationMenu = new JMenu("Run Applications");
+		this.applicationMenu.add(this.executeApplicationItem);
+		this.applicationMenu.addSeparator();
+	}
+
+	private void createExecuteApplicationItem() {
+		this.executeApplicationItem = new JMenuItem("Execute Application");
+		this.executeApplicationItem.addActionListener(new AbstractAction() {
+			private LaunchApplicationWindow window;
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                if (this.window == null) {
+                    this.window = new LaunchApplicationWindow(ApplicationMenuItem.this.engine);
+                }
+                try {
+                    this.window.show();
+                } catch (Exception e1) {
+                    ApplicationMenuItem.this.engine.getGUI().getErrorWindow().error(e1);
+                }
+            }
+        });
+		
+	}
+
+	public JMenu getMenu() {
+		return this.applicationMenu;
+	}
+
+	
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/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 6cfde9f..0320e06 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
@@ -45,8 +45,7 @@ import org.apache.airavata.xbaya.XBayaConfiguration.XBayaExecutionMode;
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.core.ide.XBayaExecutionModeListener;
 import org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorConfigurationWindow;
-import org.apache.airavata.xbaya.ui.experiment.LaunchApplicationWindow;
-//import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
+import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
 import org.apache.airavata.xbaya.ui.monitor.MonitorStarter;
 import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
 import org.apache.airavata.xbaya.ui.widgets.ToolbarButton;
@@ -268,8 +267,7 @@ public class RunMenuItem  implements EventListener, XBayaExecutionModeListener{
     private void createLaunchXBayaInterpreterItem() {
         this.launchXBayaInterpreterItem = new JMenuItem("Run on Interpreter Server...", MenuIcons.RUN_ICON);
         AbstractAction action = new AbstractAction() {
-        	//private WorkflowInterpreterLaunchWindow window;
-            private LaunchApplicationWindow window;
+        	private WorkflowInterpreterLaunchWindow window;            
             public void actionPerformed(ActionEvent e) {
                 if(!engine.getMonitor().hasCurrentExecutionTerminatedNotificationReceived()
&& engine.getMonitor().isMonitoring()){
                     if (JOptionPane.showConfirmDialog(null,
@@ -279,8 +277,7 @@ public class RunMenuItem  implements EventListener, XBayaExecutionModeListener{
                     }
                 }
 //                if (this.window == null) {
-                //this.window = new WorkflowInterpreterLaunchWindow(engine);
-                this.window = new LaunchApplicationWindow(engine);
+                this.window = new WorkflowInterpreterLaunchWindow(engine);
 //                }
                 try {
                     this.window.show();

http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
index 5b472ed..3eb385a 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
@@ -53,6 +53,8 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
 	private RegistryMenuItem registryMenuItem;
 
     private AmazonEC2MenuItem amazonEC2MenuItem;
+    
+    private ApplicationMenuItem applicationMenuItem;
 
 //	private ToolsMenuItem toolsMenuItem;
 
@@ -80,7 +82,7 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
 		runMenuItem = new RunMenuItem(getEngine(), getToolBar());
 		registryMenuItem = new RegistryMenuItem(getEngine(),getToolBar());
 //		toolsMenuItem = new ToolsMenuItem(getEngine());
-
+		applicationMenuItem = new ApplicationMenuItem(getEngine());
 		createMenuBar();
 		executionModeChanged(getEngine().getConfiguration());
 	}
@@ -106,6 +108,7 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
 //        menuBar.add(toolsMenuItem.getMenu());
         menuBar.add(registryMenuItem.getMenu());
         menuBar.add(amazonEC2MenuItem.getMenu());
+        menuBar.add(applicationMenuItem.getMenu());
         // Space before Help
         this.menuBar.add(Box.createHorizontalGlue());
 


Mime
View raw message