Пример #1
0
 private int showMultipleOutputTablesWarning(boolean includeCancel) {
   MessageBox mb =
       new MessageBox(shell, SWT.OK | (includeCancel ? SWT.CANCEL : SWT.NONE) | SWT.ICON_ERROR);
   mb.setMessage(BaseMessages.getString(PKG, "SapInputDialog.MultipleOutputTables.DialogMessage"));
   mb.setText(BaseMessages.getString(PKG, "SapInputDialog.MultipleOutputTables.DialogTitle"));
   return mb.open();
 }
  public SQLStatement getSQLStatements(
      TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev) throws KettleStepException {
    SQLStatement retval =
        new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

    if (databaseMeta != null) {
      if (prev != null && prev.size() > 0) {
        // Copy the row
        RowMetaInterface tableFields = new RowMeta();

        // Now change the field names
        for (int i = 0; i < fieldTable.length; i++) {
          ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
          if (v != null) {
            ValueMetaInterface tableField = v.clone();
            tableField.setName(fieldTable[i]);
            tableFields.addValueMeta(tableField);
          } else {
            throw new KettleStepException(
                "Unable to find field [" + fieldStream[i] + "] in the input rows");
          }
        }

        if (!Const.isEmpty(tableName)) {
          Database db = new Database(loggingObject, databaseMeta);
          db.shareVariablesWith(transMeta);
          try {
            db.connect();

            String schemaTable =
                databaseMeta.getQuotedSchemaTableCombination(
                    transMeta.environmentSubstitute(schemaName),
                    transMeta.environmentSubstitute(tableName));
            String sql = db.getDDL(schemaTable, tableFields, null, false, null, true);

            if (sql.length() == 0) retval.setSQL(null);
            else retval.setSQL(sql);
          } catch (KettleException e) {
            retval.setError(
                BaseMessages.getString(PKG, "GPBulkLoaderMeta.GetSQL.ErrorOccurred")
                    + e.getMessage()); // $NON-NLS-1$
          }
        } else {
          retval.setError(
              BaseMessages.getString(
                  PKG, "GPBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection")); // $NON-NLS-1$
        }
      } else {
        retval.setError(
            BaseMessages.getString(
                PKG, "GPBulkLoaderMeta.GetSQL.NotReceivingAnyFields")); // $NON-NLS-1$
      }
    } else {
      retval.setError(
          BaseMessages.getString(
              PKG, "GPBulkLoaderMeta.GetSQL.NoConnectionDefined")); // $NON-NLS-1$
    }

    return retval;
  }
  private void getParameters(TransMeta inputTransMeta) {
    try {
      if (inputTransMeta == null) {
        JobEntryTrans jet = new JobEntryTrans();
        getInfo(jet);
        inputTransMeta = jet.getTransMeta(rep, metaStore, jobMeta);
      }
      String[] parameters = inputTransMeta.listParameters();

      String[] existing = wParameters.getItems(1);

      for (int i = 0; i < parameters.length; i++) {
        if (Const.indexOfString(parameters[i], existing) < 0) {
          TableItem item = new TableItem(wParameters.table, SWT.NONE);
          item.setText(1, parameters[i]);
        }
      }
      wParameters.removeEmptyRows();
      wParameters.setRowNums();
      wParameters.optWidth(true);
    } catch (Exception e) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(
              PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Title"),
          BaseMessages.getString(
              PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Message"),
          e);
    }
  }
  private void get() {
    try {
      String columnName = wColumnName.getText();
      String tableName = wTableName.getText();

      wColumnName.removeAll();
      wTableName.removeAll();
      RowMetaInterface r = transMeta.getPrevStepFields(stepname);
      if (r != null) {
        r.getFieldNames();

        for (int i = 0; i < r.getFieldNames().length; i++) {
          wTableName.add(r.getFieldNames()[i]);
          wColumnName.add(r.getFieldNames()[i]);
        }
      }
      wColumnName.setText(columnName);
      wTableName.setText(tableName);
    } catch (KettleException ke) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "ColumnExistsDialog.FailedToGetFields.DialogTitle"),
          BaseMessages.getString(PKG, "ColumnExistsDialog.FailedToGetFields.DialogMessage"),
          ke); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
 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);
   }
 }
