Search in sources :

Example 1 with SPArgsInfo

use of com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo in project cubrid-manager by CUBRID.

the class EditFunctionDialog method initialize.

private void initialize() {
    for (String name : sqlTypeMap.keySet()) {
        returnTypeCombo.add(name);
    }
    returnTypeCombo.select(0);
    returnTypeCombo.setData("-1");
    if (!newFlag && spInfo != null) {
        funcNameText.setEnabled(false);
        String returnType = spInfo.getReturnType();
        String target = spInfo.getTarget();
        String[] javaParamType = null;
        funcNameText.setText(spInfo.getSpName());
        if (isCommentSupport && StringUtil.isNotEmpty(spInfo.getDescription())) {
            funcDescriptionText.setText(spInfo.getDescription());
        }
        if ("void".equalsIgnoreCase(returnType)) {
            returnTypeCombo.select(0);
            List<String> list = javaTypeMap.get("0");
            javaTypeList.removeAll();
            if (list != null) {
                for (String tmp : list) {
                    javaTypeList.add(tmp);
                }
            }
            javaTypeList.select(0);
        } else {
            returnTypeCombo.setText(returnType);
            String level = sqlTypeMap.get(returnType);
            if (level == null || "".equals(level)) {
                level = "-1";
            }
            returnTypeCombo.setData(level);
            List<String> list = javaTypeMap.get(level);
            javaTypeList.removeAll();
            if (list != null) {
                for (String tmp : list) {
                    javaTypeList.add(tmp);
                }
            }
            javaTypeList.select(0);
        }
        if (target != null && target.length() > 0) {
            String returnJavaType = null;
            String javaFuncName = target.substring(0, target.indexOf("(")).trim();
            javaParamType = (target.substring(target.indexOf("(") + 1, target.indexOf(")"))).split(",");
            if (target.substring(target.indexOf(")")).indexOf("return ") > 0) {
                returnJavaType = target.substring(target.indexOf(")") + 1).replaceFirst("return ", "").trim();
            }
            if ("4".equals(returnTypeCombo.getData()) || "-1".equals(returnTypeCombo.getData())) {
                setJavaTypeEnable(false);
                if (returnJavaType != null) {
                    javaTypeText.setText(returnJavaType);
                }
            } else {
                setJavaTypeEnable(true);
                if (returnJavaType != null) {
                    for (int i = 0; i < javaTypeList.getItemCount(); i++) {
                        String type = javaTypeList.getItem(i);
                        if (returnJavaType.equals(type)) {
                            javaTypeList.select(i);
                        }
                    }
                }
            }
            javaNameText.setText(javaFuncName);
        }
        List<SPArgsInfo> argsInfoList = spInfo.getArgsInfoList();
        if (javaParamType == null || argsInfoList.size() != javaParamType.length) {
            return;
        }
        while (!funcParamsListData.isEmpty()) {
            funcParamsListData.remove(0);
        }
        for (int i = 0; i < javaParamType.length; i++) {
            for (SPArgsInfo spArgsInfo : argsInfoList) {
                if (spArgsInfo.getIndex() == i) {
                    Map<String, String> model = new HashMap<String, String>();
                    model.put("0", spArgsInfo.getArgName());
                    model.put("1", spArgsInfo.getDataType());
                    model.put("2", javaParamType[i]);
                    model.put("3", spArgsInfo.getSpArgsType().toString());
                    if (isCommentSupport) {
                        model.put("4", spArgsInfo.getDescription());
                    }
                    funcParamsListData.add(model);
                }
            }
        }
        funcParamsTableViewer.refresh();
        for (int i = 0; i < funcParamsTableViewer.getTable().getColumnCount(); i++) {
            funcParamsTableViewer.getTable().getColumn(i).pack();
        }
    }
}
Also used : HashMap(java.util.HashMap) SPArgsInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo)

Example 2 with SPArgsInfo

use of com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo in project cubrid-manager by CUBRID.

the class EditProcedureDialog method initialize.

/**
	 * Initial data
	 */
