Search in sources :

Example 1 with JobEntryRunConfigurableInterface

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

the class RunConfigurationDelegate method updateLoadedJobs.

protected void updateLoadedJobs(String key, RunConfiguration runConfig) {
    for (JobMeta job : spoonSupplier.get().getLoadedJobs()) {
        for (int i = 0; i < job.nrJobEntries(); i++) {
            JobEntryInterface entry = job.getJobEntry(i).getEntry();
            if (entry instanceof JobEntryRunConfigurableInterface) {
                JobEntryRunConfigurableInterface jet = (JobEntryRunConfigurableInterface) entry;
                if (jet.getRunConfiguration() != null) {
                    if (jet.getRunConfiguration().equals(key)) {
                        try {
                            ExtensionPointHandler.callExtensionPoint(job.getLogChannel(), KettleExtensionPoint.JobEntryTransSave.id, new Object[] { job, runConfig.getName() });
                        } catch (KettleException e) {
                            spoonSupplier.get().getLog().logBasic("Unable to set run configuration in job " + job.getName());
                        }
                        jet.setRunConfiguration(runConfig.getName());
                        if (runConfig instanceof DefaultRunConfiguration) {
                            jet.setRemoteSlaveServerName(((DefaultRunConfiguration) runConfig).getServer());
                            jet.setLoggingRemoteWork(((DefaultRunConfiguration) runConfig).isLogRemoteExecutionLocally());
                        }
                        jet.setChanged();
                    }
                }
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryRunConfigurableInterface(org.pentaho.di.job.entry.JobEntryRunConfigurableInterface) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 2 with JobEntryRunConfigurableInterface

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

the class RunConfigurationSaveExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    JobMeta jobMeta = (JobMeta) ((Object[]) o)[0];
    final EmbeddedMetaStore embeddedMetaStore = jobMeta.getEmbeddedMetaStore();
    RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
    embeddedRunConfigurationManager.deleteAll();
    List<String> runConfigurationNames = new ArrayList<>();
    boolean embedAll = false;
    for (JobEntryCopy jobEntryCopy : jobMeta.getJobCopies()) {
        if (jobEntryCopy.getEntry() instanceof JobEntryRunConfigurableInterface) {
            String usedConfiguration = ((JobEntryRunConfigurableInterface) jobEntryCopy.getEntry()).getRunConfiguration();
            embedAll = embedAll || StringUtil.isVariable(usedConfiguration);
            if (!Utils.isEmpty(usedConfiguration) && !runConfigurationNames.contains(usedConfiguration)) {
                runConfigurationNames.add(usedConfiguration);
            }
        }
    }
    if (embedAll) {
        embedAllRunConfigurations(embeddedRunConfigurationManager);
    } else {
        embedRunConfigurations(embeddedRunConfigurationManager, runConfigurationNames);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) ArrayList(java.util.ArrayList) JobEntryRunConfigurableInterface(org.pentaho.di.job.entry.JobEntryRunConfigurableInterface) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)

Example 3 with JobEntryRunConfigurableInterface

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

the class RunConfigurationSaveExtensionPointTest method createCopy.

private JobEntryCopy createCopy(Class<? extends JobEntryRunConfigurableInterface> type, String runConfigurationName) {
    JobEntryCopy jobEntryCopy = mock(JobEntryCopy.class);
    JobEntryRunConfigurableInterface jobEntryInterface = mock(type);
    when(jobEntryCopy.getEntry()).thenReturn((JobEntryInterface) jobEntryInterface);
    when(jobEntryInterface.getRunConfiguration()).thenReturn(runConfigurationName);
    return jobEntryCopy;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryRunConfigurableInterface(org.pentaho.di.job.entry.JobEntryRunConfigurableInterface)

Aggregations

JobEntryRunConfigurableInterface (org.pentaho.di.job.entry.JobEntryRunConfigurableInterface)3 JobMeta (org.pentaho.di.job.JobMeta)2 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)2 ArrayList (java.util.ArrayList)1 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)1 RunConfigurationManager (org.pentaho.di.engine.configuration.impl.RunConfigurationManager)1 DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)1 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)1