Search in sources :

Example 11 with Collection

use of org.wso2.carbon.registry.api.Collection in project ballerina by ballerina-lang.

the class PackageActionFunctionAndTypesFilter method populateIterableOperations.

private void populateIterableOperations(SymbolInfo variable, List<SymbolInfo> symbolInfoList) {
    BType bType = variable.getScopeEntry().symbol.getType();
    if (bType instanceof BArrayType || bType instanceof BMapType || bType instanceof BJSONType || bType instanceof BXMLType || bType instanceof BTableType || bType instanceof BIntermediateCollectionType) {
        fillForeachIterableOperation(bType, symbolInfoList);
        fillMapIterableOperation(bType, symbolInfoList);
        fillFilterIterableOperation(bType, symbolInfoList);
        fillCountIterableOperation(symbolInfoList);
        if (bType instanceof BArrayType && (((BArrayType) bType).eType.toString().equals("int") || ((BArrayType) bType).eType.toString().equals("float"))) {
            fillMinIterableOperation(symbolInfoList);
            fillMaxIterableOperation(symbolInfoList);
            fillAverageIterableOperation(symbolInfoList);
            fillSumIterableOperation(symbolInfoList);
        }
    // TODO: Add support for Table and Tuple collection
    }
}
Also used : BMapType(org.wso2.ballerinalang.compiler.semantics.model.types.BMapType) BXMLType(org.wso2.ballerinalang.compiler.semantics.model.types.BXMLType) BArrayType(org.wso2.ballerinalang.compiler.semantics.model.types.BArrayType) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BJSONType(org.wso2.ballerinalang.compiler.semantics.model.types.BJSONType) BIntermediateCollectionType(org.wso2.ballerinalang.compiler.semantics.model.types.BIntermediateCollectionType) BTableType(org.wso2.ballerinalang.compiler.semantics.model.types.BTableType)

Example 12 with Collection

use of org.wso2.carbon.registry.api.Collection in project ballerina by ballerina-lang.

the class BallerinaFunctionDocGenTest method testABalWithMultipleFunctions.

@Test(description = "Test a Bal file with multiple Functions")
public void testABalWithMultipleFunctions() {
    try {
        Map<String, BLangPackage> docsMap = BallerinaDocGenerator.generatePackageDocsFromBallerina(sourceRoot, "balWith2Functions.bal");
        Assert.assertNotNull(docsMap);
        Assert.assertEquals(docsMap.size(), 1);
        BallerinaDocGenTestUtils.printDocMap(docsMap);
        BLangPackage doc = docsMap.get(".");
        Collection<BLangFunction> functions = doc.getFunctions();
        Assert.assertEquals(functions.size(), 2);
        Iterator<BLangFunction> iterator = functions.iterator();
        BLangFunction function = iterator.next();
        Assert.assertEquals(function.getParameters().size(), 1);
        Assert.assertEquals(function.getReturnParameters().size(), 1);
        BLangFunction function1 = iterator.next();
        Assert.assertEquals(function1.getParameters().size(), 2);
        Assert.assertEquals(function1.getReturnParameters().size(), 0);
    } catch (IOException e) {
        Assert.fail();
    } finally {
        BallerinaDocGenTestUtils.cleanUp();
    }
}
Also used : BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 13 with Collection

use of org.wso2.carbon.registry.api.Collection in project wso2-dss-connectors by wso2-attic.

the class MongoDBDataSource method decodeQuery.

private Object[] decodeQuery(String query) throws DataServiceFault {
    int i1 = query.indexOf('.');
    if (i1 == -1) {
        throw new DataServiceFault("The MongoDB Collection not specified in the query '" + query + "'");
    }
    String collection = query.substring(0, i1).trim();
    int i2 = query.indexOf('(', i1);
    if (i2 == -1 || i2 - i1 <= 1) {
        throw new DataServiceFault("Invalid MongoDB operation in the query '" + query + "'");
    }
    String operation = query.substring(i1 + 1, i2).trim();
    int i3 = query.lastIndexOf(')');
    if (i3 == -1) {
        throw new DataServiceFault("Invalid MongoDB operation in the query '" + query + "'");
    }
    String opQuery = null;
    if (i3 - i2 > 1) {
        opQuery = query.substring(i2 + 1, i3).trim();
    }
    MongoOperation mongoOp = this.convertToMongoOp(operation);
    if (mongoOp == MongoOperation.UPDATE) {
        List<Object> result = new ArrayList<Object>();
        result.add(collection);
        result.add(mongoOp);
        result.addAll(parseInsertQuery(opQuery));
        return result.toArray();
    } else {
        return new Object[] { collection, mongoOp, this.checkAndCleanOpQuery(opQuery) };
    }
}
Also used : MongoOperation(org.wso2.dss.connectors.mongodb.MongoDBDSConstants.MongoOperation) DataServiceFault(org.wso2.carbon.dataservices.core.DataServiceFault) ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject)

