org.pentaho.di.core.CheckResult Java Examples

The following examples show how to use org.pentaho.di.core.CheckResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaConsumerMeta.java    From pentaho-kafka-consumer with Apache License 2.0 6 votes vote down vote up
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
                  String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
                  IMetaStore metaStore) {

    if (topic == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidTopic"), stepMeta));
    }
    if (field == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidField"), stepMeta));
    }
    if (keyField == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidKeyField"), stepMeta));
    }
    try {
        new ConsumerConfig(kafkaProperties);
    } catch (IllegalArgumentException e) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta));
    }
}
 
Example #2
Source File: KafkaProducerMeta.java    From pentaho-kafka-producer with Apache License 2.0 6 votes vote down vote up
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
		String input[], String output[], RowMetaInterface info) {

	if (isEmpty(topic)) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
				Messages.getString("KafkaProducerMeta.Check.InvalidTopic"), stepMeta));
	}
	if (isEmpty(messageField)) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
				Messages.getString("KafkaProducerMeta.Check.InvalidMessageField"), stepMeta));
	}
	try {
		new ProducerConfig(kafkaProperties);
	} catch (IllegalArgumentException e) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta));
	}
}
 
Example #3
Source File: MultiMergeJoinMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
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 Need to check for the following: 1) Join type must be one of INNER / LEFT OUTER / RIGHT OUTER / FULL OUTER
   * 2) Number of input streams must be two (for now at least) 3) The field names of input streams must be unique
   */
  CheckResult cr =
      new CheckResult( CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString( PKG,
          "MultiMergeJoinMeta.CheckResult.StepNotVerified" ), stepMeta );
  remarks.add( cr );
}
 
Example #4
Source File: AbortMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  // See if we have input streams leading to this step!
  if ( input.length == 0 ) {
    CheckResult cr =
      new CheckResult( CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(
        PKG, "AbortMeta.CheckResult.NoInputReceivedError" ), stepinfo );
    remarks.add( cr );
  }
}
 
Example #5
Source File: MQTTClientBuilder.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
static void checkVersion( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                          String value ) {
  String version = space.environmentSubstitute( value );
  if ( !StringUtil.isEmpty( version ) ) {
    try {
      ( new MqttConnectOptions() ).setMqttVersion( Integer.parseInt( version ) );
    } catch ( Exception e ) {
      remarks.add( new CheckResult(
        CheckResultInterface.TYPE_RESULT_ERROR,
        getString( PKG, "MQTTMeta.CheckResult.NotCorrectVersion",
          getString( PKG, "MQTTDialog.Options." + MQTT_VERSION ), version ),
        stepMeta ) );
    }
  }
}
 
Example #6
Source File: ElasticSearchBulkMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void checkInputFields( List<CheckResultInterface> remarks, RowMetaInterface prev, StepMeta stepMeta ) {

    if ( prev != null && prev.size() > 0 ) {
      if ( isJsonInsert() ) { // JSON
        if ( StringUtils.isBlank( getJsonField() ) ) { // jsonField not set
          String jsonFieldLabel = BaseMessages.getString( PKG, "ElasticSearchBulkDialog.JsonField.Label" );
          String isJsonLabel = BaseMessages.getString( PKG, "ElasticSearchBulkDialog.IsJson.Label" );
          remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG,
                  "ElasticSearchBulkMeta.CheckResult.MissingRequiredDependent", jsonFieldLabel, isJsonLabel ),
                  stepMeta ) );
        } else if ( prev.indexOfValue( getJsonField() ) < 0 ) { // jsonField not in input
          remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG,
                  "ElasticSearchBulkMeta.CheckResult.MissingInput", getJsonField() ), stepMeta ) );
        }
      } else { // not JSON
        for ( Field f : fields ) {
          if ( prev.indexOfValue( f.name ) < 0 ) { // fields not found
            remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG,
                    "ElasticSearchBulkMeta.CheckResult.MissingInput", f.name ), stepMeta ) );
          }
        }
      }
    } else { // no input
      remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG,
              "ElasticSearchBulkMeta.CheckResult.NoInput" ), stepMeta ) );
    }

  }
 
