Search in sources :

Example 41 with JobMeta

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();
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta)

Example 42 with JobMeta

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;
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) ModifyListener(org.eclipse.swt.events.ModifyListener) LogTablePluginInterface(org.pentaho.di.core.logging.LogTablePluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException)

Example 43 with JobMeta

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();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) ArrayList(java.util.ArrayList)

Example 44 with JobMeta

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);
}
Also used : FormData(org.eclipse.swt.layout.FormData) JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 45 with JobMeta

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));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) SlaveServerJobStatus(org.pentaho.di.www.SlaveServerJobStatus) Repository(org.pentaho.di.repository.Repository) VariableSpace(org.pentaho.di.core.variables.VariableSpace) Matchers.anyString(org.mockito.Matchers.anyString) Job(org.pentaho.di.job.Job) SlaveServer(org.pentaho.di.cluster.SlaveServer) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12