Commit f8e8e4bf authored by Maxime Chaillet's avatar Maxime Chaillet

Merge branch 'issue57' into 'master'

Issue57

Closes #57

See merge request !63
parents 34de74a2 7cde4905
Pipeline #5980 passed with stages
in 18 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,6 @@ function DOIController(view) {
// doiServer = the server which provides doi details from a given doi name.
this.doiServer = "https://data.datacite.org/";
// 10.5072 is the test esrf doi prefix;
// 10.15151 is the production esrf doi prefix;
this.acceptedPrefix = ["10.5072", "10.15151"];
......@@ -68,7 +67,7 @@ DOIController.prototype.getData = function (doi) {
var jsonExtractor = new JsonExtractor();
doiData.abstract = jsonExtractor.getAbstract(data);
doiData.investigationId = jsonExtractor.extractInvestigationId(data);
doiData.investigationId = jsonExtractor.getInvestigationId(data);
doiData.mintingYear = jsonExtractor.getMintingYear(data);
doiData.proposalType = jsonExtractor.getFieldFromSubject(data.subject, "Proposal Type Description");
doiData.resourceType = jsonExtractor.getResourceType(data);
......
......@@ -54,7 +54,8 @@ DOIView.prototype.renderExperimentalReportData = function (data) {
DOIView.prototype.renderDOIData = function (doiData) {
var _this = this;
dust.render('landingpage_tpl', {
data: doiData
data: doiData,
constants : CONSTANTS
}, function (err, out) {
$('#' + _this.mainPanelId).html(out);
_this.isDOIAlreadyRendered = true;
......
......@@ -7,9 +7,12 @@ function JsonExtractor(json) {
* @param {string} data The data object provided by datacite
* @return {string} investigationId The investigationID requested for accessing data in ICAT.
*/
JsonExtractor.prototype.extractInvestigationId = function (data) {
JsonExtractor.prototype.getInvestigationId = function (data) {
var regExp = RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);
return regExp.exec( data.doi )[1];
if (regExp.exec( data.doi )){
return regExp.exec( data.doi )[1];
}
return null;
};
/**
......
......@@ -83,7 +83,13 @@
<div class="row">
<div class="col-1"> </div>
<div class="col-10">
{data.resourceType}
{constants.ES_RESOURCE_TYPE}
{@eq key=data.resourceType value=constants.ES_RESOURCE_TYPE}
<form action="https://icat.esrf.fr/#/browse/facility/ESRF/proposal/{data.proposalName}/investigation/{data.investigationId}/dataset" target="_blank">
{:else}
<form action="https://icat.esrf.fr/?#/my-data/ESRF" target="_blank">
{/eq}
<button type="submit" class="btn btn-primary btn-lg btn-block"> Access data </button>
</form>
</div>
......
......@@ -135,4 +135,22 @@ describe("jsonExtractor", () => {
expect(myJsonExtractor.getMergedProposalAndBeamline(actualProposals, actualBeamlines, actualBeamlineUrls)).toEqual(expectedMerge);
})
})
describe("GetInvestigationId", () => {
it("returns investigationId for a experimental session doi", () => {
let actualDOIdata = { doi: "10.15151/ESRF-ES-130874985" };
let expectedInvestigationId = "130874985";
let myJsonExtractor = new JsonExtractor();
expect(myJsonExtractor.getInvestigationId(actualDOIdata)).toEqual(expectedInvestigationId);
})
it("returns null for a data collection doi", () => {
let actualDOIdata = { doi: "10.15151/ESRF-DC-130874985" };
let expectedInvestigationId = null;
let myJsonExtractor = new JsonExtractor();
expect(myJsonExtractor.getInvestigationId(actualDOIdata)).toEqual(expectedInvestigationId);
})
})
})
Below are doi created for the tests:
- 10.5072/TEST-ESRF-MAX3 : data collection DOI
- DOI=10.5072/ESRF-ES-130884741 : experiment session DOI
\ No newline at end of file
Markdown is supported
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