Example #7
Source File: ElasticSearchBulkMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void checkRequiredString( List<CheckResultInterface> remarks, StepMeta stepMeta, String value,
                                  String fieldName ) {
  if ( StringUtils.isBlank( value ) ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, BaseMessages.getString( PKG,
            "ElasticSearchBulkMeta.CheckResult.MissingRequired", fieldName ), stepMeta ) );
  } else {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_OK, BaseMessages.getString( PKG,
            "ElasticSearchBulkMeta.CheckResult.RequiredOK", fieldName, value ), stepMeta ) );
  }
}
 
Example #8
Source File: StepOption.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void checkBoolean( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                                 String identifier, String value ) {
  if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) && null == BooleanUtils
    .toBooleanObject( space.environmentSubstitute( value ) ) ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotABoolean", identifier ),
      stepMeta ) );
  }
}
 
Example #9
Source File: StepOption.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void checkLong( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                              String identifier, String value ) {
  try {
    if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) ) {
      Long.parseLong( space.environmentSubstitute( value ) );
    }
  } catch ( NumberFormatException e ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotAInteger", identifier ),
      stepMeta ) );
  }
}
 
Example #10
Source File: StepOption.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void checkInteger( List<CheckResultInterface> remarks, StepMeta stepMeta, VariableSpace space,
                                 String identifier, String value ) {
  try {
    if ( !StringUtil.isEmpty( space.environmentSubstitute( value ) ) ) {
      Integer.parseInt( space.environmentSubstitute( value ) );
    }
  } catch ( NumberFormatException e ) {
    remarks.add( new CheckResult(
      CheckResultInterface.TYPE_RESULT_ERROR,
      BaseMessages.getString( PKG, "StepOption.CheckResult.NotAInteger", identifier ),
      stepMeta ) );
  }
}
 
Example #11
Source File: RowGenerator.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
  try {
    meta = (RowGeneratorMeta) smi;
    data = (RowGeneratorData) sdi;

    if ( super.init( smi, sdi ) ) {
      // Determine the number of rows to generate...
      data.rowLimit = Const.toLong( environmentSubstitute( meta.getRowLimit() ), -1L );
      data.rowsWritten = 0L;
      data.delay = Const.toLong( environmentSubstitute( meta.getIntervalInMs() ), -1L );

      if ( data.rowLimit < 0L ) { // Unable to parse
        logError( BaseMessages.getString( PKG, "RowGenerator.Wrong.RowLimit.Number" ) );
        return false; // fail
      }

      // Create a row (constants) with all the values in it...
      List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>(); // stores the errors...
      RowMetaAndData outputRow = buildRow( meta, remarks, getStepname() );
      if ( !remarks.isEmpty() ) {
        for ( int i = 0; i < remarks.size(); i++ ) {
          CheckResult cr = (CheckResult) remarks.get( i );
          logError( cr.getText() );
        }
        return false;
      }

      data.outputRowData = outputRow.getData();
      data.outputRowMeta = outputRow.getRowMeta();
      return true;
    }
    return false;
  } catch ( Exception e ) {
    setErrors( 1L );
    logError( "Error initializing step", e );
    return false;
  }
}
 
Example #12
Source File: MergeJoinMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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 Need to check for the following: 1) Join type must be one of INNER / LEFT OUTER / RIGHT OUTER / FULL OUTER
   * 2) Number of input streams must be two (for now at least) 3) The field names of input streams must be unique
   */
  CheckResult cr =
    new CheckResult( CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(
      PKG, "MergeJoinMeta.CheckResult.StepNotVerified" ), stepMeta );
  remarks.add( cr );
}
 
