diff --git a/mdm-frontend/src/app/legacy/ordermanagement/services/citationHintGenerator.service.js b/mdm-frontend/src/app/legacy/ordermanagement/services/citationHintGenerator.service.js index af41ef8960..3d6e3b2fba 100644 --- a/mdm-frontend/src/app/legacy/ordermanagement/services/citationHintGenerator.service.js +++ b/mdm-frontend/src/app/legacy/ordermanagement/services/citationHintGenerator.service.js @@ -74,19 +74,24 @@ function($interpolate, LanguageService, $filter, $rootScope) { }); }; - var generateBibtexForAttachment = function(attachment) { + var generateBibtexForAttachment = function(attachment, dataPackage) { if ($rootScope.bowser.msie) { throw 'citation.js is not compatible with IE11'; } var citeJson = { title: attachment.title, type: 'report', + DOI: dataPackage.doi, publisher: attachment.citationDetails.institution, 'publisher-place': attachment.citationDetails.location, issued: [{'date-parts': [attachment.citationDetails.publicationYear]}], author: mapPeopleToCiteJson(attachment.citationDetails.authors) }; - return new Cite(citeJson).format('bibtex') + return new Cite(citeJson).format('biblatex') // use biblatex to include the doi and map fields back to bibtex names + .replace('@report', '@techreport') + .replace('date =', 'year =') + .replace('location =', 'address =') + .replace('publisher =', 'institution =') // remove spaces in latex code for umlauts .replace(/{\\.\s./g, function(match) { return match.replace(' ', ''); @@ -118,14 +123,17 @@ function($interpolate, LanguageService, $filter, $rootScope) { }; }; - var generateCitationHintForAttachment = function(attachment) { + var generateCitationHintForAttachment = function(attachment, dataPackage) { var citationHint = '{{attachment.citationDetails.authors | displayPersons}} ' + '({{attachment.citationDetails.publicationYear}}). ' + '{{attachment.title}}. ' + '{{attachment.citationDetails.location}}: ' + '{{attachment.citationDetails.institution}}.'; - return $interpolate(citationHint)({attachment: attachment}); + if (!!dataPackage.doi) { + citationHint += ' https://doi.org/{{dataPackage.doi}}'; + } + return $interpolate(citationHint)({attachment: attachment, dataPackage: dataPackage}); }; return { diff --git a/mdm-frontend/src/app/legacy/ordermanagement/views/data-package-citation-dialog.controller.js b/mdm-frontend/src/app/legacy/ordermanagement/views/data-package-citation-dialog.controller.js index d5dfee8967..d2563e42e9 100644 --- a/mdm-frontend/src/app/legacy/ordermanagement/views/data-package-citation-dialog.controller.js +++ b/mdm-frontend/src/app/legacy/ordermanagement/views/data-package-citation-dialog.controller.js @@ -38,10 +38,10 @@ angular.module('metadatamanagementApp') ctrl.methodReportsCitationHint = { de: germanMethodReports.length > 0 ? CitationHintGeneratorService.generateCitationHintForAttachment( - germanMethodReports[0]) : null, + germanMethodReports[0], dataPackage) : null, en: englishMethodReports.length > 0 ? CitationHintGeneratorService.generateCitationHintForAttachment( - englishMethodReports[0]) : null, + englishMethodReports[0], dataPackage) : null, }; ctrl.methodReports = { de: germanMethodReports.length > 0 ? germanMethodReports[0] : null, @@ -74,7 +74,7 @@ angular.module('metadatamanagementApp') } if (methodReport) { ctrl.saveBibtex(CitationHintGeneratorService - .generateBibtexForAttachment(methodReport)); + .generateBibtexForAttachment(methodReport, dataPackage)); } };