Search in sources :

Example 51 with JobEntryCopy

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

the class JobFileListener method processLinkedTrans.

protected JobMeta processLinkedTrans(JobMeta jobMeta) {
    for (int i = 0; i < jobMeta.nrJobEntries(); i++) {
        JobEntryCopy jec = jobMeta.getJobEntry(i);
        if (jec.getEntry() instanceof JobEntryTrans) {
            JobEntryTrans jet = (JobEntryTrans) jec.getEntry();
            ObjectLocationSpecificationMethod specMethod = jet.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) {
                jet.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                String filename = jet.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("/"));
                    jet.setTransname(jobname);
                    jet.setDirectory(directory);
                } else {
                    jet.setTransname(filename);
                }
                jobMeta.setJobEntry(i, jec);
            }
        }
    }
    return jobMeta;
}
Also used : ObjectLocationSpecificationMethod(org.pentaho.di.core.ObjectLocationSpecificationMethod) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 52 with JobEntryCopy

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

the class RepositoryImporterTest method createRepositoryImporter.

private static RepositoryImporter createRepositoryImporter(final JobEntryInterface jobEntryInterface, final StepMetaInterface stepMetaInterface, final boolean needToCheckPathForVariables) {
    Repository repository = mock(Repository.class);
    LogChannelInterface log = mock(LogChannelInterface.class);
    RepositoryImporter importer = new RepositoryImporter(repository, log) {

        @Override
        JobMeta createJobMetaForNode(Node jobnode) throws KettleXMLException {
            JobMeta meta = mock(JobMeta.class);
            JobEntryCopy jec = mock(JobEntryCopy.class);
            when(jec.isTransformation()).thenReturn(true);
            when(jec.getEntry()).thenReturn(jobEntryInterface);
            when(meta.getJobCopies()).thenReturn(Collections.singletonList(jec));
            return meta;
        }

        @Override
        TransMeta createTransMetaForNode(Node transnode) throws KettleMissingPluginsException, KettleXMLException {
            TransMeta meta = mock(TransMeta.class);
            StepMeta stepMeta = mock(StepMeta.class);
            when(stepMeta.isMapping()).thenReturn(true);
            when(stepMeta.getStepMetaInterface()).thenReturn(stepMetaInterface);
            when(meta.getSteps()).thenReturn(Collections.singletonList(stepMeta));
            return meta;
        }

        @Override
        protected void replaceSharedObjects(JobMeta transMeta) throws KettleException {
        }

        @Override
        protected void replaceSharedObjects(TransMeta transMeta) throws KettleException {
        }

        @Override
        boolean needToCheckPathForVariables() {
            return needToCheckPathForVariables;
        }
    };
    return importer;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Node(org.w3c.dom.Node) TransMeta(org.pentaho.di.trans.TransMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 53 with JobEntryCopy

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

the class JobEntryFilesExistTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new JobEntryFilesExist();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    JobMeta mockJobMeta = mock(JobMeta.class);
    entry.setParentJobMeta(mockJobMeta);
    job.setStopped(false);
    existingFile1 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile1.ext", entry);
    existingFile2 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile2.ext", entry);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) Before(org.junit.Before)

Example 54 with JobEntryCopy

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

the class JobEntryFolderIsEmptyTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new JobEntryFolderIsEmpty();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    JobMeta mockJobMeta = mock(JobMeta.class);
    entry.setParentJobMeta(mockJobMeta);
    job.setStopped(false);
    File dir = Files.createTempDirectory("dir", new FileAttribute<?>[0]).toFile();
    dir.deleteOnExit();
    emptyDir = dir.getPath();
    dir = Files.createTempDirectory("dir", new FileAttribute<?>[0]).toFile();
    dir.deleteOnExit();
    nonEmptyDir = dir.getPath();
    File file = File.createTempFile("existingFile", "ext", dir);
    file.deleteOnExit();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) Before(org.junit.Before)

Example 55 with JobEntryCopy

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

the class JobEntryFTPTest method setUp.

@Before
public void setUp() throws Exception {
    job = new Job(null, new JobMeta());
    entry = new MockedJobEntryFTP();
    job.getJobMeta().addJobEntry(new JobEntryCopy(entry));
    entry.setParentJob(job);
    job.setStopped(false);
    entry.setServerName("some.server");
    entry.setUserName("anonymous");
    entry.setFtpDirectory(".");
    entry.setWildcard("robots.txt");
    entry.setBinaryMode(false);
    entry.setSuccessCondition("success_if_no_errors");
    existingDir = TestUtils.createTempDir();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Job(org.pentaho.di.job.Job) Before(org.junit.Before)

Aggregations

JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)149 Point (org.pentaho.di.core.gui.Point)54 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)51 JobMeta (org.pentaho.di.job.JobMeta)47 KettleException (org.pentaho.di.core.exception.KettleException)30 Test (org.junit.Test)28 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)28 NotePadMeta (org.pentaho.di.core.NotePadMeta)24 JobHopMeta (org.pentaho.di.job.JobHopMeta)24 ArrayList (java.util.ArrayList)18 Job (org.pentaho.di.job.Job)18 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)16 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)15 MessageBox (org.eclipse.swt.widgets.MessageBox)13 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)10 Result (org.pentaho.di.core.Result)8 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)8 AreaOwner (org.pentaho.di.core.gui.AreaOwner)8 JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)8 Before (org.junit.Before)7