Search in sources :

Example 1 with ProcedureParameter

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;
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) CallableStatement(java.sql.CallableStatement) ProcedureParameterBinding(org.apache.cayenne.access.translator.ProcedureParameterBinding) ParameterBinding(org.apache.cayenne.access.translator.ParameterBinding)

Example 2 with ProcedureParameter

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);
            }
        }
    }
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter)

Example 3 with ProcedureParameter

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);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) ProcedureParameterDisplayEvent(org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Procedure(org.apache.cayenne.map.Procedure) DataMap(org.apache.cayenne.map.DataMap)

Example 4 with ProcedureParameter

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);
    }
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProcedureParameterEvent(org.apache.cayenne.configuration.event.ProcedureParameterEvent) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 5 with ProcedureParameter

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);
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ProjectController(org.apache.cayenne.modeler.ProjectController)

Aggregations

ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)22 Procedure (org.apache.cayenne.map.Procedure)7 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)5 ProjectController (org.apache.cayenne.modeler.ProjectController)5 DataMap (org.apache.cayenne.map.DataMap)4 ProcedureParameterEvent (org.apache.cayenne.configuration.event.ProcedureParameterEvent)3 ProcedureParameterDisplayEvent (org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent)3 ArrayList (java.util.ArrayList)2 DataRow (org.apache.cayenne.DataRow)2 ExtendedType (org.apache.cayenne.access.types.ExtendedType)2 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)2 DbAttribute (org.apache.cayenne.map.DbAttribute)2 DbEntity (org.apache.cayenne.map.DbEntity)2 DbRelationship (org.apache.cayenne.map.DbRelationship)2 Embeddable (org.apache.cayenne.map.Embeddable)2 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 ObjRelationship (org.apache.cayenne.map.ObjRelationship)2 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)2