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

java.lang.Object
  extended by org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
      extended by org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
          extended by org.jasig.services.persondir.support.AbstractQueryPersonAttributeDao
              extended by org.jasig.services.persondir.support.jdbc.AbstractJdbcPersonAttributeDao
                  extended by org.jasig.services.persondir.support.jdbc.MultiRowJdbcPersonAttributeDao
All Implemented Interfaces:
org.jasig.services.persondir.IPersonAttributeDao

public class MultiRowJdbcPersonAttributeDao
extends AbstractJdbcPersonAttributeDao

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. This contrasts SingleRowJdbcPersonAttributeDao which expects a single row result for a user query.


Configuration:
Property Description Required Default
attributeNameMappings Maps attribute names as defined in the database to attribute names to be exposed to the client code. The keys of the Map must be Strings, the values may be null, String or a Set of Strings. The keySet of this Map is returned as the possibleUserAttributeNames property. If an attribute name is not in the map the attribute name will be used in as the returned attribute name. No Collections.EMPTY_MAP
nameValueColumnMappings The Map of columns from a name column to value columns. Keys are Strings, Values are Strings or List of Strings Yes null

Since:
uPortal 2.5
Version:
$Revision: 43106 $ $Date: 2008-02-14 11:22:40 -0600 (Thu, 14 Feb 2008) $
Author:
andrew.petro@yale.edu, Eric Dalquist edalquist@unicon.net

Field Summary
 
Fields inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
logger
 
Constructor Summary
MultiRowJdbcPersonAttributeDao(DataSource ds, List<String> attrList, String sql)
          Creates a new MultiRowJdbcPersonAttributeDao specifying the DataSource and SQL to use.
 
Method Summary
 Map<String,Set<String>> getAttributeNameMappings()
          Get the Map from non-null String column names to Sets of non-null Strings representing the names of the uPortal attributes to be initialized from the specified column.
 Map<String,Set<String>> getNameValueColumnMappings()
           
 Set<String> getPossibleUserAttributeNames()
           
protected  Map<String,List<Object>> parseAttributeMapFromResults(List<Map<String,Object>> queryResults)
          Returned Map will have values of String or a List of String.
 void setAttributeNameMappings(Map<String,Object> attributeNameMap)
          The passed Map must have keys of type String and values of type String or a Set of String.
 void setNameValueColumnMappings(Map<String,? extends Object> nameValueColumnMap)
          The Map of columns from a name column to value columns.
 
Methods inherited from class org.jasig.services.persondir.support.jdbc.AbstractJdbcPersonAttributeDao
getSql, getUserAttributesIfNeeded
 
Methods inherited from class org.jasig.services.persondir.support.AbstractQueryPersonAttributeDao
getMultivaluedUserAttributes, getQueryArgumentArray, getQueryAttributes, getUserAttributesIfNeeded, setQueryAttributes
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getDefaultAttributeName, getMultivaluedUserAttributes, setDefaultAttributeName
 
Methods inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
flattenResults, 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,
                                      List<String> attrList,
                                      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.
attrList - Sets the query attribute list to pass to AbstractJdbcPersonAttributeDao.AbstractJdbcPersonAttributeDao(DataSource, String) and AbstractQueryPersonAttributeDao.setQueryAttributes(List)
sql - The SQL to execute for user attributes, may not be null.
Method Detail

parseAttributeMapFromResults

protected Map<String,List<Object>> parseAttributeMapFromResults(List<Map<String,Object>> queryResults)
Returned Map will have values of String or a List of String.

Specified by:
parseAttributeMapFromResults in class AbstractJdbcPersonAttributeDao
Parameters:
queryResults - Results from the query.
Returns:
The results of the query, as specified by IPersonAttributeDao.getMultivaluedUserAttributes(Map)
See Also:
IPersonAttributeDao.getUserAttributes(java.util.Map)

getPossibleUserAttributeNames

public Set<String> getPossibleUserAttributeNames()

getAttributeNameMappings

public Map<String,Set<String>> getAttributeNameMappings()
Get the Map from non-null String column names to Sets of non-null Strings representing the names of the uPortal attributes to be initialized from the specified column.

Returns:
Returns the attributeMappings mapping.

setAttributeNameMappings

public void setAttributeNameMappings(Map<String,Object> attributeNameMap)
The passed Map must have keys of type String and values of type String or a Set of String.

Parameters:
attributeNameMap - Map from column names to attribute names, may not be null.
Throws:
IllegalArgumentException - If the Map doesn't follow the rules stated above.
See Also:
MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(Map)

getNameValueColumnMappings

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

setNameValueColumnMappings

public void setNameValueColumnMappings(Map<String,? extends Object> 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).


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