Search in sources :

Example 81 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class IfImpl method getArrows.

/**
 * Get the arrow coordinates of the activities
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the activity
 * @return An element which contains the arrow coordinates of the If activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    if (subActivities != null) {
        ActivityInterface prevActivity = null;
        ActivityInterface prevElseActivity = null;
        ActivityInterface activity = null;
        ActivityInterface seqActivity = null;
        boolean throwOrNot = true;
        String id = null;
        // Coordinates of the start icon exit arrow
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        // Coordinates of the end icon entry arrow
        SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
        // Coordinates of the Else activity start icon entry arrow
        SVGCoordinates myStartElseCoords = getStartIconElseArrowCoords();
        SVGCoordinates exitCoords = null;
        SVGCoordinates activityEntryCoords = null;
        SVGCoordinates activityExitCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        Element subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            // Gets the entry and exit coordinates of the iterated activity
            activityEntryCoords = activity.getEntryArrowCoords();
            activityExitCoords = activity.getExitArrowCoords();
            // Checks if the iterated activity is an instance of ElseIf or Else activity
            if (activity instanceof ElseIfImpl || activity instanceof ElseImpl) {
                // Checks whether there is a  previous activity and if so whether that activity is an ElseIf
                if (prevActivity != null && prevActivity instanceof ElseIfImpl) {
                    // Get the exit arrow coordinates of the ElseIf activity
                    exitCoords = ((ElseIfInterface) prevActivity).getNextElseExitArrowCoords();
                    // id is assigned with the id of the previous activity + id of the current activity
                    id = prevActivity.getId() + "-" + activity.getId();
                    // Checks whether the activity is an instance of Else
                    if (activity instanceof ElseImpl) {
                        // Gets the boolean value assigned inside ElseImpl when a throw activity is in Else
                        boolean check = ((ElseImpl) activity).throwOrNot;
                        // Define the entry arrow flow coordinates for the activity
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft() - getEndIconWidth() / 2, exitCoords.getYTop(), id));
                        // If there is a Throw activity inside Else, no exit arrow from Throw activity
                        if (check != true) {
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else if (activity instanceof ElseIfImpl) {
                        // Checks whether the activity is an instance of ElseIf
                        // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
                        boolean check = ((ElseIfImpl) activity).throwOrNot;
                        // Define the entry arrow flow coordinates for the activity
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        // If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
                        if (check != true) {
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else {
                        // Entry and exit arrow flows defined for other activities except for instances of Elseif and
                        // Else
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else if (prevActivity instanceof ThrowImpl && activity instanceof ElseImpl) {
                    // IF conditon fifnished --> ELSE IF ( previous activity is null and its is not an instance of
                    // ElseIf)
                    /*Checks if the previous activity is a Throw and if the current activity an Else, if so no exit
                        arrow flows only entry arrow flows.
                        */
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                } else if (activity instanceof ElseIfImpl) {
                    // Checks whether the activity is an instance of ElseIf
                    // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in ElseIf
                    boolean check = ((ElseIfImpl) activity).throwOrNot;
                    // Define the entry arrow flow coordinates for the activity
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    // If there is a Throw activity inside ElseIf, no exit arrow from Throw activity
                    if (check != true) {
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else if (activity instanceof ElseImpl) {
                    // Checks whether the activity is an instance of Else
                    // Gets the boolean value assigned inside ElseIfImpl when a throw activity is in Else
                    boolean check = ((ElseImpl) activity).throwOrNot;
                    // Define the entry arrow flow coordinates for the activity
                    subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    // If there is a Throw activity inside Else, no exit arrow from Throw activity
                    if (check != true) {
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                } else {
                    id = prevActivity.getId() + "-" + activity.getId();
                    // flows
                    if (activity instanceof ThrowImpl) {
                        subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    } else {
                        // Define both the entry and the exit arrow flows to the activity
                        subGroup.appendChild(getArrowDefinition(doc, myStartElseCoords.getXLeft(), myStartElseCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                }
            } else if (activity instanceof ThrowImpl) {
                // Checks if the current activity a Throw activity, if so no exit arrow flows only entry arrow flows
                subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            } else if (activity instanceof SourceImpl || activity instanceof TargetImpl || activity instanceof SourcesImpl || activity instanceof TargetsImpl) {
            // Checks if the current activity a Source/s or Target/s activity, if so no exit or entry arrow flows
            // as no icons are defined
            // No arrow flows for Sources or Targets..
            } else {
                if (prevActivity != null) {
                    // Gets the coordinates of the exit arrows of the previous activity
                    exitCoords = prevActivity.getExitArrowCoords();
                    id = prevActivity.getId() + "-" + activity.getId();
                    // arrow flows as no icons are defined
                    if (prevActivity instanceof SourceImpl || prevActivity instanceof TargetImpl || prevActivity instanceof SourcesImpl || prevActivity instanceof TargetsImpl) {
                    // No arrow flows for Sources or Targets..
                    } else {
                        subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                    }
                } else {
                    // Checks whether the activity is a Sequence
                    if (activity instanceof SequenceImpl) {
                        List<ActivityInterface> sub = activity.getSubActivities();
                        // Iterates through the subActivities
                        Iterator<ActivityInterface> as = sub.iterator();
                        while (as.hasNext()) {
                            seqActivity = as.next();
                            // Checks if the subActivity is a Throw activity
                            if (seqActivity instanceof ThrowImpl) {
                                throwOrNot = true;
                                // if condition breaks if the subActivity is a Throw activity
                                break;
                            } else {
                                throwOrNot = false;
                            }
                        }
                        // If its a Throw activity , no exit arrow flow only entry arrow flow to the activity
                        if (throwOrNot == true) {
                            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        } else {
                            // If not, define both the entry and the exit arrow flows to the activity
                            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                        }
                    } else {
                        // Define both the entry and the exit arrow flows to the activity
                        subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
                        subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
                    }
                }
            }
            // current activity is assigned to the previous activity
            prevActivity = activity;
        }
        return subGroup;
    }
    return null;
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 82 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class IfImpl method getExitArrowCoords.

/**
 * At the start: xLeft=0, yTop=0
 * Calculates the coordinates of the arrow which leaves an activity
 *
 * @return coordinates/exit point of the exit arrow for the activities
 */
@Override
public SVGCoordinates getExitArrowCoords() {
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = getEndIconXLeft() + (getEndIconWidth() / 2);
        yTop = getEndIconYTop() + getEndIconHeight();
    } else {
        xLeft = getEndIconXLeft() + getEndIconWidth();
        yTop = getEndIconYTop() + (getEndIconHeight() / 2);
    }
    // Returns the calculated coordinate points of the exit arrow
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 83 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class IfImpl method getStartIconExitArrowCoords.

/**
 * At the start: xLeft=0, yTop=0
 * Calculates the coordinates of the arrow which leaves the start If Icon
 *
 * @return coordinates of the exit arrow for the start icon
 * After Calculations(Vertical Layout): xLeft= Xleft of Icon + (width of icon)/2 , yTop= Ytop of the Icon +
 * height of the icon
 */
protected SVGCoordinates getStartIconExitArrowCoords() {
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = getStartIconXLeft() + (getStartIconWidth() / 2);
        yTop = getStartIconYTop() + getStartIconHeight();
    } else {
        xLeft = getStartIconXLeft() + getStartIconWidth();
        yTop = getStartIconYTop() + (getStartIconHeight() / 2);
    }
    // Returns the calculated coordinate points of the exit arrow of the startIcon
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 84 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class OnMessageImpl method layoutVertical.

/**
 * Sets the x and y positions of the activities
 * At the start: startXLeft=0, startYTop=0
 * centreOfMyLayout- center of the the SVG
 *
 * @param startXLeft x-coordinate
 * @param startYTop  y-coordinate
 */
public void layoutVertical(int startXLeft, int startYTop) {
    // Aligns the activities to the center of the layout
    int centreOfMyLayout = startXLeft + (dimensions.getWidth() / 2);
    // Positioning the startIcon
    int xLeft = centreOfMyLayout - (getStartIconWidth() / 2);
    int yTop = startYTop + (getYSpacing() / 2);
    ActivityInterface activity;
    Iterator<ActivityInterface> itr = getSubActivities().iterator();
    // Adjusting the childXLeft and childYTop positions
    int childYTop = yTop + getStartIconHeight() + (getYSpacing() / 2);
    int childXLeft;
    // Iterates through all the subActivities
    while (itr.hasNext()) {
        activity = itr.next();
        // Sets the xLeft position of the iterated activity : childXleft= center of the layout - (width of the
        // activity icon)/2
        childXLeft = centreOfMyLayout - activity.getDimensions().getWidth() / 2;
        // Sets the xLeft and yTop position of the iterated activity
        activity.layout(childXLeft, childYTop);
        childYTop += activity.getDimensions().getHeight();
    }
    // Sets the xLeft and yTop positions of the start icon
    setStartIconXLeft(xLeft);
    setStartIconYTop(yTop);
    // Sets the xLeft and yTop positions of the start icon text
    setStartIconTextXLeft(startXLeft + BOX_MARGIN);
    setStartIconTextYTop(startYTop + BOX_MARGIN + BPEL2SVGFactory.TEXT_ADJUST);
    // Sets the xLeft and yTop positions of the SVG  of the activity after setting the dimensions
    getDimensions().setXLeft(startXLeft);
    getDimensions().setYTop(startYTop);
}
Also used : ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)

Example 85 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class OnMessageImpl method getEntryArrowCoords.

/**
 * At the start: xLeft=0, yTop=0
 * Calculates the coordinates of the arrow which enters an activity
 *
 * @return coordinates/entry point of the entry arrow for the activities
 * After Calculations(Vertical Layout): xLeft=Xleft of Icon + (width of icon)/2 , yTop= Ytop of the Icon
 */
@Override
public SVGCoordinates getEntryArrowCoords() {
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = getStartIconXLeft() + (getStartIconWidth() / 2);
        yTop = getStartIconYTop();
    } else {
        xLeft = getStartIconXLeft();
        yTop = getStartIconYTop() + (getStartIconHeight() / 2);
    }
    // Returns the calculated coordinate points of the entry arrow
    SVGCoordinates coords = new SVGCoordinates(xLeft, yTop);
    return coords;
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Aggregations

SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)57 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)47 Test (org.testng.annotations.Test)17 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)17 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)17 Event (org.wso2.siddhi.core.event.Event)17 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)13 SVGDimension (org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)11 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)11 ArrayList (java.util.ArrayList)10 OMElement (org.apache.axiom.om.OMElement)10 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)10 Element (org.w3c.dom.Element)9 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)9 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 ZoneId (java.time.ZoneId)5 HashMap (java.util.HashMap)5 Analyzer (org.wso2.carbon.apimgt.core.api.Analyzer)5 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)5