/*
 * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.wso2.siddhi.core.query.table.util;

import org.wso2.siddhi.annotation.Example;
import org.wso2.siddhi.annotation.Extension;
import org.wso2.siddhi.core.exception.ConnectionUnavailableException;
import org.wso2.siddhi.core.table.record.AbstractRecordTable;
import org.wso2.siddhi.core.table.record.ExpressionBuilder;
import org.wso2.siddhi.core.table.record.RecordIterator;
import org.wso2.siddhi.core.util.collection.operator.CompiledCondition;
import org.wso2.siddhi.core.util.collection.operator.CompiledExpression;
import org.wso2.siddhi.core.util.config.ConfigReader;
import org.wso2.siddhi.query.api.annotation.Element;
import org.wso2.siddhi.query.api.definition.TableDefinition;
import org.wso2.siddhi.query.api.util.AnnotationHelper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.wso2.siddhi.core.util.SiddhiConstants.ANNOTATION_STORE;

/**
 * Custom store for testing purposes.
 */
@Extension(
        name = "test",
        namespace = "store",
        description = "Using this implementation a testing for store extension can be done.",
        examples = {
                @Example(
                        syntax = "@store(type='test')" +
                                "define table testTable (symbol string, price int, volume float); ",
                        description = "The above syntax initializes a test type store."
                )
        }
)
public class TestStore extends AbstractRecordTable {
    public static Map<String, String> systemConfigs;

    @Override
    protected void init(TableDefinition tableDefinition, ConfigReader configReader) {
        systemConfigs = new HashMap<>();
        systemConfigs = AnnotationHelper.getAnnotation(ANNOTATION_STORE, tableDefinition.getAnnotations())
                .getElements().stream().collect(Collectors.toMap(
                        Element::getKey, Element::getValue
                ));
    }

    @Override
    public void add(List<Object[]> records) throws ConnectionUnavailableException {
        //Not Applicable
    }

    @Override
    public RecordIterator<Object[]> find(Map<String, Object> findConditionParameterMap,
                                            CompiledCondition compiledCondition)
            throws ConnectionUnavailableException {
        //Not Applicable
        return null;
    }

    @Override
    public boolean contains(Map<String, Object> containsConditionParameterMap,
                               CompiledCondition compiledCondition) throws ConnectionUnavailableException {
        //Not Applicable
        return false;
    }

    @Override
    public void delete(List<Map<String, Object>> deleteConditionParameterMaps,
                          CompiledCondition compiledCondition) throws ConnectionUnavailableException {
        //Not Applicable
    }


    @Override
    public void update(CompiledCondition updateCondition,
                          List<Map<String, Object>> updateConditionParameterMaps,
                          Map<String, CompiledExpression> updateSetExpressions,
                          List<Map<String, Object>> updateSetParameterMaps) throws ConnectionUnavailableException {
        //Not Applicable
    }

    /**
     * Try updating the records if they exist else add the records
     *
     * @param updateCondition              the compiledCondition against which records should be matched for update
     * @param updateConditionParameterMaps map of matching StreamVariable Ids and their values corresponding to the
     *                                     compiled condition based on which the records will be updated
     * @param updateSetExpressions         the set of updates mappings and related complied expressions
     * @param updateSetParameterMaps       map of matching StreamVariable Ids and their values corresponding to the
     *                                     update set
     * @param addingRecords                the values for adding new records if the update condition did not match
     */
    @Override
    public void updateOrAdd(CompiledCondition updateCondition,
                               List<Map<String, Object>> updateConditionParameterMaps,
                               Map<String, CompiledExpression> updateSetExpressions,
                               List<Map<String, Object>> updateSetParameterMaps,
                               List<Object[]> addingRecords)
            throws ConnectionUnavailableException {
        //Not Applicable
    }

    @Override
    public CompiledCondition compileCondition(ExpressionBuilder expressionBuilder) {
        return null;    //not implemented
    }

    /**
     * Compiles the expression in a set clause
     *
     * @param expressionBuilder helps visiting the conditions in order to compile the condition
     * @return compiled expression that can be used for matching events in find, contains, delete, update and
     * updateOrAdd
     */
    @Override
    public CompiledExpression compileSetAttribute(ExpressionBuilder expressionBuilder) {
        return null;
    }

    @Override
    protected void connect() throws ConnectionUnavailableException {
        //Not Applicable
    }

    @Override
    protected void disconnect() {
        //Not Applicable
    }

    @Override
    protected void destroy() {
        //Not Applicable
    }
}

@@ -2654,29 +2654,32 @@
 erride%0A    p
-ublic
+rotected
  void add(Li
@@ -2791,21 +2791,24 @@
 de%0A    p
-ublic
+rotected
  RecordI
@@ -3082,21 +3082,24 @@
 de%0A    p
-ublic
+rotected
  boolean
@@ -3336,29 +3336,32 @@
 erride%0A    p
-ublic
+rotected
  void delete
@@ -3564,37 +3564,40 @@
  @Override%0A    p
-ublic
+rotected
  void update(Com
@@ -4773,21 +4773,24 @@
 de%0A    p
-ublic
+rotected
  void up
@@ -5243,37 +5243,40 @@
  @Override%0A    p
-ublic
+rotected
  CompiledConditi
@@ -5697,21 +5697,24 @@
 de%0A    p
-ublic
+rotected
  Compile

Revert change to TestStore