From 21680e11f9724c42d223f7536757e889ed77c714 Mon Sep 17 00:00:00 2001 From: Mark Hale Date: Sat, 28 Oct 2023 22:54:08 +0100 Subject: [PATCH] Add namespace encoder for urn:uuid:. --- .../com/msd/gin/halyard/common/TableConfig.java | 3 ++- .../main/java/com/msd/gin/halyard/vocab/UUID.java | 15 +++++++++++++++ .../common/IdValueFactoryExtendedTest.java | 3 ++- .../msd/gin/halyard/common/RDFFactoryTest.java | 3 ++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/com/msd/gin/halyard/vocab/UUID.java diff --git a/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java b/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java index 8384cb7ae..b4f3e861e 100644 --- a/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java +++ b/common/src/main/java/com/msd/gin/halyard/common/TableConfig.java @@ -12,7 +12,8 @@ public final class TableConfig { static final int VERSION_4_6_1 = 461; static final int VERSION_4_6_2 = 462; static final int VERSION_4_7 = 470; - static final int CURRENT_VERSION = VERSION_4_7; + static final int VERSION_4_9 = 490; + static final int CURRENT_VERSION = VERSION_4_9; public static final String ID_HASH = "halyard.id.hash"; public static final String ID_JAVA_HASH = "halyard.id.javaHash"; diff --git a/common/src/main/java/com/msd/gin/halyard/vocab/UUID.java b/common/src/main/java/com/msd/gin/halyard/vocab/UUID.java new file mode 100644 index 000000000..16504f7ad --- /dev/null +++ b/common/src/main/java/com/msd/gin/halyard/vocab/UUID.java @@ -0,0 +1,15 @@ +package com.msd.gin.halyard.vocab; + +import com.msd.gin.halyard.common.Vocabulary; + +import org.eclipse.rdf4j.model.Namespace; +import org.kohsuke.MetaInfServices; + +@MetaInfServices(Vocabulary.class) +public final class UUID implements Vocabulary { + public static final String PREFIX = "uuid"; + + public static final String NAMESPACE = "urn:uuid:"; + + public static final Namespace NS = new UUIDNamespace(PREFIX, NAMESPACE); +} diff --git a/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java b/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java index dad8bea0f..6f76cc024 100644 --- a/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java +++ b/common/src/test/java/com/msd/gin/halyard/common/IdValueFactoryExtendedTest.java @@ -79,7 +79,8 @@ private static List createData(ValueFactory vf) { vf.createIRI(HALYARD.VALUE_ID_NS.getName(), "eRg5UlsxjZuh-4meqlYQe3-J8X8"), vf.createIRI(WIKIDATA.WDV_NAMESPACE, "400f9abd3fd761c62af23dbe8f8432158a6ce272"), vf.createIRI(WIKIDATA.WDV_NAMESPACE, "invalid"), - vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/") + vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/"), + vf.createIRI("urn:uuid:8104c873-b648-44de-aaee-cb65f1dcafbb") ); } diff --git a/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java b/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java index 4e206c637..8baeae648 100644 --- a/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java +++ b/common/src/test/java/com/msd/gin/halyard/common/RDFFactoryTest.java @@ -88,7 +88,8 @@ static List createData(ValueFactory vf) { new Object[] {vf.createIRI(HALYARD.VALUE_ID_NS.getName(), "eRg5UlsxjZuh-4meqlYQe3-J8X8"), ValueIO.ENCODED_IRI_TYPE}, new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE, "400f9abd3fd761c62af23dbe8f8432158a6ce272"), ValueIO.ENCODED_IRI_TYPE}, new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE, "invalid"), ValueIO.NAMESPACE_HASH_TYPE}, - new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/"), ValueIO.END_SLASH_ENCODED_IRI_TYPE} + new Object[] {vf.createIRI(WIKIDATA.WDV_NAMESPACE+"400f9abd3fd761c62af23dbe8f8432158a6ce272/"), ValueIO.END_SLASH_ENCODED_IRI_TYPE}, + new Object[] {vf.createIRI("urn:uuid:8104c873-b648-44de-aaee-cb65f1dcafbb")} ); }