Search in sources :

Example 16 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class UniqueRowsByHashSetDialog method open.

public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);
    // ///////////////////////////////
    // START OF Settings GROUP //
    // ///////////////////////////////
    wSettings = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wSettings);
    wSettings.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Settings.Label"));
    FormLayout SettingsgroupLayout = new FormLayout();
    SettingsgroupLayout.marginWidth = 10;
    SettingsgroupLayout.marginHeight = 10;
    wSettings.setLayout(SettingsgroupLayout);
    wlStoreValues = new Label(wSettings, SWT.RIGHT);
    wlStoreValues.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.StoreValues.Label"));
    props.setLook(wlStoreValues);
    fdlStoreValues = new FormData();
    fdlStoreValues.left = new FormAttachment(0, 0);
    fdlStoreValues.top = new FormAttachment(wStepname, margin);
    fdlStoreValues.right = new FormAttachment(middle, -margin);
    wlStoreValues.setLayoutData(fdlStoreValues);
    wStoreValues = new Button(wSettings, SWT.CHECK);
    props.setLook(wStoreValues);
    wStoreValues.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.StoreValues.ToolTip", Const.CR));
    fdStoreValues = new FormData();
    fdStoreValues.left = new FormAttachment(middle, 0);
    fdStoreValues.top = new FormAttachment(wStepname, margin);
    wStoreValues.setLayoutData(fdStoreValues);
    wStoreValues.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    wlRejectDuplicateRow = new Label(wSettings, SWT.RIGHT);
    wlRejectDuplicateRow.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.RejectDuplicateRow.Label"));
    props.setLook(wlRejectDuplicateRow);
    fdlRejectDuplicateRow = new FormData();
    fdlRejectDuplicateRow.left = new FormAttachment(0, 0);
    fdlRejectDuplicateRow.top = new FormAttachment(wStoreValues, margin);
    fdlRejectDuplicateRow.right = new FormAttachment(middle, -margin);
    wlRejectDuplicateRow.setLayoutData(fdlRejectDuplicateRow);
    wRejectDuplicateRow = new Button(wSettings, SWT.CHECK);
    props.setLook(wRejectDuplicateRow);
    wRejectDuplicateRow.setToolTipText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.RejectDuplicateRow.ToolTip", Const.CR));
    fdRejectDuplicateRow = new FormData();
    fdRejectDuplicateRow.left = new FormAttachment(middle, 0);
    fdRejectDuplicateRow.top = new FormAttachment(wStoreValues, margin);
    wRejectDuplicateRow.setLayoutData(fdRejectDuplicateRow);
    wRejectDuplicateRow.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setErrorDesc();
        }
    });
    wlErrorDesc = new Label(wSettings, SWT.LEFT);
    wlErrorDesc.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.ErrorDescription.Label"));
    props.setLook(wlErrorDesc);
    fdlErrorDesc = new FormData();
    fdlErrorDesc.left = new FormAttachment(wRejectDuplicateRow, margin);
    fdlErrorDesc.top = new FormAttachment(wStoreValues, margin);
    wlErrorDesc.setLayoutData(fdlErrorDesc);
    wErrorDesc = new TextVar(transMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wErrorDesc);
    wErrorDesc.addModifyListener(lsMod);
    fdErrorDesc = new FormData();
    fdErrorDesc.left = new FormAttachment(wlErrorDesc, margin);
    fdErrorDesc.top = new FormAttachment(wStoreValues, margin);
    fdErrorDesc.right = new FormAttachment(100, 0);
    wErrorDesc.setLayoutData(fdErrorDesc);
    fdSettings = new FormData();
    fdSettings.left = new FormAttachment(0, margin);
    fdSettings.top = new FormAttachment(wStepname, margin);
    fdSettings.right = new FormAttachment(100, -margin);
    wSettings.setLayoutData(fdSettings);
    // ///////////////////////////////////////////////////////////
    // / END OF Settings GROUP
    // ///////////////////////////////////////////////////////////
    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Get.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fdOK = new FormData();
    setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
    wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wSettings, margin);
    wlFields.setLayoutData(fdlFields);
    final int FieldsRows = input.getCompareFields() == null ? 0 : input.getCompareFields().length;
    colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "UniqueRowsByHashSetDialog.ColumnInfo.Fieldname"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false) };
    wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wOK, -2 * margin);
    wFields.setLayoutData(fdFields);
    // 
    // Search the fields in the background
    final Runnable runnable = new Runnable() {

        public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
                try {
                    RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
                    // Remember these fields...
                    for (int i = 0; i < row.size(); i++) {
                        inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsGet = new Listener() {

        public void handleEvent(Event e) {
            get();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wGet.addListener(SWT.Selection, lsGet);
    wOK.addListener(SWT.Selection, lsOK);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    setErrorDesc();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : Group(org.eclipse.swt.widgets.Group) KettleException(org.pentaho.di.core.exception.KettleException) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) TextVar(org.pentaho.di.ui.core.widget.TextVar) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 17 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class UpdateDialog method create.

// Generate code for create table...
// Conversions done by Database
private void create() {
    try {
        UpdateMeta info = new UpdateMeta();
        getInfo(info);
        // new name might not yet be linked to other steps!
        String name = stepname;
        StepMeta stepinfo = new StepMeta(BaseMessages.getString(PKG, "UpdateDialog.StepMeta.Title"), name, info);
        RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
        SQLStatement sql = info.getSQLStatements(transMeta, stepinfo, prev, repository, metaStore);
        if (!sql.hasError()) {
            if (sql.hasSQL()) {
                SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
                sqledit.open();
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
                mb.setMessage(BaseMessages.getString(PKG, "UpdateDialog.NoSQLNeeds.DialogMessage"));
                mb.setText(BaseMessages.getString(PKG, "UpdateDialog.NoSQLNeeds.DialogTitle"));
                mb.open();
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(sql.getError());
            mb.setText(BaseMessages.getString(PKG, "UpdateDialog.SQLError.DialogTitle"));
            mb.open();
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "UpdateDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "UpdateDialog.CouldNotBuildSQL.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SQLEditor(org.pentaho.di.ui.core.database.dialog.SQLEditor) UpdateMeta(org.pentaho.di.trans.steps.update.UpdateMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) SQLStatement(org.pentaho.di.core.SQLStatement) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 18 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class SpoonTransformationDelegateTest method testSetParamsIntoMetaInExecuteTransformation.

@Test
@SuppressWarnings("ResultOfMethodCallIgnored")
public void testSetParamsIntoMetaInExecuteTransformation() throws KettleException {
    doCallRealMethod().when(delegate).executeTransformation(transMeta, true, false, false, false, false, null, false, LogLevel.BASIC);
    RowMetaInterface rowMeta = mock(RowMetaInterface.class);
    TransExecutionConfiguration transExecutionConfiguration = mock(TransExecutionConfiguration.class);
    TransGraph activeTransGraph = mock(TransGraph.class);
    activeTransGraph.transLogDelegate = mock(TransLogDelegate.class);
    doReturn(rowMeta).when(spoon.variables).getRowMeta();
    doReturn(EMPTY_STRING_ARRAY).when(rowMeta).getFieldNames();
    doReturn(transExecutionConfiguration).when(spoon).getTransExecutionConfiguration();
    doReturn(MAP_WITH_TEST_PARAM).when(transExecutionConfiguration).getParams();
    doReturn(activeTransGraph).when(spoon).getActiveTransGraph();
    doReturn(TEST_LOG_LEVEL).when(transExecutionConfiguration).getLogLevel();
    doReturn(TEST_BOOLEAN_PARAM).when(transExecutionConfiguration).isClearingLog();
    doReturn(TEST_BOOLEAN_PARAM).when(transExecutionConfiguration).isSafeModeEnabled();
    doReturn(TEST_BOOLEAN_PARAM).when(transExecutionConfiguration).isGatheringMetrics();
    delegate.executeTransformation(transMeta, true, false, false, false, false, null, false, LogLevel.BASIC);
    verify(transMeta).setParameterValue(TEST_PARAM_KEY, TEST_PARAM_VALUE);
    verify(transMeta).activateParameters();
    verify(transMeta).setLogLevel(TEST_LOG_LEVEL);
    verify(transMeta).setClearingLog(TEST_BOOLEAN_PARAM);
    verify(transMeta).setSafeModeEnabled(TEST_BOOLEAN_PARAM);
    verify(transMeta).setGatheringMetrics(TEST_BOOLEAN_PARAM);
}
Also used : TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) TransLogDelegate(org.pentaho.di.ui.spoon.trans.TransLogDelegate) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) Test(org.junit.Test)

Example 19 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class ValidatorDialog method getFields.

private void getFields() {
    Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
    shell.setCursor(busy);
    try {
        String sourceStepName = wSourceStep.getText();
        if (!Utils.isEmpty(sourceStepName)) {
            String fieldName = wSourceField.getText();
            RowMetaInterface r = transMeta.getStepFields(sourceStepName);
            if (r != null) {
                wSourceField.setItems(r.getFieldNames());
            }
            wSourceField.setText(fieldName);
        }
        shell.setCursor(null);
        busy.dispose();
    } catch (KettleException ke) {
        shell.setCursor(null);
        busy.dispose();
        new ErrorDialog(shell, BaseMessages.getString(PKG, "ValidatorDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ValidatorDialog.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Cursor(org.eclipse.swt.graphics.Cursor)

Example 20 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class WebServiceDialog method getOutWebServiceFields.

private RowMetaInterface getOutWebServiceFields() {
    RowMetaInterface r = null;
    if (outWsdlParamContainer != null) {
        r = new RowMeta();
        String[] outParams = outWsdlParamContainer.getParamNames();
        // If we have already saved fields mapping, we only show these mappings
        for (int cpt = 0; cpt < outParams.length; cpt++) {
            ValueMetaInterface value = new ValueMeta(outParams[cpt], XsdType.xsdTypeToKettleType(outWsdlParamContainer.getParamType(outParams[cpt])));
            r.addValueMeta(value);
        }
    }
    return r;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)908 KettleException (org.pentaho.di.core.exception.KettleException)369 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)330 RowMeta (org.pentaho.di.core.row.RowMeta)275 ArrayList (java.util.ArrayList)206 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)196 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)180 Test (org.junit.Test)169 StepMeta (org.pentaho.di.trans.step.StepMeta)150 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)142 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)110 KettleStepException (org.pentaho.di.core.exception.KettleStepException)107 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)101 TableItem (org.eclipse.swt.widgets.TableItem)84 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)84 Database (org.pentaho.di.core.database.Database)81 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)79 FormAttachment (org.eclipse.swt.layout.FormAttachment)76 FormData (org.eclipse.swt.layout.FormData)76 FormLayout (org.eclipse.swt.layout.FormLayout)76