org.jasig.services.persondir.support.jdbc
Class AbstractJdbcPersonAttributeDao<R>

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<R>
All Implemented Interfaces:
IPersonAttributeDao
Direct Known Subclasses:
MultiRowJdbcPersonAttributeDao, SingleRowJdbcPersonAttributeDao

public abstract class AbstractJdbcPersonAttributeDao<R>
extends AbstractQueryPersonAttributeDao<org.jasig.services.persondir.support.jdbc.PartialWhereClause>

Provides common logic for executing a JDBC based query including building the WHERE clause SQL string.

Configuration:

Property Description Required Default
queryType How multiple attributes in a query should be concatenated together. The other option is OR. No AND

Version:
$Revision$
Author:
Eric Dalquist

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
AbstractJdbcPersonAttributeDao(DataSource ds, String queryTemplate)
           
 
Method Summary
protected  org.jasig.services.persondir.support.jdbc.PartialWhereClause appendAttributeToQuery(org.jasig.services.persondir.support.jdbc.PartialWhereClause queryBuilder, String dataAttribute, List<Object> queryValues)
          Append the attribute and value to the queryBuilder.
protected  List<IPersonAttributes> getPeopleForQuery(org.jasig.services.persondir.support.jdbc.PartialWhereClause queryBuilder, String queryUserName)
          Executes the query for the generated queryBuilder object and returns a list where each entry is a Map of attributes for a single IPersonAttributes.
 String getQueryTemplate()
           
 QueryType getQueryType()
           
protected abstract  org.springframework.jdbc.core.simple.ParameterizedRowMapper<R> getRowMapper()
           
protected abstract  List<IPersonAttributes> parseAttributeMapFromResults(List<R> queryResults, String queryUserName)
          Takes the List from the query and parses it into the List of IPersonAttributes attributes to be returned.
 void setQueryType(QueryType queryType)
          Type of logical operator to use when joining WHERE clause components
 
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

AbstractJdbcPersonAttributeDao

public AbstractJdbcPersonAttributeDao(DataSource ds,
                                      String queryTemplate)
Parameters:
ds - The DataSource to use for queries
queryTemplate - Template to use for SQL query generation. Use {0} as the placeholder for where the generated portion of the WHERE clause should be inserted.
Method Detail

getQueryTemplate

public String getQueryTemplate()
Returns:
the queryTemplate

getQueryType

public QueryType getQueryType()
Returns:
the queryType

setQueryType

public void setQueryType(QueryType queryType)
Type of logical operator to use when joining WHERE clause components

Parameters:
queryType - the queryType to set

parseAttributeMapFromResults

protected abstract List<IPersonAttributes> parseAttributeMapFromResults(List<R> queryResults,
                                                                        String queryUserName)
Takes the List from the query and parses it into the List of IPersonAttributes attributes to be returned.

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

getRowMapper

protected abstract org.springframework.jdbc.core.simple.ParameterizedRowMapper<R> getRowMapper()
Returns:
The ParameterizedRowMapper to handle the results of the SQL query.

appendAttributeToQuery

protected org.jasig.services.persondir.support.jdbc.PartialWhereClause appendAttributeToQuery(org.jasig.services.persondir.support.jdbc.PartialWhereClause queryBuilder,
                                                                                              String dataAttribute,
                                                                                              List<Object> queryValues)
Description copied from class: AbstractQueryPersonAttributeDao
Append the attribute and value to the queryBuilder.

Specified by:
appendAttributeToQuery in class AbstractQueryPersonAttributeDao<org.jasig.services.persondir.support.jdbc.PartialWhereClause>
Parameters:
queryBuilder - The sub-class specific query builder object
dataAttribute - The full attribute name to append
queryValues - The values for the data attribute
Returns:
An updated queryBuiler

getPeopleForQuery

protected List<IPersonAttributes> getPeopleForQuery(org.jasig.services.persondir.support.jdbc.PartialWhereClause queryBuilder,
                                                    String queryUserName)
Description copied from class: AbstractQueryPersonAttributeDao
Executes the query for the generated queryBuilder object and returns a list where each entry is a Map of attributes for a single IPersonAttributes.

Specified by:
getPeopleForQuery in class AbstractQueryPersonAttributeDao<org.jasig.services.persondir.support.jdbc.PartialWhereClause>
Parameters:
queryBuilder - The query generated by calls to AbstractQueryPersonAttributeDao.appendAttributeToQuery(Object, String, List)
queryUserName - The username passed in the query map, if no username attribute existed in the query Map null is provided.
Returns:
The list of IPersons found by the query. The user attributes should be using the raw names from the data layer.


Copyright © 2012 Jasig. All Rights Reserved.