org.jasig.portal.services.persondir.support
Class JdbcPersonAttributeDaoImpl

java.lang.Object
  extended by org.jasig.portal.services.persondir.support.AbstractDefaultQueryPersonAttributeDao
      extended by org.jasig.portal.services.persondir.support.JdbcPersonAttributeDaoImpl
All Implemented Interfaces:
IPersonAttributeDao

public class JdbcPersonAttributeDaoImpl
extends AbstractDefaultQueryPersonAttributeDao

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.

Since:
uPortal 2.5
Version:
$Revision: 1.9 $ $Date: 2005/04/17 21:26:20 $
Author:
andrew.petro@yale.edu, Eric Dalquist edalquist@unicon.net

Nested Class Summary
private  class JdbcPersonAttributeDaoImpl.PersonAttributeMappingQuery
          An object which will execute a SQL query with the expectation of yielding a ResultSet with zero or one rows, which it maps to null or to a Map from uPortal attribute names to values.
 
Field Summary
private  java.util.Map attributeMappings
          Map from column names to attribute names.
private  JdbcPersonAttributeDaoImpl.PersonAttributeMappingQuery query
          The MappingSqlQuery to use to get attributes.
private  java.util.List queryAttributes
          List of attributes to use in the query.
private  java.util.Set userAttributes
          Set of attributes that may be provided for a user.
 
Fields inherited from class org.jasig.portal.services.persondir.support.AbstractDefaultQueryPersonAttributeDao
log
 
Constructor Summary
JdbcPersonAttributeDaoImpl(javax.sql.DataSource ds, java.util.List attrList, java.lang.String sql)
          Create the DAO, configured with the needed query information.
 
Method Summary
 java.util.Map 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.
 java.util.Set getPossibleUserAttributeNames()
          Gets a Set of attribute names that may be returned by the IPersonAttributeDao.getUserAttributes(Map).
 java.util.Map getUserAttributes(java.util.Map seed)
          Returned Map will have values of String or a List of String.
 void setColumnsToAttributes(java.util.Map columnsToAttributesMap)
          Set the Map to use for mapping from a column name to a attribute name or Set of attribute names.
 java.lang.String toString()
           
 
Methods inherited from class org.jasig.portal.services.persondir.support.AbstractDefaultQueryPersonAttributeDao
getDefaultAttributeName, getUserAttributes, setDefaultAttributeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributeMappings

private java.util.Map attributeMappings
Map from column names to attribute names.


userAttributes

private java.util.Set userAttributes
Set of attributes that may be provided for a user.


queryAttributes

private java.util.List queryAttributes
List of attributes to use in the query.


query

private JdbcPersonAttributeDaoImpl.PersonAttributeMappingQuery query
The MappingSqlQuery to use to get attributes.

Constructor Detail

JdbcPersonAttributeDaoImpl

public JdbcPersonAttributeDaoImpl(javax.sql.DataSource ds,
                                  java.util.List attrList,
                                  java.lang.String sql)
Create the DAO, configured with the needed query information.

Parameters:
ds - The DataSource to run the queries against.
attrList - The list of arguments for the query.
sql - The SQL query to run.
Method Detail

getUserAttributes

public java.util.Map getUserAttributes(java.util.Map seed)
Returned Map will have values of String or a List of String.

Parameters:
seed - immutable Map of attributes to values to seed the query
Returns:
Map from attribute names to values
See Also:
IPersonAttributeDao.getUserAttributes(java.util.Map)

getPossibleUserAttributeNames

public java.util.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.

getColumnsToAttributes

public java.util.Map 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(java.util.Map 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.
Throws:
java.lang.IllegalArgumentException - If the Map doesn't follow the rules stated above.
See Also:
MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(Map)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object