/** * Find a job using the container/carte object ID. * * @param id * the container/carte object ID * @return The job if it's found, null if the ID couldn't be found in the job map. */ public synchronized Job findJob( String id ) { for ( Job job : jobMap.values() ) { if ( job.getContainerObjectId().equals( id ) ) { return job; } } return null; }
@Override WebResult generateBody( HttpServletRequest request, HttpServletResponse response, boolean useXML ) throws IOException, KettleException { final String xml = IOUtils.toString( request.getInputStream() ); // Parse the XML, create a job configuration JobConfiguration jobConfiguration = JobConfiguration.fromXML( xml ); Job job = createJob( jobConfiguration ); String message = "Job '" + job.getJobname() + "' was added to the list with id " + job.getContainerObjectId(); return new WebResult( WebResult.STRING_OK, message, job.getContainerObjectId() ); } }
public synchronized void registerJob( Job job, JobConfiguration jobConfiguration ) { job.setContainerObjectId( UUID.randomUUID().toString() ); CarteObjectEntry entry = new CarteObjectEntry( job.getJobMeta().getName(), job.getContainerObjectId() ); jobMap.put( entry, job ); configurationMap.put( entry, jobConfiguration ); }
/** * Sets the parent job. * * @param parentJob * the new parent job */ public void setParentJob( Job parentJob ) { this.parentJob = parentJob; this.logLevel = parentJob.getLogLevel(); this.log = new LogChannel( this, parentJob ); this.containerObjectId = parentJob.getContainerObjectId(); }
private static Job mockJob( int id ) { Job job = mock( Job.class ); when( job.getContainerObjectId() ).thenReturn( JOB_NAME_STRING + id ); return job; }
@Test public void testNewJobWithContainerObjectId() { Repository repository = mock( Repository.class ); JobMeta meta = mock( JobMeta.class ); String carteId = UUID.randomUUID().toString(); doReturn( carteId ).when( meta ).getContainerObjectId(); Job job = new Job( repository, meta ); assertEquals( carteId, job.getContainerObjectId() ); }
/** * This test demonstrates the fix for PDI-17398. * Two schedules -> two Carte object Ids -> two log channel Ids */ @Test public void testTwoJobsGetDifferentLogChannelIdWithDifferentCarteId() { Repository repository = mock( Repository.class ); JobMeta meta1 = mock( JobMeta.class ); JobMeta meta2 = mock( JobMeta.class ); String carteId1 = UUID.randomUUID().toString(); String carteId2 = UUID.randomUUID().toString(); doReturn( carteId1 ).when( meta1 ).getContainerObjectId(); doReturn( carteId2 ).when( meta2 ).getContainerObjectId(); Job job1 = new Job( repository, meta1 ); Job job2 = new Job( repository, meta2 ); assertNotEquals( job1.getContainerObjectId(), job2.getContainerObjectId() ); assertNotEquals( job1.getLogChannelId(), job2.getLogChannelId() ); }
resultId = job.getContainerObjectId(); } else { Node node =