Java Code Examples for org.pentaho.di.job.JobMeta#setDescription()

The following examples show how to use org.pentaho.di.job.JobMeta#setDescription() . 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: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testVerifyRule_SameAsMinimumLenghtDescription_EnabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, true );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription(
    "1234567890" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( jobMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.APPROVAL, feedback.getResultType() );
  assertTrue( feedback.isApproval() );
}
 
Example 2
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testVerifyRule_LongDescription_EnabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, true );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription(
    "A very long description that has more characters than the minimum required to be a valid one!" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( jobMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.APPROVAL, feedback.getResultType() );
  assertTrue( feedback.isApproval() );
}
 
Example 3
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private JobMeta buildJobMeta( final RepositoryFile file, final RepositoryDirectoryInterface parentDir,
                              final NodeRepositoryFileData data, final ObjectRevision revision )
  throws KettleException {
  JobMeta jobMeta = new JobMeta();
  jobMeta.setName( file.getTitle() );
  jobMeta.setFilename( file.getName() );
  jobMeta.setDescription( file.getDescription() );
  jobMeta.setObjectId( new StringObjectId( file.getId().toString() ) );
  jobMeta.setObjectRevision( revision );
  jobMeta.setRepository( this );
  jobMeta.setRepositoryDirectory( parentDir );
  jobMeta.setMetaStore( getMetaStore() );
  readJobMetaSharedObjects( jobMeta ); // This should read from the local cache
  jobDelegate.dataNodeToElement( data.getNode(), jobMeta );
  jobMeta.clearChanged();
  return jobMeta;
}
 
Example 4
Source File: JobHasDescriptionImportRuleIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void testRule() throws Exception {

    JobMeta jobMeta = new JobMeta();
    jobMeta.setDescription( "This job is used for testing an import rule" );

    PluginRegistry registry = PluginRegistry.getInstance();

    PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "JobHasDescription" );
    assertNotNull( "The 'job has description' rule could not be found in the plugin registry!", plugin );

    JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) registry.loadClass( plugin );
    assertNotNull( "The 'job has description rule' class could not be loaded by the plugin registry!", plugin );

    rule.setMinLength( 20 );
    rule.setEnabled( true );

    List<ImportValidationFeedback> feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty() );
    assertTrue(
      "An approval ruling was expected",
      feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL );

    rule.setMinLength( 2000 );
    rule.setEnabled( true );

    feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty() );
    assertTrue(
      "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR );

    rule.setEnabled( false );

    feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't expect any feedback from the 'job has description rule' while disabled", feedback
      .isEmpty() );
  }
 
Example 5
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_NullDescription_EnabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, true );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( null );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( jobMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 6
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_EmptyDescription_EnabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, true );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( "" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( jobMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 7
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_ShortDescription_EnabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, true );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( "short" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( jobMeta );

  assertNotNull( feedbackList );
  assertFalse( feedbackList.isEmpty() );
  ImportValidationFeedback feedback = feedbackList.get( 0 );
  assertNotNull( feedback );
  assertEquals( ImportValidationResultType.ERROR, feedback.getResultType() );
  assertTrue( feedback.isError() );
}
 
Example 8
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_NullDescription_DisabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, false );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( null );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 9
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_EmptyDescription_DisabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, false );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( "" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 10
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_ShortDescription_DisabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, false );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription( "short" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 11
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_SameAsMinimumLenghtDescription_DisabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, false );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription(
    "1234567890" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 12
Source File: JobHasDescriptionImportRuleTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testVerifyRule_LongDescription_DisabledRule() {
  JobHasDescriptionImportRule importRule = getImportRule( 10, false );
  JobMeta jobMeta = new JobMeta();
  jobMeta.setDescription(
    "A very long description that has more characters than the minimum required to be a valid one!" );

  List<ImportValidationFeedback> feedbackList = importRule.verifyRule( null );

  assertNotNull( feedbackList );
  assertTrue( feedbackList.isEmpty() );
}
 
Example 13
Source File: RepositoryTestBase.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected JobMeta createJobMeta( String jobName ) throws Exception {
  RepositoryDirectoryInterface rootDir = loadStartDirectory();
  JobMeta jobMeta = new JobMeta();
  jobMeta.setName( jobName );
  jobMeta.setDescription( EXP_JOB_DESC );
  jobMeta.setExtendedDescription( EXP_JOB_EXTENDED_DESC );
  jobMeta.setRepositoryDirectory( rootDir.findDirectory( DIR_JOBS ) );
  jobMeta.setJobversion( EXP_JOB_VERSION );
  jobMeta.setJobstatus( EXP_JOB_STATUS );
  jobMeta.setCreatedUser( EXP_JOB_CREATED_USER );
  jobMeta.setCreatedDate( EXP_JOB_CREATED_DATE );
  jobMeta.setModifiedUser( EXP_JOB_MOD_USER );
  jobMeta.setModifiedDate( EXP_JOB_MOD_DATE );
  jobMeta.addParameterDefinition( EXP_JOB_PARAM_1_NAME, EXP_JOB_PARAM_1_DEF, EXP_JOB_PARAM_1_DESC );
  // TODO mlowery other jobLogTable fields could be set for testing here
  JobLogTable jobLogTable = JobLogTable.getDefault( jobMeta, jobMeta );
  jobLogTable.setConnectionName( EXP_JOB_LOG_TABLE_CONN_NAME );
  jobLogTable.setLogInterval( EXP_JOB_LOG_TABLE_INTERVAL );
  jobLogTable.setSchemaName( EXP_JOB_LOG_TABLE_SCHEMA_NAME );
  jobLogTable.setLogSizeLimit( EXP_JOB_LOG_TABLE_SIZE_LIMIT );
  jobLogTable.setTableName( EXP_JOB_LOG_TABLE_TABLE_NAME );
  jobLogTable.setTimeoutInDays( EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS );
  jobMeta.setJobLogTable( jobLogTable );
  // TODO mlowery other jobEntryLogTable fields could be set for testing here
  JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault( jobMeta, jobMeta );
  jobEntryLogTable.setConnectionName( EXP_JOB_LOG_TABLE_CONN_NAME );
  jobEntryLogTable.setSchemaName( EXP_JOB_LOG_TABLE_SCHEMA_NAME );
  jobEntryLogTable.setTableName( EXP_JOB_LOG_TABLE_TABLE_NAME );
  jobEntryLogTable.setTimeoutInDays( EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS );
  jobMeta.setJobEntryLogTable( jobEntryLogTable );
  // TODO mlowery other channelLogTable fields could be set for testing here
  ChannelLogTable channelLogTable = ChannelLogTable.getDefault( jobMeta, jobMeta );
  channelLogTable.setConnectionName( EXP_JOB_LOG_TABLE_CONN_NAME );
  channelLogTable.setSchemaName( EXP_JOB_LOG_TABLE_SCHEMA_NAME );
  channelLogTable.setTableName( EXP_JOB_LOG_TABLE_TABLE_NAME );
  channelLogTable.setTimeoutInDays( EXP_JOB_LOG_TABLE_TIMEOUT_IN_DAYS );
  jobMeta.setChannelLogTable( channelLogTable );
  jobMeta.setBatchIdPassed( EXP_JOB_BATCH_ID_PASSED );
  jobMeta.setSharedObjectsFile( EXP_JOB_SHARED_OBJECTS_FILE );
  DatabaseMeta entryDbMeta = createDatabaseMeta( EXP_DBMETA_NAME_JOB.concat( jobName ) );
  repository.save( entryDbMeta, VERSION_COMMENT_V1, null );
  deleteStack.push( entryDbMeta );
  JobEntryCopy jobEntryCopy1 = createJobEntry1Copy( entryDbMeta );
  jobMeta.addJobEntry( jobEntryCopy1 );
  JobEntryCopy jobEntryCopy2 = createJobEntry2Copy( entryDbMeta );
  jobMeta.addJobEntry( jobEntryCopy2 );
  jobMeta.addJobHop( createJobHopMeta( jobEntryCopy1, jobEntryCopy2 ) );
  jobMeta.addNote( createNotePadMeta( jobName ) );
  return jobMeta;
}