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

The following examples show how to use org.pentaho.di.job.JobMeta#addJobEntry() . 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: SpoonJobDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void dupeJobEntry( JobMeta jobMeta, JobEntryCopy jobEntry ) {
  if ( jobEntry == null ) {
    return;
  }

  if ( jobEntry.isStart() ) {
    MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION );
    mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.OnlyUseStartOnce.Message" ) );
    mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.OnlyUseStartOnce.Title" ) );
    mb.open();
    return;
  }

  JobEntryCopy dupejge = (JobEntryCopy) jobEntry.clone();
  dupejge.setNr( jobMeta.findUnusedNr( dupejge.getName() ) );
  if ( dupejge.isDrawn() ) {
    Point p = jobEntry.getLocation();
    dupejge.setLocation( p.x + 10, p.y + 10 );
  }
  jobMeta.addJobEntry( dupejge );
  spoon.refreshGraph();
  spoon.refreshTree();
  spoon.setShellText();

}
 
Example 2
Source File: RunConfigurationDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateLoadedJobs_Spark() {
  JobEntryTrans trans = new JobEntryTrans();
  trans.setRunConfiguration( "key" );

  JobMeta meta = new JobMeta();
  meta.addJobEntry( new JobEntryCopy( trans ) );

  JobMeta[] jobs = new JobMeta[] { meta };
  doReturn( jobs ).when( spoon ).getLoadedJobs();

  SparkRunConfiguration config = new SparkRunConfiguration();
  config.setName( "Test" );

  delegate.updateLoadedJobs( "key", config );

  assertEquals( "Test", trans.getRunConfiguration() );
}
 
Example 3
Source File: RunConfigurationDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateLoadedJobs_PDI16777() {
  JobEntryTrans trans = new JobEntryTrans();
  trans.setRunConfiguration( "key" );

  JobMeta meta = new JobMeta();
  meta.addJobEntry( new JobEntryCopy( trans ) );

  JobMeta[] jobs = new JobMeta[] { meta };
  doReturn( jobs ).when( spoon ).getLoadedJobs();

  DefaultRunConfiguration config = new DefaultRunConfiguration();
  config.setName( "Test" );
  config.setServer( "localhost" );

  delegate.updateLoadedJobs( "key", config );

  assertEquals( "Test", trans.getRunConfiguration() );
  assertEquals( "localhost", trans.getRemoteSlaveServerName() );
}
 
Example 4
Source File: RunConfigurationDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateLoadedJobs_Exception() throws Exception {
  JobEntryTrans trans = new JobEntryTrans();
  trans.setRunConfiguration( "key" );

  JobMeta meta = new JobMeta();
  meta.addJobEntry( new JobEntryCopy( trans ) );

  JobMeta[] jobs = new JobMeta[] { meta };
  doReturn( jobs ).when( spoon ).getLoadedJobs();

  DefaultRunConfiguration config = new DefaultRunConfiguration();
  config.setName( "Test" );
  config.setServer( "localhost" );

  LogChannelInterface log = mock( LogChannelInterface.class );
  doReturn( log ).when( spoon ).getLog();

  PowerMockito.mockStatic( ExtensionPointHandler.class );
  PowerMockito.when( ExtensionPointHandler.class, "callExtensionPoint", any(), any(), any() ).thenThrow( KettleException.class );

  delegate.updateLoadedJobs( "key", config );

  verify( log, times( 1 ) ).logBasic( any() );
}
 
Example 5
Source File: ExecuteJobServletTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private JobMeta buildJobMeta() {
  JobMeta jobMeta = new JobMeta();
  jobMeta.setCarteObjectId( JOB_ID );
  jobMeta.setName( JOB_NAME );
  JobEntryCopy jobEntryCopy = new JobEntryCopy( );
  jobEntryCopy.setEntry( new JobEntryEmpty() );
  jobEntryCopy.setLocation( 150, 50 );
  jobMeta.addJobEntry( jobEntryCopy );
  return jobMeta;
}
 
Example 6
Source File: GetJobImageServletTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private Job buildJob() {
  JobMeta jobMeta = new JobMeta();
  jobMeta.setCarteObjectId( JOB_ID );
  jobMeta.setName( JOB_NAME );
  JobEntryCopy jobEntryCopy = new JobEntryCopy( );
  jobEntryCopy.setEntry( new JobEntryEmpty() );
  jobEntryCopy.setLocation( 150, 50 );
  jobMeta.addJobEntry( jobEntryCopy );

  Job job = new Job( null, jobMeta );
  job.setName( JOB_NAME );
  return job;
}
 
Example 7
Source File: JobEntryTransIntIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Test(timeout=30000)
public void testPDI14676() throws KettleException, IOException, InterruptedException {

  String transFilename = createPDI14676Transformation();

  // Setup Job
  JobEntrySpecial startEntry = new JobEntrySpecial( "Start", true, false );
  JobEntryCopy startCopy = new JobEntryCopy( startEntry );
  startCopy.setLocation( 50, 50 );
  startCopy.setDrawn();

  JobEntryTrans transEntry = new JobEntryTrans( "PDI-13676 example" );
  transEntry.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME );
  transEntry.setFileName( transFilename );
  JobEntryCopy transCopy = new JobEntryCopy( transEntry );
  transCopy.setLocation( 200, 50 );
  transCopy.setDrawn();

  JobMeta jobMeta = new JobMeta();
  jobMeta.addJobEntry( startCopy );
  jobMeta.addJobEntry( transCopy );
  jobMeta.addJobHop( new JobHopMeta( startCopy, transCopy ) );

  // Run job
  Job jobInstance = new Job( null, jobMeta );
  jobInstance.start();

  // Allow job startup time
  while ( !jobInstance.isActive() ) {
    if ( jobInstance.isStopped() || jobInstance.isFinished() ) {
      break;
    }
    Thread.sleep( 10 );
  }

  // Let the job run for a short period
  Thread.sleep( 300 );

  assertFalse( jobInstance.isStopped() );
  assertFalse( jobInstance.isFinished() );

  // Tell the job to stop.
  jobInstance.stopAll();
  assertTrue( jobInstance.isStopped() );

  // Allow the job's thread to stop and be cleaned up
  while ( !jobInstance.isFinished() || jobInstance.isActive() ) {
    Thread.sleep( 10 );      
  }

  // Ensure that the job and the thread have both stopped
  assertTrue( jobInstance.isFinished() );
  assertFalse( jobInstance.isAlive() );
}
 
Example 8
Source File: JobHasNoDisabledHopsImportRuleIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void testRule() throws Exception {

    // Create a job to test.
    //
    JobMeta jobMeta = new JobMeta();

    // Add 3 dummy steps connected with hops.
    //
    JobEntryCopy lastCopy = null;
    for ( int i = 0; i < 3; i++ ) {
      JobEntrySpecial dummy = new JobEntrySpecial();
      dummy.setDummy( true );
      dummy.setName( "dummy" + ( i + 1 ) );

      JobEntryCopy copy = new JobEntryCopy( dummy );
      copy.setLocation( 50 + i * 50, 50 );
      copy.setDrawn();
      jobMeta.addJobEntry( copy );

      if ( lastCopy != null ) {
        JobHopMeta hop = new JobHopMeta( lastCopy, copy );
        jobMeta.addJobHop( hop );
      }
      lastCopy = copy;
    }

    // Load the plugin to test from the registry.
    //
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "JobHasNoDisabledHops" );
    assertNotNull( "The 'job has no disabled hops' rule could not be found in the plugin registry!", plugin );

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

    rule.setEnabled( true );

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

    jobMeta.getJobHop( 0 ).setEnabled( false );

    feedback = rule.verifyRule( jobMeta );
    assertTrue( "We didn't get any feedback from the 'job has no disabled hops'", !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 no disabled hops' while disabled", feedback
      .isEmpty() );
  }
 
Example 9
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;
}