Search in sources :

Example 81 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.

the class AttachmentMgtDAOBasicOperationsTest method testAttachmentDAORemoveTest.

/**
 * This method tests the attachment removal functionality
 */
public void testAttachmentDAORemoveTest() {
    AttachmentManagerService service = new AttachmentManagerService();
    try {
        if (service.remove(attachmentID)) {
            log.info("Attachment with id: " + attachmentID + " was successfully removed from data-source.");
            assertTrue("Attachment successfully has been removed from data-source.", true);
        } else {
            Assert.fail("Attachment with id: " + attachmentID + " couldn't be removed.");
        }
    } catch (AttachmentMgtException e) {
        log.error(e.getLocalizedMessage(), e);
        Assert.fail("Attachment removal failed due to reason: " + e.getLocalizedMessage());
    }
}
Also used : AttachmentManagerService(org.wso2.carbon.attachment.mgt.core.service.AttachmentManagerService) AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)

Example 82 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.

the class SequenceImpl 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 Sequence activity and its subActivities
 */
protected Element getArrows(SVGDocument doc) {
    Element subGroup = null;
    // Creating an SVG Container "g" to place the activities
    subGroup = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks for the subActivities
    if (subActivities != null) {
        ActivityInterface prevActivity = null;
        ActivityInterface activity = null;
        String id = null;
        SVGCoordinates exitCoords = null;
        SVGCoordinates entryCoords = null;
        Iterator<ActivityInterface> itr = subActivities.iterator();
        // Iterates through all the subActivities
        while (itr.hasNext()) {
            activity = itr.next();
            // Checks whether the previous activity is null
            if (prevActivity != null) {
                // Get the exit arrow coordinates of the previous activity
                exitCoords = prevActivity.getExitArrowCoords();
                // Get the entry arrow coordinates of the current activity
                entryCoords = activity.getEntryArrowCoords();
                // id is assigned with the id of the previous activity + id of the current activity
                id = prevActivity.getId() + "-" + activity.getId();
                /*Check whether the activity is a Throw activity, if so setCheck()= true
                      This check is done to remove the exit arrow coming from the Throw activity,as when the process
                      reaches
                       a Throw activity, the process terminates.
                    */
                if (activity instanceof ThrowImpl) {
                    setCheck(true);
                }
                if (prevActivity instanceof SourcesImpl || prevActivity instanceof SourceImpl || prevActivity instanceof TargetImpl || prevActivity instanceof TargetsImpl || activity instanceof SourcesImpl || activity instanceof SourceImpl || activity instanceof TargetImpl || activity instanceof TargetsImpl || prevActivity instanceof ThrowImpl) {
                // No exit arrow for Source or Target as it doesn't have an icon specified.
                // Checks whether the previous activity is a Throw activity, if so no exit arrow
                } else {
                    subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(), exitCoords.getYTop(), entryCoords.getXLeft(), entryCoords.getYTop(), id));
                }
            }
            prevActivity = activity;
        }
    }
    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)

Example 83 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.

the class BPELServerImpl method init.

/**
 * Initialize the ODE BPEL engine.
 *
 * @throws Exception if failed to start the BPEL engine.
 */
public void init() throws Exception {
    bpelServerConfiguration = new BPELServerConfiguration();
    odeConfigurationProperties = new ODEConfigurationProperties(bpelServerConfiguration);
    if (log.isDebugEnabled()) {
        log.debug("Initializing transaction manager");
    }
    initTransactionManager();
    if (log.isDebugEnabled()) {
        log.debug("Creating data source");
    }
    initDataSource();
    if (log.isDebugEnabled()) {
        log.debug("Starting DAO");
    }
    initDAO();
    BPELEndpointReferenceContextImpl eprContext = new BPELEndpointReferenceContextImpl();
    if (log.isDebugEnabled()) {
        log.debug("Initializing BPEL process store");
    }
    initProcessStore(eprContext);
    if (log.isDebugEnabled()) {
        log.debug("Initializing BPEL server");
    }
    initBPELServer(eprContext);
    if (log.isDebugEnabled()) {
        log.debug("Initializing multithreaded connection manager");
    }
    initHttpConnectionManager();
    /* Register event listeners configured in ode-axis2.properties file*/
    registerEventListeners();
    /* Register message exchange interceptors configured in ode-axis.properties file*/
    registerMexInterceptors();
    registerExtensionActivityBundles();
    registerExtensionCorrelationFilters();
    try {
        odeBpelServer.start();
    } catch (Exception e) {
        shutdown();
        String errMsg = "BPEL Server failed to start.";
        log.error(errMsg, e);
        throw new Exception(errMsg, e);
    }
    if (bpelServerConfiguration.getUseDistributedLock() && isAxis2ClusteringEnabled()) {
        BPELServerHolder.getInstance().addObserver(this);
        if (log.isDebugEnabled()) {
            log.debug("Clustering Enabled, Registering Observer for HazelCast service");
        }
    }
    registerMBeans();
}
Also used : BPELServerConfiguration(org.wso2.carbon.bpel.core.ode.integration.config.BPELServerConfiguration) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanRegistrationException(javax.management.MBeanRegistrationException) BpelEngineException(org.apache.ode.bpel.iapi.BpelEngineException)

Example 84 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.

the class HTRenderingApiImpl method getRenderingOutputElements.

/**
 * Function to retrieve output rendering elements
 *
 * @param taskIdentifier interested task identifier
 * @return set of output renderings wrapped within OutputType
 * @throws IllegalArgumentFault        error occured while retrieving renderings from task definition
 * @throws IOException                 If an error occurred while reading from the input source
 * @throws SAXException                If the xml content in the input source is invalid
 * @throws IllegalOperationFault
 * @throws IllegalAccessFault
 * @throws IllegalStateFault
 * @throws XPathExpressionException    If error occurred while xpath evaluation
 * @throws GetRenderingsFaultException If unable to find unique id for the wso2:output rendering element
 */
