Search in sources :

Example 11 with JobHopMeta

use of org.pentaho.di.job.JobHopMeta in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryJobDelegate method loadJobHopMeta.

public JobHopMeta loadJobHopMeta(ObjectId id_job_hop, List<JobEntryCopy> jobcopies) throws KettleException {
    JobHopMeta jobHopMeta = new JobHopMeta();
    try {
        RowMetaAndData r = getJobHop(id_job_hop);
        if (r != null) {
            long id_jobentry_copy_from = r.getInteger("ID_JOBENTRY_COPY_FROM", -1L);
            long id_jobentry_copy_to = r.getInteger("ID_JOBENTRY_COPY_TO", -1L);
            jobHopMeta.setEnabled(r.getBoolean("ENABLED", true));
            jobHopMeta.setEvaluation(r.getBoolean("EVALUATION", true));
            jobHopMeta.setConditional();
            if (r.getBoolean("UNCONDITIONAL", !jobHopMeta.getEvaluation())) {
                jobHopMeta.setUnconditional();
            }
            jobHopMeta.setFromEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_from)));
            jobHopMeta.setToEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_to)));
            return jobHopMeta;
        } else {
            throw new KettleException("Unable to find job hop with ID : " + id_job_hop);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "JobHopMeta.Exception.UnableToLoadHopInfoRep", "" + id_job_hop), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobHopMeta(org.pentaho.di.job.JobHopMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 12 with JobHopMeta

use of org.pentaho.di.job.JobHopMeta in project pentaho-kettle by pentaho.

the class JobEntryTransIntIT method testPDI14676.

/*
   * Tests whether the job can force a transformation to stop, when the job is asked to stop.
   * A timeout parameter is required, to avoid a failed unit test from running forever.
   */
@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());
}
Also used : JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobHopMeta(org.pentaho.di.job.JobHopMeta) Job(org.pentaho.di.job.Job) Test(org.junit.Test)

Example 13 with JobHopMeta

use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.

the class JobMetaJsonSerializer method serializeHops.

@Override
protected void serializeHops(JobMeta meta, JsonGenerator json) throws IOException {
    // Hops
    json.writeArrayFieldStart(JSON_PROPERTY_HOPS);
    int numberOfHops = meta.nrJobHops();
    for (int i = 0; i < numberOfHops; i++) {
        JobHopMeta hopMeta = meta.getJobHop(i);
        HopInfo hopInfo = new HopInfo(hopMeta);
        json.writeObject(hopInfo);
    }
    json.writeEndArray();
}
Also used : HopInfo(org.pentaho.metaverse.api.model.kettle.HopInfo) JobHopMeta(org.pentaho.di.job.JobHopMeta)

Example 14 with JobHopMeta

use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.

the class JobAnalyzerTest method testAnalyzerJobWithEntriesAndHop.

@Test
public void testAnalyzerJobWithEntriesAndHop() throws MetaverseAnalyzerException {
    JobEntryCopy mockToEntryMeta = mock(JobEntryCopy.class);
    when(mockToEntryMeta.getEntry()).thenReturn(mockJobEntryInterface);
    when(mockToEntryMeta.getParentJobMeta()).thenReturn(mockContent);
    when(mockContent.nrJobEntries()).thenReturn(2);
    when(mockContent.getJobEntry(0)).thenReturn(mockJobEntry);
    when(mockContent.getJobEntry(1)).thenReturn(mockToEntryMeta);
    when(mockContent.nrJobHops()).thenReturn(1);
    final JobHopMeta hop = new JobHopMeta(mockJobEntry, mockToEntryMeta);
    when(mockContent.getJobHop(0)).thenReturn(hop);
    IMetaverseNode node = analyzer.analyze(descriptor, mockJobDoc);
    assertNotNull(node);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobHopMeta(org.pentaho.di.job.JobHopMeta) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 15 with JobHopMeta

use of org.pentaho.di.job.JobHopMeta in project pentaho-metaverse by pentaho.

the class JobMetaJsonSerializerTest method testSerializeHops.

@Test
public void testSerializeHops() throws Exception {
    JobHopMeta jobHopMeta = mock(JobHopMeta.class);
    JobEntryCopy fromJobEntry = mock(JobEntryCopy.class);
    JobEntryCopy toJobEntry = mock(JobEntryCopy.class);
    when(meta.nrJobHops()).thenReturn(2);
    when(meta.getJobHop(anyInt())).thenReturn(jobHopMeta);
    when(jobHopMeta.getFromEntry()).thenReturn(fromJobEntry);
    when(jobHopMeta.getToEntry()).thenReturn(toJobEntry);
    when(jobHopMeta.isEnabled()).thenReturn(true);
    when(fromJobEntry.getName()).thenReturn("from");
    when(toJobEntry.getName()).thenReturn("to");
    serializer.serializeHops(meta, json);
    verify(json, times(2)).writeObject(any(HopInfo.class));
}
Also used : HopInfo(org.pentaho.metaverse.api.model.kettle.HopInfo) JobHopMeta(org.pentaho.di.job.JobHopMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Test(org.junit.Test)

Aggregations

JobHopMeta (org.pentaho.di.job.JobHopMeta)31 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)24 Point (org.pentaho.di.core.gui.Point)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)16 NotePadMeta (org.pentaho.di.core.NotePadMeta)12 KettleException (org.pentaho.di.core.exception.KettleException)10 JobMeta (org.pentaho.di.job.JobMeta)10 ArrayList (java.util.ArrayList)8 MessageBox (org.eclipse.swt.widgets.MessageBox)6 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)6 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)4 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)4 AreaOwner (org.pentaho.di.core.gui.AreaOwner)4 Job (org.pentaho.di.job.Job)4 Date (java.util.Date)3 Test (org.junit.Test)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)3 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)3 XulException (org.pentaho.ui.xul.XulException)3