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

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.SingleRowJdbcPersonAttributeDao
All Implemented Interfaces:
org.jasig.services.persondir.IPersonAttributeDao

public class SingleRowJdbcPersonAttributeDao
extends AbstractJdbcPersonAttributeDao

An IPersonAttributeDao implementation that maps from column names in the result of a SQL query to attribute names.
You must set a Map from column names to attribute names and only column names appearing as keys in that map will be used.

Configuration:

Property Description Required Default
columnsToAttributes The Map of String columns names to String or Sets of Strings to use as attribute names in the returned Map. If a column name is not in the map the column name will be used in as the returned attribute name. No Collections.EMPTY_MAP

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

Field Summary
 
Fields inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
logger
 
Constructor Summary
SingleRowJdbcPersonAttributeDao(DataSource ds, List<String> attrList, String sql)
          Creates a new MultiRowJdbcPersonAttributeDao specifying the DataSource and SQL to use.
 
Method Summary
protected  void addMappedAttributes(Map<String,Object> rs, String columnName, Map<String,List<Object>> rowResults)
          Tries to get the attributes specified for the column, determin the mapping for the column and add it to the rowResults Map.
 Map<String,Set<String>> getColumnsToAttributes()
          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.
 Set<String> getPossibleUserAttributeNames()
           
protected  Map<String,List<Object>> parseAttributeMapFromResults(List<Map<String,Object>> queryResults)
          Takes the List of Maps from the query and parses it into the attribute Map to be returned.
 void setColumnsToAttributes(Map<String,Object> columnsToAttributesMap)
          Set the Map to use for mapping from a column name to a attribute name or Set of attribute names.
 
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

SingleRowJdbcPersonAttributeDao

public SingleRowJdbcPersonAttributeDao(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
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)
Description copied from class: AbstractJdbcPersonAttributeDao
Takes the List of Maps from the query and parses it into the attribute Map to be returned.

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

getPossibleUserAttributeNames

public Set<String> getPossibleUserAttributeNames()

addMappedAttributes

protected void addMappedAttributes(Map<String,Object> rs,
                                   String columnName,
                                   Map<String,List<Object>> rowResults)
Tries to get the attributes specified for the column, determin the mapping for the column and add it to the rowResults Map.

Parameters:
rs - The Map of results to get the attribute value from.
columnName - The name of the column to get the attribute value from.
rowResults - The Map to add the mapped attribute to.

getColumnsToAttributes

public Map<String,Set<String>> getColumnsToAttributes()
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.

setColumnsToAttributes

public void setColumnsToAttributes(Map<String,Object> columnsToAttributesMap)
Set the Map to use for mapping from a column name to a attribute name or Set of attribute names. Column names that are specified but have null mappings will use the column name for the attribute name. Column names that are not specified as keys in this Map will be ignored.
The passed Map must have keys of type String and values of type String or a Set of String.

Parameters:
columnsToAttributesMap - 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)


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