/* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getFunctionScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO)
   */
  @Override
  public String getFunctionScript(ProcedureFunctionDAO functionDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    StringBuilder result = new StringBuilder("");
    result.append("/* DROP FUNCTION " + functionDAO.getName() + "; */ \n\n");

    List<String> srcProcList = client.queryForList("getFunctionScript", functionDAO.getName());
    for (int i = 0; i < srcProcList.size(); i++) {
      result.append(srcProcList.get(i));
    }

    return result.toString();
  }
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getProcedureScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO)
   */
  @Override
  public String getProcedureScript(ProcedureFunctionDAO procedureDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
    Map srcList = (HashMap) client.queryForObject("getProcedureScript", procedureDAO.getName());
    String strSource = "" + srcList.get("Create Procedure");
    strSource = StringUtils.substringAfterLast(strSource, "PROCEDURE");

    return "CREATE PROCEDURE " + strSource;
  }
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getProcedureScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO)
   */
  @Override
  public String getProcedureScript(ProcedureFunctionDAO procedureDAO) throws Exception {
    try {
      SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

      StringBuilder result = new StringBuilder("");
      result.append("/* DROP PROCEDURE '" + procedureDAO.getName() + "'; */ \n\n");

      List<String> srcProcList = client.queryForList("getProcedureScript", procedureDAO.getName());
      for (int i = 0; i < srcProcList.size(); i++) {
        result.append(srcProcList.get(i));
      }

      return result.toString();
    } catch (Exception e) {
      logger.error("get view script [" + procedureDAO.getName() + "]", e);

      throw e;
    }
  }
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getFunctionScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO)
   */
  @Override
  public String getFunctionScript(ProcedureFunctionDAO functionDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    StringBuilder result = new StringBuilder("");

    Map srcList = (HashMap) client.queryForObject("getFunctionScript", functionDAO.getName());
    String strSource = "" + srcList.get("Create Function");
    strSource = StringUtils.substringAfterLast(strSource, "FUNCTION");

    return "CREATE FUNCTION " + strSource;
  }
 @Override
 public List<InOutParameterDAO> getProcedureOutParamter(ProcedureFunctionDAO procedureDAO)
     throws Exception {
   SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
   return client.queryForList("getProcedureOutParamter", procedureDAO.getName());
 }