Add the ability to link to sameAs and exampleOfWork entities
authorDan Scott <dscott@laurentian.ca>
Tue, 16 Dec 2014 04:29:35 +0000 (23:29 -0500)
committerDan Scott <dscott@laurentian.ca>
Sat, 7 Feb 2015 19:50:11 +0000 (14:50 -0500)
Look for standard identifiers with known URIs, such as
LCCNs, OCLC numbers, and URIs identified in 024 fields,
and add http://schema.org/sameAs or
http://schema.org/exampleOfWork properties to the record.
This helps us link out to the broader linked data world,
and should help those consuming our data to better
understand what resources we have to offer.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Conflicts:
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/body.tt2

Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/body.tt2

index 1d734b8..34d19a1 100644 (file)
 
         # These are URIs that link out to related works for linked data purposes,
         # such as OCLC Work Entities like http://worldcat.org/entity/work/id/415491
-        args.links = []; 
+
+        # We differentiate between http://schema.org/sameAs relations, which
+        # are roughly the same as the work we're describing here, and
+        # http://schema.org/exampleOfWork which point to a broader work, of which
+        # this is a more specific edition or manifestation.
+        args.links.sameAs = [];
+        args.links.exampleOfWork = [];
         FOR link_node IN xml.findnodes('//*[@tag="024"]/*[@code="2" and text()="uri"]');
             my_parent = link_node.parentNode();
             FOR link IN my_parent.findnodes('./*[@code="a"]');
                 link_uri = link.textContent | trim;
-                args.links.push(link_uri);
+                IF link_uri.search('worldcat.org/entity/work');
+                    args.links.exampleOfWork.push(link_uri);
+                ELSE;
+                    args.links.sameAs.push(link_uri);
+                END;
             END;
         END;
         FOR lccn IN xml.findnodes('//*[@tag="010"]/*[@code="a"]');
             lccn_num = lccn.textContent | trim;
-            args.links.push('http://lccn.loc.gov/' _ lccn_num);
+            args.links.sameAs.push('http://lccn.loc.gov/' _ lccn_num);
         END;
         FOR oclcnum IN xml.findnodes('//*[@tag="035"]/*[@code="a"]');
             oclcnum = oclcnum.textContent | trim;
             oclcnum = oclcnum | remove('ocm');
             oclcnum = oclcnum | remove('ocn');
             oclcnum = oclcnum | remove('on') | trim;
-            args.links.push('http://www.worldcat.org/oclc/' _ oclcnum);
+            args.links.sameAs.push('http://www.worldcat.org/oclc/' _ oclcnum);
         END;
-        args.links = args.links.unique;
+        args.links.sameAs = args.links.sameAs.unique;
 
         args.issns = [];
         FOR sub IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
index d758846..616ede0 100644 (file)
@@ -5,9 +5,12 @@
     ctx.record_attrs = attrs; # capture for JS
 %]
 <div id='canvas_main' class='canvas' vocab="http://schema.org/" typeof='[% args.schema.itemtype %] Product' resource="#schemarecord">
-[%- FOREACH link IN args.links; %]
+[%- FOREACH link IN args.links.sameAs; %]
     <link property="sameAs" href="[% link %]">
 [%- END; %]
+[%- FOREACH link IN args.links.exampleOfWork; %]
+    <link property="exampleOfWork" href="[% link %]">
+[%- END; %]
     [%- INCLUDE "opac/parts/record/navigation.tt2" %]
     [%- IF ctx.bib_is_dead %]
     <div id='rdetail_deleted_exp'>