use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class BaseEntryManager method dumpAttributes.
protected void dumpAttributes(String variableName, List<AttributeData> attributesToPersist) {
System.out.println("\n" + variableName + ": START");
for (AttributeData attribute : attributesToPersist) {
System.out.println(String.format("%s\t\t%s\t%b", attribute.getName(), Arrays.toString(attribute.getValues()), attribute.getMultiValued()));
}
System.out.println(variableName + ": END");
}
use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class BaseEntryManager method getCustomObjectClasses.
protected String[] getCustomObjectClasses(Object entry, Class<?> entryClass) {
List<String> result = new ArrayList<String>();
List<PropertyAnnotation> customObjectAnnotations = getEntryCustomObjectClassAnnotations(entryClass);
for (PropertyAnnotation propertiesAnnotation : customObjectAnnotations) {
String propertyName = propertiesAnnotation.getPropertyName();
Getter getter = getGetter(entryClass, propertyName);
if (getter == null) {
throw new MappingException("Entry should has getter for property " + propertyName);
}
Class<?> parameterType = getSetterPropertyType(entryClass, propertyName);
boolean multiValued = isMultiValued(parameterType);
AttributeData attribute = getAttributeData(propertyName, propertyName, getter, entry, multiValued, false);
if (attribute != null) {
for (String objectClass : attribute.getStringValues()) {
if (objectClass != null) {
result.add(objectClass);
}
}
}
break;
}
return result.toArray(new String[0]);
}
use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class BaseEntryManager method createAttributesFilter.
protected Filter[] createAttributesFilter(List<AttributeData> attributes) {
if ((attributes == null) || (attributes.size() == 0)) {
return null;
}
List<Filter> results = new ArrayList<Filter>(attributes.size());
for (AttributeData attribute : attributes) {
String attributeName = attribute.getName();
for (Object value : attribute.getValues()) {
Filter filter = Filter.createEqualityFilter(attributeName, value);
if ((attribute.getMultiValued() != null) && attribute.getMultiValued()) {
filter.multiValued();
}
results.add(filter);
}
}
return results.toArray(new Filter[results.size()]);
}
use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class BaseEntryManager method getEntryKey.
private String getEntryKey(Object dnValue, boolean caseSensetive, List<PropertyAnnotation> propertiesAnnotations, List<AttributeData> attributesData) {
StringBuilder sb = new StringBuilder("_HASH__").append((String.valueOf(dnValue)).toLowerCase()).append("__");
List<String> processedProperties = new ArrayList<String>();
Map<String, AttributeData> attributesDataMap = getAttributesDataMap(attributesData);
for (PropertyAnnotation propertiesAnnotation : propertiesAnnotations) {
Annotation ldapAttribute = ReflectHelper.getAnnotationByType(propertiesAnnotation.getAnnotations(), AttributeName.class);
if (ldapAttribute == null) {
continue;
}
String ldapAttributeName = ((AttributeName) ldapAttribute).name();
if (StringHelper.isEmpty(ldapAttributeName)) {
ldapAttributeName = propertiesAnnotation.getPropertyName();
}
processedProperties.add(ldapAttributeName);
String[] values = null;
AttributeData attributeData = attributesDataMap.get(ldapAttributeName);
if ((attributeData != null) && (attributeData.getValues() != null)) {
values = attributeData.getStringValues();
Arrays.sort(values);
}
addPropertyWithValuesToKey(sb, ldapAttributeName, values);
}
for (AttributeData attributeData : attributesData) {
if (processedProperties.contains(attributeData.getName())) {
continue;
}
addPropertyWithValuesToKey(sb, attributeData.getName(), attributeData.getStringValues());
}
if (caseSensetive) {
return sb.toString();
} else {
return sb.toString().toLowerCase();
}
}
use of io.jans.orm.model.AttributeData in project jans by JanssenProject.
the class SqlOperationServiceImpl method lookup.
@Override
public List<AttributeData> lookup(String key, String objectClass, String... attributes) throws SearchException, EntryConvertationException {
Instant startTime = OperationDurationUtil.instance().now();
TableMapping tableMapping = connectionProvider.getTableMappingByKey(key, objectClass);
List<AttributeData> result = lookupImpl(tableMapping, key, attributes);
Duration duration = OperationDurationUtil.instance().duration(startTime);
OperationDurationUtil.instance().logDebug("SQL operation: lookup, duration: {}, table: {}, key: {}, attributes: {}", duration, tableMapping.getTableName(), key, attributes);
return result;
}
Aggregations