From 6e75a51b12907bec1660b6dbcf8f32bddca3a46e Mon Sep 17 00:00:00 2001 From: Simon Oakes Date: Mon, 18 May 2026 16:00:45 +0100 Subject: [PATCH 1/2] Add property to determine whether a term binding label is a valid short name. --- .../com/epimorphics/lda/core/EndpointMetadata.java | 11 +++++++++-- .../java/com/epimorphics/lda/shortnames/BuiltIn.java | 1 + .../java/com/epimorphics/lda/vocabularies/API.java | 6 ++++-- .../com/epimorphics/lda/vocabularies/ELDA_API.java | 9 +++++++-- .../lda/metadata/tests/TestGeneratedMetadata.java | 4 ++-- vocabs/api.ttl | 2 ++ vocabs/elda_api.ttl | 5 +++++ 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java b/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java index eeb61748b..8cabd43bf 100644 --- a/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java +++ b/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java @@ -14,6 +14,7 @@ import com.epimorphics.lda.query.WantsMetadata; import com.epimorphics.lda.renderers.Factories.FormatNameAndType; import com.epimorphics.lda.shortnames.CompleteContext; +import com.epimorphics.lda.shortnames.ShortnameService; import com.epimorphics.lda.sources.Source; import com.epimorphics.lda.specs.APIEndpointSpec; import com.epimorphics.lda.specs.EndpointDetails; @@ -47,13 +48,16 @@ public class EndpointMetadata { protected final boolean isListEndpoint; protected final boolean isParameterBasedFormat; - public EndpointMetadata(EndpointDetails ep, Resource thisPage, String pageNumber, Bindings bindings) { + private final ShortnameService sns; + + public EndpointMetadata(EndpointDetails ep, Resource thisPage, String pageNumber, Bindings bindings, ShortnameService sns) { this.bindings = bindings; this.thisPage = thisPage; this.pageNumber = pageNumber; this.isListEndpoint = ep.isListEndpoint(); this.isParameterBasedFormat = ep.hasParameterBasedContentNegotiation(); this.thisPageAsURI = URIUtils.newURI(thisPage.getURI()); + this.sns = sns; } public static void addAllMetadata @@ -144,7 +148,7 @@ public EndpointMetadata(EndpointDetails ep, Resource thisPage, String pageNumber if (suppress_IPTO == false) content.addProperty(FOAF.isPrimaryTopicOf, thisMetaPage); } // - EndpointMetadata em = new EndpointMetadata(details, thisMetaPage, "" + page, bindings); + EndpointMetadata em = new EndpointMetadata(details, thisMetaPage, "" + page, bindings, spec.getAPISpec().getShortnameService()); Model metaModel1 = mergedModels.getMetaModel(); Model mergedModels1 = mergedModels.getMergedModel(); // @@ -327,6 +331,9 @@ public void addTermBindings(Model toScan, Model meta, Resource exec, CompleteCon exec.addProperty(API.termBinding, tb); tb.addProperty(API.label, shorty); tb.addProperty(API.property, term); + if (sns.expand(shorty) == null) { + tb.addProperty(ELDA_API.isShortName, ResourceFactory.createTypedLiteral(true)); + } } } } diff --git a/elda-lda/src/main/java/com/epimorphics/lda/shortnames/BuiltIn.java b/elda-lda/src/main/java/com/epimorphics/lda/shortnames/BuiltIn.java index 5881db76f..03b37e7a7 100644 --- a/elda-lda/src/main/java/com/epimorphics/lda/shortnames/BuiltIn.java +++ b/elda-lda/src/main/java/com/epimorphics/lda/shortnames/BuiltIn.java @@ -127,6 +127,7 @@ private static Set magicURIs() { magic.add(DCTerms.isVersionOf); magic.add(ELDA_API.listURL); magic.add(ELDA_API.sparqlQuery); + magic.add(ELDA_API.isShortName); magic.add(FOAF.isPrimaryTopicOf); magic.add(FOAF.primaryTopic); magic.add(OpenSearch.itemsPerPage); diff --git a/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/API.java b/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/API.java index e90878138..7e35d4c11 100644 --- a/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/API.java +++ b/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/API.java @@ -3,8 +3,8 @@ import org.apache.jena.rdf.model.*; /** - * Vocabulary definitions from /mnt/data/kal/Projects/elda/elda-lda/../vocabs/api.ttl - * @author Auto-generated by schemagen on 20 Nov 2025 14:26 + * Vocabulary definitions from elda-lda/../vocabs/api.ttl + * @author Auto-generated by schemagen on 18 May 2026 15:56 */ @SuppressWarnings({"removal", "deprecated"}) public class API { @@ -68,6 +68,8 @@ public class API { */ public static final Property include = M_MODEL.createProperty( "http://purl.org/linked-data/api/vocab#include" ); + public static final Property isShortName = M_MODEL.createProperty( "http://purl.org/linked-data/api/vocab#isShortName" ); + /**

A template for the URI of the item that the item endpoint should return. Any * instances of {varName} within the string are replaced by the value of the * relevant variable.

diff --git a/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/ELDA_API.java b/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/ELDA_API.java index 3cd084a89..a5ac188bd 100644 --- a/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/ELDA_API.java +++ b/elda-lda/src/main/java/com/epimorphics/lda/vocabularies/ELDA_API.java @@ -3,8 +3,8 @@ import org.apache.jena.rdf.model.*; /** - * Vocabulary definitions from /home/der/projects/java-workspace/elda/elda-lda/../vocabs/elda_api.ttl - * @author Auto-generated by schemagen on 05 Feb 2026 18:29 + * Vocabulary definitions from /home/simon/dev/elda/elda-lda/../vocabs/elda_api.ttl + * @author Auto-generated by schemagen on 18 May 2026 15:56 */ @SuppressWarnings({"removal", "deprecated"}) public class ELDA_API extends API { @@ -136,6 +136,11 @@ public class ELDA_API extends API { /**

Configs can include sub-config fragments.

*/ public static final Property includesFragment = M_MODEL.createProperty( "http://www.epimorphics.com/vocabularies/lda#includesFragment" ); + /**

Determines whether a term binding corresponds to a valid short name for filtering + * purposes.

+ */ + public static final Property isShortName = M_MODEL.createProperty( "http://www.epimorphics.com/vocabularies/lda#isShortName" ); + /**

Property of a JSONFormatter that says if xsd:date and xsd:dateTime values * should be encoded based on ISO 8601. Default value is false.

*/ diff --git a/elda-lda/src/test/java/com/epimorphics/lda/metadata/tests/TestGeneratedMetadata.java b/elda-lda/src/test/java/com/epimorphics/lda/metadata/tests/TestGeneratedMetadata.java index 0fd4e77b9..2834b3725 100644 --- a/elda-lda/src/test/java/com/epimorphics/lda/metadata/tests/TestGeneratedMetadata.java +++ b/elda-lda/src/test/java/com/epimorphics/lda/metadata/tests/TestGeneratedMetadata.java @@ -67,7 +67,8 @@ public boolean hasParameterBasedContentNegotiation() { return false; } }; - EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, noBindings); + ShortnameService sns = new StandardShortnameService(); + EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, noBindings, sns); // PrefixMapping pm = PrefixMapping.Factory.create().setNsPrefix("this", "http://example.com/root#"); Model toScan = ModelIOUtils.modelFromTurtle(":a :b."); @@ -75,7 +76,6 @@ public boolean hasParameterBasedContentNegotiation() { Resource predicate = toScan.createProperty("http://example.com/root#predicate"); Model meta = ModelFactory.createDefaultModel(); Resource exec = meta.createResource("fake:exec"); - ShortnameService sns = new StandardShortnameService(); CompleteContext cc = new CompleteContext(CompleteContext.Mode.PreferPrefixes, sns.asContext(), pm); diff --git a/vocabs/api.ttl b/vocabs/api.ttl index fe427c65e..5e6003477 100755 --- a/vocabs/api.ttl +++ b/vocabs/api.ttl @@ -374,6 +374,8 @@ api:variableBinding a rdf:Property. api:termBinding a rdf:Property. +api:isShortName a rdf:Property. + api:Page a rdfs:Class. api:HtmlFormatter a rdfs:Class. diff --git a/vocabs/elda_api.ttl b/vocabs/elda_api.ttl index b46add059..e2768da5f 100755 --- a/vocabs/elda_api.ttl +++ b/vocabs/elda_api.ttl @@ -297,6 +297,11 @@ elda:termBinding a rdf:Property ; rdfs:comment "Property from page to term bindings" . +elda:isShortName a rdf:Property + ; rdfs:label "isShortName" + ; rdfs:comment "Determines whether a term binding corresponds to a valid short name for filtering purposes." + . + elda:textContentProperty a rdf:Property ; rdfs:comment "" . From fc4b1e516f77247ab203b854d43b9815d4e7b977 Mon Sep 17 00:00:00 2001 From: Simon Oakes Date: Tue, 19 May 2026 15:33:50 +0100 Subject: [PATCH 2/2] Make shortnameservice member protected. --- .../main/java/com/epimorphics/lda/core/EndpointMetadata.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java b/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java index 8cabd43bf..3e21a6964 100644 --- a/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java +++ b/elda-lda/src/main/java/com/epimorphics/lda/core/EndpointMetadata.java @@ -48,7 +48,7 @@ public class EndpointMetadata { protected final boolean isListEndpoint; protected final boolean isParameterBasedFormat; - private final ShortnameService sns; + protected final ShortnameService sns; public EndpointMetadata(EndpointDetails ep, Resource thisPage, String pageNumber, Bindings bindings, ShortnameService sns) { this.bindings = bindings;