Search in sources :

Example 11 with SiddhiAppValidationException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException in project ballerina by ballerina-lang.

the class SiddhiApp method addQuery.

public SiddhiApp addQuery(Query query) {
    if (query == null) {
        throw new SiddhiAppValidationException("Query should not be null");
    }
    String name = null;
    Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants.ANNOTATION_ELEMENT_NAME, query.getAnnotations());
    if (element != null) {
        name = element.getValue();
    }
    if (name != null && executionElementNameList.contains(name)) {
        throw new SiddhiAppValidationException("Cannot add Query as another Execution Element already uses " + "its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
    }
    executionElementNameList.add(name);
    this.executionElementList.add(query);
    return this;
}
Also used : ExecutionElement(org.ballerinalang.siddhi.query.api.execution.ExecutionElement) Element(org.ballerinalang.siddhi.query.api.annotation.Element) SiddhiAppValidationException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)

Example 12 with SiddhiAppValidationException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException in project ballerina by ballerina-lang.

the class SiddhiApp method defineWindow.

public SiddhiApp defineWindow(WindowDefinition windowDefinition) {
    if (windowDefinition == null) {
        throw new SiddhiAppValidationException("Window Definition should not be null");
    } else if (windowDefinition.getId() == null) {
        throw new SiddhiAppValidationException("Window Id should not be null for Window Definition", windowDefinition.getQueryContextStartIndex(), windowDefinition.getQueryContextEndIndex());
    }
    checkDuplicateDefinition(windowDefinition);
    this.windowDefinitionMap.put(windowDefinition.getId(), windowDefinition);
    return this;
}
Also used : SiddhiAppValidationException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)

Example 13 with SiddhiAppValidationException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException in project ballerina by ballerina-lang.

the class SiddhiApp method defineFunction.

public void defineFunction(FunctionDefinition functionDefinition) {
    if (functionDefinition == null) {
        throw new SiddhiAppValidationException("Function Definition should not be null");
    } else if (functionDefinition.getId() == null) {
        throw new SiddhiAppValidationException("Function Id should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex());
    } else if (functionDefinition.getReturnType() == null) {
        throw new SiddhiAppValidationException("Return type should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex());
    } else if (functionDefinition.getBody() == null) {
        throw new SiddhiAppValidationException("Body should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex());
    } else if (functionDefinition.getLanguage() == null) {
        throw new SiddhiAppValidationException("Language should not be null for Function Definition", functionDefinition.getQueryContextStartIndex(), functionDefinition.getQueryContextEndIndex());
    }
    checkDuplicateFunctionExist(functionDefinition);
    this.functionDefinitionMap.put(functionDefinition.getId(), functionDefinition);
}
Also used : SiddhiAppValidationException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)

Example 14 with SiddhiAppValidationException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException in project ballerina by ballerina-lang.

the class SiddhiApp method defineTrigger.

public SiddhiApp defineTrigger(TriggerDefinition triggerDefinition) {
    if (triggerDefinition == null) {
        throw new SiddhiAppValidationException("Trigger Definition should not be null");
    } else if (triggerDefinition.getId() == null) {
        throw new SiddhiAppValidationException("Trigger Id should not be null for Trigger Definition", triggerDefinition.getQueryContextStartIndex(), triggerDefinition.getQueryContextEndIndex());
    }
    StreamDefinition streamDefinition = StreamDefinition.id(triggerDefinition.getId()).attribute(SiddhiConstants.TRIGGERED_TIME, Attribute.Type.LONG);
    streamDefinition.setQueryContextStartIndex(triggerDefinition.getQueryContextStartIndex());
    streamDefinition.setQueryContextEndIndex(triggerDefinition.getQueryContextEndIndex());
    try {
        checkDuplicateDefinition(streamDefinition);
    } catch (DuplicateDefinitionException e) {
        throw new DuplicateDefinitionException("Trigger '" + triggerDefinition.getId() + "' cannot be defined as," + " " + e.getMessageWithOutContext(), e, triggerDefinition.getQueryContextStartIndex(), triggerDefinition.getQueryContextEndIndex());
    }
    if (triggerDefinitionMap.containsKey(triggerDefinition.getId())) {
        throw new DuplicateDefinitionException("Trigger Definition with same Id '" + triggerDefinition.getId() + "' already exist '" + triggerDefinitionMap.get(triggerDefinition.getId()) + "', hence cannot add '" + triggerDefinition + "'", triggerDefinition.getQueryContextStartIndex(), triggerDefinition.getQueryContextEndIndex());
    }
    this.triggerDefinitionMap.put(triggerDefinition.getId(), triggerDefinition);
    this.streamDefinitionMap.put(streamDefinition.getId(), streamDefinition);
    return this;
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) DuplicateDefinitionException(org.ballerinalang.siddhi.query.api.exception.DuplicateDefinitionException) SiddhiAppValidationException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)

Example 15 with SiddhiAppValidationException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException in project ballerina by ballerina-lang.

the class SiddhiApp method addPartition.

public SiddhiApp addPartition(Partition partition) {
    if (partition == null) {
        throw new SiddhiAppValidationException("Partition should not be null");
    }
    String name = null;
    Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants.ANNOTATION_ELEMENT_NAME, partition.getAnnotations());
    if (element != null) {
        name = element.getValue();
    }
    if (name != null && executionElementNameList.contains(name)) {
        throw new SiddhiAppValidationException("Cannot add Partition as another Execution Element already " + "uses its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
    }
    executionElementNameList.add(name);
    this.executionElementList.add(partition);
    return this;
}
Also used : ExecutionElement(org.ballerinalang.siddhi.query.api.execution.ExecutionElement) Element(org.ballerinalang.siddhi.query.api.annotation.Element) SiddhiAppValidationException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)

Aggregations

SiddhiAppValidationException (org.ballerinalang.siddhi.query.api.exception.SiddhiAppValidationException)22 ConstantExpressionExecutor (org.ballerinalang.siddhi.core.executor.ConstantExpressionExecutor)6 Element (org.ballerinalang.siddhi.query.api.annotation.Element)5 StreamEvent (org.ballerinalang.siddhi.core.event.stream.StreamEvent)4 SiddhiAppCreationException (org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException)4 Attribute (org.ballerinalang.siddhi.query.api.definition.Attribute)4 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)3 AbstractDefinition (org.ballerinalang.siddhi.query.api.definition.AbstractDefinition)3 ExecutionElement (org.ballerinalang.siddhi.query.api.execution.ExecutionElement)3 ArrayList (java.util.ArrayList)2 SiddhiAppContext (org.ballerinalang.siddhi.core.config.SiddhiAppContext)2 MetaStateEvent (org.ballerinalang.siddhi.core.event.state.MetaStateEvent)2 StreamEventPool (org.ballerinalang.siddhi.core.event.stream.StreamEventPool)2 ZeroStreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.ZeroStreamEventConverter)2 OperationNotSupportedException (org.ballerinalang.siddhi.core.exception.OperationNotSupportedException)2 VariableExpressionExecutor (org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)2 Window (org.ballerinalang.siddhi.core.window.Window)2 Annotation (org.ballerinalang.siddhi.query.api.annotation.Annotation)2 AttributeNotExistException (org.ballerinalang.siddhi.query.api.exception.AttributeNotExistException)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1