Search in sources :

Example 36 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.

the class CodeGenerator method getWorkerDataChannelInfo.

private WorkerDataChannelInfo getWorkerDataChannelInfo(CallableUnitInfo callableUnit, String source, String target) {
    WorkerDataChannelInfo workerDataChannelInfo = callableUnit.getWorkerDataChannelInfo(WorkerDataChannelInfo.generateChannelName(source, target));
    if (workerDataChannelInfo == null) {
        UTF8CPEntry sourceCPEntry = new UTF8CPEntry(source);
        int sourceCPIndex = this.currentPkgInfo.addCPEntry(sourceCPEntry);
        UTF8CPEntry targetCPEntry = new UTF8CPEntry(target);
        int targetCPIndex = this.currentPkgInfo.addCPEntry(targetCPEntry);
        workerDataChannelInfo = new WorkerDataChannelInfo(sourceCPIndex, source, targetCPIndex, target);
        workerDataChannelInfo.setUniqueName(workerDataChannelInfo.getChannelName() + this.workerChannelCount);
        String uniqueName = workerDataChannelInfo.getUniqueName();
        UTF8CPEntry uniqueNameCPEntry = new UTF8CPEntry(uniqueName);
        int uniqueNameCPIndex = this.currentPkgInfo.addCPEntry(uniqueNameCPEntry);
        workerDataChannelInfo.setUniqueNameCPIndex(uniqueNameCPIndex);
        callableUnit.addWorkerDataChannelInfo(workerDataChannelInfo);
        this.workerChannelCount++;
    }
    return workerDataChannelInfo;
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString) WorkerDataChannelInfo(org.wso2.ballerinalang.programfile.WorkerDataChannelInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 37 with Source

use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.

the class ASTBuilderUtil method generateArgExprs.

static List<BLangExpression> generateArgExprs(DiagnosticPos pos, List<BLangVariable> args, List<BVarSymbol> formalParams, SymbolResolver symResolver) {
    List<BLangExpression> argsExpr = new ArrayList<>();
    final List<BLangSimpleVarRef> variableRefList = createVariableRefList(pos, args);
    for (int i = 0; i < variableRefList.size(); i++) {
        BLangSimpleVarRef varRef = variableRefList.get(i);
        BType target = formalParams.get(i).type;
        BType source = varRef.symbol.type;
        if (source != target) {
            argsExpr.add(generateConversionExpr(varRef, target, symResolver));
            continue;
        }
        argsExpr.add(varRef);
    }
    return argsExpr;
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) ArrayList(java.util.ArrayList) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 38 with Source

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

the class BPELServerImpl method initDataSource.

/**
 * Initialize the data source.
 *
 * @throws BPELEngineException If error occured while initializing datasource
 */
private void initDataSource() throws BPELEngineException {
    db = new Database(odeConfigurationProperties);
    db.setTransactionManager(transactionManager);
    if (System.getProperty("setup") != null) {
        BPELDatabaseCreator bpelDBCreator;
        try {
            bpelDBCreator = new BPELDatabaseCreator(db.<DataSource>lookupInJndi(odeConfigurationProperties.getDbDataSource()));
        } catch (Exception e) {
            String errMsg = "Error creating BPELDatabaseCreator";
            log.error(errMsg, e);
            throw new BPELEngineException(errMsg, e);
        }
        if (!bpelDBCreator.isDatabaseStructureCreated("SELECT * FROM ODE_SCHEMA_VERSION")) {
            try {
                // TODO rename following method
                bpelDBCreator.createRegistryDatabase();
            } catch (Exception e) {
                String errMsg = "Error creating BPEL database";
                log.error(errMsg, e);
                throw new BPELEngineException(errMsg, e);
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("BPEL database already exists. Using the old database.");
            }
        }
    }
    // In carbon, embedded H2 database for ODE is located at CARBON_HOME/repository/database
    String dbRoot = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "database";
    File dbRootDir = new File(dbRoot);
    if (dbRootDir.exists() && dbRootDir.isDirectory()) {
        db.setWorkRoot(dbRootDir);
    } else {
        db.setWorkRoot(null);
    }
    try {
        db.start();
    } catch (Exception e) {
        String errMsg = "Error starting database connections, check the database configuration!";
        log.error(errMsg, e);
        throw new BPELEngineException(errMsg, e);
    }
}
Also used : Database(org.apache.ode.il.dbutil.Database) BPELDatabaseCreator(org.wso2.carbon.bpel.core.ode.integration.utils.BPELDatabaseCreator) File(java.io.File) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanRegistrationException(javax.management.MBeanRegistrationException) BpelEngineException(org.apache.ode.bpel.iapi.BpelEngineException) DataSource(javax.sql.DataSource)

Example 39 with Source

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

the class BPELServerConfiguration method populateDataSourceConfigFields.

private void populateDataSourceConfigFields() {
    TDataBaseConfig databaseConfig = bpsConfigDocument.getWSO2BPS().getDataBaseConfig();
    if (databaseConfig != null) {
        // Now we do not have concept called EMBEDDED. All the DBs are configured as EXTERNAL.
        // This way users can modify the default db config as well. And also support the
        // -Dsetup
        dsType = DataSourceType.EXTERNAL;
        if (databaseConfig.getDataSource().getName() != null && databaseConfig.getDataSource().getName().length() > 0) {
            dataSourceName = databaseConfig.getDataSource().getName();
        } else {
            throw new RuntimeException("Data Source name cannot be null, " + "when data source mode is external.");
        }
        if (databaseConfig.getDataSource().isSetJNDI()) {
            TDataBaseConfig.DataSource.JNDI jndiConfig = databaseConfig.getDataSource().getJNDI();
            if (jndiConfig.getContextFactory() != null && jndiConfig.getContextFactory().length() > 0 && jndiConfig.getProviderURL() != null && jndiConfig.getProviderURL().length() > 0) {
                dataSourceJNDIRepoInitialContextFactory = jndiConfig.getContextFactory().trim();
                dataSourceJNDIRepoProviderURL = jndiConfig.getProviderURL().trim();
                // Read Port Offset
                int portOffset = readPortOffset();
                // applying port offset operation
                String urlWithoutPort = dataSourceJNDIRepoProviderURL.substring(0, dataSourceJNDIRepoProviderURL.lastIndexOf(':') + 1);
                int dataSourceJNDIRepoProviderPort = Integer.parseInt(dataSourceJNDIRepoProviderURL.substring(urlWithoutPort.length())) + portOffset;
                dataSourceJNDIRepoProviderURL = urlWithoutPort + dataSourceJNDIRepoProviderPort;
            }
        }
    }
}
Also used : TDataBaseConfig(org.wso2.carbon.bpel.config.TDataBaseConfig)

Example 40 with Source

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

the class ProcessImpl method getLinkArrows.

/**
 * Gets the Link arrow coordinates when there is a FLOW activity in the process
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the process
 * @return An element which contains the link arrow coordinates of the Process
 */
private Element getLinkArrows(SVGDocument doc) {
    Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks whether the any links exist
    if (links != null && !links.isEmpty()) {
        // Returns a collection-view of the map with the link names, sources(starting activity) and the target
        // (ending activity)
        Set linksSet = links.entrySet();
        Iterator linksIterator = linksSet.iterator();
        // Iterates through the links
        while (linksIterator.hasNext()) {
            Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
            // Gets the source/start activity of the link
            ActivityInterface startActivity = link.getValue().getSource();
            // Gets the target/end activity of the link
            ActivityInterface endActivity = link.getValue().getTarget();
            // Get the link name
            String linkName = link.getKey();
            // Check if the source and the target of the link contains a value
            if (endActivity != null && startActivity != null) {
                // Define the link flow/path by giving the coordinates of the start and end activity
                group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
            }
        }
    }
    return group;
}
Also used : Set(java.util.Set) ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) Map(java.util.Map) Link(org.wso2.carbon.bpel.ui.bpel2svg.Link)

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