use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method loadJob.
// JobMeta
/**
* Load a job in a directory
*
* @param jobname
* The name of the job
* @param repdir
* The directory in which the job resides.
* @param the
* monitor to use as feedback in a UI (or null if not used)
* @throws KettleException
*/
public JobMeta loadJob(String jobname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, String versionName) throws KettleException {
try {
securityProvider.validateAction(RepositoryOperation.READ_JOB);
JobMeta jobMeta = jobDelegate.loadJobMeta(jobname, repdir, monitor);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobMetaLoaded.id, jobMeta);
return jobMeta;
} finally {
connectionDelegate.closeReadTransaction();
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobDialog method getLogTableUserInterface.
private LogTableUserInterface getLogTableUserInterface(LogTableInterface logTable, JobMeta jobMeta, ModifyListener lsMod) {
if (!(logTable instanceof LogTablePluginInterface)) {
return null;
}
LogTablePluginInterface pluginInterface = (LogTablePluginInterface) logTable;
String uiClassName = pluginInterface.getLogTablePluginUIClassname();
Class<?> uiClass;
Class<?>[] paramClasses = new Class<?>[] { JobMeta.class, ModifyListener.class, JobDialog.class };
Object[] paramArgs = new Object[] { jobMeta, lsMod, this };
Constructor<?> uiConstructor;
try {
uiClass = pluginInterface.getClass().getClassLoader().loadClass(uiClassName);
uiConstructor = uiClass.getConstructor(paramClasses);
return (LogTableUserInterface) uiConstructor.newInstance(paramArgs);
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Unable to load UI interface class: " + uiClassName, e);
return null;
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobExecutionConfigurationDialog method getData.
public void getData() {
wSafeMode.setSelection(configuration.isSafeModeEnabled());
wClearLog.setSelection(configuration.isClearingLog());
wExpandRemote.setSelection(getConfiguration().isExpandingRemoteJob());
wLogLevel.select(DefaultLogLevel.getLogLevel().getLevel());
wGatherMetrics.setSelection(configuration.isGatheringMetrics());
List<String> runConfigurations = new ArrayList<>();
try {
ExtensionPointHandler.callExtensionPoint(Spoon.getInstance().getLog(), KettleExtensionPoint.SpoonRunConfiguration.id, new Object[] { runConfigurations, JobMeta.XML_TAG });
} catch (KettleException e) {
// Ignore errors
}
wRunConfiguration.setItems(runConfigurations.toArray(new String[0]));
if (!runConfigurations.contains(getConfiguration().getRunConfiguration())) {
getConfiguration().setRunConfiguration(null);
}
if (Utils.isEmpty(getConfiguration().getRunConfiguration())) {
wRunConfiguration.select(0);
} else {
wRunConfiguration.setText(getConfiguration().getRunConfiguration());
}
String startCopy = "";
if (!Utils.isEmpty(getConfiguration().getStartCopyName())) {
JobEntryCopy copy = ((JobMeta) abstractMeta).findJobEntry(getConfiguration().getStartCopyName(), getConfiguration().getStartCopyNr(), false);
if (copy != null) {
startCopy = getJobEntryCopyName(copy);
}
}
wStartCopy.setText(startCopy);
getParamsData();
getVariablesData();
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobExecutionConfigurationDialog method optionsSectionControls.
protected void optionsSectionControls() {
wExpandRemote = new Button(gDetails, SWT.CHECK);
wExpandRemote.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ExpandRemote.Label"));
wExpandRemote.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ExpandRemote.Tooltip"));
props.setLook(wExpandRemote);
FormData fd_expandCheckButton = new FormData();
fd_expandCheckButton.top = new FormAttachment(0, 10);
fd_expandCheckButton.left = new FormAttachment(0, 10);
wExpandRemote.setLayoutData(fd_expandCheckButton);
wClearLog = new Button(gDetails, SWT.CHECK);
wClearLog.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ClearLog.Label"));
wClearLog.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ClearLog.Tooltip"));
props.setLook(wClearLog);
FormData fdClearLog = new FormData();
fdClearLog.top = new FormAttachment(wExpandRemote, 10);
fdClearLog.left = new FormAttachment(0, 10);
wClearLog.setLayoutData(fdClearLog);
wSafeMode = new Button(gDetails, SWT.CHECK);
wSafeMode.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.SafeMode.Label"));
wSafeMode.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.SafeMode.Tooltip"));
props.setLook(wSafeMode);
FormData fdSafeMode = new FormData();
fdSafeMode.top = new FormAttachment(wClearLog, 7);
fdSafeMode.left = new FormAttachment(0, 10);
wSafeMode.setLayoutData(fdSafeMode);
wGatherMetrics = new Button(gDetails, SWT.CHECK);
wGatherMetrics.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.GatherMetrics.Label"));
wGatherMetrics.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.GatherMetrics.Tooltip"));
props.setLook(wGatherMetrics);
FormData fdGatherMetrics = new FormData();
fdGatherMetrics.top = new FormAttachment(wSafeMode, 7);
fdGatherMetrics.left = new FormAttachment(0, 10);
fdGatherMetrics.bottom = new FormAttachment(100, -10);
wGatherMetrics.setLayoutData(fdGatherMetrics);
wlLogLevel = new Label(gDetails, SWT.RIGHT);
wlLogLevel.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Label"));
wlLogLevel.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Tooltip"));
props.setLook(wlLogLevel);
FormData fdlLogLevel = new FormData();
fdlLogLevel.top = new FormAttachment(0, 10);
fdlLogLevel.left = new FormAttachment(45, 0);
wlLogLevel.setLayoutData(fdlLogLevel);
wLogLevel = new CCombo(gDetails, SWT.READ_ONLY | SWT.BORDER);
wLogLevel.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Tooltip"));
props.setLook(wLogLevel);
FormData fdLogLevel = new FormData();
fdLogLevel.top = new FormAttachment(wlLogLevel, -2, SWT.TOP);
fdLogLevel.width = 180;
fdLogLevel.left = new FormAttachment(wlLogLevel, 6);
wLogLevel.setLayoutData(fdLogLevel);
wLogLevel.setItems(LogLevel.getLogLevelDescriptions());
Label lblStartJob = new Label(gDetails, SWT.RIGHT);
lblStartJob.setText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Label"));
lblStartJob.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Tooltip"));
props.setLook(lblStartJob);
FormData fd_lblStartJob = new FormData();
fd_lblStartJob.top = new FormAttachment(wlLogLevel, 18);
fd_lblStartJob.right = new FormAttachment(wlLogLevel, 0, SWT.RIGHT);
lblStartJob.setLayoutData(fd_lblStartJob);
wStartCopy = new CCombo(gDetails, SWT.READ_ONLY | SWT.BORDER);
wStartCopy.setToolTipText(BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Tooltip"));
props.setLook(wStartCopy);
FormData fd_startJobCombo = new FormData();
fd_startJobCombo.top = new FormAttachment(lblStartJob, -2, SWT.TOP);
fd_startJobCombo.width = 180;
fd_startJobCombo.left = new FormAttachment(lblStartJob, 6);
wStartCopy.setLayoutData(fd_startJobCombo);
JobMeta jobMeta = (JobMeta) super.abstractMeta;
String[] names = new String[jobMeta.getJobCopies().size()];
for (int i = 0; i < names.length; i++) {
JobEntryCopy copy = jobMeta.getJobCopies().get(i);
names[i] = getJobEntryCopyName(copy);
}
wStartCopy.setItems(names);
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobEntryJobIT method testLogfileWritesFromRemote.
@Test
public void testLogfileWritesFromRemote() throws Exception {
JobEntryJob job = spy(new JobEntryJob(JOB_ENTRY_JOB_NAME));
doCallRealMethod().when(job).execute(any(Result.class), anyInt());
Job parentJob = mock(Job.class);
JobMeta parentJobMeta = mock(JobMeta.class);
JobMeta jobMeta = mock(JobMeta.class);
SlaveServer slaveServer = mock(SlaveServer.class);
LogChannelInterface log = mock(LogChannelInterface.class);
SlaveServerJobStatus status = mock(SlaveServerJobStatus.class);
when(parentJob.getLogLevel()).thenReturn(LogLevel.BASIC);
when(parentJobMeta.getRepositoryDirectory()).thenReturn(null);
when(jobMeta.getRepositoryDirectory()).thenReturn(mock(RepositoryDirectoryInterface.class));
when(jobMeta.getName()).thenReturn(JOB_META_NAME);
when(parentJob.getJobMeta()).thenReturn(parentJobMeta);
when(parentJobMeta.findSlaveServer(REMOTE_SLAVE_SERVER_NAME)).thenReturn(slaveServer);
when(slaveServer.getLogChannel()).thenReturn(log);
when(log.getLogLevel()).thenReturn(LogLevel.BASIC);
when(slaveServer.sendXML(anyString(), anyString())).thenReturn(REPLY);
when(slaveServer.execService(anyString())).thenReturn(REPLY);
when(slaveServer.getJobStatus(anyString(), anyString(), anyInt())).thenReturn(status);
when(status.getResult()).thenReturn(mock(Result.class));
when(status.getLoggingString()).thenReturn(LOG);
file = Files.createTempFile("file", "");
doReturn(LOG_FILE_NAME).when(job).getLogFilename();
doReturn(file.toString()).when(job).environmentSubstitute(LOG_FILE_NAME);
doReturn(REMOTE_SLAVE_SERVER_NAME).when(job).environmentSubstitute(REMOTE_SLAVE_SERVER_NAME);
doReturn(jobMeta).when(job).getJobMeta(any(Repository.class), any(VariableSpace.class));
doNothing().when(job).copyVariablesFrom(anyObject());
doNothing().when(job).setParentVariableSpace(anyObject());
job.setLogfile = true;
job.createParentFolder = false;
job.logFileLevel = LogLevel.BASIC;
job.execPerRow = false;
job.paramsFromPrevious = false;
job.argFromPrevious = false;
job.waitingToFinish = true;
job.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
job.setRemoteSlaveServerName(REMOTE_SLAVE_SERVER_NAME);
job.setParentJob(parentJob);
job.setParentJobMeta(parentJobMeta);
job.execute(new Result(), 0);
String result = Files.lines(file).collect(Collectors.joining(""));
assertTrue(result.contains(LOG));
}
Aggregations