Skip to content

Conversation

@berezovskyi
Copy link
Contributor

@berezovskyi berezovskyi commented Nov 29, 2025

This is a proposal for Lyo Designer to generate better vocabulary helpers. It consists of two changes:

  1. Generate a constant for every single class and prop.
  2. Provide helpers for QNames of every prop for easy use in extended props.

These changes together will ensure that users do not need to do any concatenation of strings or call "new QName" for well-known RDF props. The QName initialization is done lazily and only once per prop, which will improve adaptor performance.

Finally, I would suggest shorter names:

  • Dcterms.NS instead of DctermsVocabularyConstants.DUBLIN_CORE_NAMSPACE
  • Dcterms.PREFIX instead of DctermsVocabularyConstants.DUBLIN_CORE_NAMSPACE_PREFIX
  • maybe even Dcterms.Q.title() instead of Dcterms.QNames.title()
  • shape constants could go under OslcRm.Shapes.NS and so on. Those are used less frequently.

Printing prop description in the javadoc for both constants and helpers would be even better!

There is also a bunch of vocabs we could consider adding, see https://github.com/berezovskyi/ldsw-scraper/tree/main/data and https://github.com/OSLC/oslc4net/blob/main/OSLC4Net_SDK/OSLC4Net.Core/Model/OslcConstants.LDP.cs

Closes #0; Closes #00 (use exactly this syntax to link to issues, one issue per statement only!)

Checklist

  • This PR adds an entry to the CHANGELOG. See https://keepachangelog.com/en/1.0.0/ for instructions. Minor edits are exempt.
  • This PR was tested on at least one Lyo OSLC server (comment @oslc-bot /test-all if not sure) or adds unit/integration tests.
  • This PR does NOT break the API
  • Lint checks pass (run mvn package org.openrewrite.maven:rewrite-maven-plugin:run spotless:apply -DskipTests -P'!enforcer' if not, commit & push)

This is a proposal for Lyo Designer to generate better vocabulary helpers. It consists of two changes:

1. Generate a constant for every single class and prop.
2. Provide helpers for QNames of every prop for easy use in extended props.

These changes together will ensure that users do not need to do any concatenation of strings or call "new QName" for well-known RDF props. The QName initialization is done lazily and only once per prop, which will improve adaptor performance.

Finally, I would suggest shorter names:

- `Dcterms.NS` instead of `DctermsVocabularyConstants.DUBLIN_CORE_NAMSPACE`
- `Dcterms.PREFIX` instead of `DctermsVocabularyConstants.DUBLIN_CORE_NAMSPACE_PREFIX`
- maybe even `Dcterms.Q.title()` instead of `Dcterms.QNames.title()`

Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
@berezovskyi
Copy link
Contributor Author

berezovskyi commented Nov 29, 2025

Would be also good to introduce a helper setProp that would do getExtendedProperties().put(). If we rename the const interface, we can make it a class (and maybe keep the old one with deprecation), so that the usage would become from

request.getExtendedProperties().put(new QName("http://purl.org/dc/terms/", "identifier"), "test-id-123");
// to           
request.getExtendedProperties().put(DctermsVocabularyConstants.QNames.identifier(), "test-id-123");
// to
request.getExtendedProperties().put(Dcterms.QNames.identifier(), "test-id-123");
// to
request.getExtendedProperties().put(Dcterms.Q.identifier(), "test-id-123");
// to
request.getExtendedProperties().put(Dcterms.identifier(), "test-id-123");
// to
request.setProp(DctermsVocabulary.identifier(), "test-id-123"); // or
request.setExtended(DctermsVocabulary.identifier(), "test-id-123");

@berezovskyi
Copy link
Contributor Author

See eclipse-lyo/lyo.designer#303

@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Nov 30, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl 🔴 Fail completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server 🔴 Fail completed Link

@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Nov 30, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl ✅ Pass completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server ✅ Pass completed Link

}

// Start of user code toString_finalize
result =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

* The class resource, everything.
* @deprecated Use {@link Rdfs#RDFSCLASS_CLASS} instead.
*/
@Deprecated public static String RDFSCLASS_CLASS = "RdfsClass";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong, the suffix should not be added to the old class

* The class resource, everything.
* @deprecated Use {@link Rdfs#RDFSCLASS_CLASS} instead.
*/
@Deprecated public static String TYPE_RDFSCLASS = Rdfs.RDFSCLASS_CLASS;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jad-el-khoury this fixes a bug where this constant previously was http://www.w3.org/2000/01/rdf-schema#RdfsClass but should be http://www.w3.org/2000/01/rdf-schema#Class.

<version>7.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Lyo :: Domains</name>
<name>oslc-domains</name>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotta revert

Copilot AI review requested due to automatic review settings December 13, 2025 17:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces strongly typed vocabulary helpers for OSLC domains to improve developer experience and performance. The changes eliminate the need for manual string concatenation or new QName() calls by providing:

  • Static class constants for every RDF class and property
  • QName helper methods with lazy initialization and caching
  • Shorter, more ergonomic naming patterns

Key changes include:

  • Adding new vocabulary helper classes (Dcterms, Foaf, Rdf, Rdfs, Prov, Oslc, Oslc_cm, Oslc_qm, Oslc_rm, Oslc_config) with constants and QName factory methods
  • Deprecating old constant names in VocabularyConstants interfaces with migration paths
  • Fixing typo: "Oscl" → "Oslc" throughout codebase
  • Reformatting DomainConstants files for better readability
  • Adding setExtended() helper method to AbstractResource
  • Updating license headers to EPL-2.0 OR BSD-3-Clause format

Reviewed changes

Copilot reviewed 146 out of 146 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Dcterms.java, Foaf.java, Rdf.java, Rdfs.java, Prov.java, Oslc.java, Oslc_cm.java, Oslc_qm.java, Oslc_rm.java, Oslc_config.java New vocabulary helper classes with constants and QName factory methods
*VocabularyConstants.java Updated with _CLASS suffix, deprecation annotations, and javadocs
*DomainConstants.java Reformatted for readability with improved comment placement
OslcVocabularyConstants.java Fixed typo from OsclVocabularyConstants
OsclVocabularyConstants.java Removed (typo file)
Nsp10DomainConstants.java Removed unused Matlab domain
AbstractResource.java Added setExtended() helper method
OslcClientTest.java Added test demonstrating new QName helper usage
oslc-client/pom.xml Added oslc-domains dependency
Various resource files Updated license headers and generation timestamps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Discussion.class);
}

public String toString() {
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method overrides Object.toString; it is advisable to add an Override annotation.

Copilot uses AI. Check for mistakes.
@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Dec 22, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl ✅ Pass completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server ✅ Pass completed Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants