protected void getFieldsFromInput() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null && !r.isEmpty()) {
       BaseStepDialog.getFieldsFromPrevious(
           r,
           wKey,
           1,
           new int[] {1, 2},
           new int[] {},
           -1,
           -1,
           new TableItemInsertListener() {
             public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
               tableItem.setText(3, LoadSatMeta.ATTRIBUTE_NORMAL);
               return true;
             }
           });
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "LoadDialog.UnableToGetFieldsError.DialogTitle"),
         BaseMessages.getString(PKG, "LoadDialog.UnableToGetFieldsError.DialogMessage"),
         ke);
   }
 }
예제 #2
0
 private void getlookup() {
   try {
     String stepFrom = wStep.getText();
     if (!Utils.isEmpty(stepFrom)) {
       RowMetaInterface r = transMeta.getStepFields(stepFrom);
       if (r != null && !r.isEmpty()) {
         BaseStepDialog.getFieldsFromPrevious(
             r, wReturn, 1, new int[] {1}, new int[] {4}, -1, -1, null);
       } else {
         MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
         mb.setMessage(
             BaseMessages.getString(PKG, "FuzzyMatchDialog.CouldNotFindFields.DialogMessage"));
         mb.setText(
             BaseMessages.getString(PKG, "FuzzyMatchDialog.CouldNotFindFields.DialogTitle"));
         mb.open();
       }
     } else {
       MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
       mb.setMessage(
           BaseMessages.getString(PKG, "FuzzyMatchDialog.StepNameRequired.DialogMessage"));
       mb.setText(BaseMessages.getString(PKG, "FuzzyMatchDialog.StepNameRequired.DialogTitle"));
       mb.open();
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "FuzzyMatchDialog.FailedToGetFields.DialogTitle"),
         BaseMessages.getString(PKG, "FuzzyMatchDialog.FailedToGetFields.DialogMessage"),
         ke);
   }
 }
 private void getUpdate() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null) {
       TableItemInsertListener listener =
           new TableItemInsertListener() {
             public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
               if (v.getType() == ValueMetaInterface.TYPE_DATE) {
                 // The default is : format is OK for dates, see if this sticks later on...
                 //
                 tableItem.setText(3, "Y");
               } else {
                 tableItem.setText(3, "Y"); // default is OK too...
               }
               return true;
             }
           };
       BaseStepDialog.getFieldsFromPrevious(
           r, wReturn, 1, new int[] {1, 2}, new int[] {}, -1, -1, listener);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(
             PKG, "LucidDBBulkLoaderDialog.FailedToGetFields.DialogTitle"), // $NON-NLS-1$
         BaseMessages.getString(PKG, "LucidDBBulkLoaderDialog.FailedToGetFields.DialogMessage"),
         ke); //$NON-NLS-1$
   }
 }
  public void get() {
    try {

      // As the user for a file to use as a reference
      //
      FileDialog dialog = new FileDialog(shell, SWT.OPEN);
      dialog.setFilterExtensions(new String[] {"*.sas7bdat;*.SAS7BDAT", "*.*"});
      dialog.setFilterNames(
          new String[] {
            BaseMessages.getString(PKG, "SASInputDialog.FileType.SAS7BAT")
                + ", "
                + BaseMessages.getString(PKG, "System.FileType.TextFiles"),
            BaseMessages.getString(PKG, "System.FileType.CSVFiles"),
            BaseMessages.getString(PKG, "System.FileType.TextFiles"),
            BaseMessages.getString(PKG, "System.FileType.AllFiles")
          });
      if (dialog.open() != null) {
        String filename =
            dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
        SasInputHelper helper = new SasInputHelper(filename);
        BaseStepDialog.getFieldsFromPrevious(
            helper.getRowMeta(), wFields, 1, new int[] {1}, new int[] {3}, 4, 5, null);
      }

    } catch (Exception e) {
      new ErrorDialog(shell, "Error", "Error reading information from file", e);
    }
  }
예제 #5
0
 private void get() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null && !r.isEmpty()) {
       BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] {1}, null, -1, -1, null);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"),
         BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"),
         ke);
   }
 }
 private void getAgg() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null && !r.isEmpty()) {
       BaseStepDialog.getFieldsFromPrevious(
           r, wAgg, 1, new int[] {1, 2}, new int[] {}, -1, -1, null);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "MemoryGroupByDialog.FailedToGetFields.DialogTitle"),
         BaseMessages.getString(PKG, "MemoryGroupByDialog.FailedToGetFields.DialogMessage"),
         ke);
   }
 }
 private void getHeaders() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null && !r.isEmpty()) {
       BaseStepDialog.getFieldsFromPrevious(
           r, wFields, 1, new int[] {1, 2}, new int[] {3}, -1, -1, null);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "RestDialog.FailedToGetHeaders.DialogTitle"),
         BaseMessages.getString(PKG, "RestDialog.FailedToGetHeaders.DialogMessage"),
         ke); //$NON-NLS-1$ //$NON-NLS-2$
   }
 }
예제 #8
0
 private void get() {
   try {
     RowMetaInterface r = transMeta.getPrevStepFields(stepname);
     if (r != null) {
       BaseStepDialog.getFieldsFromPrevious(
           r, wFields, 1, new int[] {1}, new int[] {}, -1, -1, null);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "ExecSQLDialog.FailedToGetFields.DialogTitle"),
         BaseMessages.getString(PKG, "ExecSQLDialog.FailedToGetFields.DialogMessage"),
         ke);
   }
 }
 private void getValues() {
   try {
     StepMeta stepMeta = transMeta.findStep(wReference.getText());
     if (stepMeta != null) {
       RowMetaInterface prev = transMeta.getStepFields(stepMeta);
       if (prev != null) {
         BaseStepDialog.getFieldsFromPrevious(
             prev, wValues, 1, new int[] {1}, new int[] {}, -1, -1, null);
       }
     }
   } catch (KettleException e) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "MergeRowsDialog.ErrorGettingFields.DialogTitle"),
         BaseMessages.getString(PKG, "MergeRowsDialog.ErrorGettingFields.DialogMessage"),
         e);
   }
 }
  private void get() {
    try {
      RowMetaInterface r = transMeta.getPrevStepFields(stepname);
      if (r != null) {
        TableItemInsertListener insertListener =
            new TableItemInsertListener() {
              public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                return true;
              }
            };

        BaseStepDialog.getFieldsFromPrevious(
            r, wFields, 1, new int[] {1}, new int[] {}, -1, -1, insertListener);
      }
    } catch (KettleException ke) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"),
          BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"),
          ke);
    }
  }
예제 #11
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, "IN");
               return true;
             }
           };
       BaseStepDialog.getFieldsFromPrevious(
           r, wFields, 1, new int[] {1}, new int[] {3}, -1, -1, listener);
     }
   } catch (KettleException ke) {
     new ErrorDialog(
         shell,
         BaseMessages.getString(PKG, "DBProcDialog.FailedToGetFields.DialogTitle"),
         BaseMessages.getString(PKG, "DBProcDialog.FailedToGetFields.DialogMessage"),
         ke); //$NON-NLS-1$ //$NON-NLS-2$
   }
 }
예제 #12
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);
    }
  }