Search in sources :

Example 6 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class Workflow method clone.

/**
 * @see java.lang.Object#clone()
 */
@Override
public Workflow clone() {
    XmlElement originalXML = toXML();
    try {
        XmlElement newXML = XMLUtil.deepClone(originalXML);
        Workflow newWorkflow = new Workflow(newXML);
        return newWorkflow;
    } catch (GraphException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (WorkflowException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (AiravataException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.infoset.XmlElement) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 7 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class GraphCanvas method paintComponent.

private void paintComponent(Graphics2D g) {
    NodeController.getGUI(this.graph).paint(g);
    // Draws a creating edge.
    if (this.draggedPort != null) {
        Point p1, p2;
        Kind kind = this.draggedPort.getKind();
        if (kind == Kind.DATA_OUT || kind == Kind.CONTROL_OUT || kind == Kind.EPR) {
            p1 = NodeController.getGUI(this.draggedPort).getPosition();
            p2 = this.mousePoint;
        } else if (kind == Kind.DATA_IN || kind == Kind.CONTROL_IN) {
            p1 = this.mousePoint;
            p2 = NodeController.getGUI(this.draggedPort).getPosition();
        } else {
            // This should not happen.
            throw new WorkflowRuntimeException();
        }
        g.setColor(Color.RED);
        Stroke originalStroke = g.getStroke();
        if (kind == Kind.CONTROL_IN || kind == Kind.CONTROL_OUT) {
            g.setStroke(EdgeGUI.CONTROL_EDGE_STROKE);
        }
        EdgeGUI.paintLine(p1, p2, g);
        g.setStroke(originalStroke);
    }
    // Draw rectangular for selection
    if (this.mousePointForSelection != null) {
        double width = Math.abs(this.mousePoint.getX() - this.mousePointForSelection.getX());
        double height = Math.abs(this.mousePoint.getY() - this.mousePointForSelection.getY());
        int x = (int) (this.mousePoint.getX() > this.mousePointForSelection.getX() ? this.mousePointForSelection.getX() : this.mousePoint.getX());
        int y = (int) (this.mousePoint.getY() > this.mousePointForSelection.getY() ? this.mousePointForSelection.getY() : this.mousePoint.getY());
        g.setColor(Color.RED);
        g.setStroke(new // End cap
        BasicStroke(// End cap
        1.0f, // End cap
        BasicStroke.CAP_ROUND, // Join style
        BasicStroke.JOIN_MITER, // Miter limit
        15.0f, // Dash pattern
        new float[] { 5.0f, 5.0f }, // Dash phase
        3.0f));
        g.drawRect(x, y, (int) width, (int) height);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) Point(java.awt.Point) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Point(java.awt.Point)

Example 8 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class XBayaDialog method init.

private void init() {
    if (this.owner instanceof Frame) {
        this.dialog = new JDialog((Frame) this.owner);
    } else if (this.owner instanceof Dialog) {
        this.dialog = new JDialog((Dialog) this.owner);
    } else {
        // This should not happen.
        throw new WorkflowRuntimeException("The owner component was neither Frame or Dialog.");
    }
    this.dialog.setTitle(this.title);
    this.dialog.setModal(true);
    this.dialog.setResizable(true);
    Container contentPane = this.dialog.getContentPane();
    int numRow = 0;
    if (this.description != null && this.description.length() > 0) {
        JLabel descriptionLabel = new JLabel("<html>" + this.description + "</html>");
        contentPane.add(descriptionLabel);
        numRow++;
    }
    contentPane.add(this.mainPanel);
    numRow++;
    contentPane.add(this.buttonPanel);
    numRow++;
    SwingUtil.layoutToGrid(contentPane, numRow, 1, numRow - 2, 0);
}
Also used : Frame(java.awt.Frame) Container(java.awt.Container) JDialog(javax.swing.JDialog) Dialog(java.awt.Dialog) JLabel(javax.swing.JLabel) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) JDialog(javax.swing.JDialog)

Example 9 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class EndBlockNode method portTypeChanged.

/**
 * @see org.apache.airavata.workflow.model.graph.system.SystemNode#portTypeChanged(org.apache.airavata.workflow.model.graph.system.SystemDataPort)
 */
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
    super.portTypeChanged(port);
    List<DataPort> inputPorts = getInputPorts();
    List<DataPort> outputPorts = getOutputPorts();
    int size = outputPorts.size();
    Kind kind = port.getKind();
    int index;
    if (kind == Kind.DATA_IN) {
        index = inputPorts.indexOf(port) % size;
    } else if (kind == Kind.DATA_OUT) {
        index = outputPorts.indexOf(port);
    } else {
        throw new WorkflowRuntimeException();
    }
    DataPort inputPort1 = inputPorts.get(index);
    DataPort inputPort2 = inputPorts.get(size + index);
    DataPort outputPort = outputPorts.get(index);
    DataType inputType1 = inputPort1.getType();
    DataType inputType2 = inputPort2.getType();
    DataType outputType = outputPort.getType();
    DataType portType = port.getType();
    if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
        // Do nothing
        return;
    }
    if (port == inputPort1) {
        // input1 -> input2
        if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort2.copyType(port);
        } else if (inputType2.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
            throw new GraphException(message);
        }
        // input1 -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
            outputPort.copyType(port);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else if (port == inputPort2) {
        // input2 -> input1
        if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort1.copyType(port);
        } else if (inputType1.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
            throw new GraphException(message);
        }
        // input2 -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
            outputPort.copyType(port);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else if (port == outputPort) {
        // output -> input1
        if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort1.copyType(port);
        } else if (inputType1.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
        // output -> input2
        if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort2.copyType(port);
        } else if (inputType2.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of input " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else {
        throw new WorkflowRuntimeException();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 10 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class EndDoWhileNode method edgeWasAdded.

/**
 * @throws GraphException
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    // XXX cannot detect if the type is array or not from WSDL at this
    // point. so no check here.
    // super.edgeWasAdded(edge);
    Port fromPort = edge.getFromPort();
    Port toPort = edge.getToPort();
    if (edge instanceof DataEdge) {
        if (fromPort instanceof EPRPort) {
            // TODO
            return;
        }
        DataPort fromDataPort = (DataPort) fromPort;
        DataPort toDataPort = (DataPort) toPort;
        DataType fromType = fromDataPort.getType();
        DataType toType = toDataPort.getType();
        if (fromDataPort.getNode() == this) {
            if (!(toType == null || toType.equals(WSConstants.XSD_ANY_TYPE))) {
                fromDataPort.copyType(toDataPort);
            }
        } else if (toDataPort.getNode() == this) {
            if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE))) {
                toDataPort.copyType(fromDataPort);
            }
        } else {
            throw new WorkflowRuntimeException();
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)41 DataPort (org.apache.airavata.workflow.model.graph.DataPort)25 GraphException (org.apache.airavata.workflow.model.graph.GraphException)13 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)12 Node (org.apache.airavata.workflow.model.graph.Node)11 DataType (org.apache.airavata.model.application.io.DataType)10 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)9 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)8 Port (org.apache.airavata.workflow.model.graph.Port)8 Kind (org.apache.airavata.workflow.model.graph.Port.Kind)7 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)7 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)6 LinkedList (java.util.LinkedList)4 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)4 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)4 Point (java.awt.Point)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)3