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);
}
}
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 */
}
}
}
}
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 */
}
}
}
}
Aggregations