private void confirmActionPerformed() {

    if (isValidData()) {
      int count = 0;
      try {
        con = getConnection();
        count = getCount(con);
      } catch (SQLException e) {
        if (con == null) {
          System.err.println("Could not establish connection");
          MessagePanes.showErrorDialog(
              LoanMemberDataExchangeScreen.this,
              props.getProperty("invalid-connection.text"),
              getLocale());
        } else {
          MessagePanes.showErrorDialog(
              LoanMemberDataExchangeScreen.this,
              props.getProperty("system-error.text"),
              getLocale());
        }
        e.printStackTrace();
      } catch (Throwable e) {
        e.printStackTrace();
      }

      ProgressMonitorHandler monitor =
          new ProgressMonitorHandler(
              this,
              new ExchangeTask(count),
              props.getProperty("progress.text") + StringUtils.rtlString("..."));
      monitor.intialize();
    } else {
      MessagePanes.showErrorDialog(this, errorMessage, getLocale());
    }
  }
Ejemplo n.º 2
0
  /**
   * <code>reportActionPerformed()</code> defiens for searching copyrights in DB according to search
   * keys.
   */
  private void reportActionPerformed() {
    filterObject = new TempRequestReport();
    int counter = 0;
    previewHeaderText = new String();
    radioValue = new String();

    if (!txfTitle.getText().equals(""))
      filterObject.setTitle((txfTitle.getText().toUpperCase().trim()));

    if (!txfNumber.getText().equals(""))
      filterObject.setNumber(StringUtils.arabicToLatinDigit(txfNumber.getText()).trim());

    if (rdoAnswerReq.isSelected()) {
      filterObject.setIsAnswered(WorkflowConstants.IS_ANSWERED_REQUEST);
      radioValue = props.getProperty("print_answered_req.name");
    } else if (rdoNoAnswerReq.isSelected()) {
      filterObject.setIsAnswered(WorkflowConstants.IS_NOT_ANSWERED_REQUEST);
      radioValue = props.getProperty("print_no_answered_req.name");
    }

    if (rdoHasNumber.isSelected()) {
      filterObject.setHasNumber(WorkflowConstants.HAS_NUMBER);
      radioValue += " " + props.getProperty("print_has_number_req.name");
    } else if (rdoNoNumber.isSelected()) {
      filterObject.setHasNumber(WorkflowConstants.NO_NUMBER);
      radioValue += " " + props.getProperty("print_no_number_req.name");
    }

    if (txfUserName.getText() != null
        && txfUserName.getText() != ""
        && txfUserName.getText().length() != 0) filterObject.setUserId(userId);

    if (rdoCopyrightReq.isSelected()) {
      filterObject.setType(WorkflowConstants.COPY_RIGHT_BOOK_TYPE);
      filterObject.setDocType("");
      radioValue += " " + props.getProperty("print_copy_right_req.name");
    } else if (rdoDepositReq.isSelected()) {
      filterObject.setType(WorkflowConstants.COPY_RIGHT_NON_BOOK_TYPE);
      if (cmbDocType.getSelectedIndex() != 0) {
        filterObject.setDocType(((ConstantTableItem) cmbDocType.getSelected()).getCode());
      } else filterObject.setDocType("");
      radioValue += " " + props.getProperty("print_deposit_req.name");
    }

    if (chkAnswerDate.isSelected()) {
      filterObject.setAnswerDate(WorkflowConstants.SELECTED);
      previewHeaderText = props.getProperty("answer_date.name");
      counter++;
    }
    if (chkRequestDate.isSelected()) {
      filterObject.setRequestDate(WorkflowConstants.SELECTED);
      if (counter > 0)
        previewHeaderText += " " + '\u060c' + " " + props.getProperty("request_date.name");
      else previewHeaderText += " " + props.getProperty("request_date.name");
      counter++;
    }

    if (chkSetNumberDate.isSelected()) {
      filterObject.setSetNumberDate(WorkflowConstants.SELECTED);
      if (counter > 0)
        previewHeaderText += " " + '\u060c' + " " + props.getProperty("set_number_date.name");
      else previewHeaderText += " " + props.getProperty("set_number_date.name");
    }

    if (txfFromDate.getDate() != null && txfToDate.getDate() != null) {
      if (txfFromDate.getDate().getTime() > txfToDate.getDate().getTime()) {
        MessagePanes.showErrorDialog(
            this, props.getProperty("from_date_larger.name"), LocaleUtils.PERSIAN);
        return;
      }
    }

    if (txfFromDate.getDate() != null) {
      filterObject.setFromDate(txfFromDate.getDate());
      if (!previewHeaderText.equals(""))
        previewHeaderText +=
            " "
                + props.getProperty("from_date.name")
                + " "
                + StringUtils.RTL_MARK
                + txfFromDate.getDate();
    }
    if (txfToDate.getDate() != null) {
      filterObject.setToDate(txfToDate.getDate());
      if (!previewHeaderText.equals(""))
        previewHeaderText +=
            " "
                + props.getProperty("to_date.name")
                + " "
                + StringUtils.RTL_MARK
                + txfToDate.getDate();
    }
    if (txfToDate.getDate() == null && txfFromDate.getDate() == null)
      previewHeaderText = new String();

    dataFetcher.setReportObject(filterObject);
    grid.refresh();
    if (grid.getDataModel().getData().getDataList() == null
        || grid.getDataModel().getData().getDataList().size() == 0)
      MessagePanes.showInfoDialog(this, props.getProperty("empty_list.name"), LocaleUtils.PERSIAN);
  }
    protected void run() {

      exchanger =
          new LoanMemberDatabaseExchange(
              txfImageURL.getText(),
              librarySelectedList,
              loanGroupSelectedList,
              (Location) cmbLocations.getSelectedItem(),
              props,
              cbUseUniqueNameToFindUser.isSelected(),
              cbIsOrg.isSelected(),
              cbIsUniversity.isSelected(),
              cbUseProfileSetting.isSelected());
      try {
        exchanger.setProgressListener(new EchangeProgressListener(this));
        exchanger.exchange(
            con,
            txfProfileDatabase.getText(),
            txfMultimediaDatabase.getText(),
            Long.valueOf(txfFromMemberNo.getText()),
            Long.valueOf(txfToMemberNo.getText()),
            txfImageURL.getText());
        MessagePanes.showInfoDialog(
            LoanMemberDataExchangeScreen.this,
            props.getProperty("successful-exchange.text"),
            getLocale());
      } catch (SQLException e) {
        if (con == null) {
          System.err.println("Could not establish connection");
          MessagePanes.showErrorDialog(
              LoanMemberDataExchangeScreen.this,
              props.getProperty("invalid-connection.text"),
              getLocale());
        } else {
          MessagePanes.showErrorDialog(
              LoanMemberDataExchangeScreen.this,
              props.getProperty("system-error.text"),
              getLocale());
        }
        e.printStackTrace();
      } catch (ImagePathException e) {
        MessagePanes.showErrorDialog(
            LoanMemberDataExchangeScreen.this,
            props.getProperty("not-valid--image-path.text")
                + "\n "
                + props.getProperty("test-file-exist1.text")
                + StringUtils.rtlString("test.pim")
                + props.getProperty("test-file-exist2.text"),
            getLocale());
        e.printStackTrace();
      } catch (Throwable e) {
        e.printStackTrace();
      } finally {
        if (con != null) {
          try {
            con.close();
          } catch (SQLException e) {
            e
                .printStackTrace(); // To change body of catch statement use File | Settings | File
                                    // Templates.
          }
        } else {
          System.err.println("Could not establish connection");
          MessagePanes.showErrorDialog(
              LoanMemberDataExchangeScreen.this,
              props.getProperty("invalid-connection.text"),
              getLocale());
        }
        //                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      }
    }