Skip to content

Commit

Permalink
#3341: removed doi.org request
Browse files Browse the repository at this point in the history
  • Loading branch information
ewolf47 committed Apr 25, 2024
1 parent 4f7f0fb commit 5574942
Showing 1 changed file with 6 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,17 @@ angular.module('metadatamanagementApp')
function(RelatedPublicationResource, CleanJSObjectService,
RelatedPublicationIdBuilderService, $http, $q) {

const updatePublicationObj = function(publicationObj, doi) {
if (doi) {
return findByDOI(doi).then(function(data) {
publicationObj.journal = data.data["container-title"] ? data.data["container-title"] : null;
if (data.data.hasOwnProperty("journal-issue")){
publicationObj.issue = data.data["journal-issue"].issue ? data.data["journal-issue"].issue : null;
}
return new RelatedPublicationResource(CleanJSObjectService.removeEmptyJsonObjects(publicationObj));
});
} else {
return $q((resolve, reject) => {
resolve(new RelatedPublicationResource(CleanJSObjectService.removeEmptyJsonObjects(publicationObj)))
});
}
const updatePublicationObj = function(publicationObj) {
return $q((resolve, reject) => {
resolve(new RelatedPublicationResource(CleanJSObjectService.removeEmptyJsonObjects(publicationObj)))
});
}

var getRelatedPublications = async function(relatedPublications) {
// var relatedPublicationsObjArray = [];
var promises = [];
for (var i = 0; i < relatedPublications.length; i++) {
var data = relatedPublications[i];
var doi = getPropertyByKeyPattern(data, /^DOI$/i);
var bibTexKey = getPropertyByKeyPattern(data, /^BibTeX Key$/i);

var publicationObj = {
Expand All @@ -37,7 +26,7 @@ angular.module('metadatamanagementApp')
bibTexKey) : undefined,
sourceReference:
getPropertyByKeyPattern(data, /^sourceReference.*$/i),
doi: doi,
doi: getPropertyByKeyPattern(data, /^DOI$/i),
title: getPropertyByKeyPattern(data, /^Titel$/i),
authors: getPropertyByKeyPattern(data, /^Autor.*$/i),
language: getPropertyByKeyPattern(data, /^Sprache$/i),
Expand All @@ -56,7 +45,7 @@ angular.module('metadatamanagementApp')
publicationAbstract: getPropertyByKeyPattern(data, /^Abstract$/i)
/* jshint +W069 */
};
promises.push(updatePublicationObj(publicationObj, doi));
promises.push(updatePublicationObj(publicationObj));
};

return await new Promise((resolve, reject) => {
Expand All @@ -72,24 +61,6 @@ angular.module('metadatamanagementApp')
})[0]];
};

/**
* This function sends a request to http://doi.org/{doi}
* and returns the response as Promise.
* @param doi A DOI code, e.g. "10.5771/0038-6073-2023-2-173"
*/
var findByDOI = function(doi) {
return $http({
method: 'GET',
url: 'http://doi.org/' + doi,
headers: {
'Accept': 'application/json'
}
}).then(function(data) {
var response = angular.fromJson(data);
return response;
});
}

return {
getRelatedPublications: getRelatedPublications
};
Expand Down

0 comments on commit 5574942

Please sign in to comment.