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