All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.aguacate.function.spi.AbstractFunctionSql Maven / Gradle / Ivy

package net.sf.aguacate.function.spi;

import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.sf.aguacate.function.FunctionContext;

public abstract class AbstractFunctionSql extends AbstractFunction {

	private static final Logger LOGGER = LogManager.getLogger(AbstractFunctionSql.class);

	private final String sql;

	private final String[] required;

	private final String[] optional;

	private final String message;

	public AbstractFunctionSql(Collection methods, String name, String message, String sql, String[] required,
			String[] optional) {
		super(methods, name);
		this.sql = sql;
		this.required = required;
		this.optional = optional;
		this.message = message;
	}

	protected Object selectSingle(FunctionContext internalContext, Map context) {
		try {
			LOGGER.trace(sql);
			return internalContext.databaseInterface().executeSqlSelectValue(getName(), message,
					internalContext.acquireConnection(), sql, context, required, optional);
		} catch (SQLException e) {
			throw new IllegalStateException(e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy