From 62867f2b7d1add9f2dfc4cf3dd42578eb4cd9585 Mon Sep 17 00:00:00 2001 From: Florian Fritze Date: Wed, 31 Jul 2024 11:05:56 +0200 Subject: [PATCH 1/3] no html tags in description for OAI DataCite export --- .../iq/dataverse/export/openaire/OpenAireExportUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java index 4b8822e8b66..a0229df00c5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java @@ -28,6 +28,7 @@ import java.util.regex.Pattern; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; +import org.jsoup.Jsoup; public class OpenAireExportUtil { @@ -36,7 +37,7 @@ public class OpenAireExportUtil { public static String XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance"; public static String SCHEMA_VERSION = "4.1"; public static String RESOURCE_NAMESPACE = "http://datacite.org/schema/kernel-4"; - public static String RESOURCE_SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-4.1/metadata.xsd"; + public static String RESOURCE_SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-4.5/metadata.xsd"; public static String FunderType = "Funder"; @@ -1139,6 +1140,8 @@ public static void writeDescriptionsElement(XMLStreamWriter xmlw, DatasetVersion FieldDTO next = iterator.next(); if (DatasetFieldConstant.descriptionText.equals(next.getTypeName())) { descriptionOfAbstract = next.getSinglePrimitive(); + // From https://stackoverflow.com/questions/240546/remove-html-tags-from-a-string + descriptionOfAbstract = Jsoup.parse(descriptionOfAbstract).text(); } } From faa26380b32e1c7461966982b3ba9a197894dc9c Mon Sep 17 00:00:00 2001 From: Florian Fritze Date: Wed, 31 Jul 2024 11:21:37 +0200 Subject: [PATCH 2/3] schema version correction --- .../iq/dataverse/export/openaire/OpenAireExportUtil.java | 2 +- .../edu/harvard/iq/dataverse/export/OpenAireExporterTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java index a0229df00c5..639574c9e08 100644 --- a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java @@ -35,7 +35,7 @@ public class OpenAireExportUtil { private static final Logger logger = Logger.getLogger(OpenAireExportUtil.class.getCanonicalName()); public static String XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance"; - public static String SCHEMA_VERSION = "4.1"; + public static String SCHEMA_VERSION = "4.5"; public static String RESOURCE_NAMESPACE = "http://datacite.org/schema/kernel-4"; public static String RESOURCE_SCHEMA_LOCATION = "http://schema.datacite.org/meta/kernel-4.5/metadata.xsd"; diff --git a/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java b/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java index 2d06436fb33..cfde085128c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java @@ -185,7 +185,7 @@ public void testGetXMLNameSpace() throws Exception { public void testGetXMLSchemaLocation() throws Exception { System.out.println("getXMLSchemaLocation"); OpenAireExporter instance = new OpenAireExporter(); - String expResult = "http://schema.datacite.org/meta/kernel-4.1/metadata.xsd"; + String expResult = "http://schema.datacite.org/meta/kernel-4.5/metadata.xsd"; String result = instance.getXMLSchemaLocation(); assertEquals(expResult, result); } @@ -197,7 +197,7 @@ public void testGetXMLSchemaLocation() throws Exception { public void testGetXMLSchemaVersion() throws Exception { System.out.println("getXMLSchemaVersion"); OpenAireExporter instance = new OpenAireExporter(); - String expResult = "4.1"; + String expResult = "4.5"; String result = instance.getXMLSchemaVersion(); assertEquals(expResult, result); } From f1a1a200e46a1c5b26eee3bfa9d3ae09bf41b2b1 Mon Sep 17 00:00:00 2001 From: Florian Fritze Date: Wed, 31 Jul 2024 11:56:43 +0200 Subject: [PATCH 3/3] topicClassTermURI to valueURI in subjects --- .../edu/harvard/iq/dataverse/DatasetFieldConstant.java | 1 + .../iq/dataverse/export/openaire/OpenAireExportUtil.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java index d91aa101eb5..25b849e938b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java @@ -97,6 +97,7 @@ public class DatasetFieldConstant implements java.io.Serializable { public final static String topicClassValue="topicClassValue"; public final static String topicClassVocab="topicClassVocab"; public final static String topicClassVocabURI="topicClassVocabURI"; + public final static String topicClassTermURI="topicClassTermURI"; public final static String descriptionText="dsDescriptionValue"; public final static String descriptionDate="dsDescriptionDate"; public final static String timePeriodCovered="timePeriodCovered"; // SEK added 6/13/2016 diff --git a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java index 639574c9e08..f27b3a1797f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/export/openaire/OpenAireExportUtil.java @@ -481,6 +481,7 @@ public static void writeSubjectsElement(XMLStreamWriter xmlw, DatasetVersionDTO String subject = null; String subjectScheme = null; String schemeURI = null; + String valueURI = null; for (Iterator iterator = fieldDTOs.iterator(); iterator.hasNext();) { FieldDTO next = iterator.next(); @@ -491,15 +492,19 @@ public static void writeSubjectsElement(XMLStreamWriter xmlw, DatasetVersionDTO if (DatasetFieldConstant.topicClassVocab.equals(next.getTypeName())) { subjectScheme = next.getSinglePrimitive(); } - + if (DatasetFieldConstant.topicClassVocabURI.equals(next.getTypeName())) { schemeURI = next.getSinglePrimitive(); } + + if (DatasetFieldConstant.topicClassTermURI.equals(next.getTypeName())) { + valueURI = next.getSinglePrimitive(); + } } if (StringUtils.isNotBlank(subject)) { subject_check = writeOpenTag(xmlw, "subjects", subject_check); - writeSubjectElement(xmlw, subjectScheme, null, schemeURI, subject, language); + writeSubjectElement(xmlw, subjectScheme, valueURI, schemeURI, subject, language); } } }