use of netscape.ldap.LDAPAttribute 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);
}
}
use of netscape.ldap.LDAPAttribute in project pentaho-kettle by pentaho.
the class LDIFInput method GetValue.
@SuppressWarnings("unchecked")
private String GetValue(LDAPAttribute[] attributes_LDIF, String AttributValue) {
String Stringvalue = null;
int i = 0;
for (int j = 0; j < attributes_LDIF.length; j++) {
LDAPAttribute attribute_DIF = attributes_LDIF[j];
if (attribute_DIF.getName().equalsIgnoreCase(AttributValue)) {
Enumeration<String> valuesLDIF = attribute_DIF.getStringValues();
while (valuesLDIF.hasMoreElements()) {
String valueLDIF = valuesLDIF.nextElement();
if (i == 0) {
Stringvalue = valueLDIF;
} else {
Stringvalue = Stringvalue + data.multiValueSeparator + valueLDIF;
}
i++;
}
}
}
return Stringvalue;
}
use of netscape.ldap.LDAPAttribute in project pentaho-kettle by pentaho.
the class LDIFInputDialog method GetValue.
@SuppressWarnings("unchecked")
private String GetValue(LDAPAttribute[] attributes_LDIF, String AttributValue) {
String Stringvalue = null;
for (int j = 0; j < attributes_LDIF.length; j++) {
LDAPAttribute attribute_DIF = attributes_LDIF[j];
if (attribute_DIF.getName().equalsIgnoreCase(AttributValue)) {
Enumeration<String> valuesLDIF = attribute_DIF.getStringValues();
// Get the first occurence
Stringvalue = valuesLDIF.nextElement();
}
}
return Stringvalue;
}
Aggregations