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
}
}
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();
}
}
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) };
}
}
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);
}
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;
}
Aggregations