Skip to content
Snippets Groups Projects
Commit c571ba4e authored by Mike Lynch's avatar Mike Lynch
Browse files

accessRights_url now added as a license. Tightened up ids around licenses - added a prefix.

Added tests for the access rights messages when there are no attachments
parent f8af783c
Branches
Tags
No related merge requests found
......@@ -155,6 +155,7 @@ async function datapub2catalog(options) {
const files = make_files(datapub);
const contactPoint = make_contactPoint(contributors[2]);
const dataset = make_dataset(id, datapub, bagged, organisation, dates, files, contributors);
const [ history, more_people ] = make_history(
......@@ -165,6 +166,8 @@ async function datapub2catalog(options) {
people = people.concat(more_people);
}
people = _.uniqBy(people, '@id');
const graph = _.flatten([
......@@ -292,9 +295,6 @@ function make_dataset(id, datapub, bagged, organisation, dates, files, contribut
ds['hasPart'] = files.map(link_id);
} else {
ds['conditionsOfAccess'] = datapub['accessRights_text'];
if( ds['accessRights_url'] ){
//FIXME
}
}
if( dm ) {
ds['contactPoint'] = { '@id': dm['contactPoint'] };
......@@ -658,27 +658,36 @@ function make_license(datapub, prefix) {
if( datapub['license_other_url'] || datapub['license_notes'] ) {
if( datapub['license_other_url'] ) {
licenses.push({
'@id': datapub['license_other_url'],
'@id': DEFAULT_IRI_PREFS['license'] + datapub['license_other_url'],
'@type': 'CreativeWork',
'url': datapub['license_other_url'],
'name': ( datapub['license_notes'] || datapub['license_other_url'])
});
} else {
licenses.push({
'@id': DEFAULT_IRI_PREFS['licenses'] + 'other',
'@id': DEFAULT_IRI_PREFS['license'] + 'other',
'@type': 'CreativeWork',
'name': datapub['license_notes']
});
}
}
if( datapub['license_identifier'] ) {
if( datapub['license_identifier'] && datapub['license_identifier'] !== 'undefined' ) {
licenses.push({
'@id': datapub['license_identifier'],
'@id': DEFAULT_IRI_PREFS['license'] + datapub['license_identifier'],
'@type': 'CreativeWork',
'name': datapub['license_identifier'],
'url': datapub['license_identifier']
});
}
if( datapub['accessRights_url']) {
licenses.push({
'@id': DEFAULT_IRI_PREFS['license'] + datapub['accessRights_url'],
'@type': 'WebSite',
'name': "Conditions of Access",
'url': datapub['accessRights_url']
});
}
return licenses;
}
......
......@@ -65,7 +65,7 @@ const IRI_PREFIXES = {
},
'spatialCoverage': '_:spatial/',
'funder': '_:funder/',
'licence': '_:licence/',
'license': '_:license/',
'citation': '_:citation/',
'contact': '_:contact/',
'location': '_:location/'
......@@ -340,7 +340,7 @@ describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
const dataset = get_id(cj, DATASET_ID);
expect(dataset).to.have.property('contactPoint');
expect(dataset['contactPoint']).to.eql({ '@id': cpid });
});
});
it("has subjects", () => {
......@@ -456,7 +456,7 @@ describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
const litem = get_id(cj, id);
expect(litem).to.be.a('object');
if( dp['license_other_url']) {
expect(id).to.equal(dp['license_other_url']);
expect(id).to.equal(IRI_PREFIXES['license'] + dp['license_other_url']);
expect(litem['name']).to.equal(dp['license_notes']);
} else {
expect(id).to.equal(dp['license_identifier']);
......@@ -467,6 +467,7 @@ describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
}
});
it("has related works", () => {
const REL_FIELDS = [ 'publications', 'websites', 'metadata', 'data', 'services' ];
const REL_TYPES = {
......@@ -542,6 +543,18 @@ describe("Create catalogs with some or none of the data payloads", () => {
});
it("can create a catalog with no selected payloads which has an access message and url stored as a license", async function() {
dp['dataLocations'].map(dl => { dl['selected'] = false });
const cj = await make_catalog(dp);
const root = get_root(cj);
expect(root).to.have.property('conditionsOfAccess', dp['accessRights_text']);
const lid = IRI_PREFIXES['license'] + dp['accessRights_url'];
const license = get_id(cj, lid);
expect(license).to.have.property('url', dp['accessRights_url']);
});
});
......@@ -209,7 +209,8 @@
],
"dataLicensingAccess_manager" : "Michael Lynch",
"dc:accessRights" : "Open",
"accessRights_url" : "",
"accessRights_url" : "https://bogus.access-rights.url/",
"accessRights_text" : "Some conditions of access",
"related_publications" : [
{
"related_title" : "Relpub1",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment