Search in sources :

Example 1 with DefaultRunConfiguration

use of org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationDelegate method create.

public void create() {
    List<String> names = configurationManager.getNames();
    String name = BaseMessages.getString(PKG, "RunConfigurationPopupMenuExtension.Configuration.Default") + " ";
    int index = 1;
    while (names.contains(name + String.valueOf(index))) {
        index++;
    }
    name = name + String.valueOf(index);
    DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration();
    defaultRunConfiguration.setName(name);
    RunConfigurationDialog dialog = new RunConfigurationDialog(spoonSupplier.get().getShell(), configurationManager, defaultRunConfiguration);
    RunConfiguration savedRunConfiguration = dialog.open();
    if (savedRunConfiguration != null) {
        configurationManager.save(savedRunConfiguration);
        spoonSupplier.get().refreshTree();
    }
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 2 with DefaultRunConfiguration

use of org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationDelegateTest method testCreate.

@Test
public void testCreate() throws Exception {
    RunConfigurationDialog dialog = mock(RunConfigurationDialog.class);
    whenNew(RunConfigurationDialog.class).withAnyArguments().thenReturn(dialog);
    List<String> list = new ArrayList<>();
    list.add("Configuration 1");
    DefaultRunConfiguration config = new DefaultRunConfiguration();
    config.setName("Test");
    config.setServer("localhost");
    doReturn(list).when(service).getNames();
    doReturn(config).when(dialog).open();
    delegate.create();
    verify(service, times(1)).save(config);
    verify(spoon, times(1)).refreshTree();
}
Also used : ArrayList(java.util.ArrayList) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with DefaultRunConfiguration

use of org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationDelegateTest method testUpdateLoadedJobs_PDI16777.

@Test
public void testUpdateLoadedJobs_PDI16777() {
    JobEntryTrans trans = new JobEntryTrans();
    trans.setRunConfiguration("key");
    JobMeta meta = new JobMeta();
    meta.addJobEntry(new JobEntryCopy(trans));
    JobMeta[] jobs = new JobMeta[] { meta };
    doReturn(jobs).when(spoon).getLoadedJobs();
    DefaultRunConfiguration config = new DefaultRunConfiguration();
    config.setName("Test");
    config.setServer("localhost");
    delegate.updateLoadedJobs("key", config);
    assertEquals("Test", trans.getRunConfiguration());
    assertEquals("localhost", trans.getRemoteSlaveServerName());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with DefaultRunConfiguration

use of org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationImportExtensionPoint method createSlaveServerRunConfigurations.

private List<RunConfiguration> createSlaveServerRunConfigurations(List<String> existingConfigurationNames, AbstractMeta abstractMeta) {
    List<RunConfiguration> runConfigurations = new ArrayList<>();
    if (abstractMeta instanceof JobMeta) {
        JobMeta jobMeta = (JobMeta) abstractMeta;
        Map<String, List<JobEntryTrans>> slaveServerGroups = jobMeta.getJobCopies().stream().map(JobEntryCopy::getEntry).filter(entry -> entry instanceof JobEntryTrans).map(entry -> (JobEntryTrans) entry).filter(entry -> Utils.isEmpty(entry.getRunConfiguration())).filter(entry -> !Utils.isEmpty(entry.getRemoteSlaveServerName())).collect(Collectors.groupingBy(JobEntryTrans::getRemoteSlaveServerName));
        slaveServerGroups.forEach((remoteServerName, entries) -> {
            String runConfigurationName = createRunConfigurationName(existingConfigurationNames, remoteServerName);
            DefaultRunConfiguration runConfiguration = createRunConfiguration(runConfigurationName, remoteServerName);
            runConfigurations.add(runConfiguration);
            entries.forEach(e -> e.setRunConfiguration(runConfiguration.getName()));
        });
    }
    return runConfigurations;
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Utils(org.pentaho.di.core.util.Utils) AbstractMeta(org.pentaho.di.base.AbstractMeta) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) List(java.util.List) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) Map(java.util.Map) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Comparator(java.util.Comparator) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) JobMeta(org.pentaho.di.job.JobMeta) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) ArrayList(java.util.ArrayList) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with DefaultRunConfiguration

use of org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationManagerTest method testSaveAndDelete.

@Test
public void testSaveAndDelete() {
    DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration();
    defaultRunConfiguration.setName("New Run Configuration");
    executionConfigurationManager.save(defaultRunConfiguration);
    DefaultRunConfiguration loadedRunConfiguration = (DefaultRunConfiguration) executionConfigurationManager.load("New Run Configuration");
    assertEquals(loadedRunConfiguration.getName(), defaultRunConfiguration.getName());
    executionConfigurationManager.delete("New Run Configuration");
    loadedRunConfiguration = (DefaultRunConfiguration) executionConfigurationManager.load("New Run Configuration");
    assertNull(loadedRunConfiguration);
}
Also used : DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) Test(org.junit.Test)

Aggregations

DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)14 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 ArrayList (java.util.ArrayList)4 JobMeta (org.pentaho.di.job.JobMeta)4 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)4 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)4 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)3 DefaultRunConfigurationProvider (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider)3 SparkRunConfiguration (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfiguration)3 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)2 RunConfigurationProvider (org.pentaho.di.engine.configuration.api.RunConfigurationProvider)2 SparkRunConfigurationExecutor (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationExecutor)2 SparkRunConfigurationProvider (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider)2 MemoryMetaStore (org.pentaho.metastore.stores.memory.MemoryMetaStore)2 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1