Пример #6
0
  public void setDefault() {
    keyStream = null;
    updateLookup = null;
    databaseMeta = null;
    commitSize = "100";
    schemaName = "";
    tableName = BaseMessages.getString(PKG, "InsertUpdateMeta.DefaultTableName");

    int nrkeys = 0;
    int nrvalues = 0;

    allocate(nrkeys, nrvalues);

    for (int i = 0; i < nrkeys; i++) {
      keyLookup[i] = "age";
      keyCondition[i] = "BETWEEN";
      keyStream[i] = "age_from";
      keyStream2[i] = "age_to";
    }

    for (int i = 0; i < nrvalues; i++) {
      updateLookup[i] = BaseMessages.getString(PKG, "InsertUpdateMeta.ColumnName.ReturnField") + i;
      updateStream[i] = BaseMessages.getString(PKG, "InsertUpdateMeta.ColumnName.NewName") + i;
      update[i] = Boolean.TRUE;
    }
  }
Пример #7
0
  private void get() {
    if (!gotPreviousFields) {
      gotPreviousFields = true;
      String source = wSourceFileNameField.getText();
      String target = wTargetFileNameField.getText();
      String base = wBaseFolderField.getText();

      try {

        wSourceFileNameField.removeAll();
        wTargetFileNameField.removeAll();
        wBaseFolderField.removeAll();
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
          String[] fields = r.getFieldNames();
          wSourceFileNameField.setItems(fields);
          wTargetFileNameField.setItems(fields);
          wBaseFolderField.setItems(fields);
        }
      } catch (KettleException ke) {
        new ErrorDialog(
            shell,
            BaseMessages.getString(PKG, "ZipFileDialog.FailedToGetFields.DialogTitle"),
            BaseMessages.getString(PKG, "ZipFileDialog.FailedToGetFields.DialogMessage"),
            ke);
      } finally {
        if (source != null) wSourceFileNameField.setText(source);
        if (target != null) wTargetFileNameField.setText(target);
        if (base != null) wBaseFolderField.setText(base);
      }
    }
  }
 private void ok() {
   if (Const.isEmpty(wStepname.getText())) {
     return;
   }
   getMeta(joinMeta);
   // Show a warning (optional)
   if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y"))) {
     MessageDialogWithToggle md =
         new MessageDialogWithToggle(
             shell,
             BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle"),
             null,
             BaseMessages.getString(
                     PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR)
                 + Const.CR,
             MessageDialog.WARNING,
             new String[] {
               BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option1")
             },
             0,
             BaseMessages.getString(PKG, "MultiMergeJoinDialog.InputNeedSort.Option2"),
             "N".equalsIgnoreCase(props.getCustomParameter(STRING_SORT_WARNING_PARAMETER, "Y")));
     MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
     md.open();
     props.setCustomParameter(STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
     props.saveProps();
   }
   stepname = wStepname.getText(); // return value
   dispose();
 }
Пример #9
0
 public void close() throws KettleException {
   try {
     if (!getQueryResult().isDone()) {
       this.qr.setDone(true);
       this.qr = null;
     }
     if (this.sObjects != null) {
       this.sObjects = null;
     }
     if (this.binding != null) {
       this.binding = null;
     }
     if (this.loginResult != null) {
       this.loginResult = null;
     }
     if (this.userInfo != null) {
       this.userInfo = null;
     }
     if (this.getDeletedList != null) {
       getDeletedList.clear();
       getDeletedList = null;
     }
     if (log.isDetailed()) {
       log.logDetailed(BaseMessages.getString(PKG, "SalesforceInput.Log.ConnectionClosed"));
     }
   } catch (Exception e) {
     throw new KettleException(
         BaseMessages.getString(PKG, "SalesforceInput.Error.ClosingConnection"), e);
   }
 }
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore) {

    // TODO: add file checking in case we don't create a table.

    // See if we have input streams leading to this step!
    if (input.length > 0) {
      CheckResult cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_OK,
              BaseMessages.getString(PKG, "AccessOutputMeta.CheckResult.ExpectedInputOk"),
              stepMeta);
      remarks.add(cr);
    } else {
      CheckResult cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_ERROR,
              BaseMessages.getString(PKG, "AccessOutputMeta.CheckResult.ExpectedInputError"),
              stepMeta);
      remarks.add(cr);
    }
  }
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore) {
    CheckResult cr;

    if (input.length > 0) {
      cr =
          new CheckResult(
              CheckResultInterface.TYPE_RESULT_OK,
              BaseMessages.getString(PKG, "GetSequenceMeta.CheckResult.StepIsReceving.Title"),
              stepMeta);
      remarks.add(cr);
    } else {
      cr =
          new CheckResult(
              CheckResultInterface.TYPE_RESULT_ERROR,
              BaseMessages.getString(PKG, "GetSequenceMeta.CheckResult.NoInputReceived.Title"),
              stepMeta);
      remarks.add(cr);
    }
  }
Пример #12
0
  public static ReturnIndicator CheckCC(String CardNumber) {
    ReturnIndicator ri = new ReturnIndicator();

    if (Const.isEmpty(CardNumber)) {
      ri.UnValidMsg = BaseMessages.getString(PKG, "CreditCardValidator.Log.EmptyNumber");
      return ri;
    }

    Matcher m = Pattern.compile("[^\\d\\s.-]").matcher(CardNumber);
    if (m.find()) {
      ri.UnValidMsg = BaseMessages.getString(PKG, "CreditCardValidator.OnlyNumbers");
      return ri;
    }

    int cardId = getCardID(CardNumber);
    if (cardId > -1) {
      if (luhnValidate(CardNumber)) {
        ri.CardValid = true;
        ri.CardType = getCardName(cardId);
      } else {
        ri.CardValid = false;
        ri.UnValidMsg = getNotValidCardNames(cardId);
      }
    } else {
      // try luhn
      // ri.UnValidMsg="This card is unsupported!";
      if (luhnValidate(CardNumber)) {
        ri.CardValid = true;
      } else {
        ri.UnValidMsg = BaseMessages.getString(PKG, "CreditCardValidator.Log.CardNotValid");
      }
    }

    return ri;
  }
Пример #13
0
  // Grab the first x lines from the given file...
  //
  private List<String> getFirst(FixedInputMeta meta, int limit)
      throws IOException, KettleValueException {

    List<String> lines = new ArrayList<String>();

    FixedInputMeta oneMeta = new FixedInputMeta();
    getInfo(oneMeta);

    // Add a single field with the width of the line...
    //
    int lineWidth = Integer.parseInt(oneMeta.getLineWidth());
    if (lineWidth <= 0) {
      throw new IOException("The width of a line can not be 0 or less.");
    }

    oneMeta.allocate(1);

    FixedFileInputField field = new FixedFileInputField();
    field.setName("Field1");
    field.setType(ValueMetaInterface.TYPE_STRING);
    field.setWidth(lineWidth);
    // CHECKSTYLE:Indentation:OFF
    oneMeta.getFieldDefinition()[0] = field;

    TransMeta previewMeta =
        TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());

    TransPreviewProgressDialog progressDialog =
        new TransPreviewProgressDialog(
            shell, previewMeta, new String[] {wStepname.getText()}, new int[] {limit});
    progressDialog.open();

    Trans trans = progressDialog.getTrans();
    String loggingText = progressDialog.getLoggingText();

    if (!progressDialog.isCancelled()) {
      if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
        EnterTextDialog etd =
            new EnterTextDialog(
                shell,
                BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"),
                BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"),
                loggingText,
                true);
        etd.setReadOnly();
        etd.open();
      }
    }

    // The rows are in the transformation...
    //
    RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
    List<Object[]> previewRowsData = progressDialog.getPreviewRows(wStepname.getText());
    for (int i = 0; i < previewRowsData.size(); i++) {
      String line = previewRowsMeta.getString(previewRowsData.get(i), 0);
      lines.add(line);
    }

    return lines;
  }
  private void ok() {
    if (Const.isEmpty(wName.getText())) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setText(BaseMessages.getString(PKG, "System.StepJobEntryNameMissing.Title"));
      mb.setMessage(BaseMessages.getString(PKG, "System.JobEntryNameMissing.Msg"));
      mb.open();
      return;
    }
    jobEntry.setName(wName.getText());
    jobEntry.setDatabase(jobMeta.findDatabase(wConnection.getText()));
    jobEntry.setSchemaname(wSchemaname.getText());
    jobEntry.setTablename(wTablename.getText());
    jobEntry.setFilename(wFilename.getText());
    jobEntry.setSeparator(wSeparator.getText());
    jobEntry.setEnclosed(wEnclosed.getText());
    jobEntry.setEscaped(wEscaped.getText());
    jobEntry.setLineterminated(wLineterminated.getText());
    jobEntry.setLinestarted(wLinestarted.getText());
    jobEntry.setReplacedata(wReplacedata.getSelection());
    jobEntry.setIgnorelines(wIgnorelines.getText());
    jobEntry.setListattribut(wListattribut.getText());
    jobEntry.prorityvalue = wProrityValue.getSelectionIndex();
    jobEntry.setLocalInfile(wLocalInfile.getSelection());

    jobEntry.setAddFileToResult(wAddFileToResult.getSelection());

    dispose();
  }
