protected void find(String searchString) {
   this.searchString = searchString;
   SAPConnection sc = null;
   try {
     sc = SAPConnectionFactory.create();
     sc.open(sapConnection);
     functionList = new ArrayList<SAPFunction>(sc.getFunctions(searchString));
   } catch (Exception e) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "SapFunctionBrowser.ExceptionDialog.ErrorDuringSearch.Title"),
         BaseMessages.getString(
             PKG, "SapFunctionBrowser.ExceptionDialog.ErrorDuringSearch.Message"),
         e);
   } finally {
     if (sc != null) {
       sc.close();
     }
   }
 }
Exemplo n.º 2
0
  private void get() {
    try {
      RowMetaInterface r = transMeta.getPrevStepFields(stepname);
      if (r != null && !r.isEmpty()) {
        TableItemInsertListener listener =
            new TableItemInsertListener() {
              public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                tableItem.setText(2, "=");
                return true;
              }
            };
        BaseStepDialog.getFieldsFromPrevious(
            r, wInput, 1, new int[] {1, 3}, new int[] {}, -1, -1, listener);
      }

      DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
      if (databaseMeta == null) {
        showDatabaseWarning(false);
        return;
      }

      // Fill in the parameters too
      //
      if (function != null) {

        wFunction.setText(function.getName());

        if (wInput.nrNonEmpty() != 0 || wOutput.nrNonEmpty() != 0) {
          MessageBox mb = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
          mb.setMessage(
              BaseMessages.getString(PKG, "SapInputDialog.ClearInputOutput.DialogMessage"));
          mb.setText(BaseMessages.getString(PKG, "SapInputDialog.ClearInputOutput.DialogTitle"));
          int answer = mb.open();
          if (answer == SWT.NO) {
            return;
          }
        }

        wInput.clearAll(false);
        wOutput.clearAll(false);
        Cursor hourGlass = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
        SAPConnection sc = SAPConnectionFactory.create();
        try {
          shell.setCursor(hourGlass);
          sc.open(databaseMeta);
          SAPFunctionSignature signature = sc.getFunctionSignature(function);

          // Populate the input view
          // TODO: clean this up a bit, feels a bit messy
          //
          int rownr = 0;
          for (SAPField field : signature.getInput()) {
            TableItem item;
            if (rownr == 0) {
              item = wInput.table.getItem(0);
            } else {
              item = new TableItem(wInput.table, SWT.NONE);
            }
            rownr++;

            SapType type = getSapType(field);

            int colnr = 1;
            item.setText(colnr++, Const.NVL(field.getName(), ""));
            item.setText(colnr++, type == null ? "" : type.getDescription());
            item.setText(colnr++, Const.NVL(field.getTable(), ""));
            item.setText(colnr++, Const.NVL(field.getName(), ""));
            item.setText(colnr++, field.getTypePentaho());
          }
          wInput.setRowNums();
          wInput.optWidth(true);

          // Get the output rows
          //
          rownr = 0;
          for (SAPField field : signature.getOutput()) {
            TableItem item;
            if (rownr == 0) {
              item = wOutput.table.getItem(0);
            } else {
              item = new TableItem(wOutput.table, SWT.NONE);
            }
            rownr++;

            SapType type = getSapType(field);

            int colnr = 1;
            item.setText(colnr++, Const.NVL(field.getName(), ""));
            item.setText(colnr++, type == null ? "" : type.getDescription());
            item.setText(colnr++, Const.NVL(field.getTable(), ""));
            item.setText(colnr++, Const.NVL(field.getName(), ""));
            item.setText(colnr++, field.getTypePentaho());
          }
          wOutput.setRowNums();
          wOutput.optWidth(true);

        } catch (Exception e) {
          throw new KettleException(e);
        } finally {
          sc.close();
          shell.setCursor(null);
          hourGlass.dispose();
        }
      }
    } catch (KettleException ke) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "SapInputDialog.GetFieldsFailed.DialogTitle"),
          BaseMessages.getString(PKG, "SapInputDialog.GetFieldsFailed.DialogMessage"),
          ke);
    }
  }