Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime Chaillet
doi-landing-page
Commits
2434ed2a
Commit
2434ed2a
authored
Oct 19, 2018
by
Maxime Chaillet
Browse files
Fix investigationId retrieval with data collection DOI because they have no investigationId.
parent
34de74a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
www/src/doicontroller.js
View file @
2434ed2a
...
@@ -68,7 +68,7 @@ DOIController.prototype.getData = function (doi) {
...
@@ -68,7 +68,7 @@ DOIController.prototype.getData = function (doi) {
var
jsonExtractor
=
new
JsonExtractor
();
var
jsonExtractor
=
new
JsonExtractor
();
doiData
.
abstract
=
jsonExtractor
.
getAbstract
(
data
);
doiData
.
abstract
=
jsonExtractor
.
getAbstract
(
data
);
doiData
.
investigationId
=
jsonExtractor
.
e
xtrac
tInvestigationId
(
data
);
doiData
.
investigationId
=
jsonExtractor
.
g
etInvestigationId
(
data
);
doiData
.
mintingYear
=
jsonExtractor
.
getMintingYear
(
data
);
doiData
.
mintingYear
=
jsonExtractor
.
getMintingYear
(
data
);
doiData
.
proposalType
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal Type Description
"
);
doiData
.
proposalType
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal Type Description
"
);
doiData
.
resourceType
=
jsonExtractor
.
getResourceType
(
data
);
doiData
.
resourceType
=
jsonExtractor
.
getResourceType
(
data
);
...
...
www/src/jsonextractor.js
View file @
2434ed2a
...
@@ -7,9 +7,12 @@ function JsonExtractor(json) {
...
@@ -7,9 +7,12 @@ function JsonExtractor(json) {
* @param {string} data The data object provided by datacite
* @param {string} data The data object provided by datacite
* @return {string} investigationId The investigationID requested for accessing data in ICAT.
* @return {string} investigationId The investigationID requested for accessing data in ICAT.
*/
*/
JsonExtractor
.
prototype
.
e
xtrac
tInvestigationId
=
function
(
data
)
{
JsonExtractor
.
prototype
.
g
etInvestigationId
=
function
(
data
)
{
var
regExp
=
RegExp
(
/
\/\w
*-*
[
Ee
][
Ss
][
Rr
][
Ff
]
-
[
Ee
][
Ss
]
-
(\d
+
)
$/
);
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
;
};
};
/**
/**
...
...
www/tests/jsonExtractor.test.js
View file @
2434ed2a
...
@@ -135,4 +135,22 @@ describe("jsonExtractor", () => {
...
@@ -135,4 +135,22 @@ describe("jsonExtractor", () => {
expect
(
myJsonExtractor
.
getMergedProposalAndBeamline
(
actualProposals
,
actualBeamlines
,
actualBeamlineUrls
)).
toEqual
(
expectedMerge
);
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
);
})
})
})
})
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment