001/*
002 *  Copyright 2010 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.externaldata.data.sql;
017
018import java.util.Collections;
019import java.util.Map;
020
021import org.ametys.core.datasource.DataSourceClientInteraction.DataSourceType;
022import org.ametys.plugins.externaldata.data.AbstractQuery;
023
024/**
025 * A query on a SQL server.
026 */
027public class SqlQuery extends AbstractQuery
028{
029    /** The query string. */
030    protected String _queryString;
031    
032    @Override
033    public DataSourceType getType()
034    {
035        return DataSourceType.SQL;
036    }
037    
038    /**
039     * Get the SQL query string.
040     * @return the SQL query string.
041     */
042    public String getQueryString()
043    {
044        return _queryString;
045    }
046    
047    /**
048     * Set the query string.
049     * @param queryString the query string
050     */
051    public void setQueryString(String queryString)
052    {
053        this._queryString = queryString;
054    }
055    
056    @Override
057    public Map<String, String> getParameters()
058    {
059        if (_parameters == null)
060        {
061            _parameters = _buildParameters(_queryString);
062        }
063        return _parameters;
064    }
065    
066    @Override
067    public Map<String, String> getAdditionalConfiguration()
068    {
069        return Collections.singletonMap("queryString", _queryString);
070    }
071}