I'm a SPARQL Junkie

My coworker Wing and I wanted to send out evites to all of our immediate coworkers and the various interns that are working with us this summer. I told Wing that if he would write up the text of the evite that I would gather the email addresses. At IBM, we have a corporate directory called BluePages and I was trying to avoid manually searching for each person and looking up and copying their (internet) email addresses.

Over the years, IBMers have developed a slew of APIs to access the information in BluePages programmatically, but as I'm unfamiliar with most of them, I turned to Elias for help. Elias said:

Why don't you use SPARQL?

In the ensuing conversation, I learned that Elias had spent some time last week setting up SquirrelRDF to map SPARQL queries to BluePages, as suggested on #swig. He whipped open a browser window with the corporate LDAP schema and a terminal window with the (RDF) configuration file mapping LDAP attributes to RDF predicates.

A few minutes later, we had achieved our goal:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ibm: <http://w3.ibm.com/bluepages#>
SELECT ?mbox
           _:elias foaf:name "Elias Torres" ; ibm:department ?dept.
           _:person ibm:department ?dept  ; foaf:mbox ?mbox .
   } UNION {
           _:wing foaf:name "Wing C. Yung" ; ibm:department ?dept.
           _:person ibm:department ?dept  ; foaf:mbox ?mbox .
   } UNION {
           _:alex foaf:name "ALEX H. CHAO" ; ibm:department ?dept ; ibm:city _:location .
           _:person ibm:department ?dept  ; foaf:mbox ?mbox ; ibm:city _:location .
} ORDER BY ?mbox

(More info: Our lab in Cambridge is composed organizationally of two different departments, and some of our interns report to yet a third department. The third department also contains people not in Cambridge, so we used seed people from each department, grabbed the information that identifies their department (and location), and found all other people matching the same criteria.) We used this SquirrelRDF config file:

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix lmap: <http://jena.hpl.hp.com/schemas/ldapmap#> .
@prefix ibm: <http://w3.ibm.com/bluepages#> .
<> a lmap:Map ;
        lmap:server <ldap://localhost/ou=bluepages,o=ibm.com> ;
        lmap:mapsProp [ lmap:property foaf:name ; lmap:attribute "cn" ; ] ;
        lmap:mapsProp [ lmap:property ibm:department ; lmap:attribute "dept" ; ] ;
        lmap:mapsProp [ lmap:property foaf:mbox ; lmap:attribute "mail" ; ] ;
        lmap:mapsProp [ lmap:property ibm:city ; lmap:attribute "workLoc" ; ] ;

(This post co-authored by Elias, Wing, and myself.)