Пример #15
0
  private void ok() {
    if (Const.isEmpty(wStepname.getText())) return;

    stepname = wStepname.getText(); // return value
    // copy info to TextFileInputMeta class (input)
    input.setSql(wSQL.getText());
    input.setDatabaseMeta(transMeta.findDatabase(wConnection.getText()));
    input.setExecutedEachInputRow(wEachRow.getSelection());
    input.setSingleStatement(wSingleStatement.getSelection());
    input.setVariableReplacementActive(wVariables.getSelection());
    input.setQuoteString(wQuoteString.getSelection());
    input.setParams(wSetParams.getSelection());
    input.setInsertField(wInsertField.getText());
    input.setUpdateField(wUpdateField.getText());
    input.setDeleteField(wDeleteField.getText());
    input.setReadField(wReadField.getText());

    int nrargs = wFields.nrNonEmpty();
    input.allocate(nrargs);
    if (log.isDebug())
      logDebug(BaseMessages.getString(PKG, "ExecSQLDialog.Log.FoundArguments", +nrargs + ""));
    for (int i = 0; i < nrargs; i++) {
      TableItem item = wFields.getNonEmpty(i);
      input.getArguments()[i] = item.getText(1);
    }

    if (input.getDatabaseMeta() == null) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setMessage(BaseMessages.getString(PKG, "ExecSQLDialog.InvalidConnection.DialogMessage"));
      mb.setText(BaseMessages.getString(PKG, "ExecSQLDialog.InvalidConnection.DialogTitle"));
      mb.open();
    }

    dispose();
  }
Пример #16
0
  public Field[] getObjectFields(String objectName) throws KettleException {
    DescribeSObjectResult describeSObjectResult = null;
    try {
      // Get object
      describeSObjectResult = getBinding().describeSObject(objectName);
      if (describeSObjectResult == null) {
        return null;
      }

      if (!describeSObjectResult.isQueryable()) {
        throw new KettleException(
            BaseMessages.getString(PKG, "SalesforceInputDialog.ObjectNotQueryable", this.module));
      } else {
        // we can query this object
        return describeSObjectResult.getFields();
      }
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(PKG, "SalesforceInput.Error.GettingModuleFields", this.module), e);
    } finally {
      if (describeSObjectResult != null) {
        describeSObjectResult = null;
      }
    }
  }
  private void ok() {
    if (Const.isEmpty(wName.getText())) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setText(BaseMessages.getString(PKG, "System.StepJobEntryNameMissing.Title"));
      mb.setMessage(BaseMessages.getString(PKG, "System.JobEntryNameMissing.Msg"));
      mb.open();
      return;
    }
    jobEntry.setName(wName.getText());

    int nritems = wFields.nrNonEmpty();

    jobEntry.connections = new DatabaseMeta[nritems];
    jobEntry.waitfors = new String[nritems];
    jobEntry.waittimes = new int[nritems];

    for (int i = 0; i < nritems; i++) {
      String arg = wFields.getNonEmpty(i).getText(1);
      DatabaseMeta dbMeta = jobMeta.findDatabase(arg);
      if (dbMeta != null) {
        jobEntry.connections[i] = dbMeta;
        jobEntry.waitfors[i] = "" + Const.toInt(wFields.getNonEmpty(i).getText(2), 0);
        jobEntry.waittimes[i] =
            JobEntryCheckDbConnections.getWaitTimeByDesc(wFields.getNonEmpty(i).getText(3));
      }
    }
    dispose();
  }