private OutputType getRenderingOutputElements(URI taskIdentifier) throws IllegalArgumentFault, IOException, SAXException, IllegalOperationFault, IllegalAccessFault, IllegalStateFault, XPathExpressionException, GetRenderingsFaultException {
    QName renderingType = new QName(htRenderingNS, "output", "wso2");
    String outputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
    // create output element
    OutputType renderingOutputs = null;
    // check availability of output renderings
    if (outputRenderings != null && outputRenderings.length() > 0) {
        // parse output renderings
        Element outputRenderingsElement = DOMUtils.stringToDOM(outputRenderings);
        // retrieve output rendering elements
        NodeList outputElementList = outputRenderingsElement.getElementsByTagNameNS(htRenderingNS, "element");
        if (outputElementList != null && outputElementList.getLength() > 0) {
            int outputElementNum = outputElementList.getLength();
            OutputElementType[] outputElements = new OutputElementType[outputElementNum];
            // TODO get task output message from the cache
            // (if not in the cache) retrieve saved output using HumanTaskClientAPI
            String savedOutputMsg = (String) taskOps.getOutput(taskIdentifier, null);
            // Element to hold parsed saved output message
            Element savedOutputElement = null;
            if (savedOutputMsg != null && savedOutputMsg.length() > 0) {
                savedOutputElement = DOMUtils.stringToDOM(savedOutputMsg);
            }
            for (int i = 0; i < outputElementNum; i++) {
                Element tempElement = (Element) outputElementList.item(i);
                if (tempElement.hasAttribute("id")) {
                    // Retrieve element data
                    String elementID = tempElement.getAttribute("id");
                    String label = tempElement.getElementsByTagNameNS(htRenderingNS, "label").item(0).getTextContent();
                    String xpath = tempElement.getElementsByTagNameNS(htRenderingNS, "xpath").item(0).getTextContent();
                    String defaultValue = tempElement.getElementsByTagNameNS(htRenderingNS, "default").item(0).getTextContent();
                    // set the readOnly attribute if Exists, default false
                    String readOnly = "false";
                    if (tempElement.hasAttribute("readOnly")) {
                        readOnly = tempElement.getAttribute("readOnly");
                    }
                    // set element data in the response message
                    outputElements[i] = new OutputElementType();
                    // set ID
                    outputElements[i].setId(elementID);
                    // set label
                    outputElements[i].setLabel(label);
                    // set xpath
                    outputElements[i].setXpath(xpath);
                    // set value
                    Element valueElement = (Element) tempElement.getElementsByTagNameNS(htRenderingNS, "value").item(0);
                    outputElements[i].setValue(createOutRenderElementValue(valueElement));
                    if (readOnly.equals("true")) {
                        outputElements[i].setReadOnly(true);
                    } else {
                        outputElements[i].setReadOnly(false);
                    }
                    if (savedOutputElement != null) {
                        // resolve default value
                        String savedOutMessageValue = evaluateXPath(xpath, savedOutputElement, outputRenderingsElement.getOwnerDocument());
                        if (savedOutMessageValue == null) {
                            outputElements[i].set_default(defaultValue);
                        } else {
                            outputElements[i].set_default(savedOutMessageValue);
                        }
                    } else {
                        // add default value specified in the HT rendering definition
                        outputElements[i].set_default(defaultValue);
                    }
                } else {
                    // no unique id for the element
                    log.error("Unable to find unique id for the wso2:output rendering element");
                    throw new GetRenderingsFaultException("Unable to find unique id for the wso2:output rendering element");
                }
            }
            renderingOutputs = new OutputType();
            renderingOutputs.setElement(outputElements);
        }
    }
    return renderingOutputs;
}
Also used : OutputElementType(org.wso2.carbon.humantask.rendering.api.OutputElementType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) GetRenderingsFaultException(org.wso2.carbon.humantask.rendering.api.GetRenderingsFaultException) OutputType(org.wso2.carbon.humantask.rendering.api.OutputType)

Example 85 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project carbon-business-process by wso2.

the class HumanTaskServer method initDataSource.

// Initialises the data source with the provided configuration parameters.
private void initDataSource() throws HumanTaskServerException {
    database = new Database(serverConfig);
    // TODO - need to handle the external transaction managers.
    database.setTransactionManager(tnxManager);
    try {
        database.start();
    } catch (Exception e) {
        String errMsg = "Humantask Database Initialization failed.";
        throw new HumanTaskServerException(errMsg, e);
    }
}
Also used : HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException) Database(org.wso2.carbon.humantask.core.db.Database) HumanTaskServerException(org.wso2.carbon.humantask.core.engine.HumanTaskServerException)

Aggregations

Test (org.testng.annotations.Test)22 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)15 ArrayList (java.util.ArrayList)11 CompilerOptions (org.wso2.ballerinalang.compiler.util.CompilerOptions)11 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)11 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)11 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)8 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)8 ParseTree (org.antlr.v4.runtime.tree.ParseTree)8 OMElement (org.apache.axiom.om.OMElement)8 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)8 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)8 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)8 DocumentInfo (org.wso2.carbon.apimgt.core.models.DocumentInfo)8 Event (org.wso2.siddhi.core.event.Event)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Compiler (org.wso2.ballerinalang.compiler.Compiler)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)6 SiddhiQLBaseVisitorImpl (org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl)6