Search in sources :

Example 6 with RunConfiguration

use of org.pentaho.di.engine.configuration.api.RunConfiguration 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 7 with RunConfiguration

use of org.pentaho.di.engine.configuration.api.RunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationSaveExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    AbstractMeta abstractMeta = (AbstractMeta) ((Object[]) o)[0];
    String runConfiguration = (String) ((Object[]) o)[1];
    final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore();
    RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
    embeddedRunConfigurationManager.deleteAll();
    RunConfiguration loadedRunConfiguration = runConfigurationManager.load(abstractMeta.environmentSubstitute(runConfiguration));
    embeddedRunConfigurationManager.save(loadedRunConfiguration);
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)

Example 8 with RunConfiguration

use of org.pentaho.di.engine.configuration.api.RunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationDialog method open.

public RunConfiguration open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 15;
    formLayout.marginHeight = 15;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "RunConfigurationDialog.Title"));
    shell.setImage(getImage());
    Composite wSettings = new Composite(shell, SWT.SHADOW_NONE);
    props.setLook(wSettings);
    FormLayout specLayout = new FormLayout();
    specLayout.marginWidth = 0;
    specLayout.marginHeight = 0;
    wSettings.setLayout(specLayout);
    wlName = new Label(wSettings, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "RunConfigurationDialog.Label.Name"));
    props.setLook(wlName);
    FormData fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.top = new FormAttachment(0, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    FormData fdName = new FormData();
    fdName.left = new FormAttachment(0, 0);
    fdName.top = new FormAttachment(wlName, 5);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    wName.addModifyListener(modifyEvent -> {
        runConfiguration.setName(wName.getText());
        if (Utils.isEmpty(runConfiguration.getName())) {
            wOK.setEnabled(false);
        } else {
            wOK.setEnabled(true);
        }
    });
    wlDescription = new Label(wSettings, SWT.RIGHT);
    wlDescription.setText(BaseMessages.getString(PKG, "RunConfigurationDialog.Label.Description"));
    props.setLook(wlDescription);
    FormData fdlDescription = new FormData();
    fdlDescription.left = new FormAttachment(0, 0);
    fdlDescription.top = new FormAttachment(wName, 10);
    wlDescription.setLayoutData(fdlDescription);
    wDescription = new Text(wSettings, SWT.MULTI | SWT.LEFT | SWT.BORDER);
    props.setLook(wDescription);
    FormData fdDescription = new FormData();
    fdDescription.height = 40;
    fdDescription.left = new FormAttachment(0, 0);
    fdDescription.top = new FormAttachment(wlDescription, 5);
    fdDescription.right = new FormAttachment(100, 0);
    wDescription.setLayoutData(fdDescription);
    wDescription.addModifyListener(modifyEvent -> runConfiguration.setDescription(wDescription.getText()));
    wlEngine = new Label(wSettings, SWT.RIGHT);
    wlEngine.setText(BaseMessages.getString(PKG, "RunConfigurationDialog.Label.Engine"));
    props.setLook(wlEngine);
    FormData fdlEngine = new FormData();
    fdlEngine.left = new FormAttachment(0, 0);
    fdlEngine.top = new FormAttachment(wDescription, 10);
    wlEngine.setLayoutData(fdlEngine);
    wEngine = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wEngine.setItems(executionConfigurationManager.getTypes());
    wEngine.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            String engine = wEngine.getText();
            if (!engine.equals(runConfiguration.getType())) {
                updateOptions(engine);
            }
        }
    });
    wEngine.select(0);
    props.setLook(wEngine);
    FormData fdEngine = new FormData();
    fdEngine.width = 150;
    fdEngine.left = new FormAttachment(0, 0);
    fdEngine.top = new FormAttachment(wlEngine, 5);
    wEngine.setLayoutData(fdEngine);
    gOptions = new Group(wSettings, SWT.SHADOW_ETCHED_IN);
    gOptions.setText(BaseMessages.getString(PKG, "RunConfigurationDialog.Group.Settings"));
    props.setLook(gOptions);
    FormData fdOptions = new FormData();
    fdOptions.top = new FormAttachment(wEngine, 15);
    fdOptions.right = new FormAttachment(100);
    fdOptions.left = new FormAttachment(0);
    fdOptions.height = 140;
    gOptions.setLayoutData(fdOptions);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdCancel = new FormData();
    fdCancel.right = new FormAttachment(100, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fdOk = new FormData();
    fdOk.right = new FormAttachment(wCancel, -5);
    fdOk.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOk);
    Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdhSpacer = new FormData();
    fdhSpacer.height = 1;
    fdhSpacer.left = new FormAttachment(0, 0);
    fdhSpacer.bottom = new FormAttachment(wCancel, -15);
    fdhSpacer.right = new FormAttachment(100, 0);
    hSpacer.setLayoutData(fdhSpacer);
    FormData fdSettings = new FormData();
    fdSettings.left = new FormAttachment(0);
    fdSettings.top = new FormAttachment(0);
    fdSettings.right = new FormAttachment(100);
    fdSettings.bottom = new FormAttachment(hSpacer, -15);
    wSettings.setLayoutData(fdSettings);
    setValues();
    Listener lsCancel = e -> cancel();
    Listener lsOK = e -> ok();
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    BaseStepDialog.setSize(shell, 450, 300);
    shell.setMinimumSize(shell.getSize());
    wName.setSelection(0, wName.getText().length());
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return savedRunConfiguration;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) StringUtils(org.apache.commons.lang.StringUtils) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) Dialog(org.eclipse.swt.widgets.Dialog) RunConfigurationService(org.pentaho.di.engine.configuration.api.RunConfigurationService) Const(org.pentaho.di.core.Const) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) Map(java.util.Map) ConstUI(org.pentaho.di.ui.core.ConstUI) BaseStepDialog(org.pentaho.di.ui.trans.step.BaseStepDialog) BaseMessages(org.pentaho.di.i18n.BaseMessages) CCombo(org.eclipse.swt.custom.CCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) FormLayout(org.eclipse.swt.layout.FormLayout) ShellEvent(org.eclipse.swt.events.ShellEvent) FormData(org.eclipse.swt.layout.FormData) PropsUI(org.pentaho.di.ui.core.PropsUI) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) Utils(org.pentaho.di.core.util.Utils) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Group(org.eclipse.swt.widgets.Group) SWT(org.eclipse.swt.SWT) MessageBox(org.eclipse.swt.widgets.MessageBox) SwtSvgImageUtil(org.pentaho.di.ui.util.SwtSvgImageUtil) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) Group(org.eclipse.swt.widgets.Group) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 9 with RunConfiguration

