[uportal-user] Re: Trouble with Database Attribute Mapping

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

[uportal-user] Re: Trouble with Database Attribute Mapping

Jonathan M. Tran-2
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.
Reply | Threaded
Open this post in threaded view
|

Re: [uportal-user] Re: Trouble with Database Attribute Mapping

Ryan Richter-2
Thanks jmt and bjagg. I've tried the suggestion regarding merging attributes and it didn't make a difference. emplid is an attribute successfully defined (I can see it in attribute swapper, is that enough to verify it's usable for this purpose?)

I think my root problem is at a lower level, I found the following error in catalina.out (this was an attempt to have a query not even be dependent on data in the table, however the original query and several other queries have met with the same error):

org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reportFailedQuery Failed Query Report SQL=

                select 'blahs' as layoutNodesCount
                from my_custom_table
            ; time=1615608778770 ms;

  The result was a blank layoutNodesCount attribute.  

On Fri, Mar 12, 2021 at 9:23 AM Benito Gonzalez <[hidden email]> wrote:
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.

--
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/CAATqWXLm3wGXoEifSEChDrngbuJZxWNuA7MFNKoK_f2g0XsouA%40mail.gmail.com.