Search in sources :

Example 41 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class DifferedInputNode method addConfigurationElement.

@Override
protected XmlElement addConfigurationElement(XmlElement nodeElement) {
    XmlElement configElement = super.addConfigurationElement(nodeElement);
    if (this.defaultValue != null) {
        XmlElement element = configElement.addElement(GraphSchema.NS, VALUE_TAG_NAME);
        element.addChild(this.defaultValue);
    }
    return configElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 42 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class DifferedInputNode method toXML.

@Override
public XmlElement toXML() {
    XmlElement nodeElement = super.toXML();
    nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_DIFFERED_INPUT);
    return nodeElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 43 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class MonitorPanel method init.

private void init() {
    this.table = new JTable(this.tableSliderModel) {

        @Override
        public String getToolTipText(MouseEvent event) {
            String tip = null;
            Point point = event.getPoint();
            int colIndex = columnAtPoint(point);
            if (colIndex == EventDataRepository.Column.MESSAGE.ordinal()) {
                tip = "Double click here to see the full message.";
            }
            return tip;
        }
    };
    this.table.getTableHeader().setReorderingAllowed(false);
    this.table.addMouseListener(new MouseInputAdapter() {

        private MonitorWindow window;

        @Override
        public void mouseClicked(MouseEvent event) {
            Point point = event.getPoint();
            int row = MonitorPanel.this.table.rowAtPoint(point);
            if (row >= 0 && row < MonitorPanel.this.table.getRowCount()) {
                EventData message = MonitorPanel.this.tableSliderModel.getEvent(row);
                int clickCount = event.getClickCount();
                if (clickCount == 1) {
                /*                     if (MonitorUtil.getType(message) == MonitorUtil.EventType.PUBLISH_URL) {
                            int column = MonitorPanel.this.table.columnAtPoint(point);
                            if (column == EventDataRepository.Column.MESSAGE.ordinal()) {
                                String url = MonitorUtil.getLocation(message);
                                try {
                                    BrowserLauncher.openURL(url);
                                } catch (Exception e) {
                                    MonitorPanel.this.xbayaGUI.getErrorWindow().error(e.getMessage(), e);
                                }
                            }
                        } else if (MonitorUtil.getType(message) == MonitorUtil.EventType.SENDING_RESULT) {
                            if (null != message && null != message.element("result")
                                    && null != message.element("result").element("body")
                                    && null != message.element("result").element("body").element("Body")) {
                                XmlElement body = message.element("result").element("body").element("Body");
                                Iterator bodyItr = body.children().iterator();
                                // find the first body Element
                                findAndLaunchBrowser(bodyItr);
                                // XmlElement output = message.element("result").element("body").
                                // element("Body").element("Visualize_OutputParams").element("Visualized_Output");
                                // Iterator children = output.children().iterator();
                                // while (children.hasNext()) {
                                // Object object = (Object) children.next();
                                // if(object instanceof String){
                                // try {
                                // new URL(((String)object).trim());
                                // try {
                                // BrowserLauncher.openURL(((String)object).trim());
                                // } catch (Throwable e) {
                                // //do nothing
                                // }
                                // } catch (MalformedURLException e) {
                                // //do nothing
                                // }
                                // }
                                //
                                // }
                            }
                        }*/
                } else if (clickCount >= 2) {
                    // Handle double clicks to pop up a window.
                    if (this.window == null) {
                        this.window = new MonitorWindow(MonitorPanel.this.xbayaGUI);
                    }
                    this.window.show(message);
                }
            }
        }

        /**
         * @param bodyItr
         */
        private void findAndLaunchBrowser(Iterator bodyItr) {
            if (bodyItr.hasNext()) {
                Object firstElement = bodyItr.next();
                if (firstElement instanceof XmlElement) {
                    findAndLuanchBrowser((XmlElement) firstElement);
                }
            }
        }

        /**
         * @param firstElement
         */
        private void findAndLuanchBrowser(XmlElement firstElement) {
            Iterator children = ((XmlElement) firstElement).children().iterator();
            while (children.hasNext()) {
                Object object = (Object) children.next();
                if (object instanceof String) {
                    try {
                        new URL(((String) object).trim());
                        try {
                            BrowserLauncher.openURL(((String) object).trim());
                        } catch (Throwable e) {
                        // do nothing
                        }
                    } catch (MalformedURLException e) {
                    // do nothing
                    }
                } else if (object instanceof XmlElement) {
                    findAndLuanchBrowser((XmlElement) object);
                }
            }
        }
    });
    // Adjust size of columns
    TableColumnModel columnModel = this.table.getColumnModel();
    int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        TableColumn column = columnModel.getColumn(i);
        if (i == columnCount - 1) {
            column.setPreferredWidth(500);
        } else {
            column.setPreferredWidth(50);
        }
    }
    this.table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    this.scrollPane = new JScrollPane(this.table);
    this.scrollPane.setMinimumSize(SwingUtil.MINIMUM_SIZE);
    this.scrollPane.setDoubleBuffered(true);
    this.slider = new JSlider(this.tableSliderModel);
    this.slider.setSnapToTicks(true);
    this.slider.setEnabled(false);
    this.panel = new JPanel();
    this.panel.setLayout(new BorderLayout());
    this.panel.add(this.scrollPane, BorderLayout.CENTER);
    this.panel.add(this.slider, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MalformedURLException(java.net.MalformedURLException) MouseEvent(java.awt.event.MouseEvent) MonitorWindow(org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow) TableColumnModel(javax.swing.table.TableColumnModel) Point(java.awt.Point) TableColumn(javax.swing.table.TableColumn) EventData(org.apache.airavata.xbaya.messaging.EventData) URL(java.net.URL) Point(java.awt.Point) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) Iterator(java.util.Iterator) XmlElement(org.xmlpull.infoset.XmlElement) JSlider(javax.swing.JSlider) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Example 44 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class InstanceNode method addConfigurationElement.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#addConfigurationElement(org.xmlpull.infoset.XmlElement)
 */
@Override
protected XmlElement addConfigurationElement(XmlElement nodeElement) {
    XmlElement configElement = super.addConfigurationElement(nodeElement);
    // save start new instance
    XmlElement element = configElement.addElement(GraphSchema.NS, NEW_TAG_NAME);
    element.addChild(String.valueOf(this.startNewInstance));
    if (this.startNewInstance) {
        // save ami id
        if (this.amiId != null) {
            XmlElement element2 = configElement.addElement(GraphSchema.NS, AMI_ID_TAG_NAME);
            element2.addChild(this.amiId);
        }
        // save instance type
        if (this.instanceType != null) {
            XmlElement element3 = configElement.addElement(GraphSchema.NS, INSTANCE_TYPE_TAG_NAME);
            element3.addChild(this.instanceType);
        }
    } else {
        // save instance id
        if (this.instanceId != null) {
            XmlElement element2 = configElement.addElement(GraphSchema.NS, INSTANCE_ID_TAG_NAME);
            element2.addChild(this.instanceId);
        }
    }
    // save username
    if (this.username != null) {
        XmlElement element2 = configElement.addElement(GraphSchema.NS, USERNAME_TAG_NAME);
        element2.addChild(this.username);
    }
    return configElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 45 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class BasicTypeMapping method getOutputArray.

public static Object getOutputArray(XmlElement element, String name, int simpleIndex) throws WorkflowException {
    try {
        // This code doesn't work when the output is a complex type.
        // Object output = this.outputMessage.getObjectPart(name);
        // return output;
        XmlElement outputElement = (XmlElement) element;
        Iterator valueElementItr = outputElement.elements(null, name).iterator();
        LinkedList<String> ret = new LinkedList<String>();
        while (valueElementItr.hasNext()) {
            XmlElement valueElement = (XmlElement) valueElementItr.next();
            Iterator childIt = valueElement.children().iterator();
            int numberOfChildren = 0;
            while (childIt.hasNext()) {
                childIt.next();
                numberOfChildren++;
            }
            if (numberOfChildren == 1) {
                Object child = valueElement.children().iterator().next();
                if (child instanceof String) {
                    // Value is a simple type. Return the string.
                    String value = (String) child;
                    ret.add(value);
                }
            }
        }
        switch(simpleIndex) {
            case 0:
                Integer[] intRet = new Integer[ret.size()];
                for (int i = 0; i < ret.size(); i++) {
                    intRet[i] = Integer.parseInt(ret.get(i));
                }
                return intRet;
            case 1:
                String[] strRet = new String[ret.size()];
                for (int i = 0; i < ret.size(); i++) {
                    strRet[i] = ret.get(i);
                }
                return strRet;
        }
        throw new WorkflowException("Unknown type");
    } catch (RuntimeException e) {
        String message = "Error in getting output. name: " + name;
        throw new WorkflowException(message, e);
    }
}
Also used : WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) Iterator(java.util.Iterator) XmlElement(org.xmlpull.infoset.XmlElement) LinkedList(java.util.LinkedList)

Aggregations

XmlElement (org.xmlpull.infoset.XmlElement)79 AiravataException (org.apache.airavata.common.exception.AiravataException)5 GraphException (org.apache.airavata.workflow.model.graph.GraphException)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)4 LinkedList (java.util.LinkedList)3 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)3 Workflow (org.apache.airavata.workflow.model.wf.Workflow)3 XmlAttribute (org.xmlpull.infoset.XmlAttribute)3 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)2 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)2 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)2 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)2 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)2 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)2 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)2