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

net.sf.aguacate.function.spi.impl.FunctionSqlCountNotZero Maven / Gradle / Ivy

package net.sf.aguacate.function.spi.impl;

import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import net.sf.aguacate.function.FunctionContext;
import net.sf.aguacate.function.FunctionEvalResult;
import net.sf.aguacate.function.Parameter;
import net.sf.aguacate.function.spi.AbstractFunctionSql;
import net.sf.aguacate.util.type.Num;

public class FunctionSqlCountNotZero extends AbstractFunctionSql {

	public FunctionSqlCountNotZero(Collection methods, String name, String message, List parameters,
			List outputContext, String outputName, String table) {
		super(methods, name, message,
				MessageFormat.format("SELECT count(*) FROM {0} WHERE {1} = ?", table, parameters.get(0).getName()),
				new String[] { parameters.get(0).getName() }, new String[] { outputName });
	}

	@Override
	public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
		Number count = (Number) selectSingle(functionContext, context);
		if (Num.isZero(count)) {
			return new FunctionEvalResult("One or more registries was not found", null);
		} else {
			return new FunctionEvalResult(null, null);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy