Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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 IPersonAttributeDao 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 IPersonAttributeDao IPersonAttributesAttributeDao in the list. Cascading is useful if an attribute from system A is needed to retrieve attributes from system B.

...

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:

Code Block
xml
xml

<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 IPerson IPersonAttributes getPerson(String). A query Map is generated for these calls using the defaultAttribute and the value passed in.

personAttributeDaos

List<IPersonAttributeDao>List<IPersonAttributesAttributeDao>

null

A List of IPersonAttributeDaos to be queried and have their results merged.

attrMerger

IAttributeMerger

new MultivaluedAttributeMergerReplacingAttributeAdder()

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 IPersonAttributeDao 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 IPersons IPersonAttributess is additive. For IPersons IPersonAttributess with the same name the person's attributes are merged into multi-valued lists.

As an example of this for two IPersons IPersonAttributess with the same name where:

  • IPerson IPersonAttributes A has attributes {email=eric.dalquist@example.com, phone=123-456-7890}
  • IPerson IPersonAttributes B has attributes {phone=[111-222-3333, 000-999-8888], office=3233}
  • The resulting merged IPerson 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 IPersons IPersonAttributess is additive. For IPersons IPersonAttributess with the same name the person's attributes are merged such that only attributes on the second IPerson IPersonAttributes that don't already exist on the first IPerson IPersonAttributes are merged in.

As an example of this for two IPersons IPersonAttributess with the same name where:

  • IPerson IPersonAttributes A has attributes {email=eric.dalquist@example.com, phone=123-456-7890}
  • IPerson IPersonAttributes B has attributes {phone=[111-222-3333, 000-999-8888], office=3233}
  • The resulting merged IPerson 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}