Exemplo n.º 1
0
 public StepPartitioningMeta(Node partitioningMethodNode) throws KettleXMLException {
   this();
   setMethod(getMethod(XMLHandler.getTagValue(partitioningMethodNode, "method")));
   partitionSchemaName = XMLHandler.getTagValue(partitioningMethodNode, "schema_name");
   hasChanged = false;
   if (partitioner != null) {
     partitioner.loadXML(partitioningMethodNode);
   }
   if (methodType != PARTITIONING_METHOD_NONE && Const.isEmpty(partitionSchemaName)) {
     throw new RuntimeException("bohoo!");
   }
 }
Exemplo n.º 2
0
  public static final String getMethod(String description) {
    if (Const.isEmpty(description)) return methodCodes[PARTITIONING_METHOD_NONE];

    for (int i = 0; i < methodDescriptions.length; i++) {
      if (methodDescriptions[i].equalsIgnoreCase(description)) {
        return methodCodes[i];
      }
    }

    for (int i = 0; i < methodCodes.length; i++) {
      if (methodCodes[i].equalsIgnoreCase(description)) return methodCodes[i];
    }

    if (StepLoader.getPartitioner(description) != null) {
      return description;
    }
    return methodCodes[PARTITIONING_METHOD_NONE];
  }
Exemplo n.º 3
0
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepinfo,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info) {
    CheckResult cr;
    String error_message = ""; // $NON-NLS-1$

    // See if we have input streams leading to this step!
    if (input.length > 0) {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_OK,
              Messages.getString("DynamicSQLRowMeta.CheckResult.ReceivingInfo"),
              stepinfo); //$NON-NLS-1$
      remarks.add(cr);
    } else {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_ERROR,
              Messages.getString("DynamicSQLRowMeta.CheckResult.NoInputReceived"),
              stepinfo); //$NON-NLS-1$
      remarks.add(cr);
    }

    // Check for SQL field
    if (Const.isEmpty(sqlfieldname)) {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_ERROR,
              Messages.getString("DynamicSQLRowMeta.CheckResult.SQLFieldNameMissing"),
              stepinfo); //$NON-NLS-1$
      remarks.add(cr);
    } else {
      ValueMetaInterface vfield = prev.searchValueMeta(sqlfieldname);
      if (vfield == null)
        cr =
            new CheckResult(
                CheckResult.TYPE_RESULT_ERROR,
                Messages.getString("DynamicSQLRowMeta.CheckResult.SQLFieldNotFound", sqlfieldname),
                stepinfo); //$NON-NLS-1$
      else
        cr =
            new CheckResult(
                CheckResult.TYPE_RESULT_OK,
                Messages.getString(
                    "DynamicSQLRowMeta.CheckResult.SQLFieldFound",
                    sqlfieldname,
                    vfield.getOrigin()),
                stepinfo);
      remarks.add(cr);
    }

    if (databaseMeta != null) {
      Database db = new Database(databaseMeta);
      databases = new Database[] {db}; // Keep track of this one for cancelQuery

      try {
        db.connect();
        if (sql != null && sql.length() != 0) {

          error_message = ""; // $NON-NLS-1$

          RowMetaInterface r = db.getQueryFields(sql, true);
          if (r != null) {
            cr =
                new CheckResult(
                    CheckResult.TYPE_RESULT_OK,
                    Messages.getString("DynamicSQLRowMeta.CheckResult.QueryOK"),
                    stepinfo); //$NON-NLS-1$
            remarks.add(cr);
          } else {
            error_message =
                Messages.getString("DynamicSQLRowMeta.CheckResult.InvalidDBQuery"); // $NON-NLS-1$
            cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepinfo);
            remarks.add(cr);
          }
        }
      } catch (KettleException e) {
        error_message =
            Messages.getString("DynamicSQLRowMeta.CheckResult.ErrorOccurred")
                + e.getMessage(); // $NON-NLS-1$
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepinfo);
        remarks.add(cr);
      } finally {
        db.disconnect();
      }
    } else {
      error_message =
          Messages.getString("DynamicSQLRowMeta.CheckResult.InvalidConnection"); // $NON-NLS-1$
      cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, error_message, stepinfo);
      remarks.add(cr);
    }
  }
Exemplo n.º 4
0
 public String getRequiredFilesDesc(String tt) {
   if (Const.isEmpty(tt)) return RequiredFoldersDesc[0];
   if (tt.equalsIgnoreCase(RequiredFoldersCode[1])) return RequiredFoldersDesc[1];
   else return RequiredFoldersDesc[0];
 }
Exemplo n.º 5
0
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepinfo,
      RowMetaInterface prev,
      String input[],
      String output[],
      RowMetaInterface info) {
    CheckResult cr;

    // See if we get input...
    if (isFoldernameDynamic) {
      if (input.length > 0)
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_OK,
                Messages.getString("GetSubFoldersMeta.CheckResult.InputOk"),
                stepinfo);
      else
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("GetSubFoldersMeta.CheckResult.InputErrorKo"),
                stepinfo);
      remarks.add(cr);

      if (Const.isEmpty(dynamicFoldernameField))
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("GetSubFoldersMeta.CheckResult.FolderFieldnameMissing"),
                stepinfo);
      else
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_OK,
                Messages.getString("GetSubFoldersMeta.CheckResult.FolderFieldnameOk"),
                stepinfo);

      remarks.add(cr);
    } else {
      if (input.length > 0)
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("GetSubFoldersMeta.CheckResult.NoInputError"),
                stepinfo);
      else
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_OK,
                Messages.getString("GetSubFoldersMeta.CheckResult.NoInputOk"),
                stepinfo);
      remarks.add(cr);
      // check specified folder names
      FileInputList fileList = getFolderList(transMeta);
      if (fileList.nrOfFiles() == 0) {
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("GetSubFoldersMeta.CheckResult.ExpectedFoldersError"),
                stepinfo);
        remarks.add(cr);
      } else {
        cr =
            new CheckResult(
                CheckResultInterface.TYPE_RESULT_OK,
                Messages.getString(
                    "GetSubFoldersMeta.CheckResult.ExpectedFilesOk", "" + fileList.nrOfFiles()),
                stepinfo);
        remarks.add(cr);
      }
    }
  }