Search in sources :

Example 71 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillProcessInfo.

/**
 * Fill in the <code>ProcessInfo</code> element of the transfer object.
 *
 * @param info               destination XMLBean
 * @param pconf              process configuration object (from store)
 * @param custom             used to customize the quantity of information produced in the
 *                           info
 * @param tenantProcessStore Tenant's Process store
 * @throws ProcessManagementException If an error occurred while filling process information
 */
private void fillProcessInfo(ProcessInfoType info, ProcessConf pconf, ProcessInfoCustomizer custom, TenantProcessStoreImpl tenantProcessStore) throws ProcessManagementException {
    if (pconf == null) {
        String errMsg = "Process configuration cannot be null.";
        log.error(errMsg);
        throw new ProcessManagementException(errMsg);
    }
    info.setPid(pconf.getProcessId().toString());
    // Active process may be retired at the same time
    if (pconf.getState() == ProcessState.RETIRED) {
        info.setStatus(ProcessStatus.RETIRED);
        info.setOlderVersion(AdminServiceUtils.isOlderVersion(pconf, tenantProcessStore));
    } else if (pconf.getState() == ProcessState.DISABLED) {
        info.setStatus(ProcessStatus.DISABLED);
        info.setOlderVersion(0);
    } else {
        info.setStatus(ProcessStatus.ACTIVE);
        info.setOlderVersion(0);
    }
    info.setVersion(pconf.getVersion());
    DefinitionInfo defInfo = new DefinitionInfo();
    defInfo.setProcessName(pconf.getType());
    BpelDefinition bpelDefinition = new BpelDefinition();
    bpelDefinition.setExtraElement(getProcessDefinition(pconf));
    defInfo.setDefinition(bpelDefinition);
    info.setDefinitionInfo(defInfo);
    DeploymentInfo depInfo = new DeploymentInfo();
    depInfo.setPackageName(pconf.getPackage());
    depInfo.setDocument(pconf.getBpelDocument());
    depInfo.setDeployDate(AdminServiceUtils.toCalendar(pconf.getDeployDate()));
    // TODO: Need to fix this by adding info to process conf.
    depInfo.setDeployer(org.wso2.carbon.bpel.core.BPELConstants.BPEL_DEPLOYER_NAME);
    info.setDeploymentInfo(depInfo);
    if (custom.includeInstanceSummary()) {
        InstanceSummary instanceSummary = new InstanceSummary();
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.ACTIVE);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.COMPLETED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.FAILED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.SUSPENDED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.TERMINATED);
        addFailuresToInstanceSummary(instanceSummary, pconf);
        info.setInstanceSummary(instanceSummary);
    }
    if (custom.includeProcessProperties()) {
        ProcessProperties processProps = new ProcessProperties();
        for (Map.Entry<QName, Node> propEntry : pconf.getProcessProperties().entrySet()) {
            QName key = propEntry.getKey();
            if (key != null) {
                Property_type0 prop = new Property_type0();
                prop.setName(new QName(key.getNamespaceURI(), key.getLocalPart()));
                OMFactory omFac = OMAbstractFactory.getOMFactory();
                OMElement propEle = omFac.createOMElement("PropertyValue", null);
                propEle.setText(propEntry.getValue().getNodeValue());
                prop.addExtraElement(propEle);
                processProps.addProperty(prop);
            }
        }
        info.setProperties(processProps);
    }
    fillPartnerLinks(info, ((ProcessConfigurationImpl) pconf).getProcessDeploymentInfo());
}
Also used : DefinitionInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo) BpelDefinition(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) InstanceSummary(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummary) Property_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Property_type0) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0) ProcessProperties(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperties) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) OMFactory(org.apache.axiom.om.OMFactory) DeploymentInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo) Map(java.util.Map)

Example 72 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ScopeImpl method getTerminationHandlerIcon.

/**
 * At start: xLeft=0, yTop=0
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the activity
 * @return Element(represents an element in a XML) which contains the TerminationHandler icon and arrow flows
 */
public Element getTerminationHandlerIcon(SVGDocument doc) {
    // Get the coordinates of the start arrow of the TerminationHandler
    SVGCoordinates coords = getStartTerminationCoords();
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = coords.getXLeft() - getHandlerIconWidth();
        yTop = coords.getYTop() - (getHandlerIconHeight() / 2);
    } else {
        xLeft = coords.getXLeft() - (getHandlerIconWidth() / 2);
        yTop = coords.getYTop() - getHandlerIconHeight();
    }
    // Gets the icon path of the activity
    String iconPath = BPEL2SVGIcons.TERMINATIONHANDLER_ICON;
    // width
    return getImageDefinition(doc, iconPath, xLeft, yTop, getHandlerIconWidth(), getHandlerIconHeight(), getId());
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 73 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ScopeImpl method getFaultHandlerIcon.

