Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 IPersonAttributesAttributeDaos 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.

...

Designed to query multiple IPersonAttributeDaos IPersonAttributesAttributeDaos in order and merge the results into a single result set.

...

This configuration will query three IPersonAttributeDaos IPersonAttributesAttributeDaos in order and merge their results using the default IAttributeMerger which is the MultivaluedAttributeMerger.

...

Designed to query multiple IPersonAttributeDaos IPersonAttributesAttributeDaos in order and merge the results into a single result set. As each IPersonAttributeDao IPersonAttributesAttributeDao is queried the attributes from the first IPerson IPersonAttributes in the result set are used as the query for the next IPersonAttributeDaoIPersonAttributesAttributeDao.

Setting up a CascadingPersonAttributeDao in Spring to would look like the following:

...

This configuration will query three IPersonAttributeDaos IPersonAttributesAttributeDaos in order and merge their results using the default IAttributeMerger which is the ReplacingAttributeAdder.

...

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 IPersonAttributesAttributeDaos 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 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 IPersons IPersonAttributess is additive. For IPersons IPersonAttributess with the same name the person's attributes are merged such that attributes on the second IPerson IPersonAttributes replace any attributes with the same name on the first IPersonIPersonAttributes.

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=[111-222-3333, 000-999-8888], office=3233}