private void checkSelection(OutputAttribute newAttribute) { for (OutputAttribute attribute : selectionList) { if (attribute.getRename().equals(newAttribute.getRename())) { throw new DuplicateAttributeException(newAttribute.getRename() + " is already defined as an output " + "attribute ", newAttribute.getQueryContextStartIndex(), attribute.getQueryContextEndIndex()); } } }
public Selector select(Variable variable) { OutputAttribute outputAttribute = new OutputAttribute(variable); checkSelection(outputAttribute); selectionList.add(outputAttribute); return this; }
private static List<StreamColumn> convertOutputStreamColumns(List<OutputAttribute> outputAttributeList) { return outputAttributeList.stream().map(outputAttribute -> { StreamColumn streamColumn = new StreamColumn(); streamColumn.setName(outputAttribute.getRename()); streamColumn.setDescription(outputAttribute.getExpression().toString()); return streamColumn; }).collect(Collectors.toList()); } }
List<OutputAttribute> list = query.getSelector().getSelectionList(); for (OutputAttribute output : list) { outputFields.add(output.getRename());
/** * obtains information of all the user defined Functions. */ private void loadFunctionData(SiddhiApp siddhiApp, List<OutputAttribute> functionList, SiddhiAppElements siddhiAppElements, String appData) { for (FunctionDefinition functionDefinition : siddhiApp.getFunctionDefinitionMap().values()) { for (OutputAttribute app : functionList) { if (app.getExpression() instanceof AttributeFunction) { if (functionDefinition.getId().equals(((AttributeFunction) app.getExpression()).getName())) { String functionDefinitionStr = getDefinition(functionDefinition, appData); siddhiAppElements.setFunction(functionDefinition.getId()); siddhiAppElements.setFunctionQuery(functionDefinitionStr); break; } } } } }
/** * Generates a SelectedAttribute object from the given Siddhi OutputAttribute * @param outputAttribute Siddhi OutputAttribute object * @return SelectedAttribute object * @throws DesignGenerationException Error while getting the definition of the OutputAttribute */ private SelectedAttribute generateSelectedAttribute(OutputAttribute outputAttribute) throws DesignGenerationException { SelectedAttribute selectedAttribute = new SelectedAttribute( ConfigBuildingUtilities.getDefinition(outputAttribute.getExpression(), siddhiAppString), outputAttribute.getRename()); preserveAndBindCodeSegment(outputAttribute, selectedAttribute); return selectedAttribute; } }
private void checkSelection(OutputAttribute newAttribute) { for (OutputAttribute attribute : selectionList) { if (attribute.getRename().equals(newAttribute.getRename())) { throw new DuplicateAttributeException(newAttribute.getRename() + " is already defined as an output " + "attribute ", newAttribute.getQueryContextStartIndex(), attribute.getQueryContextEndIndex()); } } }
public Selector select(String rename, Expression expression) { OutputAttribute outputAttribute = new OutputAttribute(rename, expression); checkSelection(outputAttribute); selectionList.add(outputAttribute); return this; }
public Selector select(Variable variable) { OutputAttribute outputAttribute = new OutputAttribute(variable); checkSelection(outputAttribute); selectionList.add(outputAttribute); return this; }
public Selector select(String rename, Expression expression) { OutputAttribute outputAttribute = new OutputAttribute(rename, expression); checkSelection(outputAttribute); selectionList.add(outputAttribute); return this; }
/** * {@inheritDoc} * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> * * @param ctx */ @Override public Object visitOutput_attribute(@NotNull SiddhiQLParser.Output_attributeContext ctx) { // output_attribute // :attribute AS attribute_name // |attribute_reference // ; if (ctx.AS() != null) { OutputAttribute outputAttribute = new OutputAttribute((String) visit(ctx.attribute_name()), (Expression) visit(ctx.attribute())); populateQueryContext(outputAttribute, ctx); return outputAttribute; } else { OutputAttribute outputAttribute = new OutputAttribute((Variable) visit(ctx.attribute_reference())); populateQueryContext(outputAttribute, ctx); return outputAttribute; } }