Skip to content

Commit

Permalink
Merge pull request #188 from mohanvive/overload
Browse files Browse the repository at this point in the history
OverloaAdd parameter overloads to design-view forms
  • Loading branch information
dnwick authored Jul 1, 2019
2 parents a7471ca + 0c68996 commit eaec2a3
Show file tree
Hide file tree
Showing 40 changed files with 3,819 additions and 1,247 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

language: java

jdk:
- openjdk8

cache:
directories:
- $HOME/.m2
install: true
script: mvn clean install
script: mvn clean install -B -V
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@

<properties>
<io.siddhi.distribution.version>0.1.1-SNAPSHOT</io.siddhi.distribution.version>
<siddhi.version>5.0.0</siddhi.version>
<siddhi.bundle.version>5.0.0</siddhi.bundle.version>
<siddhi.version>5.0.1</siddhi.version>
<siddhi.bundle.version>5.0.1</siddhi.bundle.version>
<siddhi.version.range>[5.0.0, 6.0.0)</siddhi.version.range>
<carbon.analytics-common.version>6.0.73</carbon.analytics-common.version>
<carbon.analytics-common.version.range>[6.0.66, 6.1.0)</carbon.analytics-common.version.range>
Expand Down Expand Up @@ -1470,6 +1470,7 @@
<maven.bundle.plugin.version>3.2.0</maven.bundle.plugin.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<maven.findbugsplugin.version.exclude>findbugs-exclude.xml</maven.findbugsplugin.version.exclude>
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>

