JdbcPersonAttributeDaoImpl
An IPersonAttributeDao implementation that maps from column names in the result of SQL query to uPortal attribute names.
Configuration examples
Using JNDI
Here's an example of getting the DataSource via JDNI and mapping a single ResultSet column to multiple uPortal attribute names.
<beans> <!-- this is the key bean, with the special id "personAttributeDao" that PersonDirectory is looking for. --> <bean id="personAttributeDao" class="org.jasig.portal.services.persondir.support.JdbcPersonAttributeDaoImpl"> <!-- the JDBC implementation takes two arguments in its constructor. the first is a DataSource --> <constructor-arg> <!-- get the DataSource via JNDI --> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>java:comp/env/jdbc/myDatasource</value></property> </bean> </constructor-arg> <!-- the second constructor argument to the JDBC implementation is the SQL query that will yield a single row. The ? will be replaced with the userid about whom we are querying --> <constructor-arg> <value>SELECT first_name, last_name FROM someschema.sometable WHERE uid = ?</value> </constructor-arg> <!-- the JDBC implementation has one other requirement: a Map from column names in the ResultSet to uPortal IPerson attribute names. Here we demonstrate mapping a single column to several attribute names --> <property name="columnsToAttributes"> <map> <entry key="first_name"> <set> <bean class="java.lang.String"> <constructor-arg> <value>firstName</value> </constructor-arg> </bean> <bean class="java.lang.String"> <constructor-arg> <value>givenName</value> </constructor-arg> </bean> </set> </entry> <entry key="last_name"> <set> <bean class="java.lang.String"> <constructor-arg> <value>lastName</value> </constructor-arg> </bean> <bean class="java.lang.String"> <constructor-arg> <value>familyName</value> </constructor-arg> </bean> </set> </entry> </map> </property> </bean> </beans>
Declaring a connection-pooling DataSource
<beans> <!-- this is the key bean, with the special id "personAttributeDao" that PersonDirectory is looking for. --> <bean id="personAttributeDao" class="org.jasig.portal.services.persondir.support.JdbcPersonAttributeDaoImpl"> <!-- the JDBC implementation takes two arguments in its constructor. the first is a DataSource --> <constructor-arg> <!-- Instantiate a connection-pooling DataSource. | The bean has no "id" attribute because it is an anonymous inner bean -- just used | for this DAO. If you wanted to re-use it, you could give it an id. +--> <bean class="org.apache.commons.dbcp.BasicDataSource"> <property name="removeAbandoned"> <value>true</value> </property> <property name="maxActive"> <value>5</value> </property> <property name="maxIdle"> <value>3</value> </property> <property name="maxWait"> <value>10000</value> </property> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc:oracle:thin:yourschema@yourserver.its.yale.edu:1521:YOURDBID</value> </property> <property name="username"> <value>your_username</value> </property> <property name="password"> <value>your_password</value> </property> </bean> </constructor-arg> <!-- the second constructor argument to the JDBC implementation is the SQL query that will yield a single row. The ? will be replaced with the userid about whom we are querying --> <constructor-arg> <value>SELECT first_name, last_name FROM someschema.sometable WHERE uid = ?</value> </constructor-arg> <!-- the JDBC implementation has one other requirement: a Map from column names in the ResultSet to uPortal IPerson attribute names. Here we demonstrate mapping a single column to several attribute names --> <property name="columnsToAttributes"> <map> <entry key="first_name"> <set> <bean class="java.lang.String"> <constructor-arg> <value>firstName</value> </constructor-arg> </bean> <bean class="java.lang.String"> <constructor-arg> <value>givenName</value> </constructor-arg> </bean> </set> </entry> <entry key="last_name"> <set> <bean class="java.lang.String"> <constructor-arg> <value>lastName</value> </constructor-arg> </bean> <bean class="java.lang.String"> <constructor-arg> <value>familyName</value> </constructor-arg> </bean> </set> </entry> </map> </property> </bean> </beans>