Trouble with Database Attribute Mapping

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with Database Attribute Mapping

Ryan Richter-2
I am attempting to map attributes based on database queries using org.apereo.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao.


This successfully creates an attribute for my user called "layoutNodesCount" with an integer value when I login.

I have a custom table in the uPortal database with three columns (emplid, student_group, timestamp).

I have the following bean defined in personDirectoryContext.xml:

  <bean id="csucStudentGroupAttributesDao" class="org.apereo.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
    <constructor-arg index="0" ref="PersonDB"/>
    <constructor-arg>
      <value>
        select * CUSTOM_TABLE where {0} and STUDENT_GROUP = 'BLAH'
      </value>
    </constructor-arg>
    <property name="usernameAttributeProvider" ref="usernameAttributeProvider"/>
    <property name="queryAttributeMapping">
      <map>
        <entry key="emplid" value="EMPLID"/>
      </map>
    </property>
    <property name="resultAttributeMapping">
      <map>
        <entry key="STUDENT_GROUP">
          <set>
            <value>
              student_group
            </value>
          </set>            
        </entry>
      </map>
    </property>
  </bean>

My emplid is in the table and it is an attribute successfully mapped by the LDAP Attribute mapper. The row with my student group is set to BLAH.

I have an attribute successfully created called "student_group" but it is blank instead of being set to BLAH (the value of the student_group column).

Anyone have any idea why this might be happening? I have even gone so far as to hard code the query with my emplid = 'my_emplid_here' instead of using {0} and I get the same result.

Thanks,
-Ryan

--
You received this message because you are subscribed to the Google Groups "uPortal Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-user/CAATqWXKWGten-a8_72gOu%3D966HzoAFRbp1gEfrA-i08bmH1A9w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with Database Attribute Mapping

Benito Gonzalez-2
Hi Ryan,


You seem to have a valid definition. Have you confirmed that your account has an 'empIid' attribute in uPortal already defined and ready to use as a queryAttributeMapping key? You can check with the User Administration portlet. 

Best,
-bjagg

On Thu, Mar 11, 2021 at 1:02 PM jmt <[hidden email]> wrote:
The one thing that I think the documentation is missing is that you need to merge the attribute sources via a CachingPersonAttributeDaoImpl bean. See https://apereo.atlassian.net/wiki/spaces/UPM43/pages/103948916/JDBC+User+Attribute+Sources

Although the documentation is for uP 4.3, the bean you need is there. Just put the bean in overlays/uPortal/src/main/resources/properties/contextOverrides/overridesContext.xml (or another XML file under overlays/uPortal/src/main/resources/properties/contextOverrides if you prefer)

Hope this helps!
On Thursday, March 11, 2021 at 12:08:21 PM UTC-8 [hidden email] wrote:
I am attempting to map attributes based on database queries using org.apereo.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao.


This successfully creates an attribute for my user called "layoutNodesCount" with an integer value when I login.

I have a custom table in the uPortal database with three columns (emplid, student_group, timestamp).

I have the following bean defined in personDirectoryContext.xml:

  <bean id="csucStudentGroupAttributesDao" class="org.apereo.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
    <constructor-arg index="0" ref="PersonDB"/>
    <constructor-arg>
      <value>
        select * CUSTOM_TABLE where {0} and STUDENT_GROUP = 'BLAH'
      </value>
    </constructor-arg>
    <property name="usernameAttributeProvider" ref="usernameAttributeProvider"/>
    <property name="queryAttributeMapping">
      <map>
        <entry key="emplid" value="EMPLID"/>
      </map>
    </property>
    <property name="resultAttributeMapping">
      <map>
        <entry key="STUDENT_GROUP">
          <set>
            <value>
              student_group
            </value>
          </set>            
        </entry>
      </map>
    </property>
  </bean>

My emplid is in the table and it is an attribute successfully mapped by the LDAP Attribute mapper. The row with my student group is set to BLAH.

I have an attribute successfully created called "student_group" but it is blank instead of being set to BLAH (the value of the student_group column).

Anyone have any idea why this might be happening? I have even gone so far as to hard code the query with my emplid = 'my_emplid_here' instead of using {0} and I get the same result.

Thanks,
-Ryan

--
You received this message because you are subscribed to the Google Groups "uPortal Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-user/90aaf99e-34f6-4ce6-8424-d6841a547db8n%40apereo.org.

--
You received this message because you are subscribed to the Google Groups "uPortal Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-user/CAJ_1GkQm2V5Oxwf8uoPAEyxd%2BpMK4fEGwHp8%3DMC_WOveRy1srA%40mail.gmail.com.