use of org.pentaho.di.engine.configuration.api.RunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationDialog method updateOptions.

private void updateOptions(String type) {
    RunConfiguration newRunConfiguration = runConfigurationMap.get(type);
    if (newRunConfiguration == null) {
        newRunConfiguration = executionConfigurationManager.getRunConfigurationByType(type);
        newRunConfiguration.setName(runConfiguration.getName());
        newRunConfiguration.setDescription(runConfiguration.getDescription());
        runConfigurationMap.put(type, newRunConfiguration);
    }
    runConfiguration = newRunConfiguration;
    setValues();
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)

Example 10 with RunConfiguration

use of org.pentaho.di.engine.configuration.api.RunConfiguration in project pentaho-kettle by pentaho.

the class RunConfigurationTreeDelegateExtension method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
    SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
    int caseNumber = treeDelExt.getCaseNumber();
    AbstractMeta meta = treeDelExt.getTransMeta();
    String[] path = treeDelExt.getPath();
    List<TreeSelection> objects = treeDelExt.getObjects();
    TreeSelection object = null;
    if (path[2].equals(RunConfigurationViewTreeExtension.TREE_LABEL)) {
        switch(caseNumber) {
            case 3:
                object = new TreeSelection(path[2], RunConfiguration.class, meta);
                break;
            case 4:
                try {
                    RunConfiguration runConfiguration = runConfigurationManager.load(path[3]);
                    if (!runConfiguration.isReadOnly()) {
                        object = new TreeSelection(path[3], runConfiguration, meta);
                    }
                } catch (Exception e) {
                // Do Nothing
                }
                break;
        }
    }
    if (object != null) {
        objects.add(object);
    }
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) AbstractMeta(org.pentaho.di.base.AbstractMeta) SpoonTreeDelegateExtension(org.pentaho.di.ui.spoon.delegates.SpoonTreeDelegateExtension) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)16 DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)7 AbstractMeta (org.pentaho.di.base.AbstractMeta)5 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)5 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)5 RunConfigurationManager (org.pentaho.di.engine.configuration.impl.RunConfigurationManager)5 ArrayList (java.util.ArrayList)3 KettleException (org.pentaho.di.core.exception.KettleException)3 Map (java.util.Map)2 Test (org.junit.Test)2 ExtensionPoint (org.pentaho.di.core.extension.ExtensionPoint)2 Utils (org.pentaho.di.core.util.Utils)2 DefaultRunConfigurationProvider (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang.StringUtils)1