Package com.dci.intellij.dbn.object

Examples of com.dci.intellij.dbn.object.DBArgument


    private void updateCursorArgumentsPanel() {
        cursorOutputTabs.removeAllTabs();
        for (ArgumentValue argumentValue : executionResult.getArgumentValues()) {
            if (argumentValue.isCursor()) {
                DBArgument argument = argumentValue.getArgument();

                MethodExecutionCursorResultForm cursorResultComponent =
                        new MethodExecutionCursorResultForm(executionResult, argument);

                TabInfo tabInfo = new TabInfo(cursorResultComponent.getComponent());
                tabInfo.setText(argument.getName());
                tabInfo.setIcon(argument.getIcon());
                tabInfo.setObject(argument);
                cursorOutputTabs.addTab(tabInfo);
            }
        }
        cursorOutputTabs.repaint();
View Full Code Here


    protected void postHookExecutionCommand(StringBuilder buffer) {}


    @Override
    public String buildExecutionCommand(MethodExecutionInput executionInput) throws SQLException {
        DBArgument returnArgument = getReturnArgument();

        StringBuilder buffer = new StringBuilder();
        buffer.append("declare\n");

        // variable declarations
        List<DBArgument> arguments = getArguments();
        for (DBArgument argument : arguments) {
            DBDataType dataType = argument.getDataType();
            if (dataType.isDeclared()) {
                buffer.append("    ");
                appendVariableName(buffer, argument);
                buffer.append(" ").append(dataType.getDeclaredType().getQualifiedName()).append(";\n");
            } else if (isBoolean(dataType)) {
                appendVariableName(buffer, argument);
                buffer.append(" boolean;\n");
            }
        }

        buffer.append("begin\n");

        preHookExecutionCommand(buffer);

        // input variable initialization
        for (DBArgument argument : arguments) {
            DBDataType dataType = argument.getDataType();

            if (argument.isInput()) {
                if (dataType.isDeclared()) {
                    List<DBTypeAttribute> attributes = dataType.getDeclaredType().getAttributes();
                    for (DBTypeAttribute attribute : attributes) {
                        buffer.append("    ");
                        appendVariableName(buffer, argument);
                        buffer.append(".").append(attribute.getName()).append(" := ?;\n");
                    }
                } else if(isBoolean(dataType)) {
                    String stringValue = parseBoolean(argument.getName(), executionInput.getInputValue(argument));

                    buffer.append("    ");
                    appendVariableName(buffer, argument);
                    buffer.append(" := ").append(stringValue).append(";\n");
                }
            }
        }

        // method call
        buffer.append("\n    ");
        if (returnArgument != null) {
            DBDataType dataType = returnArgument.getDataType();
            if (dataType.isDeclared() || isBoolean(dataType))
                appendVariableName(buffer, returnArgument); else
                buffer.append("?");

            buffer.append(" := ");
View Full Code Here

    }


    @Override
    protected void prepareCall(MethodExecutionInput executionInput, CallableStatement callableStatement) throws SQLException {
        DBArgument returnArgument = getReturnArgument();

        // bind input variables
        int parameterIndex = 1;
        for (DBArgument argument : getArguments()) {
            if (argument.isInput()) {
                DBDataType dataType = argument.getDataType();
                DBType type = dataType.getDeclaredType();
                if (dataType.isDeclared()) {
                    List<DBTypeAttribute> attributes = type.getAttributes();
                    for (DBTypeAttribute attribute : attributes) {
                        String stringValue = executionInput.getInputValue(argument, attribute);
                        setParameterValue(callableStatement, parameterIndex, attribute.getDataType(), stringValue);
                        parameterIndex++;
                    }
                }
            }
        }

        // bind return variable (functions only)
        if (returnArgument != null) {
            DBDataType dataType = returnArgument.getDataType();
            if(!dataType.isDeclared() && !isBoolean(dataType)) {
                callableStatement.registerOutParameter(parameterIndex, returnArgument.getDataType().getSqlType());
                parameterIndex++;
            }
        }

        // bind input/output parameters
View Full Code Here

        }
    }

    @Override
    public void loadValues(MethodExecutionResult executionResult, CallableStatement callableStatement) throws SQLException {
        DBArgument returnArgument = getReturnArgument();

        // increment parameter index for input variables
        int parameterIndex = 1;
        for (DBArgument argument : getArguments()) {
            DBDataType dataType = argument.getDataType();
            if (dataType.isDeclared()) {
                if (argument.isInput()) {
                    parameterIndex = parameterIndex + dataType.getDeclaredType().getAttributes().size();
                }
            }
        }

        // get return value (functions only)
        if (returnArgument != null) {
            DBDataType dataType = returnArgument.getDataType();
            if (!dataType.isDeclared() && !isBoolean(dataType)) {
                Object result = callableStatement.getObject(parameterIndex);
                executionResult.addArgumentValue(returnArgument, result);
                parameterIndex++;
View Full Code Here

                        SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
            }

            if (userValue instanceof DBArgumentRef) {
                DBArgumentRef argumentRef = (DBArgumentRef) userValue;
                DBArgument argument = DBObjectRef.get(argumentRef);
                setIcon(argument == null ? Icons.DBO_ARGUMENT : argument.getIcon());
                append(argumentRef.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }

            if (userValue instanceof ArgumentValue) {
                ArgumentValue argumentValue = (ArgumentValue) userValue;
                DBArgument argument = argumentValue.getArgument();
                DBTypeAttribute attribute = argumentValue.getAttribute();
                Object originalValue = argumentValue.getValue();
                String displayValue = originalValue instanceof ResultSet ? "" : "" + originalValue;

                if (attribute == null) {
                    setIcon(argument.getIcon());
                    append(argument.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
                    append(" = ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
                    DBDataType dataType = argument.getDataType();
                    if (dataType != null) {
                        append("{" + dataType.getName().toLowerCase() + "} " , SimpleTextAttributes.GRAY_ATTRIBUTES);
                    }

                    append(displayValue, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
View Full Code Here

        return DBObjectType.ARGUMENT;
    }

    public int compareTo(@NotNull Object o) {
        if (o instanceof DBArgument) {
            DBArgument argument = (DBArgument) o;
            DBMethod thisMethod = getMethod();
            DBMethod thatMethod = argument.getMethod();
            if (thisMethod.equals(thatMethod)) {
                return getPosition() - argument.getPosition();
            } else {
                return thisMethod.compareTo(thatMethod);
            }
        }
        return super.compareTo(o);
View Full Code Here

    }

    @Override
    public boolean equals(Object obj) {
        if (super.equals(obj)) {
            DBArgument argument = (DBArgument) obj;
            return getOverload() == argument.getOverload() &&
                    getPosition() == argument.getPosition();
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.object.DBArgument

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.