コード例 #1
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTableScript(com.hangum.tadpole.dao.mysql.TableDAO)
   */
  @Override
  public String getTableScript(TableDAO tableDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    Map srcList = (HashMap) client.queryForObject("getTableScript", tableDAO.getName());
    return "" + srcList.get("Create Table");
  }
コード例 #2
0
  /**
   * 데이터 수정.
   *
   * @param userDB
   * @param title
   * @param desc
   * @param cronExp
   * @param listSchedule
   * @return
   * @throws Exception
   */
  public static ScheduleMainDAO modifySchedule(
      final UserDBDAO userDB, ScheduleMainDAO scheduleDao, List<ScheduleDAO> listSchedule)
      throws Exception {

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    sqlClient.update("scheduleMainUpdate", scheduleDao);

    // 기존 데이터를 삭제합니다.
    sqlClient.update("deleteSchedule", scheduleDao.getSeq());

    // save schedule
    for (ScheduleDAO scheduleDAO : listSchedule) {
      scheduleDAO.setSchedule_main_seq(scheduleDao.getSeq());
      ScheduleDAO retScheduleDAO = (ScheduleDAO) sqlClient.insert("scheduleInsert", scheduleDAO);

      // sql
      String[] sqls = SQLUtil.makeResourceDataArays(scheduleDAO.getSql());
      ScheduleDetailDAO detailDao = null;
      for (String sql : sqls) {
        detailDao = new ScheduleDetailDAO();
        detailDao.setSchedule_seq(retScheduleDAO.getSeq());
        detailDao.setDatas(sql);

        sqlClient.insert("scheduleDetailInsert", detailDao);
      }
    }

    return scheduleDao;
  }
コード例 #3
0
  /* (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;
  }
コード例 #4
0
  /**
   * schedule result
   *
   * @param seq
   * @param isResult
   * @param msg
   */
  public static void saveScheduleResult(int seq, boolean isResult, String msg) throws Exception {
    ScheduleResultDAO dao = new ScheduleResultDAO();
    dao.setSchedule_main_seq(seq);
    dao.setResult(
        isResult ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name());
    dao.setDescription(msg);

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    sqlClient.insert("scheduleResultInsert", dao);
  }
コード例 #5
0
  /**
   * sequenc
   *
   * @param dao
   * @return
   * @throws TadpoleSQLManagerException, SQLException
   */
  public static TadpoleSequenceDAO getSequence(TadpoleSequenceDAO dao)
      throws TadpoleSQLManagerException, SQLException {
    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    dao = (TadpoleSequenceDAO) sqlClient.queryForObject("lastSequene", dao);

    dao.setNo(dao.getNo() + 1);
    sqlClient.update("updateSequence", dao);

    return dao;
  }
コード例 #6
0
  /**
   * 마지막 실행했떤 쿼리 100개를 리턴합니다.
   *
   * @param user_seq
   * @param dbSeq
   * @return
   * @throws Exception
   */
  public static List<SQLHistoryDAO> getExecuteQueryHistory(int user_seq, int dbSeq, String filter)
      throws Exception {
    List<SQLHistoryDAO> returnSQLHistory = new ArrayList<SQLHistoryDAO>();

    Map<String, Object> queryMap = new HashMap<String, Object>();
    queryMap.put("user_seq", user_seq);
    queryMap.put("db_seq", dbSeq);
    queryMap.put("filter", "%" + filter + "%");
    queryMap.put("count", 50);

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    List<java.util.Map> listResourceData =
        sqlClient.queryForList("getExecuteQueryHistory", queryMap);

    for (Map resultMap : listResourceData) {
      int seq = (Integer) resultMap.get("executed_sql_resource_seq");

      Long startdateexecute = 0l;
      // This case sqlite
      if (resultMap.get("startdateexecute") instanceof Long) {
        startdateexecute = (Long) resultMap.get("startdateexecute");
        // This case mysql
      } else {
        startdateexecute = ((Timestamp) resultMap.get("startdateexecute")).getTime();
      }
      String strSQLText = (String) resultMap.get("datas");
      Long enddateexecute = 0l;
      // This case sqlite
      if (resultMap.get("enddateexecute") instanceof Long) {
        enddateexecute = (Long) resultMap.get("enddateexecute");
        // This case mysql
      } else {
        enddateexecute = ((Timestamp) resultMap.get("enddateexecute")).getTime();
      }

      String strMessage = (String) resultMap.get("message");

      int row = (Integer) resultMap.get("row");
      String result = (String) resultMap.get("result");

      SQLHistoryDAO dao =
          new SQLHistoryDAO(
              new Timestamp(startdateexecute),
              strSQLText,
              new Timestamp(enddateexecute),
              row,
              result,
              strMessage);
      dao.setSeq(seq);
      returnSQLHistory.add(dao);
    }

    return returnSQLHistory;
  }
コード例 #7
0
  /**
   * table의 컬럼 정보를 가져옵니다.
   *
   * @param strTBName
   * @return
   * @throws Exception
   */
  public List<TableColumnDAO> getColumns(String strTBName) throws Exception {
    Map<String, String> param = new HashMap<String, String>();
    param.put("db", userDB.getDb()); // $NON-NLS-1$
    param.put("table", strTBName); // $NON-NLS-1$

    if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT) {
      return new TajoConnectionManager().tableColumnList(userDB, param);
    } else {
      SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
      return sqlClient.queryForList("tableColumnList", param); // $NON-NLS-1$
    }
  }
コード例 #8
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getViewScript(java.lang.String)
   */
  @Override
  public String getViewScript(String strName) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    StringBuilder result = new StringBuilder("");

    Map srcList = (HashMap) client.queryForObject("getViewScript", strName);
    String strSource = "" + srcList.get("Create View");
    strSource = StringUtils.substringAfterLast(strSource, "VIEW");

    return "CREATE VIEW " + strSource;
  }
コード例 #9
0
  /* (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;
  }
コード例 #10
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTriggerScript(com.hangum.tadpole.dao.mysql.TriggerDAO)
   */
  @Override
  public String getTriggerScript(TriggerDAO triggerDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    StringBuilder result = new StringBuilder("");

    Map srcList = (HashMap) client.queryForObject("getTriggerScript", triggerDAO.getTrigger());
    String strSource = "" + srcList.get("SQL Original Statement");
    strSource = StringUtils.substringAfterLast(strSource, "TRIGGER");

    return "CREATE TRIGGER " + strSource;
  }
コード例 #11
0
  /**
   * resource data
   *
   * @param userDBResource
   * @param contents
   * @throws Exception
   */
  private static void insertResourceData(ExecutedSqlResourceDAO userDBResource, String contents)
      throws Exception {
    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());

    // content data를 저장합니다.
    ExecutedSqlResourceDataDAO dataDao = new ExecutedSqlResourceDataDAO();
    dataDao.setExecuted_sql_resource_seq(userDBResource.getSeq());
    String[] arrayContent = SQLUtil.makeResourceDataArays(contents);
    for (String content : arrayContent) {
      dataDao.setDatas(content);
      sqlClient.insert("userExecuteSQLResourceDataInsert", dataDao); // $NON-NLS-1$			
    }
  }
コード例 #12
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getViewScript(java.lang.String)
   */
  @Override
  public String getViewScript(String strName) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    StringBuilder result = new StringBuilder("");
    result.append("/* DROP VIEW " + strName + "; */ \n\n");

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

    return result.toString();
  }
コード例 #13
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTriggerScript(com.hangum.tadpole.dao.mysql.TriggerDAO)
   */
  @Override
  public String getTriggerScript(TriggerDAO triggerDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

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

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

    return result.toString();
  }
コード例 #14
0
  /* (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();
  }
コード例 #15
0
  /**
   * seq
   *
   * @param seq {@link ScheduleDAO#getSeq()}
   * @return
   * @throws Exception
   */
  public static List<ScheduleDAO> findSchedule(final int seq) throws Exception {
    List<ScheduleDAO> listSchedule = new ArrayList<ScheduleDAO>();

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    listSchedule = sqlClient.queryForList("getSchedule", seq);
    for (ScheduleDAO scheduleDAO : listSchedule) {

      List<ScheduleDetailDAO> listDetail =
          sqlClient.queryForList("getScheduleDetail", scheduleDAO.getSeq());
      StringBuffer sbSQL = new StringBuffer();

      for (ScheduleDetailDAO scheduleDetailDAO : listDetail) {
        sbSQL.append(scheduleDetailDAO.getDatas());
      }
      scheduleDAO.setSql(sbSQL.toString());
    }

    return listSchedule;
  }
コード例 #16
0
  /* (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;
    }
  }
コード例 #17
0
  private void initUI() {
    try {
      SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
      List listTableInform =
          sqlClient.queryForList("tableInformation", userDB.getDb()); // $NON-NLS-1$

      tvTableInform.setInput(listTableInform);
      tvTableInform.refresh();
    } catch (Exception e) {
      logger.error("initialize session list", e); // $NON-NLS-1$

      Status errStatus =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
      ExceptionDetailsErrorDialog.openError(
          null, "Error", Messages.MainEditor_19, errStatus); // $NON-NLS-1$
    }

    // google analytic
    AnalyticCaller.track(RDBDBInfosEditor.ID, "TablesComposite"); // $NON-NLS-1$
  }
コード例 #18
0
  /**
   * Is executed procedure?
   *
   * @param procedureDAO
   * @param useDB
   * @return
   */
  public boolean isExecuted(ProcedureFunctionDAO procedureDAO, UserDBDAO selectUseDB) {
    if (!isSupport()) {
      MessageDialog.openError(null, "Error", "Not Support database");
      return false;
    }
    if (!procedureDAO.isValid()) {
      MessageDialog.openError(null, "Error", "Not valid this procedure.");
      return false;
    }

    if (DBDefine.getDBDefine(userDB) == DBDefine.MYSQL_DEFAULT) {
      double dbVersion = 0.0;
      try {
        SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
        DBInfoDAO dbInfo = (DBInfoDAO) sqlClient.queryForObject("findDBInfo"); // $NON-NLS-1$
        dbVersion = Double.parseDouble(StringUtils.substring(dbInfo.getProductversion(), 0, 3));

        if (dbVersion < 5.5) {
          MessageDialog.openError(
              null, "Error", "The current version does not support.\n\n5.5 or later is supported.");
          return false;
        }
      } catch (Exception e) {
        logger.error("find DB info", e);

        return false;
      }
    }

    try {
      ProcedureExecutor procedureExecutor = getExecuter();
      procedureExecutor.getInParameters();
    } catch (Exception e) {
      MessageDialog.openError(null, "Error", e.getMessage());
      return false;
    }

    return true;
  }
コード例 #19
0
  /**
   * @param userDB
   * @param title
   * @param desc
   * @param cronExp
   * @param listSchedule
   */
  public static ScheduleMainDAO addSchedule(
      final UserDBDAO userDB,
      String title,
      String desc,
      String cronExp,
      List<ScheduleDAO> listSchedule)
      throws Exception {
    int userSeq = SessionManager.getUserSeq();

    ScheduleMainDAO dao = new ScheduleMainDAO();
    dao.setSeq(userSeq);
    dao.setUser_seq(SessionManager.getUserSeq());
    dao.setDb_seq(userDB.getSeq());
    dao.setTitle(title);
    dao.setDescription(desc);
    dao.setCron_exp(cronExp);

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    dao = (ScheduleMainDAO) sqlClient.insert("scheduleMainInsert", dao);

    // save schedule
    for (ScheduleDAO scheduleDAO : listSchedule) {
      scheduleDAO.setSchedule_main_seq(dao.getSeq());
      ScheduleDAO retScheduleDAO = (ScheduleDAO) sqlClient.insert("scheduleInsert", scheduleDAO);

      // sql
      String[] sqls = SQLUtil.makeResourceDataArays(scheduleDAO.getSql());
      ScheduleDetailDAO detailDao = null;
      for (String sql : sqls) {
        detailDao = new ScheduleDetailDAO();
        detailDao.setSchedule_seq(retScheduleDAO.getSeq());
        detailDao.setDatas(sql);

        sqlClient.insert("scheduleDetailInsert", detailDao);
      }
    }

    return dao;
  }
コード例 #20
0
  /**
   * get db collation
   *
   * @param userDB
   * @return
   */
  public static String[] getCollation(UserDBDAO userDB) {
    String strSQL = "SHOW COLLATION";

    ResultSet resultSet = null;
    java.sql.Connection javaConn = null;
    Statement statement = null;

    List<String> listCollation = new ArrayList<String>();
    try {
      SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
      javaConn = client.getDataSource().getConnection();
      statement = javaConn.createStatement();

      resultSet = statement.executeQuery(strSQL);
      while (resultSet.next()) listCollation.add(resultSet.getString("Collation"));
    } catch (Exception e) {
      logger.error("mysql collatioon", e);
    } finally {
      if (resultSet != null)
        try {
          resultSet.close();
        } catch (Exception e) {
        }
      if (statement != null)
        try {
          statement.close();
        } catch (Exception e) {
        }
      if (javaConn != null)
        try {
          javaConn.close();
        } catch (Exception e) {
        }
    }

    return listCollation.toArray(new String[listCollation.size()]);
  }
コード例 #21
0
  /**
   * save sqlhistory
   *
   * @param user_seq
   * @param userDB
   * @param sqlType
   * @param sqlHistoryDAO
   */
  public static void saveExecuteSQUeryResource(
      int user_seq,
      UserDBDAO userDB,
      PublicTadpoleDefine.EXECUTE_SQL_TYPE sqlType,
      SQLHistoryDAO sqlHistoryDAO)
      throws Exception {
    if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getIs_profile())) {
      ExecutedSqlResourceDAO executeSQLResourceDao = new ExecutedSqlResourceDAO();
      executeSQLResourceDao.setDb_seq(userDB.getSeq());
      executeSQLResourceDao.setUser_seq(user_seq);
      executeSQLResourceDao.setTypes(sqlType.toString());

      executeSQLResourceDao.setStartDateExecute(sqlHistoryDAO.getStartDateExecute());
      executeSQLResourceDao.setEndDateExecute(sqlHistoryDAO.getEndDateExecute());
      long duration =
          sqlHistoryDAO.getEndDateExecute().getTime()
              - sqlHistoryDAO.getStartDateExecute().getTime();
      executeSQLResourceDao.setDuration(Integer.parseInt("" + duration));

      executeSQLResourceDao.setRow(sqlHistoryDAO.getRows());
      executeSQLResourceDao.setResult(sqlHistoryDAO.getResult());
      executeSQLResourceDao.setMessage(
          sqlHistoryDAO
              .getMesssage()); // ""+(sqlHistoryDAO.getEndDateExecute().getTime() -
                               // sqlHistoryDAO.getStartDateExecute().getTime()));
      executeSQLResourceDao.setIpAddress(sqlHistoryDAO.getIpAddress());
      // 기존에 등록 되어 있는지 검사한다
      SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
      ExecutedSqlResourceDAO executeSQL =
          (ExecutedSqlResourceDAO)
              sqlClient.insert(
                  "userExecuteSQLResourceInsert", executeSQLResourceDao); // $NON-NLS-1$

      insertResourceData(executeSQL, sqlHistoryDAO.getStrSQLText());
    }
  }
コード例 #22
0
 @Override
 public List<InOutParameterDAO> getProcedureOutParamter(ProcedureFunctionDAO procedureDAO)
     throws Exception {
   SqlMapClient client = TadpoleSQLManager.getInstance(userDB);
   return client.queryForList("getProcedureOutParamter", procedureDAO.getName());
 }
コード例 #23
0
  /**
   * 쿼리 실행 히스토리 디테일 창을 얻습니다.
   *
   * @param strType
   * @param dbSeq
   * @param executeTime
   * @param durationLimit
   * @return
   * @throws Exception
   */
  public static List<SQLHistoryDAO> getExecuteQueryHistoryDetail(
      String strType,
      String dbSeq,
      long startTime,
      long endTime,
      int duringExecute,
      String strSearch)
      throws Exception {
    List<SQLHistoryDAO> returnSQLHistory = new ArrayList<SQLHistoryDAO>();

    Map<String, Object> queryMap = new HashMap<String, Object>();
    queryMap.put("db_seq", dbSeq);
    queryMap.put("type", strType);

    if (ApplicationArgumentUtils.isDBServer()) {
      Date date = new Date(startTime);
      DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
      queryMap.put("startTime", formatter.format(date));

      Date dateendTime = new Date(endTime);
      queryMap.put("endTime", formatter.format(dateendTime));
    } else {
      queryMap.put("startTime", startTime);
      queryMap.put("endTime", endTime);
    }

    queryMap.put("duration", duringExecute);
    queryMap.put("count", 1000);
    queryMap.put("strSearch", strSearch);

    SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
    List<java.util.Map> listResourceData = new ArrayList<Map>();
    if (PublicTadpoleDefine.EXECUTE_SQL_TYPE.API.name().endsWith(strType)) {
      listResourceData = sqlClient.queryForList("getExecuteQueryHistoryAPIDetail", queryMap);
    } else {
      listResourceData = sqlClient.queryForList("getExecuteQueryHistoryDetail", queryMap);
    }

    for (Map resultMap : listResourceData) {
      int seq = (Integer) resultMap.get("executed_sql_resource_seq");

      Long startdateexecute = 0l;
      String strSQLText = (String) resultMap.get("datas");
      Long enddateexecute = 0l;

      if (ApplicationArgumentUtils.isDBServer()) {
        startdateexecute = ((Timestamp) resultMap.get("startdateexecute")).getTime();
        enddateexecute = ((Timestamp) resultMap.get("enddateexecute")).getTime();
      } else {
        startdateexecute = (Long) resultMap.get("startdateexecute");
        enddateexecute = (Long) resultMap.get("enddateexecute");
      }

      int row = (Integer) resultMap.get("row");
      String result = (String) resultMap.get("result");

      String userName = resultMap.get("name") == null ? "" : (String) resultMap.get("name");
      String dbName = (String) resultMap.get("display_name");

      String ipAddress = (String) resultMap.get("ipaddress");
      int dbSeq2 = (Integer) resultMap.get("dbseq");

      String strMessage = (String) resultMap.get("message");

      SQLHistoryDAO dao =
          new SQLHistoryDAO(
              userName,
              dbName,
              new Timestamp(startdateexecute),
              strSQLText,
              new Timestamp(enddateexecute),
              row,
              result,
              strMessage,
              ipAddress,
              dbSeq2);
      dao.setSeq(seq);
      if (PublicTadpoleDefine.EXECUTE_SQL_TYPE.API.name().endsWith(strType)) {
        dao.setEXECUSTE_SQL_TYPE(PublicTadpoleDefine.EXECUTE_SQL_TYPE.API);
      } else {
        dao.setEXECUSTE_SQL_TYPE(PublicTadpoleDefine.EXECUTE_SQL_TYPE.EDITOR);
      }

      returnSQLHistory.add(dao);
    }

    return returnSQLHistory;
  }
コード例 #24
0
  @Override
  public void run(IStructuredSelection selection, UserDBDAO userDB, OBJECT_TYPE actionType) {
    try {
      PublicTadpoleDefine.QUERY_DML_TYPE queryType = QUERY_DML_TYPE.INSERT;
      if (queryType == QUERY_DML_TYPE.INSERT) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getInsert_lock())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
      queryType = QUERY_DML_TYPE.UPDATE;
      if (queryType == QUERY_DML_TYPE.UPDATE) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getUpdate_lock())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
      queryType = QUERY_DML_TYPE.DELETE;
      if (queryType == QUERY_DML_TYPE.DELETE) {
        if (PublicTadpoleDefine.YES_NO
            .YES
            .name()
            .equals(userDB.getDbAccessCtl().getDelete_locl())) {
          throw new Exception(Messages.get().MainEditor_21);
        }
      }
    } catch (Exception e) {
      MessageDialog.openError(
          getWindow().getShell(), Messages.get().ObjectDeleteAction_2, e.getMessage());
      return;
    }

    try {
      if (!GrantCheckerUtils.ifExecuteQuery(userDB)) return;
    } catch (Exception e) {
      MessageDialog.openError(
          getWindow().getShell(), Messages.get().ObjectDeleteAction_2, e.getMessage());
      return;
    }

    TableDAO tableDAO = (TableDAO) selection.getFirstElement();
    try {
      // get the table columns
      SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
      Map<String, String> mapParam = new HashMap<String, String>();
      mapParam.put("db", userDB.getDb()); // $NON-NLS-1$
      mapParam.put("table", tableDAO.getName()); // $NON-NLS-1$
      List showTableColumns = sqlClient.queryForList("tableColumnList", mapParam); // $NON-NLS-1$

      // Open the table director editor
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

      DBTableEditorInput dbEditorInput = new DBTableEditorInput(tableDAO, userDB, showTableColumns);
      page.openEditor(dbEditorInput, TableInformationEditor.ID, false);
    } catch (Exception e) {
      logger.error("Load the table data", e); // $NON-NLS-1$

      Status errStatus =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
      ExceptionDetailsErrorDialog.openError(
          null, "Error", Messages.get().ExplorerViewer_39, errStatus); // $NON-NLS-1$
    }
  }
コード例 #25
0
 /**
  * 보여 주어야할 목록을 정의합니다.
  *
  * @param userDB
  * @return
  * @throws Exception
  */
 public static List<OracleSynonymDAO> getSynonymList(final UserDBDAO userDB) throws Exception {
   SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB);
   return sqlClient.queryForList("synonymList", userDB.getDb()); // $NON-NLS-1$
 }
コード例 #26
0
 /**
  * find schedule main
  *
  * @param seq {@link ScheduleMainDAO#getSeq()}
  * @return
  * @throws Exception
  */
 public static ScheduleMainDAO findScheduleMain(final int seq) throws Exception {
   SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
   return (ScheduleMainDAO) sqlClient.queryForObject("getScheduleMain", seq);
 }
コード例 #27
0
 /**
  * get result
  *
  * @param seq
  * @return
  * @throws Exception
  */
 public static List<ScheduleResultDAO> getScheduleResult(int seq) throws Exception {
   SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
   return sqlClient.queryForList("getScheduleResult", seq);
 }
コード例 #28
0
 /**
  * find user schedule
  *
  * @return
  * @throws Exception
  */
 public static List<ScheduleMainDAO> findUserScheduleMain() throws Exception {
   SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
   return sqlClient.queryForList("getUserScheduleMain", SessionManager.getUserSeq());
 }
コード例 #29
0
  /* (non-Javadoc)
   * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTableScript(com.hangum.tadpole.dao.mysql.TableDAO)
   */
  @Override
  public String getTableScript(TableDAO tableDAO) throws Exception {
    SqlMapClient client = TadpoleSQLManager.getInstance(userDB);

    List<HashMap> srcList = client.queryForList("getTableScript", tableDAO.getName());

    StringBuilder result = new StringBuilder("");
    result.append("/* DROP TABLE " + tableDAO.getName() + " CASCADE CONSTRAINT; */ \n\n");
    result.append("CREATE TABLE " + tableDAO.getName() + "( \n");
    for (int i = 0; i < srcList.size(); i++) {
      HashMap<String, Object> source = srcList.get(i);

      result.append("\t");
      if (i > 0) result.append(",");
      result.append(source.get("COLUMN_NAME")).append(" ");
      result.append(source.get("DATA_TYPE"));

      if (source.get("DATA_PRECISION") != null
          && ((Integer) source.get("DATA_PRECISION")).intValue() > 0) {
        result.append("(" + source.get("DATA_PRECISION"));
        if (source.get("DATA_SCALE") != null
            && ((Integer) source.get("DATA_SCALE")).intValue() > 0) {
          result.append("," + source.get("DATA_SCALE"));
        }

        result.append(")");
      } else if (!StringUtils.contains((String) source.get("DATA_TYPE"), "DATE")
          && !StringUtils.contains((String) source.get("DATA_TYPE"), "NUMBER")
          && ((Integer) source.get("DATA_LENGTH")).intValue() > 0) {
        result.append("(" + source.get("DATA_LENGTH") + ")");
      } else {
        result.append(" ");
      }

      if (source.get("DATA_DEFAULT") != null) {

        if (StringUtils.contains((String) source.get("DATA_TYPE"), "CHAR")) {
          result.append(" DEFAULT '" + (String) source.get("DATA_DEFAULT") + "'");
        } else {
          result.append(" DEFAULT " + (String) source.get("DATA_DEFAULT"));
        }
      }

      if ("NO".equals(source.get("NULLABLE"))) {
        result.append(" NOT NULL ");
      }

      result.append("\n");
    }

    // primary key
    List<HashMap> srcPkList = client.queryForList("getTableScript.pk", tableDAO.getName());
    for (int i = 0; i < srcPkList.size(); i++) {
      HashMap<String, Object> source = srcPkList.get(i);
      if (i == 0) {
        result
            .append("\t,CONSTRAINT ")
            .append(source.get("CONSTRAINT_NAME"))
            .append(" PRIMARY KEY ");
        if ("CLUSTERED".equals(source.get("INDEX_TYPE"))) {
          result.append(" CLUSTERED ");
        }
        result.append(" ( ").append(source.get("COLUMN_NAME"));

        if ((Boolean) source.get("DESCENDING")) {
          result.append(" DESC ");
        }
      } else {
        result.append(", " + source.get("COLUMN_NAME"));
        if ((Boolean) source.get("DESCENDING")) {
          result.append(" DESC ");
        }
      }

      if (i == srcPkList.size() - 1) {
        result.append(") \n");
      }
    }

    result.append("); \n\n");

    // table, column comments
    List<String> srcCommentList =
        client.queryForList("getTableScript.comments", tableDAO.getName());
    for (int i = 0; i < srcCommentList.size(); i++) {
      result.append(srcCommentList.get(i) + "\n");
    }

    // foreign key

    // column constraint (사용자 정의 컬럼 제약조건)

    // partition table define

    // storage option

    // iot_type table define

    // table grant

    // table trigger

    // table synonyms

    return result.toString();
  }
コード例 #30
0
 /**
  * delete schedule
  *
  * @param seq
  * @throws Exception
  */
 public static void deleteSchedule(int seq) throws Exception {
   SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB());
   sqlClient.update("deleteScheduleMain", seq);
 }