Search in sources :

Example 11 with Variable

use of org.wso2.siddhi.query.api.expression.Variable in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitSet_clause.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public UpdateSet visitSet_clause(@NotNull SiddhiQLParser.Set_clauseContext ctx) {
    UpdateSet updateSet = new UpdateSet();
    for (SiddhiQLParser.Set_assignmentContext setAssignmentContext : ctx.set_assignment()) {
        updateSet.set(((Variable) visit(setAssignmentContext.attribute_reference())), (Expression) visit(setAssignmentContext.expression()));
    }
    populateQueryContext(updateSet, ctx);
    return updateSet;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) UpdateSet(org.wso2.siddhi.query.api.execution.query.output.stream.UpdateSet)

Example 12 with Variable

use of org.wso2.siddhi.query.api.expression.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for enums.
 * @param enumNode ballerina enum node.
 * @return documentation for enum.
 */
public static EnumDoc createDocForNode(EnumNode enumNode) {
    String enumName = enumNode.getName().getValue();
    List<Variable> enumerators = new ArrayList<>();
    // Iterate through the enumerators
    if (enumNode.getEnumerators().size() > 0) {
        for (EnumNode.Enumerator enumerator : enumNode.getEnumerators()) {
            String desc = fieldAnnotation((BLangNode) enumNode, (BLangNode) enumerator);
            Variable variable = new Variable(enumerator.getName().getValue(), "", desc);
            enumerators.add(variable);
        }
    }
    return new EnumDoc(enumName, description((BLangNode) enumNode), new ArrayList<>(), enumerators);
}
Also used : EnumDoc(org.ballerinalang.docgen.model.EnumDoc) BLangNode(org.wso2.ballerinalang.compiler.tree.BLangNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) ArrayList(java.util.ArrayList) EnumNode(org.ballerinalang.model.tree.EnumNode)

Example 13 with Variable

use of org.wso2.siddhi.query.api.expression.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for connectors.
 * @param connectorNode ballerina connector node.
 * @return documentation for connectors.
 */
public static ConnectorDoc createDocForNode(BLangConnector connectorNode) {
    String connectorName = connectorNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Documentable> actions = new ArrayList<>();
    // Iterate through the connector parameters
    if (connectorNode.getParameters().size() > 0) {
        for (BLangVariable param : connectorNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(connectorNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the actions of the connectors
    if (connectorNode.getActions().size() > 0) {
        for (BLangAction action : connectorNode.getActions()) {
            actions.add(createDocForNode(action));
        }
    }
    return new ConnectorDoc(connectorName, description(connectorNode), actions, parameters);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) Documentable(org.ballerinalang.docgen.model.Documentable) ArrayList(java.util.ArrayList) ConnectorDoc(org.ballerinalang.docgen.model.ConnectorDoc) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Example 14 with Variable

use of org.wso2.siddhi.query.api.expression.Variable in project ballerina by ballerina-lang.

the class Generator method createDocForNode.

/**
 * Create documentation for functions.
 * @param functionNode ballerina function node.
 * @return documentation for functions.
 */
public static FunctionDoc createDocForNode(BLangFunction functionNode) {
    String functionName = functionNode.getName().value;
    List<Variable> parameters = new ArrayList<>();
    List<Variable> returnParams = new ArrayList<>();
    // Iterate through the parameters
    if (functionNode.getParameters().size() > 0) {
        for (BLangVariable param : functionNode.getParameters()) {
            String dataType = type(param);
            String desc = paramAnnotation(functionNode, param);
            Variable variable = new Variable(param.getName().value, dataType, desc);
            parameters.add(variable);
        }
    }
    // Iterate through the return types
    if (functionNode.getReturnParameters().size() > 0) {
        for (int i = 0; i < functionNode.getReturnParameters().size(); i++) {
            BLangVariable returnParam = functionNode.getReturnParameters().get(i);
            String dataType = type(returnParam);
            String desc = returnParamAnnotation(functionNode, i);
            Variable variable = new Variable(returnParam.getName().value, dataType, desc);
            returnParams.add(variable);
        }
    }
    return new FunctionDoc(functionName, description(functionNode), new ArrayList<>(), parameters, returnParams);
}
Also used : BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) Variable(org.ballerinalang.docgen.model.Variable) FunctionDoc(org.ballerinalang.docgen.model.FunctionDoc) ArrayList(java.util.ArrayList) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 15 with Variable

use of org.wso2.siddhi.query.api.expression.Variable 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)

Aggregations

RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)37 ArrayList (java.util.ArrayList)31 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)31 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)30 Test (org.testng.annotations.Test)28 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)26 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)26 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)26 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)23 BJSON (org.ballerinalang.model.values.BJSON)22 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)18 IOException (java.io.IOException)17 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)17 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)17 Variable (org.wso2.siddhi.query.api.expression.Variable)17 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)16 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)15 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)15 Response (javax.ws.rs.core.Response)14 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)13