use of org.apache.cayenne.map.ProcedureParameter in project cayenne by apache.
the class ProcedureTranslator method createStatement.
/**
* Creates and binds a PreparedStatement to execute query SQL via JDBC.
*/
public PreparedStatement createStatement() throws Exception {
this.callParams = getProcedure().getCallParameters();
this.values = new ArrayList<>(callParams.size());
initValues();
String sqlStr = createSqlString();
if (logger.isLoggable()) {
// need to convert OUT/VOID parameters to loggable strings
ParameterBinding[] parameterBindings = new ParameterBinding[values.size()];
for (int i = 0; i < values.size(); i++) {
ProcedureParameter procedureParameter = callParams.get(i);
Object value = values.get(i);
if (value instanceof NotInParam) {
value = value.toString();
}
parameterBindings[i] = new ParameterBinding(value, procedureParameter.getType(), procedureParameter.getPrecision());
}
logger.logQuery(sqlStr, parameterBindings);
}
CallableStatement stmt = connection.prepareCall(sqlStr);
initStatement(stmt);
return stmt;
}
use of org.apache.cayenne.map.ProcedureParameter in project cayenne by apache.
the class ProcedureTranslator method initStatement.
/**
* Set IN and OUT parameters.
*/
protected void initStatement(CallableStatement stmt) throws Exception {
if (values != null && values.size() > 0) {
List<ProcedureParameter> params = getProcedure().getCallParameters();
int len = values.size();
for (int i = 0; i < len; i++) {
ProcedureParameter param = params.get(i);
// at the same time
if (param.isOutParam()) {
setOutParam(stmt, param, i + 1);
}
if (param.isInParameter()) {
setInParam(stmt, param, values.get(i), i + 1);
}
}
}
}
use of org.apache.cayenne.map.ProcedureParameter in project cayenne by apache.
the class ProcedureParameterErrorMsg method displayField.
public void displayField(ProjectController mediator, JFrame frame) {
Object object = super.validationFailure.getSource();
DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
ProcedureParameter procedureParameter = (ProcedureParameter) object;
Procedure procedure = procedureParameter.getProcedure();
DataMap map = procedure.getDataMap();
// Race condition between the two events...?
// first display the stored procedure
// for whatever reason, other validators do not require this step
// (E.g. DbAttributeErrorMsg)
ProcedureDisplayEvent procedureEvent = new ProcedureDisplayEvent(frame, procedure, map, domain);
procedureEvent.setTabReset(true);
mediator.fireProcedureDisplayEvent(procedureEvent);
// now show the failed parameter
ProcedureParameterDisplayEvent event = new ProcedureParameterDisplayEvent(frame, procedureParameter, procedure, map, domain);
event.setTabReset(true);
mediator.fireProcedureParameterDisplayEvent(event);
}
use of org.apache.cayenne.map.ProcedureParameter in project cayenne by apache.
the class RemoveProcedureParameterAction method removeProcedureParameters.
public void removeProcedureParameters(Procedure procedure, ProcedureParameter[] parameters) {
ProjectController mediator = getProjectController();
for (ProcedureParameter parameter : parameters) {
procedure.removeCallParameter(parameter.getName());
ProcedureParameterEvent e = new ProcedureParameterEvent(Application.getFrame(), parameter, MapEvent.REMOVE);
mediator.fireProcedureParameterEvent(e);
}
}
use of org.apache.cayenne.map.ProcedureParameter in project cayenne by apache.
the class RemoveProcedureParameterAction method removeProcedureParameters.
protected void removeProcedureParameters() {
ProjectController mediator = getProjectController();
ProcedureParameter[] parameters = mediator.getCurrentProcedureParameters();
removeProcedureParameters(mediator.getCurrentProcedure(), parameters);
}
Aggregations