<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version>
<carbon.feature.plugin.version>3.1.4</carbon.feature.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ProcessorMetaData {
private String namespace;
private String description;
private List<ParameterMetaData> parameters;
private List<String[]> parameterOverloads;
private List<AttributeMetaData> returnAttributes;
private String[] examples;

Expand Down Expand Up @@ -93,4 +94,14 @@ public void setReturnAttributes(List<AttributeMetaData> returnAttributes) {
this.returnAttributes = returnAttributes;
}

public void setParameterOverloads(List<String[]> parameterOverloads) {

this.parameterOverloads = parameterOverloads;
}

public List<String[]> getParameterOverloads() {

return parameterOverloads;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.siddhi.core.query.processor.stream.function.StreamFunctionProcessor;
import io.siddhi.core.query.processor.stream.window.WindowProcessor;
import io.siddhi.core.query.selector.attribute.aggregator.AttributeAggregatorExecutor;
import io.siddhi.core.query.selector.attribute.aggregator.incremental.IncrementalAttributeAggregator;
import io.siddhi.core.stream.input.source.Source;
import io.siddhi.core.stream.input.source.SourceMapper;
import io.siddhi.core.stream.output.sink.Sink;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class Constants {
public static final String FAULT_STREAM_PREFIX = "!";
static final String FUNCTION_EXECUTOR = "FunctionExecutor";
static final String ATTRIBUTE_AGGREGATOR = "AttributeAggregatorExecutor";
static final String INCREMENTAL_AGGREGATOR = "IncrementalAggregator";
static final String WINDOW_PROCESSOR = "WindowProcessor";
static final String STREAM_FUNCTION_PROCESSOR = "StreamFunctionProcessor";
static final String STREAM_PROCESSOR = "StreamProcessor";
Expand All @@ -82,6 +84,7 @@ public class Constants {
// Populating the processor super class map
SUPER_CLASS_MAP = new HashMap<>();
SUPER_CLASS_MAP.put(FUNCTION_EXECUTOR, FunctionExecutor.class);
SUPER_CLASS_MAP.put(INCREMENTAL_AGGREGATOR, IncrementalAttributeAggregator.class);
SUPER_CLASS_MAP.put(ATTRIBUTE_AGGREGATOR, AttributeAggregatorExecutor.class);
SUPER_CLASS_MAP.put(WINDOW_PROCESSOR, WindowProcessor.class);
SUPER_CLASS_MAP.put(STREAM_FUNCTION_PROCESSOR, StreamFunctionProcessor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io.siddhi.annotation.Extension;
import io.siddhi.annotation.Parameter;
import io.siddhi.annotation.ParameterOverload;
import io.siddhi.annotation.ReturnAttribute;
import io.siddhi.core.SiddhiAppRuntime;
import io.siddhi.distribution.editor.core.commons.metadata.AttributeMetaData;
Expand Down Expand Up @@ -353,6 +354,10 @@ private static Map<String, MetaData> generateExtensionsMetaData(Map<String, Clas
.isAssignableFrom(extensionClass)) {
processorType = Constants.ATTRIBUTE_AGGREGATOR;
processorMetaDataList = metaData.getFunctions();
} else if (Constants.SUPER_CLASS_MAP.get(Constants.INCREMENTAL_AGGREGATOR)
.isAssignableFrom(extensionClass)) {
processorType = Constants.INCREMENTAL_AGGREGATOR;
processorMetaDataList = metaData.getFunctions();
} else if (Constants.SUPER_CLASS_MAP.get(Constants.STREAM_FUNCTION_PROCESSOR)
.isAssignableFrom(extensionClass)) {
processorType = Constants.STREAM_FUNCTION_PROCESSOR;
Expand Down Expand Up @@ -496,6 +501,15 @@ private static ProcessorMetaData generateProcessorMetaData(Class<?> processorCla
}
processorMetaData.setExamples(examples);
}

//Adding parameter overloads data
if (extensionAnnotation.parameterOverloads().length > 0) {
List<String[]> parameterOverloads = new ArrayList<>();
for (ParameterOverload parameterOverload : extensionAnnotation.parameterOverloads()) {
parameterOverloads.add(parameterOverload.parameterNames());
}
processorMetaData.setParameterOverloads(parameterOverloads);
}
}
return processorMetaData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,12 @@ public EventFlowBuilder loadExecutionElements() throws DesignGenerationException
PartitionConfigGenerator partitionConfigGenerator =
new PartitionConfigGenerator(siddhiAppString, siddhiApp, partitionedInnerStreamDefinitions);
int partitionCounter = 0;
int queryCounter = 0;
for (ExecutionElement executionElement : siddhiApp.getExecutionElementList()) {
if (executionElement instanceof Query) {
QueryConfig queryConfig = queryConfigGenerator.generateQueryConfig((Query) executionElement);
queryCounter++;
QueryConfig queryConfig = queryConfigGenerator.generateQueryConfig((Query) executionElement,
queryCounter);
siddhiAppConfig.addQuery(QueryConfigGenerator.getQueryListType(queryConfig), queryConfig);
} else if (executionElement instanceof Partition) {
String partitionId = (String) partitionedInnerStreamDefinitions.keySet().toArray()[partitionCounter];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ private Map<QueryListType, List<QueryConfig>> generateQueryList(List<Query> quer

Map<QueryListType, List<QueryConfig>> queryLists = populateEmptyQueryLists();
QueryConfigGenerator queryConfigGenerator = new QueryConfigGenerator(siddhiAppString, siddhiApp);
int queryCounter = 0;
for (Query query : queryList) {
QueryConfig queryConfig = queryConfigGenerator.generateQueryConfig(query);
queryCounter++;
QueryConfig queryConfig = queryConfigGenerator.generateQueryConfig(query, queryCounter);
QueryListType queryListType = QueryConfigGenerator.getQueryListType(queryConfig);
queryLists.get(queryListType).add(queryConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static QueryListType getQueryListType(QueryConfig queryConfig) {
* @return QueryConfig object
* @throws DesignGenerationException Error when loading designer view
*/
public QueryConfig generateQueryConfig(Query query)
public QueryConfig generateQueryConfig(Query query, int queryCounter)
throws DesignGenerationException {

QueryConfig queryConfig = new QueryConfig();
Expand All @@ -109,7 +109,7 @@ public QueryConfig generateQueryConfig(Query query)
queryConfig.setOutputRateLimit(generateOutputRateLimit(query.getOutputRate()));
queryConfig.setAnnotationListObjects(removeInfoAnnotation(query.getAnnotations()));
queryConfig.setAnnotationList(generateAnnotationList(query.getAnnotations()));
queryConfig.setQueryName(generateQueryName(query.getAnnotations()));
queryConfig.setQueryName(generateQueryName(query.getAnnotations(), queryCounter));
preserveAndBindCodeSegment(query, queryConfig);
return queryConfig;
}
Expand Down Expand Up @@ -293,16 +293,22 @@ private List<Annotation> removeInfoAnnotation(List<Annotation> queryAnnotations)
* Extracts the query name from the annotation list, or returns the default query name.
*
* @param annotations Query annotation list
* @param queryNumber to generate unique query name
* @return query name name of the query
*/
private String generateQueryName(List<Annotation> annotations) {

private String generateQueryName(List<Annotation> annotations , int queryNumber) {
String queryName = "";
boolean isQueryName = false;
for (Annotation annotation : annotations) {
if (annotation.getName().equalsIgnoreCase("info")) {
preserveCodeSegment(annotation);
return annotation.getElement("name");
queryName = annotation.getElement("name");
isQueryName = true;
}
}
return DEFAULT_QUERY_NAME;
if (!isQueryName) {
queryName = DEFAULT_QUERY_NAME + queryNumber;
}
return queryName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ define(['require', 'lodash', 'jquery', 'log', 'backbone', 'file_browser', 'boots
"<div class='modal-content'>" +
"<div class='modal-header'>" +
"<button type='button' class='close' data-dismiss='modal' aria-label='Close'>" +
"<span aria-hidden='true'>&times;</span>" +
"<i class='fw fw-cancel about-dialog-close'></i>" +
"</button>" +
"<h4 class='modal-title file-dialog-title' id='newConfigModalLabel'>Save To Workspace</h4>" +
"<hr class='style1'>"+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Contributing

I *really* welcome contributions! Please feel free to fork and issue pull
requests when...

* You have a very nice idea to improve this plugin!
* You found a bug!
* You're good at English and can help my bad English!

For IE problems, please refer
to [IE Support](https://github.com/utatti/perfect-scrollbar#ie-support).

## Introduction

First of all, thank you in advance for your contribution!

This document will introduce something you should know before making some
contributions to **perfect-scrollbar**. I'll try to explain as easy as
possible. If there are something missed or not well-documented, please let me
know.

Also, the project is not actively maintained. No maintainer is paid, and most of
us are busy on our professional or personal works. Please understand that it may
take a while for an issue to be resolved. Uploading a PR would be the fastest
way to fix an issue.

## Directory structure

Please don't edit files in the `dist` directory as they should only be
updated on releases. You'll find source code in the `src` directory.

Files concerning CSS is placed in the `css` directory.

`examples` directory is for the example sources. If you have any example you
want to add with a new feature, please add it in the directory.

`docs` is for GitHub Pages.

## Getting started

First, ensure that you have stable [Node.js](https://nodejs.org/)
and [npm](https://npmjs.com) 5 installed.

After basic installation, follow the steps below.

1. Fork and clone the repo.
1. Run `npm install` to install all dev dependencies.
1. Run `npm test` to check if everything's well.

Assuming that you don't see any error, you're ready to go.

## Code conventions

[Prettier](https://github.com/prettier/prettier) is used for code
formatting. Please `npm run format` before each commit.

## Building sources

You can use the `npm run build` command to build source files into output files.

## Submitting pull requests

1. Create a new branch. Working in your `master` branch is okay, but not
recommended.
1. Modify the sources.
1. Run `npm test` to see if the code fit into the code convention and build
without an error. Repeat steps 2-3 until done.
1. Update the documentation to reflect any changes.
1. Create examples if needed.
1. Push to your fork and submit a pull request.

For further information about pull requests, please refer to
GitHub's [Using Pull Requests](https://help.github.com/articles/using-pull-requests).

## Code Review

When the pull request is created, anyone can review the source code. After the
review is finished and the patch doesn't have any problem, it'll be merged.

## Conclusion

The process looks somewhat difficult, but it's necessary to avoid maintanance
issues and make the code easy to read and use.

If there is any opinion or question, please feel free to ask me.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT) Copyright (c) 2012-2017 Hyunje Jun and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit eaec2a3

Please sign in to comment.