add support for nsfReviewer to RDF/Zotero RDF

This commit is contained in:
Simon Kornblith 2010-01-17 18:00:59 +00:00
parent ce4327ddb6
commit 59e21310a3
2 changed files with 98 additions and 24 deletions

View file

@ -32,6 +32,9 @@ var n = {
prism:"http://prismstandard.org/namespaces/1.2/basic/", prism:"http://prismstandard.org/namespaces/1.2/basic/",
foaf:"http://xmlns.com/foaf/0.1/", foaf:"http://xmlns.com/foaf/0.1/",
vcard:"http://nwalsh.com/rdf/vCard#", vcard:"http://nwalsh.com/rdf/vCard#",
vcard2:"http://www.w3.org/2006/vcard/ns#", // currently used only for NSF, but is probably
// very similar to the nwalsh vcard ontology in a
// different namespace
link:"http://purl.org/rss/1.0/modules/link/", link:"http://purl.org/rss/1.0/modules/link/",
z:"http://www.zotero.org/namespaces/export#" z:"http://www.zotero.org/namespaces/export#"
}; };
@ -292,7 +295,7 @@ function importItem(newItem, node, type) {
} }
// title // title
newItem.title = getFirstResults(node, [n.dc+"title"], true); newItem.title = getFirstResults(node, [n.dc+"title", n.vcard2+"fn"], true);
if(!newItem.itemType && !newItem.title) { // require the title if(!newItem.itemType && !newItem.title) { // require the title
// (if not a known type) // (if not a known type)
return false; return false;
@ -364,7 +367,7 @@ function importItem(newItem, node, type) {
newItem.artworkMedium = newItem.interviewMedium = getFirstResults(node, [n.dcterms+"medium"], true); newItem.artworkMedium = newItem.interviewMedium = getFirstResults(node, [n.dcterms+"medium"], true);
// publisher // publisher
var publisher = getFirstResults(node, [n.dc+"publisher"]); var publisher = getFirstResults(node, [n.dc+"publisher", n.vcard2+"org"]);
if(publisher) { if(publisher) {
if(typeof(publisher[0]) == "string") { if(typeof(publisher[0]) == "string") {
newItem.publisher = publisher[0]; newItem.publisher = publisher[0];
@ -378,6 +381,8 @@ function importItem(newItem, node, type) {
if(place) { if(place) {
newItem.place = getFirstResults(place[0], [n.vcard+"locality"]); newItem.place = getFirstResults(place[0], [n.vcard+"locality"]);
} }
} else if(type == n.vcard2+"Organization") {
newItem.publisher = getFirstResults(publisher[0], [n.vcard2+"organization-name"], true);
} }
} }
} }
@ -387,7 +392,7 @@ function importItem(newItem, node, type) {
newItem.distributor = newItem.label = newItem.company = newItem.institution = newItem.publisher; newItem.distributor = newItem.label = newItem.company = newItem.institution = newItem.publisher;
// date // date
newItem.date = getFirstResults(node, [n.dc+"date"], true); newItem.date = getFirstResults(node, [n.dc+"date", n.dcterms+"dateSubmitted"], true);
if (!newItem.date) { if (!newItem.date) {
newItem.date = getFirstResults(node, [n.dc+"date.issued"], true); newItem.date = getFirstResults(node, [n.dc+"date.issued"], true);
if (!newItem.date) { if (!newItem.date) {
@ -399,7 +404,6 @@ function importItem(newItem, node, type) {
// lastModified // lastModified
newItem.lastModified = getFirstResults(node, [n.dcterms+"modified"], true); newItem.lastModified = getFirstResults(node, [n.dcterms+"modified"], true);
// identifier // identifier
var identifiers = getFirstResults(node, [n.dc+"identifier"]); var identifiers = getFirstResults(node, [n.dc+"identifier"]);
if(container) { if(container) {
@ -439,6 +443,13 @@ function importItem(newItem, node, type) {
} }
} }
if(!newItem.url) {
var url = getFirstResults(node, [n.vcard2+"url"]);
if(url) {
newItem.url = Zotero.RDF.getResourceURI(url[0]);
}
}
// archiveLocation // archiveLocation
newItem.archiveLocation = getFirstResults(node, [n.dc+"coverage"], true); newItem.archiveLocation = getFirstResults(node, [n.dc+"coverage"], true);
@ -473,6 +484,21 @@ function importItem(newItem, node, type) {
// journalAbbreviation // journalAbbreviation
newItem.journalAbbreviation = getFirstResults((container ? container : node), [n.dcterms+"alternative"], true); newItem.journalAbbreviation = getFirstResults((container ? container : node), [n.dcterms+"alternative"], true);
// address
var adr = getFirstResults(node, [n.vcard2+"adr"]);
if(adr) {
newItem.address = getFirstResults(adr[0], [n.vcard2+"label"], true);
}
// telephone
newItem.telephone = getFirstResults(node, [n.vcard2+"tel"], true);
// email
newItem.email = getFirstResults(node, [n.vcard2+"email"], true);
// accepted
newItem.accepted = getFirstResults(node, [n.dcterms+"dateAccepted"], true);
// see also // see also
processSeeAlso(node, newItem); processSeeAlso(node, newItem);

View file

@ -25,6 +25,9 @@ var n = {
prism:"http://prismstandard.org/namespaces/1.2/basic/", prism:"http://prismstandard.org/namespaces/1.2/basic/",
foaf:"http://xmlns.com/foaf/0.1/", foaf:"http://xmlns.com/foaf/0.1/",
vcard:"http://nwalsh.com/rdf/vCard#", vcard:"http://nwalsh.com/rdf/vCard#",
vcard2:"http://www.w3.org/2006/vcard/ns#", // currently used only for NSF, but is probably
// very similar to the nwalsh vcard ontology in a
// different namespace
link:"http://purl.org/rss/1.0/modules/link/", link:"http://purl.org/rss/1.0/modules/link/",
z:"http://www.zotero.org/namespaces/export#" z:"http://www.zotero.org/namespaces/export#"
}; };
@ -175,9 +178,10 @@ function generateItem(item, zoteroType, resource) {
// generate container // generate container
if(container) { if(container) {
if(item.ISSN && !Zotero.RDF.getArcsIn("urn:issn:"+item.ISSN)) { var testISSN = "urn:issn:"+encodeURI(item.ISSN);
if(item.ISSN && !Zotero.RDF.getArcsIn(testISSN)) {
// use ISSN as container URI if no other item is // use ISSN as container URI if no other item is
containerElement = "urn:issn:"+item.ISSN; containerElement = testISSN;
} else { } else {
containerElement = Zotero.RDF.newResource(); containerElement = Zotero.RDF.newResource();
} }
@ -197,12 +201,20 @@ function generateItem(item, zoteroType, resource) {
} }
// generate publisher // generate publisher
if(item.publisher || item.distributor || item.label || item.company || item.institution || item.place) { // BEGIN NSF
if(zoteroType == "nsfReviewer") {
var organization = Zotero.RDF.newResource(); var organization = Zotero.RDF.newResource();
// set organization type Zotero.RDF.addStatement(organization, rdf+"type", n.vcard2+"Organization", false);
Zotero.RDF.addStatement(organization, rdf+"type", n.foaf+"Organization", false); Zotero.RDF.addStatement(resource, n.vcard2+"org", organization, false);
// add relationship to resource } else {
Zotero.RDF.addStatement(resource, n.dc+"publisher", organization, false); // END NSF
if(item.publisher || item.distributor || item.label || item.company || item.institution || item.place) {
var organization = Zotero.RDF.newResource();
// set organization type
Zotero.RDF.addStatement(organization, rdf+"type", n.foaf+"Organization", false);
// add relationship to resource
Zotero.RDF.addStatement(resource, n.dc+"publisher", organization, false);
}
} }
var typeProperties = ["reportType", "videoRecordingType", "letterType", var typeProperties = ["reportType", "videoRecordingType", "letterType",
@ -285,18 +297,30 @@ function generateItem(item, zoteroType, resource) {
if(!value) continue; if(!value) continue;
if(property == "title") { // title if(property == "title") { // title
Zotero.RDF.addStatement(resource, n.dc+"title", value, true); // BEGIN NSF
if(zoteroType == "nsfReviewer") {
Zotero.RDF.addStatement(resource, n.vcard2+"fn", value, true);
} else {
// END NSF
Zotero.RDF.addStatement(resource, n.dc+"title", value, true);
}
} else if(property == "source") { // authors/editors/contributors } else if(property == "source") { // authors/editors/contributors
Zotero.RDF.addStatement(resource, n.dc+"source", value, true); Zotero.RDF.addStatement(resource, n.dc+"source", value, true);
} else if(property == "url") { // url } else if(property == "url") { // url
// add url as identifier // BEGIN NSF
var term = Zotero.RDF.newResource(); if(item.homepage) {
// set term type Zotero.RDF.addStatement(resource, n.vcard2+"url", value, false);
Zotero.RDF.addStatement(term, rdf+"type", n.dcterms+"URI", false); } else {
// set url value // END NSF
Zotero.RDF.addStatement(term, rdf+"value", value, true); // add url as identifier
// add relationship to resource var term = Zotero.RDF.newResource();
Zotero.RDF.addStatement(resource, n.dc+"identifier", term, false); // set term type
Zotero.RDF.addStatement(term, rdf+"type", n.dcterms+"URI", false);
// set url value
Zotero.RDF.addStatement(term, rdf+"value", value, true);
// add relationship to resource
Zotero.RDF.addStatement(resource, n.dc+"identifier", term, false);
}
} else if(property == "accessionNumber") { // accessionNumber as generic ID } else if(property == "accessionNumber") { // accessionNumber as generic ID
Zotero.RDF.addStatement(resource, n.dc+"identifier", value, true); Zotero.RDF.addStatement(resource, n.dc+"identifier", value, true);
} else if(property == "rights") { // rights } else if(property == "rights") { // rights
@ -305,7 +329,11 @@ function generateItem(item, zoteroType, resource) {
property == "version") { // version property == "version") { // version
Zotero.RDF.addStatement(resource, n.prism+"edition", value, true); Zotero.RDF.addStatement(resource, n.prism+"edition", value, true);
} else if(property == "date") { // date } else if(property == "date") { // date
Zotero.RDF.addStatement(resource, n.dc+"date", value, true); if(item.dateSent) {
Zotero.RDF.addStatement(resource, n.dcterms+"dateSubmitted", value, true);
} else {
Zotero.RDF.addStatement(resource, n.dc+"date", value, true);
}
} else if(property == "accessDate") { // accessDate } else if(property == "accessDate") { // accessDate
Zotero.RDF.addStatement(resource, n.dcterms+"dateSubmitted", value, true); Zotero.RDF.addStatement(resource, n.dcterms+"dateSubmitted", value, true);
} else if(property == "issueDate") { // issueDate } else if(property == "issueDate") { // issueDate
@ -362,7 +390,13 @@ function generateItem(item, zoteroType, resource) {
property == "label" || // label (audioRecording) property == "label" || // label (audioRecording)
property == "company" || // company (computerProgram) property == "company" || // company (computerProgram)
property == "institution") { // institution (report) property == "institution") { // institution (report)
Zotero.RDF.addStatement(organization, n.foaf+"name", value, true); // BEGIN NSF
if(zoteroType == "nsfReviewer") {
Zotero.RDF.addStatement(organization, n.vcard2+"organization-name", value, true);
} else {
// END NSF
Zotero.RDF.addStatement(organization, n.foaf+"name", value, true);
}
} else if(property == "place") { // place } else if(property == "place") { // place
var address = Zotero.RDF.newResource(); var address = Zotero.RDF.newResource();
// set address type // set address type
@ -395,6 +429,19 @@ function generateItem(item, zoteroType, resource) {
Zotero.RDF.addStatement(resource, rdf+"value", value, true); Zotero.RDF.addStatement(resource, rdf+"value", value, true);
} }
} }
// BEGIN NSF
} else if(property == "address") {
var address = Zotero.RDF.newResource();
Zotero.RDF.addStatement(address, rdf+"type", n.vcard2+"Address", false);
Zotero.RDF.addStatement(address, n.vcard2+"label", value, true);
Zotero.RDF.addStatement(resource, n.vcard2+"adr", address, false);
} else if(property == "telephone") {
Zotero.RDF.addStatement(resource, n.vcard2+"tel", value, true);
} else if(property == "email") {
Zotero.RDF.addStatement(resource, n.vcard2+"email", value, true);
} else if(property == "accepted") {
Zotero.RDF.addStatement(resource, n.dcterms+"dateAccepted", value, true);
// END NSF
// THIS CATCHES ALL REMAINING PROPERTIES // THIS CATCHES ALL REMAINING PROPERTIES
} else if(ignoreProperties.indexOf(property) == -1) { } else if(ignoreProperties.indexOf(property) == -1) {
Zotero.debug("Zotero RDF: using Zotero namespace for property "+property); Zotero.debug("Zotero RDF: using Zotero namespace for property "+property);
@ -422,8 +469,9 @@ function doExport() {
while(item = Zotero.nextItem()) { while(item = Zotero.nextItem()) {
items.push(item); items.push(item);
if(item.ISBN && !usedResources["urn:isbn:"+item.ISBN]) { var testISBN = "urn:isbn:"+encodeURI(item.ISBN);
itemResources[item.itemID] = "urn:isbn:"+item.ISBN; if(item.ISBN && !usedResources[testISBN]) {
itemResources[item.itemID] = testISBN;
usedResources[itemResources[item.itemID]] = true; usedResources[itemResources[item.itemID]] = true;
} else if(item.itemType != "attachment" && item.url && !usedResources[item.url]) { } else if(item.itemType != "attachment" && item.url && !usedResources[item.url]) {
itemResources[item.itemID] = item.url; itemResources[item.itemID] = item.url;