org.jasig.services.persondir.support.jdbc
Class NamedParameterJdbcPersonAttributeDao

java.lang.Object
  extended by org.jasig.services.persondir.support.BasePersonAttributeDao
      extended by org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
          extended by org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
              extended by org.jasig.services.persondir.support.jdbc.NamedParameterJdbcPersonAttributeDao
All Implemented Interfaces:
IPersonAttributeDao, org.springframework.beans.factory.InitializingBean

public class NamedParameterJdbcPersonAttributeDao
extends AbstractDefaultAttributePersonAttributeDao
implements org.springframework.beans.factory.InitializingBean

Implementation of PersonAttributeDao based on Spring's NamedParameterJdbcTemplate. Specify any valid SQL, using named parameters as necessary. Name the columns you want as attributes with the property 'userAttributeNames' (you can adjust names to taste using aliases in your SQL). Supports multi-valued attributes through inner joins.

Example SQL: SELECT USER_ID FROM UP_USER WHERE USER_NAME = :username

Example Sprring Configuration:

<bean id="rolesUserSource" class="org.jasig.services.persondir.support.jdbc.NamedParameterJdbcPersonAttributeDao"> <property name="dataSource" ref="PersonDB" /> <property name="sql"> <value> SELECT rolename AS scsRoleName from s_external_role where oprid = UPPER(:username) </value> </property> <property name="usernameAttributeProvider" ref="usernameAttributeProvider" /> <property name="userAttributeNames"> <set> <value>scsRoleName</value> </set> </property> </bean>

Author:
drew wills

Field Summary
 
Fields inherited from class org.jasig.services.persondir.support.BasePersonAttributeDao
logger
 
Fields inherited from interface org.jasig.services.persondir.IPersonAttributeDao
WILDCARD, WILDCARD_PATTERN
 
Constructor Summary
NamedParameterJdbcPersonAttributeDao()
           
 
Method Summary
 void afterPropertiesSet()
           
 Set<String> getAvailableQueryAttributes()
           
 Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(Map<String,List<Object>> queryParameters)
           
 Set<String> getPossibleUserAttributeNames()
           
 void setAvailableQueryAttributes(Set<String> availableQueryAttributes)
           
 void setDataSource(DataSource dataSource)
           
 void setSql(String sql)
           
 void setUserAttributeNames(Set<String> userAttributeNames)
           
 void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider)
          The IUsernameAttributeProvider to use for determining the username attribute to use when none is provided.
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getPerson, getUsernameAttributeProvider, toSeedMap
 
Methods inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
getPeople, toMultivaluedSeed
 
Methods inherited from class org.jasig.services.persondir.support.BasePersonAttributeDao
flattenResults, getMultivaluedUserAttributes, getMultivaluedUserAttributes, getUserAttributes, getUserAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedParameterJdbcPersonAttributeDao

public NamedParameterJdbcPersonAttributeDao()
Method Detail

setDataSource

public void setDataSource(DataSource dataSource)

setSql

public void setSql(String sql)

setUsernameAttributeProvider

public void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider)
Description copied from class: AbstractDefaultAttributePersonAttributeDao
The IUsernameAttributeProvider to use for determining the username attribute to use when none is provided. The provider is used when calls are made to AbstractDefaultAttributePersonAttributeDao.getPerson(String) to build a query Map and then call IPersonAttributeDao.getPeopleWithMultivaluedAttributes(Map)

Overrides:
setUsernameAttributeProvider in class AbstractDefaultAttributePersonAttributeDao
Parameters:
usernameAttributeProvider - the usernameAttributeProvider to set

setAvailableQueryAttributes

public void setAvailableQueryAttributes(Set<String> availableQueryAttributes)

setUserAttributeNames

public void setUserAttributeNames(Set<String> userAttributeNames)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

getAvailableQueryAttributes

public Set<String> getAvailableQueryAttributes()
Specified by:
getAvailableQueryAttributes in interface IPersonAttributeDao

getPeopleWithMultivaluedAttributes

public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(Map<String,List<Object>> queryParameters)
Specified by:
getPeopleWithMultivaluedAttributes in interface IPersonAttributeDao

getPossibleUserAttributeNames

public Set<String> getPossibleUserAttributeNames()
Specified by:
getPossibleUserAttributeNames in interface IPersonAttributeDao


Copyright © 2012 Jasig. All Rights Reserved.