...
Advanced configuration examples
Here's an example of getting the DataSource via JDNI and mapping a single ResultSet column to multiple uPortal attribute names.
Code Block | ||||
---|---|---|---|---|
| ||||
<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> <!-- here we're using aget the DataSource backedvia byJNDI RDBMServices --> <bean <bean id="dataSource" class="org.jasigspringframework.portal.services.db.RDBMServicesDataSourcejndi.JndiObjectFactoryBean"> <property name="dbName"> <value>personDb</value> </property> 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, shirtlast_colorname 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>name</value> <value>givenName</value> </constructor-arg> </bean> </set> </entry> <entry key="shirt_color">last_name"> <set> <bean class="java.lang.String"> <constructor-arg> <value>lastName</value> </constructor-arg> </bean> <bean class="java.lang.String"> <constructor-arg> <value>shirtColor</value> <value>familyName</value> </constructor-arg> </bean> </set> </entry> </map> </property> </bean> </beans> |