net.sf.aguacate.context.spi.sql.impl.SentenceSqlInsertWithId Maven / Gradle / Ivy
package net.sf.aguacate.context.spi.sql.impl;
import java.math.BigInteger;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.sf.aguacate.function.FunctionContext;
import net.sf.aguacate.function.FunctionEvalResult;
public class SentenceSqlInsertWithId extends AbstractSentenceSql {
private static final Logger LOGGER = LogManager.getLogger(SentenceSqlInsertWithId.class);
private final String table;
private final String[] required;
private final String[] optional;
private final String[] outputContext;
private final String outputName;
private final String[] columns;
public SentenceSqlInsertWithId(String name, String message, String table, List methods,
List required, List optional, List outputContext, String outputName,
String column) {
super(name, message, methods);
this.table = table;
this.required = required.toArray(new String[required.size()]);
this.optional = optional.toArray(new String[optional.size()]);
this.outputContext = outputContext.toArray(new String[outputContext.size()]);
this.outputName = outputName;
this.columns = new String[] { column };
}
@Override
public FunctionEvalResult evaluate0(FunctionContext functionContext, Map context)
throws SQLException {
BigInteger id = functionContext.databaseInterface().executeInsertWithId(functionContext.acquireConnection(),
table, context, required, optional, columns);
LOGGER.debug("id: {}", id);
return new FunctionEvalResult(true, id);
}
@Override
public String getOutputName() {
return outputName;
}
@Override
public String[] getOutputContext() {
return outputContext;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy