/**
   * 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);
  }
  @Override
  protected Control createContents(Composite parent) {

    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(2, false));

    Label lblResultType = new Label(container, SWT.NONE);
    lblResultType.setText(Messages.get().RDBPreferencePage_resultType);

    comboRDBResultType = new Combo(container, SWT.READ_ONLY);
    comboRDBResultType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboRDBResultType.add("Table");
    //		comboRDBResultType.add("Text");
    //		comboRDBResultType.add("JSON");
    comboRDBResultType.select(0);

    Label lblNumberColumnAdd = new Label(container, SWT.NONE);
    lblNumberColumnAdd.setText(Messages.get().RDBPreferencePage_lblNumberColumnAdd_text);

    comboRDBNumberComma = new Combo(container, SWT.READ_ONLY);
    comboRDBNumberComma.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboRDBNumberComma.add(PublicTadpoleDefine.YES_NO.YES.name());
    comboRDBNumberComma.add(PublicTadpoleDefine.YES_NO.NO.name());
    comboRDBNumberComma.select(0);

    Label lblNewLabel = new Label(container, SWT.NONE);
    lblNewLabel.setText(Messages.get().DefaultPreferencePage_0);

    textSelectLimit = new Text(container, SWT.BORDER);
    textSelectLimit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblNewLabel_1 = new Label(container, SWT.NONE);
    lblNewLabel_1.setText(Messages.get().DefaultPreferencePage_other_labelText_1);

    textResultPage = new Text(container, SWT.BORDER);
    textResultPage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblResultViewFont = new Label(container, SWT.NONE);
    lblResultViewFont.setText(Messages.get().RDBPreferencePage_lblResultViewFont_text);

    lblUserFont = new Label(container, SWT.NONE);
    lblUserFont.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblUserFont.setText("");
    new Label(container, SWT.NONE);

    Button btnNewButton = new Button(container, SWT.NONE);
    btnNewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            setFontData();
          }
        });
    btnNewButton.setText(Messages.get().RDBPreferencePage_btnNewButton_text);

    Label lblQueryTimeout = new Label(container, SWT.NONE);
    lblQueryTimeout.setText(Messages.get().RDBPreferencePage_lblQueryTimeout_text);

    textQueryTimeout = new Text(container, SWT.BORDER);
    textQueryTimeout.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblCommitCount = new Label(container, SWT.NONE);
    lblCommitCount.setText(Messages.get().RDBPreferencePage_lblCommitCount_text);

    textCommitCount = new Text(container, SWT.BORDER);
    textCommitCount.setText(Messages.get().RDBPreferencePage_text_text);
    textCommitCount.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblCharacterShownIn = new Label(container, SWT.NONE);
    lblCharacterShownIn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblCharacterShownIn.setText(Messages.get().RDBPreferencePage_lblCharacterShownIn_text);

    textShowInTheColumn = new Text(container, SWT.BORDER);
    textShowInTheColumn.setText(Messages.get().RDBPreferencePage_text_text_1);
    textShowInTheColumn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    label.setText(""); // $NON-NLS-1$

    Label lblNewLabel_2 = new Label(container, SWT.NONE);
    lblNewLabel_2.setText(Messages.get().DefaultPreferencePage_other_labelText);

    textOraclePlan = new Text(container, SWT.BORDER);
    textOraclePlan.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(container, SWT.NONE);

    Button btnCreatePlanTable = new Button(container, SWT.NONE);
    btnCreatePlanTable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            TadpoleSimpleMessageDialog planDialog =
                new TadpoleSimpleMessageDialog(
                    getShell(), textOraclePlan.getText(), ORACLE_PLAN_TABLE);
            planDialog.open();
          }
        });
    btnCreatePlanTable.setText(Messages.get().RDBPreferencePage_btnCreatePlanTable_text);

    initDefaultValue();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

    return container;
  }
Ejemplo n.º 3
0
  @Override
  protected void okPressed() {
    String strEmail = StringUtils.trimToEmpty(textEMail.getText());
    String strPass = StringUtils.trimToEmpty(textPasswd.getText());

    if (!validation(strEmail, strPass)) return;

    try {
      UserDAO userDao = TadpoleSystem_UserQuery.login(strEmail, strPass);

      // firsttime email confirm
      if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getIs_email_certification())) {
        InputDialog inputDialog =
            new InputDialog(
                getShell(),
                Messages.get().LoginDialog_10,
                Messages.get().LoginDialog_17,
                "",
                null); //$NON-NLS-3$ //$NON-NLS-1$
        if (inputDialog.open() == Window.OK) {
          if (!userDao.getEmail_key().equals(inputDialog.getValue())) {
            throw new Exception(Messages.get().LoginDialog_19);
          } else {
            TadpoleSystem_UserQuery.updateEmailConfirm(strEmail);
          }
        } else {
          throw new Exception(Messages.get().LoginDialog_20);
        }
      }

      if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getApproval_yn())) {
        MessageDialog.openError(
            getParentShell(), Messages.get().LoginDialog_7, Messages.get().LoginDialog_27);

        return;
      }

      // Check the allow ip
      String strAllowIP = userDao.getAllow_ip();
      boolean isAllow = IPFilterUtil.ifFilterString(strAllowIP, RequestInfoUtils.getRequestIP());
      if (logger.isDebugEnabled())
        logger.debug(
            Messages.get().LoginDialog_21
                + userDao.getEmail()
                + Messages.get().LoginDialog_22
                + strAllowIP
                + Messages.get().LoginDialog_23
                + RequestInfoUtils.getRequestIP());
      if (!isAllow) {
        logger.error(
            Messages.get().LoginDialog_21
                + userDao.getEmail()
                + Messages.get().LoginDialog_22
                + strAllowIP
                + Messages.get().LoginDialog_26
                + RequestInfoUtils.getRequestIP());
        MessageDialog.openError(
            getParentShell(), Messages.get().LoginDialog_7, Messages.get().LoginDialog_28);
        return;
      }

      if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDao.getUse_otp())) {
        OTPLoginDialog otpDialog = new OTPLoginDialog(getShell());
        otpDialog.open();

        if (!GoogleAuthManager.getInstance()
            .isValidate(userDao.getOtp_secret(), otpDialog.getIntOTPCode())) {
          throw new Exception(Messages.get().LoginDialog_2);
        }
      }

      // 로그인 유지.
      registLoginID(userDao.getEmail());

      SessionManager.addSession(userDao);

      // save login_history
      TadpoleSystem_UserQuery.saveLoginHistory(userDao.getSeq());
    } catch (Exception e) {
      logger.error(
          String.format(
              "Login exception. request email is %s, reason %s",
              strEmail, e.getMessage())); // $NON-NLS-1$
      MessageDialog.openError(getParentShell(), Messages.get().LoginDialog_29, e.getMessage());

      textPasswd.setFocus();
      return;
    }

    super.okPressed();
  }
  @Override
  public boolean makeUserDBDao(boolean isTest) {
    if (!isValidateInput(isTest)) return false;

    DBDefine selectDB = (DBDefine) comboDriverType.getData(comboDriverType.getText());

    String dbUrl =
        String.format(
            selectDB.getDB_URL_INFO(),
            StringUtils.trimToEmpty(textHost.getText()),
            StringUtils.trimToEmpty(textPort.getText()),
            StringUtils.trimToEmpty(textDatabase.getText()));

    if (!"".equals(textJDBCOptions.getText())) {
      dbUrl += "?" + textJDBCOptions.getText();
    }

    userDB = new UserDBDAO();
    userDB.setDbms_type(selectDB.getDBToString());
    userDB.setUrl(dbUrl);
    userDB.setUrl_user_parameter(textJDBCOptions.getText());
    userDB.setDb(StringUtils.trimToEmpty(textDatabase.getText()));
    userDB.setGroup_name(StringUtils.trimToEmpty(preDBInfo.getComboGroup().getText()));
    userDB.setDisplay_name(StringUtils.trimToEmpty(preDBInfo.getTextDisplayName().getText()));
    userDB.setOperation_type(
        PublicTadpoleDefine.DBOperationType.getNameToType(
                preDBInfo.getComboOperationType().getText())
            .toString());
    userDB.setHost(StringUtils.trimToEmpty(textHost.getText()));
    userDB.setPort(StringUtils.trimToEmpty(textPort.getText()));
    userDB.setUsers(StringUtils.trimToEmpty(textUser.getText()));
    userDB.setPasswd(StringUtils.trimToEmpty(textPassword.getText()));

    // others connection 정보를 입력합니다.
    //		setOtherConnectionInfo();
    OthersConnectionInfoDAO otherConnectionDAO = othersConnectionInfo.getOthersConnectionInfo();
    userDB.setIs_readOnlyConnect(
        otherConnectionDAO.isReadOnlyConnection()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setIs_autocommit(
        otherConnectionDAO.isAutoCommit()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setIs_showtables(
        otherConnectionDAO.isShowTables()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    //
    //	userDB.setIs_table_filter(otherConnectionDAO.isTableFilter()?PublicTadpoleDefine.YES_NO.YES.name():PublicTadpoleDefine.YES_NO.NO.name());
    //		userDB.setTable_filter_include(otherConnectionDAO.getStrTableFilterInclude());
    //		userDB.setTable_filter_exclude(otherConnectionDAO.getStrTableFilterExclude());

    userDB.setIs_profile(
        otherConnectionDAO.isProfiling()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setQuestion_dml(
        otherConnectionDAO.isDMLStatement()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    userDB.setIs_external_browser(
        otherConnectionDAO.isExterBrowser()
            ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    // 처음 등록자는 권한이 어드민입니다.
    userDB.setRole_id(PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString());

    return true;
  }