grouper-users - RE: [grouper-users] composite value for the description attribute of person subjects?
Subject: Grouper Users - Open Discussion List
List archive
RE: [grouper-users] composite value for the description attribute of person subjects?
Chronological Thread
- From: Chris Hyzer <>
- To: "" <>, "" <>
- Subject: RE: [grouper-users] composite value for the description attribute of person subjects?
- Date: Wed, 17 Feb 2010 23:48:24 -0500
- Accept-language: en-US
- Acceptlanguage: en-US
Hey,
We discussed this on the call today and I added this to the subject API. It
is in the 1.6 branch, but if you copy the subject.jar and commons-jexl.jar to
the lib dir for grouper 1.5 it should work (haven't tried it :) ). Here is
where the jars are if you like:
http://anonsvn.internet2.edu/cgi-bin/viewvc.cgi/i2mi/trunk/grouper/lib/grouper/
https://bugs.internet2.edu/jira/browse/MCO-25
Also, if you implement a Source, without extending BaseSourceAdapter (not
recommended), you need to add some methods. Finally, if you are using
subjects which do not extend SubjectImpl, and you want to take advantage of
this, you will need to use the static methods from SubjectImpl to init the
virtual attributes.
If you need to do something and dont know how, it is probably easy, just ask
the mailing list.
These virtual attributes are lazy initted, and are evaluated once, then
stored in the attribute map.
Here is the documentation from the sources.example.xml
<!--
You can make virtual attributes (attributes with formatting or based on
other attributes) like this:
init-param name is subjectVirtualAttribute_<index>_<name> where index
is the order to be processed
if some depend on others (0 to 99). The value is the jexl expression
language. You can use subjectUtils
methods (aliased with "subjectUtils", or you can register your own
class (must have default constructor).
Here are examples:
<init-param>
<param-name>subjectVirtualAttribute_0_loginIdLfName</param-name>
<param-value>Hey ${subject.getAttributeValue('LOGINID')} and
${subject.getAttributeValue('LFNAME')}</param-value>
</init-param>
<init-param>
<param-name>subjectVirtualAttribute_1_loginIdLfNameLoginId</param-name>
<param-value>${subject.getAttributeValue('loginIdLfName')} Hey
${subject.getAttributeValue('LOGINID')} and
${subject.getAttributeValue('LFNAME')}</param-value>
</init-param>
<init-param>
<param-name>subjectVirtualAttributeVariable_JDBCSourceAdapterTest</param-name>
<param-value>edu.internet2.middleware.subject.provider.JDBCSourceAdapterTest</param-value>
</init-param>
<init-param>
<param-name>subjectVirtualAttribute_2_loginIdSquared</param-name>
<param-value>${JDBCSourceAdapterTest.appendToSelf(subject.getAttributeValue('LOGINID'))}</param-value>
</init-param>
The first virtual attribute is accessible via:
subject.getAttributeValue("loginIdLfNameLoginId");
-->
This should work for subjects in any source (including the Group source).
Anyways, let me know any feedback.
Thanks,
Chris
-----Original Message-----
From: Dominique Petitpierre
[mailto:]
Sent: Tuesday, February 16, 2010 10:30 AM
To:
Subject: [grouper-users] composite value for the description attribute of
person subjects?
Hello,
On the Grouper Wiki I noticed that some sites display a composite
value for each person subject members of a group, e.g.
Michael Christopher Hyzer (chyzer, 12345678) Pennpay, Staff
This is very informative and helps group managers to avoid confusion
between homonyms.
It is possible to construct a "description" attribute from many source
fields with a SQL query when the JDBC source adapter is used, but I
did not find a simple way to configure Grouper to do this when using
the JNDI source adapter, and adding a new attribute on the LDAP side
is not a practical option.
This was discussed on grouper-users some time ago in the following
thread (item 3.):
https://mail.internet2.edu/wws/arc/grouper-users/2008-07/msg00032.html
Chris Hyzer <
>
mentionned
(cf.
https://mail.internet2.edu/wws/arc/grouper-users/2008-07/msg00035.html):
| Or we could make a change request to allow multiple fields in this
| config or the media.properties one...
and "GW Brown, Information Systems and Computing" <
>
added
(cf https://mail.internet2.edu/wws/arc/grouper-users/2008-07/msg00039.html):
| Rather than add UI configuration through media.properties, having
| 'virtual attributes' in the Subject API may be preferable so that
| any Subject API client can use the same mechanism to combine
| attributes.
It would be a useful feature for sites that use the JNDI source
adapter for the Subject API.
- Has this been done? I.e. is there a way to specify a composite value
for the description attribute when using the JNDI source adapter?
Not finding a way to configure it I followed the advice to modify the
JSP code for the Admin UI (and the java code for the new Lite UI), to
display the "name" and "subjectId" Grouper attributes in addition to
the "description" attribute:
diff grouper-ui-1.5.1/webapp/WEB-INF/jsp/subjectView.jsp{.01,}
12c12
< /></c:if><c:if test="${empty inLink}"><span class="<c:out
value="${viewObject.subjectType}"/>Subject"></c:if><c:out
value="${viewObject[mediaMap[attrKey]]}" /><c:if test="${empty
inLink}"></span></c:if>
---
> /></c:if><c:if test="${empty inLink}"><span class="<c:out
> value="${viewObject.subjectType}"/>Subject"></c:if><c:if
> test="${viewObject.subjectType=='person'}"><c:out
> value="${viewObject['description']} (${viewObject['name']},
> ${viewObject['subjectId']})" /></c:if><c:if
> test="${viewObject.subjectType!='person'}"><c:out
> value="${viewObject[mediaMap[attrKey]]}" /></c:if><c:if test="${empty
> inLink}"></span></c:if>
This displays the person subjects in the Admin UI as
description (name, subjectId)
e.g.
Michael Christopher Hyzer (chyzer, 12345678)
diff
grouper-ui-1.5.1/java/src/edu/internet2/middleware/grouper/ui/util/GrouperUiUtils.java{.01,}
1006c1006,1011
< label = subject.getDescription();
---
> if ("person".equals(subject.getType().getName())) {
> label = subject.getDescription() + " (" + subject.getName() + ")";
> } else {
> label = subject.getDescription();
> }
>
and this displays the person subjects in the Lite UI as
description (name)
e.g.
Michael Christopher Hyzer (chyzer)
- Is this workaround reasonable? (i.e. will it work in all cases and
not break anything)?
- Should "webapp/WEB-INF/jsp/subjectSearchResultView.jsp" also be
modified? (It does not seem to be used anywhere.)
Currently this workaround is limited to use only the three Grouper
attributes defined in the subject API source.xml configuration file
(SubjectID_AttributeType, Name_AttributeType,
Description_AttributeType).
- Is there a way to use the other attributes declared in source.xml
(e.g <attribute>employeeType</attribute>) in this JSP or java code?
In any case, modifying source code instead of configuring in
properties or xml files might not be very stable across releases and I
hope that the feature discussed above will be available!
Best regards,
Dominique
--
Mr Dominique Petitpierre, Dominique.Petitpierre(at)unige.ch
Division Informatique, University of Geneva, Switzerland
- composite value for the description attribute of person subjects?, Dominique Petitpierre, 02/16/2010
- Re: [grouper-users] composite value for the description attribute of person subjects?, GW Brown, Information Systems and Computing, 02/16/2010
- RE: [grouper-users] composite value for the description attribute of person subjects?, Chris Hyzer, 02/16/2010
- RE: [grouper-users] composite value for the description attribute of person subjects?, Chris Hyzer, 02/17/2010
Archive powered by MHonArc 2.6.16.