Package org.mule.module.db.internal.domain.param

Examples of org.mule.module.db.internal.domain.param.DefaultInputQueryParam


                    throw new QueryTemplateParsingException("Invalid Mule expression: " + sqlText.substring(tokenStart));
                }

                tokenEnd++;
                String value = sqlText.substring(tokenStart, tokenEnd);
                QueryParam inputParam = new DefaultInputQueryParam(paramIndex++, UnknownDbType.getInstance(), value);
                parameterList.add(inputParam);
                sqlToUse = sqlToUse + "?";
                tokenStart = tokenEnd;
            }
            else if (currentChar == ':')
            {
                String parameter;

                while (tokenEnd < sqlTextChars.length && !isParameterSeparator(sqlTextChars[tokenEnd]))
                {
                    tokenEnd++;
                }
                if (tokenEnd - tokenStart > 1)
                {
                    sqlToUse = sqlToUse + "?";
                    parameter = sqlText.substring(tokenStart + 1, tokenEnd);
                    QueryParam inputParam = new DefaultInputQueryParam(paramIndex++, UnknownDbType.getInstance(), null, parameter);
                    parameterList.add(inputParam);
                }
                tokenStart = tokenEnd;
            }
            else if (isParamChar(currentChar))
            {
                QueryParam inputParam = new DefaultInputQueryParam(paramIndex++, UnknownDbType.getInstance(), null);
                parameterList.add(inputParam);
                tokenStart++;
                sqlToUse = sqlToUse + currentChar;
            }
            else
View Full Code Here


        {
            overriddenParam = new DefaultInOutQueryParam(templateParam.getIndex(), paramType, templateParam.getName(), ((InOutQueryParam) queryParam).getValue());
        }
        else if (queryParam instanceof InputQueryParam)
        {
            overriddenParam = new DefaultInputQueryParam(templateParam.getIndex(), paramType, ((InputQueryParam) queryParam).getValue(), templateParam.getName());
        }
        else
        {
            overriddenParam = new DefaultOutputQueryParam(templateParam.getIndex(), paramType, templateParam.getName());
        }
View Full Code Here

            else
            {
                value = param.getValue();
            }

            DefaultInputQueryParam newParam = new DefaultInputQueryParam(param.getIndex(), param.getType(), value, param.getName());

            paramDefinitions.add(newParam);
        }
    }
View Full Code Here

            {
                newParam = new DefaultInOutQueryParam(originalParam.getIndex(), type, originalParam.getName(), ((InOutQueryParam) originalParam).getValue());
            }
            else if (originalParam instanceof InputQueryParam)
            {
                newParam = new DefaultInputQueryParam(originalParam.getIndex(), type, ((InputQueryParam) originalParam).getValue(), originalParam.getName());
            }
            else if (originalParam instanceof OutputQueryParam)
            {
                newParam = new DefaultOutputQueryParam(originalParam.getIndex(), type, originalParam.getName());
            }
View Full Code Here

        int index = 1;
        for (DbType paramType : paramTypes)
        {

            InputQueryParam inputQueryParam = new DefaultInputQueryParam(index, paramType, "param" + index);
            queryParams.add(inputQueryParam);
            index++;
        }

        return new QueryTemplate(staticSqlText, QueryType.SELECT, queryParams);
View Full Code Here

    private final DbConnection connection = mock(DbConnection.class);

    @Test
    public void resolvesUnknownTypeUsingMetadata() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", "param1")));

        when(metadataParamTypeResolver.getParameterTypes(connection, queryTemplate)).thenReturn(Collections.singletonMap(1, JdbcTypes.INTEGER_DB_TYPE));

        Map<Integer, DbType> parameterTypes = paramTypeResolver.getParameterTypes(connection, queryTemplate);
View Full Code Here

    }

    @Test
    public void requestsMetadataOnce() throws Exception
    {
        DefaultInputQueryParam param1 = new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", "param1");
        DefaultInputQueryParam param2 = new DefaultInputQueryParam(2, UnknownDbType.getInstance(), "A", "param2");
        List<QueryParam> params = new ArrayList<QueryParam>();
        params.add(param1);
        params.add(param2);

        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, params);
View Full Code Here

    }

    @Test
    public void usesUnknownTypesWhenNoMetadataAvailable() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", "param1")));

        when(metadataParamTypeResolver.getParameterTypes(connection, queryTemplate)).thenThrow(new SQLException("Error"));

        Map<Integer, DbType> parameterTypes = paramTypeResolver.getParameterTypes(connection, queryTemplate);
View Full Code Here

    }

    @Test
    public void resolvesDynamicDbType() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, new DynamicDbType(CUSTOM_TYPE_NAME), "7", "param1")));

        DbType customType = mock(DbType.class);
        when(dbTypeManager.lookup(connection, CUSTOM_TYPE_NAME)).thenReturn(customType);

        Map<Integer, DbType> parameterTypes = paramTypeResolver.getParameterTypes(connection, queryTemplate);
View Full Code Here

    }

    @Test
    public void skipsResolvedTypes() throws Exception
    {
        QueryTemplate queryTemplate = new QueryTemplate(SQL_TEXT, QueryType.SELECT, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, JdbcTypes.INTEGER_DB_TYPE, "7", "param1")));

        Map<Integer, DbType> parameterTypes = paramTypeResolver.getParameterTypes(connection, queryTemplate);

        assertThat(1, equalTo(parameterTypes.size()));
        assertThat(JdbcTypes.INTEGER_DB_TYPE, equalTo(parameterTypes.get(1)));
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.domain.param.DefaultInputQueryParam

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.