Example #13
Source File: GoogleSpreadsheetOutputMeta.java    From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    if (prev == null || prev.size() == 0) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_WARNING, "Not receiving any fields from previous steps!", stepMeta));
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, String.format("Step is connected to previous one, receiving %1$d fields", prev.size()), stepMeta));
    }

    if (input.length > 0) {
        remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Step is receiving info from other steps", stepMeta) );
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "No input received from other steps!", stepMeta));
    }
}
 
Example #14
Source File: FilterRowsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private Optional<CheckResult> checkTarget( StepMeta stepMeta, String target, String targetStepName,
                                           String[] output ) {
  if ( targetStepName != null ) {
    int trueTargetIdx = Const.indexOfString( targetStepName, output );
    if ( trueTargetIdx < 0 ) {
      return Optional.of( new CheckResult(
        CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "FilterRowsMeta.CheckResult.TargetStepInvalid", target, targetStepName ),
        stepMeta
      ) );
    }
  }
  return Optional.empty();
}
 
Example #15
Source File: JobEntryValidatorUtils.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static void addOkRemark( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks ) {
  final int SUBSTRING_LENGTH = 20;
  String value = ValidatorUtils.getValueAsString( source, propertyName );
  String substr = null;
  if ( value != null ) {
    substr = value.substring( 0, Math.min( SUBSTRING_LENGTH, value.length() ) );
    if ( value.length() > SUBSTRING_LENGTH ) {
      substr += "...";
    }
  }
  remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_OK, ValidatorMessages.getString(
    "messages.passed", propertyName, substr ), source ) );
}
 
Example #16
Source File: PentahoMapReduceJobBuilderImplTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyTransMetaCheckSuccess() throws KettleException {
  String inputStepName = "inputStepName";
  String outputStepName = "outputStepName";
  StepMeta inputStepMeta = mock( StepMeta.class );
  when( transMeta.findStep( inputStepName ) ).thenReturn( inputStepMeta );
  RowMetaInterface rowMetaInterface = mock( RowMetaInterface.class );
  when( rowMetaInterface.getFieldNames() ).thenReturn( new String[] { "key", "value" } );
  when( transMeta.getStepFields( inputStepMeta ) ).thenReturn( rowMetaInterface );
  Trans trans = mock( Trans.class );
  when( transFactory.create( transMeta ) ).thenReturn( trans );
  when( trans.getStepInterface( inputStepName, 0 ) ).thenReturn( mock( StepInterface.class ) );
  final StepMeta outputStepMeta = mock( StepMeta.class );
  PentahoMapReduceOutputStepMetaInterface pentahoMapReduceOutputStepMetaInterface =
    mock( PentahoMapReduceOutputStepMetaInterface.class );
  doAnswer( new Answer<Void>() {
    @Override public Void answer( InvocationOnMock invocation ) throws Throwable {
      List<CheckResultInterface> checkResultInterfaces = (List<CheckResultInterface>) invocation.getArguments()[ 0 ];
      checkResultInterfaces.add( new CheckResult( CheckResultInterface.TYPE_RESULT_OK, "test", outputStepMeta ) );
      return null;
    }
  } ).when( pentahoMapReduceOutputStepMetaInterface )
    .checkPmr( anyList(), eq( transMeta ), eq( outputStepMeta ), any( RowMetaInterface.class ) );
  when( outputStepMeta.getStepMetaInterface() ).thenReturn( pentahoMapReduceOutputStepMetaInterface );
  when( transMeta.findStep( outputStepName ) ).thenReturn( outputStepMeta );
  pentahoMapReduceJobBuilder.verifyTransMeta( transMeta, inputStepName, outputStepName );
}
 
