Search in sources :

Example 1 with JobEntryJob

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

the class JobFileListenerTest method testProcessLinkedJobsWithNoFilename.

@Test
public void testProcessLinkedJobsWithNoFilename() {
    JobEntryJob jobJobExecutor = spy(new JobEntryJob());
    jobJobExecutor.setFileName(null);
    jobJobExecutor.setDirectory("/path/to");
    jobJobExecutor.setJobName("Job1");
    jobJobExecutor.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    JobEntryCopy jobEntry = mock(JobEntryCopy.class);
    when(jobEntry.getEntry()).thenReturn(jobJobExecutor);
    JobMeta parent = mock(JobMeta.class);
    when(parent.nrJobEntries()).thenReturn(1);
    when(parent.getJobEntry(0)).thenReturn(jobEntry);
    JobMeta result = jobFileListener.processLinkedJobs(parent);
    JobEntryCopy meta = result.getJobEntry(0);
    assertNotNull(meta);
    JobEntryJob resultExecMeta = (JobEntryJob) meta.getEntry();
    assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
    assertEquals(resultExecMeta.getDirectory(), "/path/to");
    assertEquals(resultExecMeta.getJobName(), "Job1");
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) Test(org.junit.Test)

Example 2 with JobEntryJob

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

the class Job method init.

/**
 * Initializes the Job.
 */
public void init() {
    jobListeners = new ArrayList<JobListener>();
    jobEntryListeners = new ArrayList<JobEntryListener>();
    delegationListeners = new ArrayList<DelegationListener>();
    activeJobEntryTransformations = new HashMap<JobEntryCopy, JobEntryTrans>();
    activeJobEntryJobs = new HashMap<JobEntryCopy, JobEntryJob>();
    extensionDataMap = new HashMap<String, Object>();
    active = new AtomicBoolean(false);
    stopped = new AtomicBoolean(false);
    jobTracker = new JobTracker(jobMeta);
    synchronized (jobEntryResults) {
        jobEntryResults.clear();
    }
    initialized = new AtomicBoolean(false);
    finished = new AtomicBoolean(false);
    errors = new AtomicInteger(0);
    batchId = -1;
    passedBatchId = -1;
    maxJobEntriesLogged = Const.toInt(EnvUtil.getSystemProperty(Const.KETTLE_MAX_JOB_ENTRIES_LOGGED), 1000);
    result = null;
    startJobEntryCopy = null;
    startJobEntryResult = null;
    this.setDefaultLogCommitSize();
}
Also used : JobTracker(org.pentaho.di.core.gui.JobTracker) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) FileObject(org.apache.commons.vfs2.FileObject) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob)

Example 3 with JobEntryJob

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

the class JobFileListener method processLinkedJobs.

protected JobMeta processLinkedJobs(JobMeta jobMeta) {
    for (int i = 0; i < jobMeta.nrJobEntries(); i++) {
        JobEntryCopy jec = jobMeta.getJobEntry(i);
        if (jec.getEntry() instanceof JobEntryJob) {
            JobEntryJob jej = (JobEntryJob) jec.getEntry();
            ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod();
            // If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone
            if (specMethod == ObjectLocationSpecificationMethod.FILENAME) {
                jej.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                String filename = jej.getFilename();
                // handle any exceptions that arise from this
                if (filename.indexOf("/") > -1) {
                    String jobname = filename.substring(filename.lastIndexOf("/") + 1, filename.lastIndexOf('.'));
                    String directory = filename.substring(0, filename.lastIndexOf("/"));
                    jej.setJobName(jobname);
                    jej.setDirectory(directory);
                } else {
                    jej.setJobName(filename);
                }
                jobMeta.setJobEntry(i, jec);
            }
        }
    }
    return jobMeta;
}
Also used : ObjectLocationSpecificationMethod(org.pentaho.di.core.ObjectLocationSpecificationMethod) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 4 with JobEntryJob

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

the class JobEntryJobDialog method getParameters.

protected void getParameters(JobMeta inputJobMeta) {
    try {
        if (inputJobMeta == null) {
            JobEntryJob jej = new JobEntryJob();
            getInfo(jej);
            inputJobMeta = jej.getJobMeta(rep, metaStore, jobMeta);
        }
        String[] parameters = inputJobMeta.listParameters();
        String[] existing = wParameters.getItems(1);
        for (int i = 0; i < parameters.length; i++) {
            if (Const.indexOfString(parameters[i], existing) < 0) {
                TableItem item = new TableItem(wParameters.table, SWT.NONE);
                item.setText(1, parameters[i]);
            }
        }
        wParameters.removeEmptyRows();
        wParameters.setRowNums();
        wParameters.optWidth(true);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryJobDialog.Exception.UnableToLoadJob.Title"), BaseMessages.getString(PKG, "JobEntryJobDialog.Exception.UnableToLoadJob.Message"), e);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

Example 5 with JobEntryJob

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

the class RepositoryExporter method convertFromFileRepository.

private void convertFromFileRepository(JobMeta jobMeta) {
    if (repository instanceof KettleFileRepository) {
        KettleFileRepository fileRep = (KettleFileRepository) repository;
        // The id of the job is the filename.
        // Setting the filename also sets internal variables needed to load the trans/job referenced.
        // 
        String jobMetaFilename = fileRep.calcFilename(jobMeta.getObjectId());
        jobMeta.setFilename(jobMetaFilename);
        for (JobEntryCopy copy : jobMeta.getJobCopies()) {
            JobEntryInterface entry = copy.getEntry();
            if (entry instanceof JobEntryTrans) {
                // convert to a named based reference.
                // 
                JobEntryTrans trans = (JobEntryTrans) entry;
                if (trans.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
                    try {
                        TransMeta meta = trans.getTransMeta(repository, repository.getMetaStore(), jobMeta);
                        FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                        trans.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                        trans.setFileName(null);
                        trans.setTransname(meta.getName());
                        trans.setDirectory(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
                    } catch (Exception e) {
                        log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadJobTrans", trans.getName()), e);
                    }
                }
            }
            if (entry instanceof JobEntryJob) {
                // convert to a named based reference.
                // 
                JobEntryJob jobEntryJob = (JobEntryJob) entry;
                if (jobEntryJob.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
                    try {
                        JobMeta meta = jobEntryJob.getJobMeta(repository, repository.getMetaStore(), jobMeta);
                        FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                        jobEntryJob.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                        jobEntryJob.setFileName(null);
                        jobEntryJob.setJobName(meta.getName());
                        jobEntryJob.setDirectory(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
                    } catch (Exception e) {
                        log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadJobJob", jobEntryJob.getName()), e);
                    }
                }
            }
        }
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta) FileObject(org.apache.commons.vfs2.FileObject) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

JobEntryJob (org.pentaho.di.job.entries.job.JobEntryJob)7 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)5 JobMeta (org.pentaho.di.job.JobMeta)4 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)3 FileObject (org.apache.commons.vfs2.FileObject)2 Test (org.junit.Test)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ObjectLocationSpecificationMethod (org.pentaho.di.core.ObjectLocationSpecificationMethod)1 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)1 JobTracker (org.pentaho.di.core.gui.JobTracker)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)1 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)1