org.jasig.services.persondir.support
Class RegexGatewayPersonAttributeDao

java.lang.Object
  extended by org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
      extended by org.jasig.services.persondir.support.RegexGatewayPersonAttributeDao
All Implemented Interfaces:
IPersonAttributeDao

public final class RegexGatewayPersonAttributeDao
extends AbstractDefaultAttributePersonAttributeDao

This DAO wraps another DAO and only executes the wrapped DAO if the data in the seed matches criteria set out by the configured patterns Map. Multiple seed attributes can be tested by specifying the attribute name as the key of the patterns Map and the regular expression pattern as the value.

Configuration:

Property Description Required Default
patterns A Map of String attribute names to String regular expression patterns. Yes null
targetPersonAttributeDao A the IPersonAttributeDao to delegate the call to if the pattern matching criteria is met. Yes null
matchAllPatterns If true all patterns in the patterns map must past the value mapping criteria for the targetPersonAttributeDao to be delegated to. If false only one of the patterns needs to pass the value mapping criteria. No false
matchAllValues If true all values for the attribute being tested must match the pattern testing it for the criteria to be met. If false only one of the values needs to match the pattern for the criteria to be met. No false


Field Summary
 
Fields inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
logger
 
Constructor Summary
RegexGatewayPersonAttributeDao(String attributeName, String pattern, IPersonAttributeDao enclosed)
          Creates a RegexGatewayPersonAttributeDao that will test a single attribute.
 
Method Summary
 Map getPatterns()
           
 Set getPossibleUserAttributeNames()
          Gets a Set of attribute names that may be returned by the IPersonAttributeDao.getUserAttributes(Map).
 IPersonAttributeDao getTargetPersonAttributeDao()
           
 Map getUserAttributes(Map seed)
          Obtains a mutable Map from attribute names to values for the given query seed which is an immutable Map.
 boolean isMatchAllPatterns()
           
 boolean isMatchAllValues()
           
 void setMatchAllPatterns(boolean matchAllPatterns)
           
 void setMatchAllValues(boolean matchAllValues)
           
 void setPatterns(Map patterns)
           
 void setTargetPersonAttributeDao(IPersonAttributeDao targetPersonAttributeDao)
           
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getDefaultAttributeName, getUserAttributes, setDefaultAttributeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexGatewayPersonAttributeDao

public RegexGatewayPersonAttributeDao(String attributeName,
                                      String pattern,
                                      IPersonAttributeDao enclosed)
Creates a RegexGatewayPersonAttributeDao that will test a single attribute. The specified attribute is also configured as the AbstractDefaultAttributePersonAttributeDao.setDefaultAttributeName(String).

Parameters:
attributeName - The attribute to test, is also set as the defaultAttributeName.
pattern - The pattern to test the specified attribute with.
enclosed - The IPersonAttributeDao to delegate to if the pattern matches.
Method Detail

getPatterns

public Map getPatterns()
Returns:
the patterns

setPatterns

public void setPatterns(Map patterns)
Parameters:
patterns - the patterns to set

getTargetPersonAttributeDao

public IPersonAttributeDao getTargetPersonAttributeDao()
Returns:
the targetPersonAttributeDao

setTargetPersonAttributeDao

public void setTargetPersonAttributeDao(IPersonAttributeDao targetPersonAttributeDao)
Parameters:
targetPersonAttributeDao - the targetPersonAttributeDao to set

isMatchAllPatterns

public boolean isMatchAllPatterns()
Returns:
the matchAllPatterns

setMatchAllPatterns

public void setMatchAllPatterns(boolean matchAllPatterns)
Parameters:
matchAllPatterns - the matchAllPatterns to set

isMatchAllValues

public boolean isMatchAllValues()
Returns:
the matchAllValues

setMatchAllValues

public void setMatchAllValues(boolean matchAllValues)
Parameters:
matchAllValues - the matchAllValues to set

getUserAttributes

public Map getUserAttributes(Map seed)
Description copied from interface: IPersonAttributeDao
Obtains a mutable Map from attribute names to values for the given query seed which is an immutable Map. The values may be mutable objects but it is recommended that they be immutable.
For the returned Map; Keys must be String, Values can be any Object, they are typically Strings.
Values may also be multi-valued, in this case they are of type List and the list contents are the values of the attribute.
This method returns according to the following rules:

Unless otherwise specified by an implementation the returned Map will not be a union of the seed and query results. If your are given a Map that includes the attribute "phone" and value "555-1212" and the returned Map contains the attribute "phone" with the value "555-1212", this means that your implementation also believes that the "phone" attribute should have this value.

Parameters:
seed - immutable Map of attributes to values to seed the query
Returns:
Map from attribute names to values

getPossibleUserAttributeNames

public Set getPossibleUserAttributeNames()
Description copied from interface: IPersonAttributeDao
Gets a Set of attribute names that may be returned by the IPersonAttributeDao.getUserAttributes(Map). The names returned represent all possible names IPersonAttributeDao.getUserAttributes(Map) could return. If the dao doesn't have a way to know all possible attribute names this method should return null.
Returns an immutable Set.

Returns:
A {link Set} of possible attribute names for user queries.


Copyright © 1998-2007 Java Architectures Special Interest Group. All Rights Reserved.