001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.type.scope.storage.db;
020
021import java.sql.SQLException;
022
023import lucee.commons.io.log.Log;
024import lucee.runtime.config.Config;
025import lucee.runtime.db.DatasourceConnection;
026import lucee.runtime.exp.PageException;
027import lucee.runtime.type.Query;
028import lucee.runtime.type.Struct;
029import lucee.runtime.type.scope.storage.StorageScopeEngine;
030import lucee.runtime.type.scope.storage.StorageScopeListener;
031import lucee.runtime.type.scope.storage.clean.DatasourceStorageScopeCleaner;
032
033public interface SQLExecutor {
034
035        /**
036         * does a select statement on the datasource to get data
037         * @param config Config of the current context
038         * @param cfid CFID of the current user
039         * @param applicationName name of the current application context
040         * @param dc Datasource Connection to use
041         * @param type storage type (Scope.SCOPE_CLIENT,Scope.SCOPE_SESSION)
042         * @param log 
043         * @param createTableIfNotExist do create the table if not existing
044         * @return data matching criteria
045         * @throws PageException
046         * @throws SQLException 
047         */
048        public Query select(Config config, String cfid,String applicationName, DatasourceConnection dc, int type, Log log, boolean createTableIfNotExist) throws PageException,SQLException;
049
050        /**
051         * updates the data in the datasource for a specific user (CFID), if the data not exist, a new record is created
052         * @param config Config of the current context
053         * @param cfid CFID of the current user
054         * @param applicationName name of the current application context
055         * @param dc Datasource Connection to use
056         * @param type storage type (Scope.SCOPE_CLIENT,Scope.SCOPE_SESSION)
057         * @param data data to store
058         * @param timeSpan timespan in millis 
059         * @param log 
060         * @throws PageException
061         * @throws SQLException
062         */
063        public void update(Config config, String cfid,String applicationName, DatasourceConnection dc,int type,Struct data,long timeSpan, Log log) throws PageException,SQLException;
064
065        /**
066         * deletes the data in the datasource for a specific user (CFID), if there is no data for this user nothing is happeing
067         * @param config Config of the current context
068         * @param cfid CFID of the current user
069         * @param applicationName name of the current application context
070         * @param dc Datasource Connection to use
071         * @param type storage type (Scope.SCOPE_CLIENT,Scope.SCOPE_SESSION)
072         * @param log 
073         * @throws PageException
074         * @throws SQLException
075         */
076        public void delete(Config config, String cfid, String applicationName, DatasourceConnection dc, int type, Log log) throws PageException,SQLException;
077 
078        public void clean(Config config, DatasourceConnection dc, int type, StorageScopeEngine engine, DatasourceStorageScopeCleaner cleaner, StorageScopeListener listener, Log log) throws PageException,SQLException;   
079
080}