use of netscape.ldap.util.LDIFRecord in project pentaho-kettle by pentaho.
the class LDIFInputDialog method get.
private void get() {
try {
LDIFInputMeta meta = new LDIFInputMeta();
getInfo(meta);
FileInputList inputList = meta.getFiles(transMeta);
// Clear Fields Grid
wFields.removeAll();
if (inputList.getFiles().size() > 0) {
// Open the file (only first file)...
LDIF InputLDIF = new LDIF(KettleVFS.getFilename(inputList.getFile(0)));
HashSet<String> attributeSet = new HashSet<String>();
// CHECKSTYLE:LineLength:OFF
for (LDIFRecord recordLDIF = InputLDIF.nextRecord(); recordLDIF != null; recordLDIF = InputLDIF.nextRecord()) {
// Get LDIF Content
LDIFContent contentLDIF = recordLDIF.getContent();
if (contentLDIF.getType() == LDIFContent.ATTRIBUTE_CONTENT) {
// Get only ATTRIBUTE_CONTENT
LDIFAttributeContent attrContentLDIF = (LDIFAttributeContent) contentLDIF;
LDAPAttribute[] attributes_LDIF = attrContentLDIF.getAttributes();
for (int j = 0; j < attributes_LDIF.length; j++) {
LDAPAttribute attribute_DIF = attributes_LDIF[j];
String attributeName = attribute_DIF.getName();
if (!attributeSet.contains(attributeName)) {
// Get attribut Name
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, attributeName);
item.setText(2, attributeName);
String attributeValue = GetValue(attributes_LDIF, attributeName);
if (IsDate(attributeValue)) {
item.setText(3, "Date");
} else if (IsInteger(attributeValue)) {
item.setText(3, "Integer");
} else if (IsNumber(attributeValue)) {
item.setText(3, "Number");
} else {
item.setText(3, "String");
}
attributeSet.add(attributeName);
}
}
}
}
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "LDIFInputMeta.ErrorRetrieveData.DialogTitle"), BaseMessages.getString(PKG, "LDIFInputMeta.ErrorRetrieveData.DialogMessage"), e);
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "LDIFInputMeta.ErrorRetrieveData.DialogTitle"), BaseMessages.getString(PKG, "LDIFInputMeta.ErrorRetrieveData.DialogMessage"), e);
}
}
Aggregations