<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~ Licensed 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.
  -->
<!--

 Please consider following queries.

 - "INSERT INTO alerts_history ( id,information,latitude,longitude,state,timeStamp) VALUES (?,?,?,?,?,?)"
 - "CREATE TABLE alerts_history (ID  varchar2(255),INFORMATION  varchar2(255),LATITUDE  BINARY_DOUBLE,LONGITUDE  BINARY_DOUBLE,STATE  varchar2(255),TIMESTAMP  varchar2(255))"
 - "UPDATE alerts_history SET information = ?  , latitude = ?  , longitude = ?  , state = ?  , timeStamp = ?  WHERE id = ? "


 Following attributes corresponds to following values

 $TABLE_NAME - alerts_history
 $COLUMN_TYPES - ID  varchar2(255),INFORMATION  varchar2(255),LATITUDE  BINARY_DOUBLE,LONGITUDE  BINARY_DOUBLE,STATE  varchar2(255),TIMESTAMP  varchar2(255)
 $COLUMNS - id,information,latitude,longitude,state,timeStamp
 $VALUES - ?,?,?,?,?,?
 $COLOUMN_VALUES - information = ?  , latitude = ?  , longitude = ?  , state = ?  , timeStamp = ?
 $CONDITION - id = ?

-->

<rdbmsConfiguration>
    <mappings>
        <mapping>
            <elements>
                <element key="string">VARCHAR(255)</element>
                <element key="double">DOUBLE</element>
                <element key="integer">INT</element>
                <element key="long">BIGINT</element>
                <element key="float">FLOAT</element>
                <element key="bool">BOOL</element>
                <element key="createTable">CREATE TABLE $TABLE_NAME ($COLUMN_TYPES)</element>
                <element key="insertDataToTable">INSERT INTO $TABLE_NAME ($COLUMNS) VALUES ($VALUES)</element>
                <element key="isTableExist">SELECT * FROM $TABLE_NAME limit 1</element>
                <element key="updateTableRow">UPDATE $TABLE_NAME SET $COLUMN_VALUES WHERE $CONDITION</element>
                <element key="comma">,</element>
                <element key="questionMark">?</element>
                <element key="equal">=</element>
                <element key="and">AND</element>
                <element key="selectAllColumnsDataTypeInTable">SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$TABLE_NAME'</element>
                <element key="selectFromTable">SELECT $COLUMNS FROM $TABLE_NAME</element>
            </elements>
        </mapping>
        <mapping db='mysql'>
            <elements>
                <element key="bool">TINYINT</element>
            </elements>
        </mapping>
        <mapping db='oracle'>
            <elements>
                <element key="string">varchar2(255)</element>
                <element key="long">NUMBER(19)</element>
                <element key="double">BINARY_DOUBLE</element>
                <element key="isTableExist">SELECT * FROM $TABLE_NAME WHERE ROWNUM = 1</element>
                <element key="selectAllColumnsDataTypeInTable">SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLS WHERE TABLE_NAME = '$TABLE_NAME'</element>
            </elements>
        </mapping>
        <mapping db='mssql'>
            <elements>
                <element key="string">varchar2(255)</element>
                <element key="isTableExist">SELECT TOP 1 * FROM $TABLE_NAME</element>
                <element key="selectAllColumnsDataTypeInTable">SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$TABLE_NAME'</element>
            </elements>
        </mapping>
        <mapping db='h2'>
            <elements>
                <element key="integer">varchar2(255)</element>
                <element key="long">REAL</element>
                <element key="selectAllColumnsDataTypeInTable">SHOW COLUMNS FROM $TABLE_NAME</element>
            </elements>
        </mapping>
    </mappings>
</rdbmsConfiguration>
