From a750be08c8c7db67077eeda85d9d686a78f1db3d Mon Sep 17 00:00:00 2001 From: Tilo Villwock Date: Wed, 6 Nov 2024 15:38:36 +0100 Subject: [PATCH 1/4] #3380 Added DOI to attachment citation and BibTex download --- .../services/citationHintGenerator.service.js | 16 ++++++++++++---- .../data-package-citation-dialog.controller.js | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) 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)); } }; From 48a0f026e12871db630f98943383d522ab91bbed Mon Sep 17 00:00:00 2001 From: Tilo Villwock Date: Thu, 7 Nov 2024 11:24:39 +0100 Subject: [PATCH 2/4] #3304 Extended markup regarding DOI and file references --- .../domain/ddicodebook/FileTxt.java | 6 +++-- .../domain/ddicodebook/IDNo.java | 27 +++++++++++++++++++ .../domain/ddicodebook/Location.java | 12 +++++++++ .../domain/ddicodebook/TitlStmt.java | 2 ++ .../domain/ddicodebook/Var.java | 4 +-- .../service/DataPackageDdiService.java | 26 +++++++++++++----- 6 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java create mode 100644 src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/FileTxt.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/FileTxt.java index 933ddb440d..7f80963489 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/FileTxt.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/FileTxt.java @@ -4,6 +4,8 @@ import lombok.AllArgsConstructor; +import java.util.List; + /** * Class representing the DDI fileTxt element. */ @@ -16,9 +18,9 @@ public class FileTxt { public FileTxt() {} @XmlElement(name = "fileName") - String fileName; + List fileName; @XmlElement(name = "fileCont") - TextElement fileCont; + List fileCont; } diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java new file mode 100644 index 0000000000..616fe501ca --- /dev/null +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java @@ -0,0 +1,27 @@ +package eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook; + +import lombok.AllArgsConstructor; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlValue; + +@AllArgsConstructor +public class IDNo { + + public IDNo() {} + + /** + * e.g. 'DOI' + */ + @XmlAttribute + String agency; + + /** + * The data package version e.g. '1.0.0' + */ + @XmlAttribute + String elementVersion; + + @XmlValue + String dataPackageDOI; +} diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java new file mode 100644 index 0000000000..ef0a911c02 --- /dev/null +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java @@ -0,0 +1,12 @@ +package eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook; + +import lombok.AllArgsConstructor; + +import javax.xml.bind.annotation.XmlAttribute; + +@AllArgsConstructor +public class Location { + + @XmlAttribute(name = "fileid") + String fileId; +} diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java index 365e700876..c9d16e19c2 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java @@ -21,4 +21,6 @@ public TitlStmt() {} @XmlElement(name = "parTitl") TextElement parTitle; + @XmlElement(name = "IDNo") + IDNo idNo; } diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Var.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Var.java index cabc51cb15..7efd3cd73c 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Var.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Var.java @@ -21,8 +21,8 @@ public Var() {} @XmlAttribute(name = "name") String name; - @XmlAttribute(name = "files") - String files; + @XmlElement + Location location; @XmlElement(name = "labl") List labl; diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java index 450eb7e67b..43fa867e20 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java @@ -19,7 +19,9 @@ import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.DataDscr; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.FileDscr; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.FileTxt; +import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.IDNo; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.LanguageEnum; +import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.Location; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.StdyDscr; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.TextElement; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.TitlStmt; @@ -243,8 +245,8 @@ private Var getDdiVar(VariableSubDocument variableDoc) { log.error("An exception occurred querying the variables index. ", e); } String name = variableDoc.getId().split("\\$")[0]; - String files = variableDoc.getDataSetId().split("\\$")[0]; - return new Var(name, files, varLablList, + final var location = new Location(variableDoc.getDataSetId().split("\\$")[0]); + return new Var(name, location, varLablList, qstnList.size() > 0 ? qstnList : null, txtList.size() > 0 ? txtList : null, catgryList); @@ -256,9 +258,17 @@ private Var getDdiVar(VariableSubDocument variableDoc) { * @return the fileDscr element */ private FileDscr getDdiFileDsrc(DataSetSubDocument dataset) { - String id = dataset.getId().split("\\$")[0]; - TextElement fileCont = new TextElement(LanguageEnum.de, dataset.getDescription().getDe()); - FileTxt fileTxt = new FileTxt(id, fileCont); + var id = dataset.getId().split("\\$")[0]; + final var fileTxt = new FileTxt( + List.of( + new TextElement(LanguageEnum.de, id), + new TextElement(LanguageEnum.en, id) + ), + List.of( + new TextElement(LanguageEnum.de, dataset.getDescription().getDe()), + new TextElement(LanguageEnum.en, dataset.getDescription().getEn()) + ) + ); return new FileDscr(id, fileTxt); } @@ -270,7 +280,11 @@ private FileDscr getDdiFileDsrc(DataSetSubDocument dataset) { private StdyDscr getDdiStdyDscr(DataPackageSearchDocument doc) { TextElement titl = new TextElement(LanguageEnum.de, doc.getTitle().getDe()); TextElement parTitl = new TextElement(LanguageEnum.en, doc.getTitle().getEn()); - Citation citation = new Citation(new TitlStmt(titl, parTitl)); + IDNo idNo = null; + if (doc.getDoi() != null && !doc.getDoi().isBlank()) { + idNo = new IDNo("DOI", doc.getRelease().getVersion(), doc.getDoi()); + } + Citation citation = new Citation(new TitlStmt(titl, parTitl, idNo)); return new StdyDscr(citation); } } From 43a2d93374879047146edc6678ad3a5f9c4f468f Mon Sep 17 00:00:00 2001 From: Tilo Villwock Date: Thu, 7 Nov 2024 11:43:48 +0100 Subject: [PATCH 3/4] #3304 Fixed code style issues --- .../ddicodebook/{IDNo.java => IdNo.java} | 16 +++++++++----- .../domain/ddicodebook/Location.java | 6 +++++ .../domain/ddicodebook/TitlStmt.java | 2 +- .../service/DataPackageDdiService.java | 22 +++++++++---------- 4 files changed, 29 insertions(+), 17 deletions(-) rename src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/{IDNo.java => IdNo.java} (59%) diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IdNo.java similarity index 59% rename from src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java rename to src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IdNo.java index 616fe501ca..125be9da53 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IDNo.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/IdNo.java @@ -5,23 +5,29 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlValue; +/** + * ID element for the study (e.g. DOI). + */ @AllArgsConstructor -public class IDNo { +public class IdNo { - public IDNo() {} + public IdNo() {} /** - * e.g. 'DOI' + * The agency the ID is registered with (e.g. 'DOI'). */ @XmlAttribute String agency; /** - * The data package version e.g. '1.0.0' + * The data package version (e.g. '1.0.0'). */ @XmlAttribute String elementVersion; + /** + * The ID value. + */ @XmlValue - String dataPackageDOI; + String value; } diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java index ef0a911c02..e98d741a69 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/Location.java @@ -4,9 +4,15 @@ import javax.xml.bind.annotation.XmlAttribute; +/** + * A wrapper element for the dataset ID a variable is linked to. + */ @AllArgsConstructor public class Location { + /** + * The dataset ID a variable is linked to (e.g. 'project-ds1'). + */ @XmlAttribute(name = "fileid") String fileId; } diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java index c9d16e19c2..23263866be 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/ddicodebook/TitlStmt.java @@ -22,5 +22,5 @@ public TitlStmt() {} TextElement parTitle; @XmlElement(name = "IDNo") - IDNo idNo; + IdNo idNo; } diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java index 43fa867e20..858fcd067b 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageDdiService.java @@ -19,7 +19,7 @@ import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.DataDscr; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.FileDscr; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.FileTxt; -import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.IDNo; +import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.IdNo; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.LanguageEnum; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.Location; import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.ddicodebook.StdyDscr; @@ -260,14 +260,14 @@ private Var getDdiVar(VariableSubDocument variableDoc) { private FileDscr getDdiFileDsrc(DataSetSubDocument dataset) { var id = dataset.getId().split("\\$")[0]; final var fileTxt = new FileTxt( - List.of( - new TextElement(LanguageEnum.de, id), - new TextElement(LanguageEnum.en, id) - ), - List.of( - new TextElement(LanguageEnum.de, dataset.getDescription().getDe()), - new TextElement(LanguageEnum.en, dataset.getDescription().getEn()) - ) + List.of( + new TextElement(LanguageEnum.de, id), + new TextElement(LanguageEnum.en, id) + ), + List.of( + new TextElement(LanguageEnum.de, dataset.getDescription().getDe()), + new TextElement(LanguageEnum.en, dataset.getDescription().getEn()) + ) ); return new FileDscr(id, fileTxt); } @@ -280,9 +280,9 @@ private FileDscr getDdiFileDsrc(DataSetSubDocument dataset) { private StdyDscr getDdiStdyDscr(DataPackageSearchDocument doc) { TextElement titl = new TextElement(LanguageEnum.de, doc.getTitle().getDe()); TextElement parTitl = new TextElement(LanguageEnum.en, doc.getTitle().getEn()); - IDNo idNo = null; + IdNo idNo = null; if (doc.getDoi() != null && !doc.getDoi().isBlank()) { - idNo = new IDNo("DOI", doc.getRelease().getVersion(), doc.getDoi()); + idNo = new IdNo("DOI", doc.getRelease().getVersion(), doc.getDoi()); } Citation citation = new Citation(new TitlStmt(titl, parTitl, idNo)); return new StdyDscr(citation); From 7ad94dbcca8c68fa3bd29f3a42e797fa8bdce7a0 Mon Sep 17 00:00:00 2001 From: Tilo Villwock Date: Mon, 11 Nov 2024 10:54:48 +0100 Subject: [PATCH 4/4] #3216 Added check for an existing release to fix save bug --- .../views/data-package-edit-or-create.controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mdm-frontend/src/app/legacy/datapackagemanagement/views/data-package-edit-or-create.controller.js b/mdm-frontend/src/app/legacy/datapackagemanagement/views/data-package-edit-or-create.controller.js index b24e68cd59..511bca8e01 100644 --- a/mdm-frontend/src/app/legacy/datapackagemanagement/views/data-package-edit-or-create.controller.js +++ b/mdm-frontend/src/app/legacy/datapackagemanagement/views/data-package-edit-or-create.controller.js @@ -498,7 +498,10 @@ angular.module('metadatamanagementApp') ctrl.saveDataPackage = function() { if ($scope.dataPackageForm.$valid) { - if (CurrentProjectService.getCurrentProject().release.isPreRelease) { + if (CurrentProjectService.getCurrentProject() && + CurrentProjectService.getCurrentProject().release && + CurrentProjectService.getCurrentProject().release.isPreRelease) + { CommonDialogsService.showConfirmEditPreReleaseDialog( 'global.common-dialogs' + '.confirm-edit-pre-released-project.title',