Example 14 with Collection

use of org.wso2.carbon.registry.api.Collection in project ballerina by ballerina-lang.

the class TaintAnalyzer method visit.

public void visit(BLangForeach foreach) {
    SymbolEnv blockEnv = SymbolEnv.createBlockEnv(foreach.body, env);
    // Propagate the tainted status of collection to foreach variables.
    foreach.collection.accept(this);
    if (getObservedTaintedStatus()) {
        foreach.varRefs.forEach(varRef -> setTaintedStatus((BLangVariableReference) varRef, getObservedTaintedStatus()));
    }
    analyzeNode(foreach.body, blockEnv);
}
Also used : BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 15 with Collection

use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getFailedActivitiesForInstance.

/**
 * Get Failed Activities for give instance id.
 *
 * @param instanceID
 * @return
 * @throws InstanceManagementException
 */
@Override
public ActivityRecoveryInfoType[] getFailedActivitiesForInstance(final long instanceID) throws InstanceManagementException {
    try {
        isOperationIsValidForTheCurrentTenant(instanceID);
    } catch (IllegalAccessException ex) {
        handleError(ex);
    }
    ActivityRecoveryInfoType[] activityRecoveryInfoTypes = null;
    try {
        BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
        Object result = bpelDb.exec(new BpelDatabase.Callable<Object>() {

            public Object run(BpelDAOConnection conn) throws InstanceManagementException {
                ProcessInstanceDAO instance = conn.getInstance(instanceID);
                Collection<ActivityRecoveryDAO> activityRecoveries = instance.getActivityRecoveries();
                return activityRecoveries;
            }
        });
        ArrayList<ActivityRecoveryDAO> activityRecoveryDAOs = (ArrayList<ActivityRecoveryDAO>) result;
        if (activityRecoveryDAOs != null) {
            activityRecoveryInfoTypes = new ActivityRecoveryInfoType[activityRecoveryDAOs.size()];
            for (int i = 0; i < activityRecoveryDAOs.size(); i++) {
                ActivityRecoveryDAO activityRecovery = activityRecoveryDAOs.get(i);
                ActivityRecoveryInfoType info = new ActivityRecoveryInfoType();
                info.setActions(activityRecovery.getActions());
                info.setActivityID(activityRecovery.getActivityId());
                info.setDateTime(String.valueOf(activityRecovery.getDateTime()));
                info.setInstanceID(instanceID);
                info.setReason(activityRecovery.getReason());
                info.setRetires(activityRecovery.getRetries());
                activityRecoveryInfoTypes[i] = info;
            }
        }
    } catch (Exception e) {
        String errMsg = "Error occurred while retrieving failed activity information for instance id " + instanceID;
        log.error(errMsg, e);
        throw new InstanceManagementException(errMsg, e);
    }
    return activityRecoveryInfoTypes;
}
Also used : BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) ArrayList(java.util.ArrayList) ActivityRecoveryInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) Collection(java.util.Collection)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)13 Collection (java.util.Collection)9 ArrayList (java.util.ArrayList)8 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)8 IOException (java.io.IOException)7 Collection (org.wso2.carbon.registry.core.Collection)7 Map (java.util.Map)6 HashSet (java.util.HashSet)5 File (java.io.File)4 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)4 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)4 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)4 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)4 Test (org.testng.annotations.Test)4 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)4 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 Response (javax.ws.rs.core.Response)3 JAXBContext (javax.xml.bind.JAXBContext)3