@Override public void substitute(Argument arg, StringBuilder builder, int index) { Literal argumentValue = arg.getArgumentValue(); builder.append(argumentValue); } });
static String getQueryParameters(Call obj) throws EdmPrimitiveTypeException { StringBuilder sb = new StringBuilder(); final List<Argument> params = obj.getArguments(); if (params != null && params.size() != 0) { Argument param = null; for (int i = 0; i < params.size(); i++) { param = params.get(i); if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) { if (i != 0) { sb.append("&"); //$NON-NLS-1$ } sb.append(WSUtil.httpURLEncode(param.getMetadataObject().getName())); sb.append(Tokens.EQ); sb.append(WSUtil.httpURLEncode(ODataTypeManager.convertToODataURIValue(param.getArgumentValue().getValue(), ODataTypeManager.odataType(param.getType()).getFullQualifiedName() .getFullQualifiedNameAsString()))); } } } return sb.toString(); }
public Argument createArgument(Argument.Direction direction, Expression value, Class<?> type, ProcedureParameter metadataReference) { return new Argument(direction, value, type, metadataReference); }
private boolean setOutCursorType(Call call) { boolean set = false; for (Argument arg : call.getArguments()) { if (arg.getDirection() == Direction.OUT) { ProcedureParameter param = arg.getMetadataObject(); if (param != null && REF_CURSOR.equalsIgnoreCase(param.getNativeType())) { arg.setType(RefCursorType.class); set = true; } } } return set; }
Argument param = (Argument)iter.next(); if(param.getDirection() == Direction.INOUT){ registerSpecificTypeOfOutParameter(statement,param.getType(), index); }else if(param.getDirection() == Direction.OUT){ registerSpecificTypeOfOutParameter(statement,param.getType(), index++); if(param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT){ bindValue(statement, param.getArgumentValue().getValue(), param.getType(), index++);
for (int i = 0; i < params.size(); i++) { param = params.get(i); ProcedureParameter metadata = param.getMetadataObject(); String argName = WSUtil.httpURLEncode(param.getMetadataObject().getName()); if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) { String in = metadata.getProperty(RestMetadataExtension.PARAMETER_TYPE, false); if (in.equalsIgnoreCase(RestMetadataExtension.ParameterType.QUERY.name())) { Object value = param.getExpression(); if (value instanceof Array) { addArgumentValue(argName, (Array)value, String argValue = getURLValue(param.getArgumentValue()); String regex = "\\{" + argName + "\\}"; //$NON-NLS-1$ //$NON-NLS-2$ uri = uri.replaceAll(regex, argValue); Object value = param.getExpression(); if (value instanceof Array) { addArgumentValue(argName, (Array)value, Object expr = param.getExpression(); if (expr instanceof Literal) { expr = ((Literal)expr).getValue(); input.addArgument(param.getMetadataObject(), expr); } else if (in.equalsIgnoreCase(RestMetadataExtension.ParameterType.HEADER.name())) { String argValue = param.getArgumentValue().getValue().toString(); headers.put(argName, Arrays.asList(argValue));
for (int i = 0; i < params.size(); i++) { param = params.get(i); if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) { if (i != 0) { this.buffer.append("&"); //$NON-NLS-1$ this.buffer.append(WSUtil.httpURLEncode(param.getMetadataObject().getName())); this.buffer.append(Tokens.EQ); this.executionFactory.convertToODataInput(param.getArgumentValue(), temp); this.buffer.append(WSUtil.httpURLEncode(temp.toString())); temp.setLength(0);
public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) { this.proc = proc; this.procExec = procExec; List<Argument> params = proc.getArguments(); resultSetCols = proc.getResultSetColumnTypes().length; if (proc.getReturnType() != null) { paramCols++; } if(params != null && !params.isEmpty()){ for (Argument param : params) { if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){ paramCols += 1; } } } if (paramCols > 0) { filler = Collections.nCopies(paramCols, null); } }
@Override public List<?> getOutputParameterValues() throws TranslatorException { try { Call proc = (Call)this.command; List<Object> result = new ArrayList<Object>(); int paramIndex = 1; if (proc.getReturnType() != null) { if (proc.getReturnParameter() != null) { addParameterValue(result, paramIndex, proc.getReturnType()); } paramIndex++; } for (Argument parameter : proc.getArguments()) { switch (parameter.getDirection()) { case IN: paramIndex++; break; case INOUT: case OUT: addParameterValue(result, paramIndex++, parameter.getType()); break; } } return result; } catch (SQLException e) { throw new TranslatorException(JDBCPlugin.Event.TEIID11005, e); } }
} else if (paramValue instanceof Argument) { Argument arg = (Argument)paramValue; value = ((Literal)arg.getExpression()).getValue(); paramType = arg.getType(); } else { Parameter param = (Parameter)paramValue;
@Override public void substitute(Argument arg, StringBuilder builder, int index) { if (this.prepared && arg.getExpression() instanceof Literal) { buffer.append(UNDEFINED_PARAM); this.preparedValues.add(arg); } else { visit(arg); } }
@Override public ResultSet executeStoredProcedure(CallableStatement statement, List<Argument> preparedValues, Class<?> returnType) throws SQLException { ResultSet rs = super.executeStoredProcedure(statement, preparedValues, returnType); if (!oracleSuppliedDriver || rs != null) { return rs; } if (returnType == RefCursorType.class) { return (ResultSet)statement.getObject(1); } for (int i = 0; i < preparedValues.size(); i++) { Argument arg = preparedValues.get(i); if (arg.getType() == RefCursorType.class) { return (ResultSet)statement.getObject(i + (returnType == null?1:2)); } } return null; }
public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) { this.proc = proc; this.procExec = procExec; List<Argument> params = proc.getArguments(); resultSetCols = proc.getResultSetColumnTypes().length; if (proc.getReturnType() != null) { paramCols++; } if(params != null && !params.isEmpty()){ for (Argument param : params) { if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){ paramCols += 1; } } } if (paramCols > 0) { filler = Collections.nCopies(paramCols, null); } }
public void visit(Argument obj) { visitNode(obj.getExpression()); }
@Override public void substitute(Argument arg, StringBuilder builder, int index) { Literal argumentValue = arg.getArgumentValue(); builder.append(argumentValue.getValue()); } });
public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) { this.proc = proc; this.procExec = procExec; List<Argument> params = proc.getArguments(); resultSetCols = proc.getResultSetColumnTypes().length; if (proc.getReturnType() != null) { paramCols++; } if(params != null && !params.isEmpty()){ for (Argument param : params) { if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){ paramCols += 1; } } } if (paramCols > 0) { filler = Collections.nCopies(paramCols, null); } }
protected BinaryWSProcedureExecution executeDirect(String method, String uri, String payload, Map<String, List<String>> headers) throws TranslatorException { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODATA, MessageLevel.DETAIL)) { try { LogManager.logDetail(LogConstants.CTX_ODATA, "Source-URL=", URLDecoder.decode(uri, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ } catch (UnsupportedEncodingException e) { } } List<Argument> parameters = new ArrayList<Argument>(); parameters.add(new Argument(Direction.IN, new Literal(method, TypeFacility.RUNTIME_TYPES.STRING), null)); parameters.add(new Argument(Direction.IN, new Literal(payload, TypeFacility.RUNTIME_TYPES.STRING), null)); parameters.add(new Argument(Direction.IN, new Literal(uri, TypeFacility.RUNTIME_TYPES.STRING), null)); parameters.add(new Argument(Direction.IN, new Literal(true, TypeFacility.RUNTIME_TYPES.BOOLEAN), null)); //the engine currently always associates out params at resolve time even if the values are not directly read by the call parameters.add(new Argument(Direction.OUT, TypeFacility.RUNTIME_TYPES.STRING, null)); Call call = this.translator.getLanguageFactory().createCall(ODataExecutionFactory.INVOKE_HTTP, parameters, null); BinaryWSProcedureExecution execution = new BinaryWSProcedureExecution(call, this.metadata, this.executionContext, null, this.connection); execution.setUseResponseContext(true); execution.setCustomHeaders(headers); execution.execute(); return execution; }
@Override public void substitute(Argument arg, StringBuilder builder, int index) { Literal argumentValue = arg.getArgumentValue(); CriteriaVisitor.appendLiteralValue(builder, argumentValue); } });
if (arg.getDirection() != Direction.IN) { throw new IllegalArgumentException(DataPlugin.Util.getString("SQLConversionVisitor.not_in_parameter", index+1)); //$NON-NLS-1$