/**
 * At start: xLeft=0, yTop=0
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the activity
 * @return Element(represents an element in a XML) which contains the FaultHandler icon and arrow flows
 */
public Element getFaultHandlerIcon(SVGDocument doc) {
    // Get the coordinates of the start arrow of the FaultHandler
    SVGCoordinates coords = getStartFaultCoords();
    int xLeft = 0;
    int yTop = 0;
    if (layoutManager.isVerticalLayout()) {
        xLeft = coords.getXLeft() - getHandlerIconWidth();
        yTop = coords.getYTop() - (getHandlerIconHeight() / 2);
    } else {
        xLeft = coords.getXLeft() - (getHandlerIconWidth() / 2);
        yTop = coords.getYTop() - getHandlerIconHeight();
    }
    // Gets the icon path of the activity
    String iconPath = BPEL2SVGIcons.FAULTHANDLER_ICON;
    // width
    return getImageDefinition(doc, iconPath, xLeft, yTop, getHandlerIconWidth(), getHandlerIconHeight(), getId());
}
Also used : SVGCoordinates(org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)

Example 74 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class BPELUploadExecutor method validateBPELPackage.

public void validateBPELPackage(String directoryPath) throws Exception {
    DeploymentUnitDir du;
    try {
        du = new DeploymentUnitDir(new File(directoryPath));
    } catch (IllegalArgumentException iae) {
        log.error("BPEL Package Validation Failure.", iae);
        throw new Exception("BPEL Package Validation Failure.", iae);
    }
    // check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
    List<File> packageFiles = du.allFiles();
    for (File packageFile : packageFiles) {
        if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
            log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
            throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
        }
    }
    try {
        du.compile();
    } catch (RuntimeException ce) {
        log.error("BPEL Process Compilation Failure.", ce);
        throw new Exception("BPEL Compilation Failure!", ce);
    } catch (Exception e) {
        log.error("BPEL Process Compilation Failure.", e);
        throw new Exception("BPEL Compilation Failure!", e);
    }
    du.scan();
    DeployDocument dd = du.getDeploymentDescriptor();
    for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
        QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
        DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
        if (cbpInfo == null) {
            // removeDeploymentArtifacts(deploymentContext, du);
            String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
            log.error(logMessage);
            throw new Exception(logMessage);
        }
        for (TProvide tProvide : processDD.getProvideList()) {
            if (tProvide.getService() == null) {
                String errMsg = "Service element missing for the provide element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
        for (TInvoke tInvoke : processDD.getInvokeList()) {
            if (tInvoke.getService() == null) {
                String errMsg = "Service element missing for the invoke element in deploy.xml";
                log.error(errMsg);
                throw new Exception(errMsg);
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) IOException(java.io.IOException) CarbonException(org.wso2.carbon.CarbonException) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) TProvide(org.apache.ode.bpel.dd.TProvide) File(java.io.File)

Example 75 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-business-process by wso2.

the class ForEachImpl 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 ForEach activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    Element subGroup = null;
    // Creating an SVG Container "g"
    subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks for the subActivities
    if (subActivities != null) {
        ActivityInterface activity = null;
        String id = null;
        SVGCoordinates myStartCoords = getStartIconExitArrowCoords();
        SVGCoordinates myExitCoords = getEndIconEntryArrowCoords();
        SVGCoordinates activityExitCoords = null;
        SVGCoordinates activityEntryCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            id = activity.getId();
            // Gets the entry and exit coordinates of the iterated activity
            activityExitCoords = activity.getExitArrowCoords();
            activityEntryCoords = activity.getEntryArrowCoords();
            // Gives the coordinates of the entry arrow to the first activity from the startIcon
            subGroup.appendChild(getArrowDefinition(doc, myStartCoords.getXLeft(), myStartCoords.getYTop(), activityEntryCoords.getXLeft(), activityEntryCoords.getYTop(), id));
            // Gives the coordinates of the entry arrow to the endIcon of ForEach
            subGroup.appendChild(getArrowDefinition(doc, activityExitCoords.getXLeft(), activityExitCoords.getYTop(), myExitCoords.getXLeft(), myExitCoords.getYTop(), id));
        }
    }
    return subGroup;
}
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)

Aggregations

Test (org.testng.annotations.Test)87 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)82 Query (org.wso2.siddhi.query.api.execution.query.Query)81 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)79 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)79 SiddhiApp (org.wso2.siddhi.query.api.SiddhiApp)79 Event (org.wso2.siddhi.core.event.Event)77 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)76 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)73 Element (org.w3c.dom.Element)34 OMElement (org.apache.axiom.om.OMElement)25 QName (javax.xml.namespace.QName)15 SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)14 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)13 NodeList (org.w3c.dom.NodeList)12 Element (org.wso2.siddhi.query.api.annotation.Element)12 Node (org.w3c.dom.Node)11 ArrayList (java.util.ArrayList)9 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)8 HashMap (java.util.HashMap)7