Attribute Aggregation
Many instances require searching for users and retrieving attributes from multiple sources and merging those results. There are two options for using multiple attribute sources. MergingPersonAttributeDaoImpl allows multiple child IPersonAttributesAttributeDao implementations to be queried and merges their results into a single result set. CascadingPersonAttributeDao is similar but it folds the results of previous IPersonAttributeDaos into the query for the next IPersonAttributesAttributeDao in the list. Cascading is useful if an attribute from system A is needed to retrieve attributes from system B.
MergingPersonAttributeDaoImpl
Designed to query multiple IPersonAttributeDaos in order and merge the results into a single result set.
Setting up a MergingPersonAttributeDaoImpl in Spring to would look like the following:
<bean id="mergingPersonAttributeDao" class="org.jasig.services.persondir.support.MergingPersonAttributeDaoImpl"> <property name="personAttributeDaos"> <list> <ref bean="jdbcPersonAttributeDao" /> <ref bean="studentLdapPersonAttributeDao" /> <ref bean="facStaffLdapPersonAttributeDao" /> </list> </property> </bean>
This configuration will query three IPersonAttributeDaos in order and merge their results using the default IAttributeMerger which is the MultivaluedAttributeMerger.
CascadingPersonAttributeDao
Designed to query multiple IPersonAttributeDaos in order and merge the results into a single result set. As each IPersonAttributesAttributeDao is queried the attributes from the first IPersonAttributes in the result set are used as the query for the next IPersonAttributesAttributeDao.
Setting up a CascadingPersonAttributeDao in Spring to would look like the following:
<bean id="mergingPersonAttributeDao" class="org.jasig.services.persondir.support.MergingPersonAttributeDaoImpl"> <property name="personAttributeDaos"> <list> <ref bean="jdbcPersonAttributeDao" /> <ref bean="studentLdapPersonAttributeDao" /> <ref bean="facStaffLdapPersonAttributeDao" /> </list> </property> </bean>
This configuration will query three IPersonAttributeDaos in order and merge their results using the default IAttributeMerger which is the ReplacingAttributeAdder.
Configuration
MergingPersonAttributeDaoImpl has an anonymous constructor.
Property |
Type |
Default Value |
|
---|---|---|---|
defaultAttribute |
String |
username |
The attribute name to use for calls to IPersonAttributes getPerson(String). A query Map is generated for these calls using the defaultAttribute and the value passed in. |
personAttributeDaos |
List<IPersonAttributesAttributeDao> |
null |
A List of IPersonAttributeDaos to be queried and have their results merged. |
attrMerger |
IAttributeMerger |
new ReplacingAttributeAdder() |
The result set merging strategy to be used. See the Merging Strategies section for more information on available options. |
recoverExceptions |
boolean |
true |
If an exception thrown by a child IPersonAttributesAttributeDao |
Merging Strategies
Both merging daos use the IAttributeMerger to actually put the multiple results together. Person Directory ships with three implementations of this interface.
MultivaluedAttributeMerger
Merging of the Sets of IPersonAttributess is additive. For IPersonAttributess with the same name the person's attributes are merged into multi-valued lists.
As an example of this for two IPersonAttributess with the same name where:
- IPersonAttributes A has attributes {email=eric.dalquist@example.com, phone=123-456-7890}
- IPersonAttributes B has attributes {phone=[111-222-3333, 000-999-8888], office=3233}
- The resulting merged IPersonAttributes would have attributes: {email=eric.dalquist@example.com, phone=[123-456-7890, 111-222-3333, 000-999-8888], office=3233}
NoncollidingAttributeAdder
Merging of the Sets of IPersonAttributess is additive. For IPersonAttributess with the same name the person's attributes are merged such that only attributes on the second IPersonAttributes that don't already exist on the first IPersonAttributes are merged in.
As an example of this for two IPersonAttributess with the same name where:
- IPersonAttributes A has attributes {email=eric.dalquist@example.com, phone=123-456-7890}
- IPersonAttributes B has attributes {phone=[111-222-3333, 000-999-8888], office=3233}
- The resulting merged IPersonAttributes would have attributes: {email=eric.dalquist@example.com, phone=123-456-7890, office=3233}
ReplacingAttributeAdder
Merging of the Sets of IPersonAttributess is additive. For IPersonAttributess with the same name the person's attributes are merged such that attributes on the second IPersonAttributes replace any attributes with the same name on the first IPersonAttributes.
As an example of this for two IPersonAttributess with the same name where:
- IPersonAttributes A has attributes {email=eric.dalquist@example.com, phone=123-456-7890}
- IPersonAttributes B has attributes {phone=[111-222-3333, 000-999-8888], office=3233}
- The resulting merged IPersonAttributes would have attributes: {email=eric.dalquist@example.com, phone=[111-222-3333, 000-999-8888], office=3233}