Search in sources :

Example 1 with LDAPInputMeta

use of org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta in project pentaho-kettle by pentaho.

the class LDAPInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the XML input step
        LDAPInputMeta oneMeta = new LDAPInputMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "LDAPInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "LDAPInputDialog.NumberRows.DialogMessage"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            progressDialog.open();
            if (!progressDialog.isCancelled()) {
                Trans trans = progressDialog.getTrans();
                String loggingText = progressDialog.getLoggingText();
                if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                    EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                    etd.setReadOnly();
                    etd.open();
                }
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
                prd.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LDAPInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "LDAPInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans) LDAPInputMeta(org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta)

Example 2 with LDAPInputMeta

use of org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta in project pentaho-kettle by pentaho.

the class LDAPInputDialog method get.

private void get() {
    LDAPConnection connection = null;
    try {
        LDAPInputMeta meta = new LDAPInputMeta();
        getInfo(meta);
        // Clear Fields Grid
        wFields.removeAll();
        // Defined a LDAP connection
        connection = new LDAPConnection(log, transMeta, meta, null);
        // connect ...
        if (meta.UseAuthentication()) {
            String username = transMeta.environmentSubstitute(meta.getUserName());
            String password = Encr.decryptPasswordOptionallyEncrypted(transMeta.environmentSubstitute(meta.getPassword()));
            connection.connect(username, password);
        } else {
            connection.connect();
        }
        // return fields
        RowMeta listattributes = connection.getFields(transMeta.environmentSubstitute(meta.getSearchBase()));
        String[] fieldsName = new String[listattributes.size()];
        for (int i = 0; i < listattributes.size(); i++) {
            ValueMetaInterface v = listattributes.getValueMeta(i);
            fieldsName[i] = v.getName();
            // Get Column Name
            TableItem item = new TableItem(wFields.table, SWT.NONE);
            item.setText(1, v.getName());
            item.setText(2, v.getName());
            if (LDAPInputField.binaryAttributes.contains(v.getName())) {
                item.setText(3, BaseMessages.getString(PKG, "LDAPInputField.FetchAttributeAs.Binary"));
            } else {
                item.setText(3, BaseMessages.getString(PKG, "LDAPInputField.FetchAttributeAs.String"));
            }
            item.setText(4, BaseMessages.getString(PKG, "System.Combo.No"));
            item.setText(5, v.getTypeDesc());
        }
        colinf[1].setComboValues(fieldsName);
        wFields.removeEmptyRows();
        wFields.setRowNums();
        wFields.optWidth(true);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LDAPInputDialog.ErrorGettingColums.DialogTitle"), BaseMessages.getString(PKG, "LDAPInputDialog.ErrorGettingColums.DialogMessage"), e);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LDAPInputDialog.ErrorGettingColums.DialogTitle"), BaseMessages.getString(PKG, "LDAPInputDialog.ErrorGettingColums.DialogMessage"), e);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (Exception e) {
            /* Ignore */
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMeta(org.pentaho.di.core.row.RowMeta) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) LDAPConnection(org.pentaho.di.trans.steps.ldapinput.LDAPConnection) KettleException(org.pentaho.di.core.exception.KettleException) LDAPInputMeta(org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 3 with LDAPInputMeta

use of org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta in project pentaho-kettle by pentaho.

the class LDAPInputDialog method test.

private void test() {
    LDAPConnection connection = null;
    try {
        LDAPInputMeta meta = new LDAPInputMeta();
        getInfo(meta);
        // Defined a LDAP connection
        connection = new LDAPConnection(log, transMeta, meta, null);
        // connect...
        if (wusingAuthentication.getSelection()) {
            connection.connect(transMeta.environmentSubstitute(meta.getUserName()), Encr.decryptPasswordOptionallyEncrypted(transMeta.environmentSubstitute(meta.getPassword())));
        } else {
            connection.connect();
        }
        // We are successfully connected
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        mb.setMessage(BaseMessages.getString(PKG, "LDAPInputDialog.Connected.OK") + Const.CR);
        mb.setText(BaseMessages.getString(PKG, "LDAPInputDialog.Connected.Title.Ok"));
        mb.open();
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LDAPInputDialog.Connected.Title.Error"), BaseMessages.getString(PKG, "LDAPInputDialog.Connected.NOK"), e);
    } finally {
        if (connection != null) {
            // Disconnect ...
            try {
                connection.close();
            } catch (Exception e) {
            /* Ignore */
            }
        }
    }
}
Also used : ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) LDAPConnection(org.pentaho.di.trans.steps.ldapinput.LDAPConnection) KettleException(org.pentaho.di.core.exception.KettleException) LDAPInputMeta(org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)3 LDAPInputMeta (org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3 LDAPConnection (org.pentaho.di.trans.steps.ldapinput.LDAPConnection)2 MessageBox (org.eclipse.swt.widgets.MessageBox)1 TableItem (org.eclipse.swt.widgets.TableItem)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 Trans (org.pentaho.di.trans.Trans)1 TransMeta (org.pentaho.di.trans.TransMeta)1 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)1 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)1 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)1 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)1