63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
const Crossref = require("./Crossref");
|
|
const CROSSREF_endpoint = "api.crossref.org";
|
|
const CROSSREF = "crossref";
|
|
|
|
const Datacite = require("./Datacite");
|
|
const DATACITE_endpoint = "api.datacite.org";
|
|
const DATACITE = "datacite";
|
|
|
|
const N2t = require("./N2t");
|
|
const N2T_endpoint = "n2t.net";
|
|
const N2T = "n2t";
|
|
|
|
const Googleapis = require("./Googleapis");
|
|
const GOOGLEAPIS_endpoint = "www.googleapis.com";
|
|
const GOOGLEAPIS = "googleapis";
|
|
|
|
const Zenodo = require("./Zenodo");
|
|
const Zenodo_endpoint = "zenodo.org";
|
|
const ZENODOD = "zenodo";
|
|
|
|
const Arxiv = require("./Arxiv");
|
|
const Arxiv_endpoint = "export.arxiv.org";
|
|
|
|
class ParserUtils {
|
|
getSupportedParsers() {
|
|
return [CROSSREF_endpoint, DATACITE_endpoint, Zenodo_endpoint/*, Arxiv_endpoint, N2T_endpoint, GOOGLEAPIS_endpoint*/];
|
|
}
|
|
|
|
getXMLParsers() {
|
|
return [Arxiv_endpoint];
|
|
}
|
|
|
|
parseJSON(pid, endpoint, data) {
|
|
console.log("parse JSON", pid, endpoint)
|
|
if (endpoint == CROSSREF_endpoint) {
|
|
const parser = new Crossref();
|
|
return parser.parse(pid, data['message']);
|
|
} else if (endpoint == DATACITE_endpoint) {
|
|
const parser = new Datacite();
|
|
return parser.parse(pid, data['data']);
|
|
} else if (endpoint == N2T_endpoint) {
|
|
const parser = new N2t();
|
|
return parser.parse(pid, data);
|
|
} else if (endpoint == GOOGLEAPIS_endpoint) {
|
|
const parser = new Googleapis();
|
|
return parser.parse(pid, data.items[0]);
|
|
} else if (endpoint == Zenodo_endpoint) {
|
|
const parser = new Zenodo();
|
|
return parser.parse(pid, data);
|
|
}
|
|
}
|
|
|
|
async parseXML(pid, endpoint, data) {
|
|
console.log("parse XML", pid, endpoint)
|
|
if (endpoint == Arxiv_endpoint) {
|
|
const parser = new Arxiv();
|
|
return parser.parse(pid, data)
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = ParserUtils;
|