Пример #18
0
  private boolean CreateFolder(String filefolder) {
    FileObject folder = null;
    try {
      folder = KettleVFS.getFileObject(filefolder, this);

      if (!folder.exists()) {
        if (createtargetfolder) {
          folder.createFolder();
          if (log.isDetailed()) {
            logDetailed(
                BaseMessages.getString(PKG, "JobSSH2GET.Log.FolderCreated", folder.toString()));
          }
        } else {
          return false;
        }
      }
      return true;
    } catch (Exception e) {
      logError(
          BaseMessages.getString(PKG, "JobSSH2GET.Log.CanNotCreateFolder", folder.toString()), e);

    } finally {
      if (folder != null) {
        try {
          folder.close();
        } catch (Exception ex) {
          /* Ignore */
        }
      }
    }
    return false;
  }
Пример #19
0
 private boolean openNextFile() {
   try {
     if (data.filenr >= data.files.nrOfFiles()) {
       if (log.isDetailed())
         logDetailed(BaseMessages.getString(PKG, "JsonInput.Log.FinishedProcessing"));
       return false;
     }
     // Close previous file if needed
     if (data.file != null) data.file.close();
     // get file
     data.file = (FileObject) data.files.getFile(data.filenr);
     if (meta.isIgnoreEmptyFile() && data.file.getContent().getSize() == 0) {
       // log only basic as a warning (was before logError)
       logBasic(
           BaseMessages.getString(PKG, "JsonInput.Error.FileSizeZero", "" + data.file.getName()));
       openNextFile();
     }
     readFileOrString();
   } catch (Exception e) {
     logError(
         BaseMessages.getString(
             PKG,
             "JsonInput.Log.UnableToOpenFile",
             "" + data.filenr,
             data.file.toString(),
             e.toString()));
     stopAll();
     setErrors(1);
     return false;
   }
   return true;
 }
Пример #20
0
  private boolean deleteOrMoveFiles(
      SFTPv3Client sftpClient, String filename, String destinationFolder) {
    boolean retval = false;

    // Delete the file if this is needed!
    if (afterFtpPut.equals("delete_file")) {
      try {
        sftpClient.rm(filename);
        retval = true;
        if (log.isDetailed()) {
          logDetailed(BaseMessages.getString(PKG, "JobSSH2GET.Log.DeletedFile", filename));
        }
      } catch (Exception e) {
        logError(
            BaseMessages.getString(PKG, "JobSSH2GET.Log.Error.CanNotDeleteRemoteFile", filename),
            e);
      }

    } else if (afterFtpPut.equals("move_file")) {
      String DestinationFullFilename = destinationFolder + Const.FILE_SEPARATOR + filename;
      try {
        sftpClient.mv(filename, DestinationFullFilename);
        retval = true;
        if (log.isDetailed()) {
          logDetailed(BaseMessages.getString(PKG, "JobSSH2GET.Log.DeletedFile", filename));
        }
      } catch (Exception e) {
        logError(
            BaseMessages.getString(
                PKG, "JobSSH2GET.Log.Error.MovedFile", filename, destinationFolder),
            e);
      }
    }
    return retval;
  }
  private void ok() {
    if (Const.isEmpty(wStepname.getText())) return;

    input.setDatabase(transMeta.findDatabase(wConnection.getText()));
    input.setSchemaname(wSchemaname.getText());
    input.setTablename(wTablenameText.getText());
    input.setTablenameInField(wTablenameInField.getSelection());
    input.setDynamicTablenameField(wTableName.getText());
    input.setDynamicColumnnameField(wColumnName.getText());
    input.setResultFieldName(wResult.getText());

    stepname = wStepname.getText(); // return value

    if (input.getDatabase() == null) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setMessage(
          BaseMessages.getString(
              PKG, "ColumnExistsDialog.InvalidConnection.DialogMessage")); // $NON-NLS-1$
      mb.setText(
          BaseMessages.getString(
              PKG, "ColumnExistsDialog.InvalidConnection.DialogTitle")); // $NON-NLS-1$
      mb.open();
    }

    dispose();
  }
  private void doSelectConnection(boolean clearCurrentData) {
    try {
      if (clearCurrentData) {
        tableViewFields.table.removeAll();
        comboCube.removeAll();
      }

      if (addConnectionLine.getText() != null) {
        DatabaseMeta dbMeta = transMeta.findDatabase(addConnectionLine.getText());
        if (dbMeta != null) {
          PaloCellOutputData data = new PaloCellOutputData(dbMeta);
          data.helper.connect();
          List<String> cubes = data.helper.getCubesNames();
          Collections.sort(cubes, new PaloNameComparator());
          for (String cubeName : cubes) {
            if (comboCube.indexOf(cubeName) == -1) {
              comboCube.add(cubeName);
            }
          }
          data.helper.disconnect();
        }
      }
    } catch (Exception ex) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "PaloCellOutputDialog.RetreiveCubesErrorTitle"),
          BaseMessages.getString(PKG, "PaloCellOutputDialog.RetreiveCubesError"),
          ex);
    }
  }
Пример #23
0
  /**
   * Creates the default kettle properties file, containing the standard header.
   *
   * @param directory the directory
   */
  private static void createDefaultKettleProperties(String directory) {

    String kpFile = directory + Const.FILE_SEPARATOR + Const.KETTLE_PROPERTIES;
    File file = new File(kpFile);
    if (!file.exists()) {
      FileOutputStream out = null;
      try {
        out = new FileOutputStream(file);
        out.write(Const.getKettlePropertiesFileHeader().getBytes());
      } catch (IOException e) {
        System.err.println(
            BaseMessages.getString(
                PKG,
                "Props.Log.Error.UnableToCreateDefaultKettleProperties.Message",
                Const.KETTLE_PROPERTIES,
                kpFile));
        System.err.println(e.getStackTrace());
      } finally {
        if (out != null) {
          try {
            out.close();
          } catch (IOException e) {
            System.err.println(
                BaseMessages.getString(
                    PKG,
                    "Props.Log.Error.UnableToCreateDefaultKettleProperties.Message",
                    Const.KETTLE_PROPERTIES,
                    kpFile));
            System.err.println(e.getStackTrace());
          }
        }
      }
    }
  }
Пример #24
0
  private void ok() {
    if (Const.isEmpty(wStepname.getText())) return;
    input.setCommitSize(Const.toInt(wCommit.getText(), 0));
    stepname = wStepname.getText(); // return value
    input.setSqlFieldName(wSQLFieldName.getText());
    // copy info to TextFileInputMeta class (input)
    input.setDatabaseMeta(transMeta.findDatabase(wConnection.getText()));

    input.setInsertField(wInsertField.getText());
    input.setUpdateField(wUpdateField.getText());
    input.setDeleteField(wDeleteField.getText());
    input.setReadField(wReadField.getText());
    input.setSqlFromfile(wSQLFromFile.getSelection());
    input.SetSendOneStatement(wSendOneStatement.getSelection());
    if (input.getDatabaseMeta() == null) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      mb.setMessage(
          BaseMessages.getString(
              PKG, "ExecSQLRowDialog.InvalidConnection.DialogMessage")); // $NON-NLS-1$
      mb.setText(
          BaseMessages.getString(
              PKG, "ExecSQLRowDialog.InvalidConnection.DialogTitle")); // $NON-NLS-1$
      mb.open();
      return;
    }

    dispose();
  }
Пример #25
0
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info) {
    CheckResult cr;

    if (input.length > 0) {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_OK,
              BaseMessages.getString(
                  PKG, "DenormaliserMeta.CheckResult.ReceivingInfoFromOtherSteps"),
              stepMeta); //$NON-NLS-1$
      remarks.add(cr);
    } else {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_ERROR,
              BaseMessages.getString(PKG, "DenormaliserMeta.CheckResult.NoInputReceived"),
              stepMeta); //$NON-NLS-1$
      remarks.add(cr);
    }
  }
