pid-parser-service/parsers/Datacite.js

31 lines
986 B
JavaScript

const Entity = require("../model/Entity");
class Datacite {
parse(pid, item) {
let entity = new Entity(pid);
entity.result.source = "datacite";
entity.result.publisher = null;
entity.result.journal = null;
entity.result.DOI = pid;
entity.id = pid;
entity.title = Array.isArray(item.attributes.titles) && item.attributes.titles[0].title ? item.attributes.titles[0].title : null;
entity.result.url = "https://doi.org/" + pid;
entity.type = 'dataset';
entity.result.date = item.attributes.publicationYear;
entity.result.accessRights = "OPEN";
entity.result.publisher = item.attributes['publisher'];
entity.result.journal = null;
if (item.attributes.creators) {
entity.result.authors = [];
for (let j = 0; j < item.attributes.creators.length; j++) {
const author = item.attributes.creators[j].name;
entity.result.authors.push(author);
}
}
return entity;
}
}
module.exports = Datacite;