use of nl.nn.adapterframework.parameters.Parameter.ParameterType in project iaf by ibissource.
the class ApiServiceDispatcher method mapParamsInRequest.
private void mapParamsInRequest(HttpServletRequest request, IAdapter adapter, ApiListener listener, JsonObjectBuilder methodBuilder) {
String uriPattern = listener.getUriPattern();
JsonArrayBuilder paramBuilder = Json.createArrayBuilder();
mapPathParameters(paramBuilder, uriPattern);
List<String> paramsFromHeaderAndCookie = mapHeaderAndParams(paramBuilder, request, listener);
// query params
Json2XmlValidator inputValidator = getJsonValidator(adapter.getPipeLine(), false);
if (inputValidator != null && !inputValidator.getParameterList().isEmpty()) {
for (Parameter parameter : inputValidator.getParameterList()) {
String parameterSessionkey = parameter.getSessionKey();
if (StringUtils.isNotEmpty(parameterSessionkey) && !parameterSessionkey.equals("headers") && !paramsFromHeaderAndCookie.contains(parameterSessionkey)) {
ParameterType parameterType = parameter.getType() != null ? parameter.getType() : ParameterType.STRING;
paramBuilder.add(addParameterToSchema(parameterSessionkey, "query", false, Json.createObjectBuilder().add("type", parameterType.toString().toLowerCase())));
}
}
}
JsonArray paramBuilderArray = paramBuilder.build();
if (!paramBuilderArray.isEmpty()) {
methodBuilder.add("parameters", paramBuilderArray);
}
}
use of nl.nn.adapterframework.parameters.Parameter.ParameterType in project iaf by ibissource.
the class JmsSender method setProperties.
/**
* Sets the JMS message properties as described in the msgProperties arraylist
*/
private void setProperties(javax.jms.Message msg, ParameterValueList pvl) throws JMSException {
for (ParameterValue property : pvl) {
ParameterType type = property.getDefinition().getType();
String name = property.getDefinition().getName();
if ((!isSoap() || !name.equals(getSoapHeaderParam()) && (StringUtils.isEmpty(getDestinationParam()) || !name.equals(getDestinationParam())))) {
if (log.isDebugEnabled()) {
log.debug(getLogPrefix() + "setting [" + type + "] property from param [" + name + "] to value [" + property.getValue() + "]");
}
switch(type) {
case BOOLEAN:
msg.setBooleanProperty(name, property.asBooleanValue(false));
break;
case INTEGER:
msg.setIntProperty(name, property.asIntegerValue(0));
break;
case STRING:
msg.setStringProperty(name, property.asStringValue(""));
break;
default:
msg.setObjectProperty(name, property.getValue());
break;
}
}
}
}
use of nl.nn.adapterframework.parameters.Parameter.ParameterType in project iaf by ibissource.
the class JdbcUtil method applyParameter.
public static void applyParameter(PreparedStatement statement, ParameterValue pv, int parameterIndex, boolean parameterTypeMatchRequired) throws SQLException, JdbcException {
String paramName = pv.getDefinition().getName();
ParameterType paramType = pv.getDefinition().getType();
Object value = pv.getValue();
if (log.isDebugEnabled())
log.debug("jdbc parameter [" + parameterIndex + "] applying parameter [" + paramName + "] value [" + value + "]");
switch(paramType) {
case DATE:
if (value == null) {
statement.setNull(parameterIndex, Types.DATE);
} else {
statement.setDate(parameterIndex, new java.sql.Date(((Date) value).getTime()));
}
break;
case DATETIME:
if (value == null) {
statement.setNull(parameterIndex, Types.TIMESTAMP);
} else {
statement.setTimestamp(parameterIndex, new Timestamp(((Date) value).getTime()));
}
break;
case TIMESTAMP:
if (value == null) {
statement.setNull(parameterIndex, Types.TIMESTAMP);
} else {
statement.setTimestamp(parameterIndex, new Timestamp(((Date) value).getTime()));
}
break;
case TIME:
if (value == null) {
statement.setNull(parameterIndex, Types.TIME);
} else {
statement.setTime(parameterIndex, new java.sql.Time(((Date) value).getTime()));
}
break;
case XMLDATETIME:
if (value == null) {
statement.setNull(parameterIndex, Types.TIMESTAMP);
} else {
statement.setTimestamp(parameterIndex, new Timestamp(((Date) value).getTime()));
}
break;
case NUMBER:
if (value == null) {
statement.setNull(parameterIndex, Types.NUMERIC);
} else {
statement.setDouble(parameterIndex, ((Number) value).doubleValue());
}
break;
case INTEGER:
if (value == null) {
statement.setNull(parameterIndex, Types.INTEGER);
} else {
statement.setInt(parameterIndex, (Integer) value);
}
break;
case BOOLEAN:
if (value == null) {
statement.setNull(parameterIndex, Types.BOOLEAN);
} else {
statement.setBoolean(parameterIndex, (Boolean) value);
}
break;
case INPUTSTREAM:
case BINARY:
try {
Message message = Message.asMessage(value);
long len = message.size();
if (message.requiresStream()) {
if (len != -1) {
statement.setBinaryStream(parameterIndex, message.asInputStream(), len);
} else {
statement.setBinaryStream(parameterIndex, message.asInputStream());
}
} else {
statement.setBytes(parameterIndex, message.asByteArray());
}
} catch (IOException e) {
throw new JdbcException("applying the parameter [" + paramName + "] failed", e);
}
break;
case BYTES:
try {
statement.setBytes(parameterIndex, Message.asByteArray(value));
} catch (IOException e) {
throw new JdbcException("Failed to get bytes for the parameter [" + paramName + "]", e);
}
break;
default:
setParameter(statement, parameterIndex, (String) value, parameterTypeMatchRequired);
}
}
Aggregations