Пример #26
0
  public boolean canFlipToNextPage() {
    DatabaseMeta source = getSourceDatabase();
    DatabaseMeta target = getTargetDatabase();

    if (source == null && target == null) {
      setErrorMessage(
          BaseMessages.getString(PKG, "CopyTableWizardPage1.SourceAndTargetIsNull.DialogMessage"));
      return false;
    } else if (source == null && target != null) {
      setErrorMessage(
          BaseMessages.getString(PKG, "CopyTableWizardPage1.SourceIsNull.DialogMessage"));
      return false;
    } else if (source != null && target == null) {
      setErrorMessage(
          BaseMessages.getString(PKG, "CopyTableWizardPage1.TargetIsNull.DialogMessage"));
      return false;
    } else if (source != null && target != null && source.equals(target)) {
      setErrorMessage(
          BaseMessages.getString(PKG, "CopyTableWizardPage1.SourceAndTargetIsSame.DialogMessage"));
      return false;
    } else {
      setErrorMessage(null);
      setMessage(BaseMessages.getString(PKG, "CopyTableWizardPage1.GoOnNext.DialogMessage"));
      return true;
    }
  }
  public RowMetaInterface getRequiredFields(VariableSpace space) throws KettleException {
    String realTableName = space.environmentSubstitute(tableName);
    String realSchemaName = space.environmentSubstitute(schemaName);

    if (databaseMeta != null) {
      Database db = new Database(loggingObject, databaseMeta);
      try {
        db.connect();

        if (!Const.isEmpty(realTableName)) {
          String schemaTable =
              databaseMeta.getQuotedSchemaTableCombination(realSchemaName, realTableName);

          // Check if this table exists...
          if (db.checkTableExists(schemaTable)) {
            return db.getTableFields(schemaTable);
          } else {
            throw new KettleException(
                BaseMessages.getString(PKG, "GPBulkLoaderMeta.Exception.TableNotFound"));
          }
        } else {
          throw new KettleException(
              BaseMessages.getString(PKG, "GPBulkLoaderMeta.Exception.TableNotSpecified"));
        }
      } catch (Exception e) {
        throw new KettleException(
            BaseMessages.getString(PKG, "GPBulkLoaderMeta.Exception.ErrorGettingFields"), e);
      } finally {
        db.disconnect();
      }
    } else {
      throw new KettleException(
          BaseMessages.getString(PKG, "GPBulkLoaderMeta.Exception.ConnectionNotDefined"));
    }
  }
Пример #28
0
  private boolean OpenFile() throws Exception {
    data.oneFileOpened = true;
    String realFilename = environmentSubstitute(meta.getFilename());
    if (log.isBasic()) {
      logBasic(BaseMessages.getString(PKG, "AccessOutput.log.WritingToFile", realFilename));
    }
    FileObject fileObject = KettleVFS.getFileObject(realFilename, getTransMeta());
    File file = FileUtils.toFile(fileObject.getURL());

    // First open or create the access file
    if (!file.exists()) {
      if (meta.isFileCreated()) {
        data.db = Database.create(file);
      } else {
        logError(
            BaseMessages.getString(PKG, "AccessOutput.InitError.FileDoesNotExist", realFilename));
        return false;
      }
    } else {
      data.db = Database.open(file);
    }

    // Add the filename to the result object...
    //
    if (meta.isAddToResultFiles()) {
      ResultFile resultFile =
          new ResultFile(
              ResultFile.FILE_TYPE_GENERAL, fileObject, getTransMeta().getName(), toString());
      resultFile.setComment("This file was created with an access output step");
      addResultFile(resultFile);
    }

    return true;
  }
Пример #29
0
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
    try {
      // Grab a row
      Object[] outputRowData = getOneRow();
      if (outputRowData == null) {
        setOutputDone(); // signal end to receiver(s)
        return false; // end of data or error.
      }

      if (isRowLevel())
        logRowlevel(
            BaseMessages.getString(
                PKG, "LoadFileInput.Log.ReadRow", data.outputRowMeta.getString(outputRowData)));

      putRow(data.outputRowMeta, outputRowData);

      if (meta.getRowLimit() > 0
          && data.rownr > meta.getRowLimit()) // limit has been reached: stop now.
      {
        setOutputDone();
        return false;
      }
    } catch (KettleException e) {
      logError(
          BaseMessages.getString(
              PKG, "LoadFileInput.ErrorInStepRunning", e.getMessage())); // $NON-NLS-1$
      logError(Const.getStackTracker(e));
      setErrors(1);
      stopAll();
      setOutputDone(); // signal end to receiver(s)
      return false;
    }
    return true;
  }
Пример #30
0
 private int showDatabaseWarning(boolean includeCancel) {
   MessageBox mb =
       new MessageBox(shell, SWT.OK | (includeCancel ? SWT.CANCEL : SWT.NONE) | SWT.ICON_ERROR);
   mb.setMessage(BaseMessages.getString(PKG, "SapInputDialog.InvalidConnection.DialogMessage"));
   mb.setText(BaseMessages.getString(PKG, "SapInputDialog.InvalidConnection.DialogTitle"));
   return mb.open();
 }