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");
}
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();
}
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;
}
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);
}
}
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);
}
}
}
}
}
}
Aggregations