private void initialize() {
    if (!newFlag && spInfo != null) {
        procNameText.setEnabled(false);
        String target = spInfo.getTarget();
        String[] javaParamType = null;
        procNameText.setText(spInfo.getSpName());
        if (isCommentSupport && StringUtil.isNotEmpty(spInfo.getDescription())) {
            procDescriptionText.setText(spInfo.getDescription());
        }
        if (target != null && target.length() > 0 && target.indexOf("(") > 0 && target.indexOf(")") > 0) {
            String javaFuncName = target.substring(0, target.indexOf("(")).trim();
            javaParamType = (target.substring(target.indexOf("(") + 1, target.indexOf(")"))).split(",");
            javaNameText.setText(javaFuncName);
        }
        List<SPArgsInfo> argsInfoList = spInfo.getArgsInfoList();
        if (javaParamType == null || argsInfoList.size() != javaParamType.length) {
            return;
        }
        while (!procParamsListData.isEmpty()) {
            procParamsListData.remove(0);
        }
        for (int i = 0; i < javaParamType.length; i++) {
            for (SPArgsInfo spArgsInfo : argsInfoList) {
                if (spArgsInfo.getIndex() == i) {
                    Map<String, String> model = new HashMap<String, String>();
                    model.put("0", spArgsInfo.getArgName());
                    model.put("1", spArgsInfo.getDataType());
                    model.put("2", javaParamType[i]);
                    model.put("3", spArgsInfo.getSpArgsType().toString());
                    if (isCommentSupport) {
                        model.put("4", spArgsInfo.getDescription());
                    }
                    procParamsListData.add(model);
                }
            }
        }
        procParamsTableViewer.refresh();
        for (int i = 0; i < procParamsTableViewer.getTable().getColumnCount(); i++) {
            procParamsTableViewer.getTable().getColumn(i).pack();
        }
    }
}
Also used : HashMap(java.util.HashMap) SPArgsInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo)

Example 3 with SPArgsInfo

use of com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo in project cubrid-manager by CUBRID.

the class GetSPInfoListTask method buildResult.

/**
	 * Create sp information list by ResultSet
	 *
	 * @throws SQLException the sql exception
	 */
private void buildResult() throws SQLException {
    // FIXME extract to utility class
    while (rs.next()) {
        String spName = rs.getString("sp_name");
        if (spName == null || spName.trim().length() <= 0) {
            continue;
        }
        String spType = rs.getString("sp_type");
        SPType type = null;
        if (spType != null && spType.trim().equalsIgnoreCase("PROCEDURE")) {
            type = SPType.PROCEDURE;
        } else if (spType != null && spType.trim().equalsIgnoreCase("FUNCTION")) {
            type = SPType.FUNCTION;
        }
        String returnType = rs.getString("return_type");
        String target = rs.getString("target");
        String language = rs.getString("lang");
        String owner = rs.getString("owner");
        String description = null;
        if (isCommentSupport) {
            description = rs.getString("comment");
        }
        SPInfo spInfo = getSPInfo(spInfoList, spName);
        if (spInfo == null) {
            spInfo = new SPInfo(spName, type, returnType, language, owner, target, description);
            spInfoList.add(spInfo);
        }
        String argName = rs.getString("arg_name");
        if (argName == null || argName.trim().length() <= 0) {
            continue;
        }
        // Get sp args
        int index = rs.getInt("index_of");
        String dataType = rs.getString("data_type");
        String mode = rs.getString("mode");
        SPArgsType spArgsType = null;
        if (mode != null && mode.trim().equalsIgnoreCase("IN")) {
            spArgsType = SPArgsType.IN;
        } else if (mode != null && mode.trim().equalsIgnoreCase("OUT")) {
            spArgsType = SPArgsType.OUT;
        } else if (mode != null && mode.trim().equalsIgnoreCase("INOUT")) {
            spArgsType = SPArgsType.INOUT;
        }
        String colDescription = null;
        if (isCommentSupport) {
            colDescription = rs.getString("col_comment");
        }
        SPArgsInfo spArgsInfo = new SPArgsInfo(spName, argName, index, dataType, spArgsType, colDescription);
        spInfo.addSPArgsInfo(spArgsInfo);
    }
}
Also used : SPArgsType(com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsType) SPType(com.cubrid.cubridmanager.core.cubrid.sp.model.SPType) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) SPArgsInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo)

Aggregations

SPArgsInfo (com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsInfo)3 HashMap (java.util.HashMap)2 SPArgsType (com.cubrid.cubridmanager.core.cubrid.sp.model.SPArgsType)1 SPInfo (com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo)1 SPType (com.cubrid.cubridmanager.core.cubrid.sp.model.SPType)1