本文整理了Java中org.wso2.siddhi.query.api.annotation.Annotation.getElements()
方法的一些代码示例,展示了Annotation.getElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getElements()
方法的具体详情如下:
包路径:org.wso2.siddhi.query.api.annotation.Annotation
类名称:Annotation
方法名:getElements
暂无
代码示例来源:origin: wso2/siddhi
if (annotation != null) {
Element element = null;
for (Element aElement : annotation.getElements()) {
if (elementName == null) {
if (aElement.getKey() == null) {
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
/**
* Traverse annotations and returns the name
*
* @param annotations
* @return
*/
private static String getName(List<Annotation> annotations) {
String name = UUID.randomUUID().toString();
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getName().equals(EventProcessorConstants.NAME)) {
name = annotation.getElements().get(0).getValue();
}
}
}
return name;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Generates AnnotationConfig String for the given Siddhi Annotation
* @param annotation Siddhi Annotation
* @return String representing the Annotation
*/
public String generateAnnotationConfig(Annotation annotation) {
StringBuilder annotationConfig = new StringBuilder();
annotationConfig.append("@");
annotationConfig.append(annotation.getName());
annotationConfig.append("(");
List<String> annotationMembers = new ArrayList<>();
for (Element element : annotation.getElements()) {
annotationMembers.add(element.toString());
}
for (Annotation innerAnnotation : annotation.getAnnotations()) {
annotationMembers.add(generateAnnotationConfig(innerAnnotation));
}
annotationConfig.append(String.join(", ", annotationMembers));
annotationConfig.append(")");
preserveCodeSegment(annotation);
return annotationConfig.toString();
}
代码示例来源:origin: org.wso2.extension.siddhi.io.file/siddhi-io-file
protected void init(StreamDefinition streamDefinition, OptionHolder optionHolder,
ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
this.siddhiAppContext = siddhiAppContext;
uriOption = optionHolder.validateAndGetOption(Constants.FILE_URI);
String append = optionHolder.validateAndGetStaticValue(Constants.APPEND, Constants.TRUE);
properties = new HashMap<>();
properties.put(Constants.ACTION, Constants.WRITE);
if (Constants.TRUE.equalsIgnoreCase(append)) {
properties.put(Constants.APPEND, append);
}
String mapType = streamDefinition.getAnnotations().get(0).getAnnotations().get(0).getElements().get(0)
.getValue();
addEventSeparator = optionHolder.isOptionExists(Constants.ADD_EVENT_SEPARATOR) ?
Boolean.parseBoolean(optionHolder.validateAndGetStaticValue(Constants.ADD_EVENT_SEPARATOR)) :
!mapType.equalsIgnoreCase("csv");
}
代码示例来源:origin: org.wso2.extension.siddhi.store.mongodb/siddhi-store-mongodb
return indices.getElements().stream().map(index -> {
Matcher matcher = indexBy.matcher(index.getValue());
if (matcher.matches() && attributeNames.contains(matcher.group(1))) {
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.sp.jobmanager.core
for (Annotation annotation : sourceStream.getValue().getAnnotations()) {
if (annotation.getName().equalsIgnoreCase(Constants.KAFKA_SOURCE)) {
for (Element sourceElement : annotation.getElements()) {
if (sourceElement.getKey().equalsIgnoreCase(Constants.KAFKA_SOURCE_TOPIC_LIST)) {
sourceList.add(sourceElement.getValue());
for (Element sinkElement : annotation.getElements()) {
if (sinkElement.getKey().equalsIgnoreCase(Constants.KAFKA_SINK_TOPIC)) {
sinkList.add(sinkElement.getValue());
代码示例来源:origin: org.wso2.extension.siddhi.io.http/siddhi-io-http
/**
* The initialization method for {@link Sink}, which will be called before other methods and validate
* the all configuration and getting the intial values.
*
* @param outputStreamDefinition containing stream definition bind to the {@link Sink}
* @param optionHolder Option holder containing static and dynamic configuration related
* to the {@link Sink}
* @param configReader to read the sink related system configuration.
* @param siddhiAppContext the context of the {@link org.wso2.siddhi.query.api.SiddhiApp} used to
* get siddhi related utilty functions.
*/
@Override
protected void init(StreamDefinition outputStreamDefinition, OptionHolder optionHolder,
ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
//read configurations
this.messageIdOption = optionHolder.validateAndGetOption(HttpConstants.MESSAGE_ID);
this.sourceId = optionHolder.validateAndGetStaticValue(HttpConstants.SOURCE_ID);
this.httpHeaderOption = optionHolder.getOrCreateOption(HttpConstants.HEADERS, HttpConstants.DEFAULT_HEADER);
this.mapType = outputStreamDefinition.getAnnotations().get(0).getAnnotations().get(0).getElements().get(0)
.getValue();
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core
/**
* Obtain query name of each siddhi app elements
*/
private void loadQueryName(List<Annotation> queryAnnotations, SiddhiAppElements siddhiAppElements) {
for (Annotation annotation : queryAnnotations) {
for (Element element : annotation.getElements()) {
siddhiAppElements.setQueryName(element.getValue());
}
}
if (siddhiAppElements.getQueryName() == null) {
siddhiAppElements.setQueryName(Constants.DEFAULT_QUERY_NAME);
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Generates MapperPayloadOrAttribute object, with the given Siddhi Annotation
* @param attributesOrPayloadAnnotation Siddhi Annotation, denoting @attribute or @payload
* @return MapperPayloadOrAttribute object
*/
private MapperPayloadOrAttribute generateMapperPayloadOrAttributes(Annotation attributesOrPayloadAnnotation) {
List<PayloadOrAttributeElement> elements = new ArrayList<>();
for (Element element : attributesOrPayloadAnnotation.getElements()) {
elements.add(generatePayloadOrAttributesElement(element));
}
MapperPayloadOrAttributeType mapperPayloadOrAttributesType = getMapperAttributeOrPayloadType(elements);
if (mapperPayloadOrAttributesType == MapperPayloadOrAttributeType.MAP) {
return generateMapperMapAttribute(attributesOrPayloadAnnotation.getName(), elements);
}
return generateMapperListAttribute(attributesOrPayloadAnnotation.getName(), elements);
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
public StoreConfig generateStoreConfig(Annotation storeAnnotation) throws DesignGenerationException {
String type = null;
Map<String, String> options = new HashMap<>();
for (Element element : storeAnnotation.getElements()) {
if (element.getKey().equalsIgnoreCase("TYPE")) {
type = element.getValue();
} else {
options.put(element.getKey(), element.getValue());
}
}
if (type == null) {
throw new DesignGenerationException("Can not find type for the Store");
}
StoreConfig storeConfig = new StoreConfig(type, options);
preserveAndBindCodeSegment(storeAnnotation, storeConfig);
return storeConfig;
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Loads App level Annotations from the Siddhi app
*
* @return A reference to this object
*/
public EventFlowBuilder loadAppAnnotations() {
String siddhiAppName = "";
String siddhiAppDescription = "";
List<String> appAnnotations = new ArrayList<>();
AnnotationConfigGenerator annotationConfigGenerator = new AnnotationConfigGenerator();
for (Annotation annotation : siddhiApp.getAnnotations()) {
if (annotation.getName().equalsIgnoreCase("NAME")) {
siddhiAppName = annotation.getElements().get(0).getValue();
annotationConfigGenerator.preserveCodeSegment(annotation);
} else if (annotation.getName().equalsIgnoreCase("DESCRIPTION")) {
siddhiAppDescription = annotation.getElements().get(0).getValue();
annotationConfigGenerator.preserveCodeSegment(annotation);
} else {
appAnnotations.add(
"@App:" + annotationConfigGenerator.generateAnnotationConfig(annotation).split("@")[1]);
}
}
siddhiAppConfig.setSiddhiAppName(siddhiAppName);
siddhiAppConfig.setSiddhiAppDescription(siddhiAppDescription);
siddhiAppConfig.setAppAnnotationList(appAnnotations);
siddhiAppConfig.addElementCodeSegments(annotationConfigGenerator.getPreservedCodeSegments());
return this;
}
代码示例来源:origin: org.wso2.extension.siddhi.store.rdbms/siddhi-store-rdbms
/**
* Util method which validates the elements from an annotation to verify that they comply to the accepted standards.
*
* @param annotation the annotation to be validated.
*/
public static void validateAnnotation(Annotation annotation) {
if (annotation == null) {
return;
}
List<Element> elements = annotation.getElements();
for (Element element : elements) {
if (isEmpty(element.getValue())) {
throw new RDBMSTableException("Annotation '" + annotation.getName() + "' contains illegal value(s). " +
"Please check your query and try again.");
}
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Generates config for a Mapper
* @param mapAnnotation Siddhi annotation that contains details of a Siddhi Mapper
* @return MapperConfig object
* @throws DesignGenerationException Error while generating MapperConfig
*/
private MapperConfig generateMapperConfig(Annotation mapAnnotation) throws DesignGenerationException {
String type = null;
List<String> options = new ArrayList<>();
for (Element element : mapAnnotation.getElements()) {
if (element.getKey().equalsIgnoreCase(TYPE)) {
type = element.getValue();
} else {
options.add(element.toString());
}
}
if (type == null) {
throw new DesignGenerationException("Unable to find 'type' of the mapper");
}
MapperPayloadOrAttribute payloadOrAttribute = null;
if (!mapAnnotation.getAnnotations().isEmpty()) {
payloadOrAttribute = generateMapperPayloadOrAttributes(mapAnnotation.getAnnotations().get(0));
}
MapperConfig mapperConfig = new MapperConfig(type, options, payloadOrAttribute);
preserveAndBindCodeSegment(mapAnnotation, mapperConfig);
return mapperConfig;
}
代码示例来源:origin: org.wso2.extension.siddhi.map.text/siddhi-map-text
for (Element el : streamDefinition.getAnnotations().get(0).getAnnotations().get(0).getElements()) {
if (el.getKey().contains(REGULAR_EXPRESSION_GROUP)) {
regexGroupMap.put(el.getKey()
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
String correlationId = null;
List<String> options = new ArrayList<>();
for (Element element : sourceOrSinkAndConnectedElement.getKey().getElements()) {
if (element.getKey().equalsIgnoreCase(TYPE)) {
type = element.getValue();
代码示例来源:origin: org.wso2.extension.siddhi.store.rdbms/siddhi-store-rdbms
if (primaryKeys != null) {
primaryKeysEnabled = true;
primaryKeys.getElements().forEach(elem -> {
for (int i = 0; i < this.attributes.size(); i++) {
if (this.attributes.get(i).getName().equalsIgnoreCase(elem.getValue())) {
代码示例来源:origin: org.wso2.extension.siddhi.store.mongodb/siddhi-store-mongodb
/**
* Utility method which can be used to check if the given primary key is valid i.e. non empty
* and is made up of attributes and return an index model when PrimaryKey is valid.
*
* @param primaryKey the PrimaryKey annotation which contains the primary key attributes.
* @param attributeNames List containing names of the attributes.
* @return List of String with primary key attributes.
*/
public static IndexModel extractPrimaryKey(Annotation primaryKey, List<String> attributeNames) {
if (primaryKey == null) {
return null;
}
Document primaryKeyIndex = new Document();
primaryKey.getElements().forEach(
element -> {
if (!isEmpty(element.getValue()) && attributeNames.contains(element.getValue())) {
primaryKeyIndex.append(element.getValue(), 1);
} else {
throw new SiddhiAppCreationException("Annotation '" + primaryKey.getName() + "' contains " +
"value '" + element.getValue() + "' which is not present in the attributes of the " +
"Event Table.");
}
}
);
return new IndexModel(primaryKeyIndex, new IndexOptions().unique(true));
}
代码示例来源:origin: org.wso2.siddhi/siddhi-query-api
if (annotation != null) {
Element element = null;
for (Element aElement : annotation.getElements()) {
if (elementName == null) {
if (aElement.getKey() == null) {
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core
/**
* Load sink related data
*/
private void loadSinks(SiddhiApp siddhiApp, SiddhiAppRuntime siddhiAppRuntime, List<SiddhiAppElements>
listOfSiddhiAppElements, String
siddhiAppString) {
for (List<Sink> sinks : siddhiAppRuntime.getSinks()) {
for (Sink sink : sinks) {
for (Annotation annotation : sink.getStreamDefinition().getAnnotations()) {
for (Element element : annotation.getElements()) {
if (Objects.equals(element.getValue(), sink.getType())) {
SiddhiAppElements siddhiAppElements = new SiddhiAppElements();
siddhiAppElements.setInputStreamId(sink.getStreamDefinition().getId());
loadInputData(siddhiApp, siddhiAppRuntime, sink.getStreamDefinition().getId(),
siddhiAppString,
siddhiAppElements);
siddhiAppElements.setOutputStreamId(sink.getType());
siddhiAppElements.setOutputStreamType(Constants.SINK_TYPE);
siddhiAppElements.setOutputStreamSiddhiApp(getDefinition(annotation, siddhiAppString));
listOfSiddhiAppElements.add(siddhiAppElements);
}
}
}
}
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core
/**
* Load source related data
*/
private void loadSources(SiddhiApp siddhiApp, SiddhiAppRuntime siddhiAppRuntime, List<SiddhiAppElements>
listOfSiddhiAppElements, String siddhiAppString) {
for (List<Source> sources : siddhiAppRuntime.getSources()) {
for (Source source : sources) {
for (Annotation annotation : source.getStreamDefinition().getAnnotations()) {
for (Element element : annotation.getElements()) {
if (Objects.equals(element.getValue(), source.getType())) {
SiddhiAppElements siddhiAppElements = new SiddhiAppElements();
siddhiAppElements.setOutputStreamId(source.getStreamDefinition().getId());
siddhiAppElements.setInputStreamId(source.getType());
siddhiAppElements.setInputStreamType(Constants.SOURCE_TYPE);
loadOutputData(siddhiApp, siddhiAppRuntime, source.getStreamDefinition().getId(),
siddhiAppString,
siddhiAppElements);
siddhiAppElements.setInputStreamSiddhiApp(getDefinition(annotation, siddhiAppString));
listOfSiddhiAppElements.add(siddhiAppElements);
}
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!