Example #17
Source File: PentahoMapReduceJobBuilderImplTest.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
@Test( expected = KettleException.class )
public void testVerifyTransMetaCheckException() throws KettleException {
  String inputStepName = "inputStepName";
  String outputStepName = "outputStepName";
  StepMeta inputStepMeta = mock( StepMeta.class );
  when( transMeta.findStep( inputStepName ) ).thenReturn( inputStepMeta );
  RowMetaInterface rowMetaInterface = mock( RowMetaInterface.class );
  when( rowMetaInterface.getFieldNames() ).thenReturn( new String[] { "key", "value" } );
  when( transMeta.getStepFields( inputStepMeta ) ).thenReturn( rowMetaInterface );
  Trans trans = mock( Trans.class );
  when( transFactory.create( transMeta ) ).thenReturn( trans );
  when( trans.getStepInterface( inputStepName, 0 ) ).thenReturn( mock( StepInterface.class ) );
  final StepMeta outputStepMeta = mock( StepMeta.class );
  PentahoMapReduceOutputStepMetaInterface pentahoMapReduceOutputStepMetaInterface =
    mock( PentahoMapReduceOutputStepMetaInterface.class );
  doAnswer( new Answer<Void>() {
    @Override public Void answer( InvocationOnMock invocation ) throws Throwable {
      List<CheckResultInterface> checkResultInterfaces = (List<CheckResultInterface>) invocation.getArguments()[ 0 ];
      checkResultInterfaces.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, "test", outputStepMeta ) );
      return null;
    }
  } ).when( pentahoMapReduceOutputStepMetaInterface )
    .checkPmr( anyList(), eq( transMeta ), eq( outputStepMeta ), any( RowMetaInterface.class ) );
  when( outputStepMeta.getStepMetaInterface() ).thenReturn( pentahoMapReduceOutputStepMetaInterface );
  when( transMeta.findStep( outputStepName ) ).thenReturn( outputStepMeta );
  try {
    pentahoMapReduceJobBuilder.verifyTransMeta( transMeta, inputStepName, outputStepName );
  } catch ( KettleException e ) {
    assertTrue( e.getMessage().trim().startsWith( BaseMessages.getString( PentahoMapReduceJobBuilderImpl.PKG,
      PentahoMapReduceJobBuilderImpl.PENTAHO_MAP_REDUCE_JOB_BUILDER_IMPL_VALIDATION_ERROR ).trim() ) );
    throw e;
  }
}
 
Example #18
Source File: GoogleSpreadsheetInputMeta.java    From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository, IMetaStore metaStore) {
    if (prev == null || prev.size() == 0) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Not receiving any fields from previous steps.", stepMeta));
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, String.format("Step is connected to previous one, receiving %1$d fields", prev.size()), stepMeta));
    }

    if (input.length > 0) {
        remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Step is receiving info from other steps!", stepMeta) );
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "No input received from other steps.", stepMeta));
    }
}
 
Example #19
Source File: JobEntryValidatorUtils.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static void addGeneralRemark( CheckResultSourceInterface source, String propertyName,
  String validatorName, List<CheckResultInterface> remarks, String key, int level ) {
  remarks.add( new CheckResult(
    CheckResultInterface.TYPE_RESULT_ERROR, ValidatorMessages.getString( key ), source ) );
}
 
Example #20
Source File: JobEntryValidatorUtils.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static void addExceptionRemark( CheckResultSourceInterface source, String propertyName,
  String validatorName, List<CheckResultInterface> remarks, Exception e ) {
  String key = "messages.failed.unableToValidate";
  remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR, ValidatorMessages.getString(
    key, propertyName, e.getClass().getSimpleName() + ": " + e.getLocalizedMessage() ), source ) );
}
 
Example #21
Source File: JobEntryValidatorUtils.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static void addFailureRemark( CheckResultSourceInterface source, String propertyName,
  String validatorName, List<CheckResultInterface> remarks, int level ) {
  String key = "messages.failed." + validatorName;
  remarks.add( new CheckResult( level, ValidatorMessages.getString( key, propertyName ), source ) );
}