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

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.AbstractQueryPersonAttributeDao<org.jasig.services.persondir.support.jdbc.PartialWhereClause>
                  extended by org.jasig.services.persondir.support.jdbc.AbstractJdbcPersonAttributeDao<Map<String,Object>>
                      extended by org.jasig.services.persondir.support.jdbc.MultiRowJdbcPersonAttributeDao
All Implemented Interfaces:
IPersonAttributeDao

public class MultiRowJdbcPersonAttributeDao
extends AbstractJdbcPersonAttributeDao<Map<String,Object>>

An IPersonAttributeDao implementation that maps attribute names and values from name and value column pairs. This is usefull if user attributes are stored in a table like:

USER_NM ATTR_NM ATTR_VL
jstudent name.given joe
jstudent name.family student
badvisor name.given bob
badvisor name.family advisor

This class expects 1 to N row results for a query, with each row containing 1 to N name value attribute mappings and the userName of the user the attributes are for. This contrasts SingleRowJdbcPersonAttributeDao which expects a single row result for a user query.


Configuration:
Property Description Required Default
nameValueColumnMappings A Map of attribute name columns to attribute value columns. A single result row can have multiple name columns and multiple value columns associated with each name. The values of the Map can be either String or Collection. Yes null

Since:
uPortal 2.5
Version:
$Revision$ $Date$
Author:
andrew.petro@yale.edu, Eric Dalquist edalquist@unicon.net

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
MultiRowJdbcPersonAttributeDao(DataSource ds, String sql)
          Creates a new MultiRowJdbcPersonAttributeDao specifying the DataSource and SQL to use.
 
Method Summary
 Map<String,Set<String>> getNameValueColumnMappings()
           
protected  org.springframework.jdbc.core.simple.ParameterizedRowMapper<Map<String,Object>> getRowMapper()
           
protected  List<IPersonAttributes> parseAttributeMapFromResults(List<Map<String,Object>> queryResults, String queryUserName)
          Takes the List from the query and parses it into the List of IPersonAttributes attributes to be returned.
 void setNameValueColumnMappings(Map<String,?> nameValueColumnMap)
          The Map of columns from a name column to value columns.
 
Methods inherited from class org.jasig.services.persondir.support.jdbc.AbstractJdbcPersonAttributeDao
appendAttributeToQuery, getPeopleForQuery, getQueryTemplate, getQueryType, setQueryType
 
Methods inherited from class org.jasig.services.persondir.support.AbstractQueryPersonAttributeDao
generateQuery, getAvailableQueryAttributes, getConfiguredUserNameAttribute, getPeopleWithMultivaluedAttributes, getPossibleUserAttributeNames, getQueryAttributeMapping, getResultAttributeMapping, getUnmappedUsernameAttribute, isRequireAllQueryAttributes, isUseAllQueryAttributes, mapPersonAttributes, setQueryAttributeMapping, setRequireAllQueryAttributes, setResultAttributeMapping, setUnmappedUsernameAttribute, setUseAllQueryAttributes
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getPerson, getUsernameAttributeProvider, setUsernameAttributeProvider, 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

MultiRowJdbcPersonAttributeDao

public MultiRowJdbcPersonAttributeDao(DataSource ds,
                                      String sql)
Creates a new MultiRowJdbcPersonAttributeDao specifying the DataSource and SQL to use.

Parameters:
ds - The DataSource to get connections from for executing queries, may not be null.
sql - The SQL to execute for user attributes, may not be null.
Method Detail

getNameValueColumnMappings

public Map<String,Set<String>> getNameValueColumnMappings()
Returns:
The Map of name column to value column(s).

setNameValueColumnMappings

public void setNameValueColumnMappings(Map<String,?> nameValueColumnMap)
The Map of columns from a name column to value columns. Keys are Strings, Values are Strings or List of Strings.

Parameters:
nameValueColumnMap - The Map of name column to value column(s).

getRowMapper

protected org.springframework.jdbc.core.simple.ParameterizedRowMapper<Map<String,Object>> getRowMapper()
Specified by:
getRowMapper in class AbstractJdbcPersonAttributeDao<Map<String,Object>>
Returns:
The ParameterizedRowMapper to handle the results of the SQL query.

parseAttributeMapFromResults

protected List<IPersonAttributes> parseAttributeMapFromResults(List<Map<String,Object>> queryResults,
                                                               String queryUserName)
Description copied from class: AbstractJdbcPersonAttributeDao
Takes the List from the query and parses it into the List of IPersonAttributes attributes to be returned.

Specified by:
parseAttributeMapFromResults in class AbstractJdbcPersonAttributeDao<Map<String,Object>>
Parameters:
queryResults - Results from the query.
queryUserName - The username passed in the query map, if no username attribute existed in the query Map null is provided.
Returns:
The results of the query


Copyright © 2012 Jasig. All Rights Reserved.