-
Notifications
You must be signed in to change notification settings - Fork 2
Helper methods for RML to MTL conversion #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Previously, Path was used, but switching to InputStream simplifies invocation from Chimera without sacrificing performance.
Previously, Path was used, but switching to InputStream simplifies invocation from Chimera without sacrificing performance.
…emplate into ref-RML-to-MTL
…emplate into ref-RML-to-MTL
…emplate into ref-RML-to-MTL
…emplate into ref-RML-to-MTL
…emplate into ref-RML-to-MTL
marioscrock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request! Great work in improving management of file paths also in the test.
There was a problem hiding this 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 helper methods for converting RML mappings to MTL templates, enabling code reuse across components. It also updates the Velocity FileResourceLoader configuration to use an empty string as the root path instead of "./".
- Adds a new
compiledMTLMappingmethod inUtilclass to handle RML to MTL conversion logic - Refactors
validateRMLto acceptInputStreaminstead ofPathfor better flexibility - Updates Velocity engine configuration to use empty string root path for FileResourceLoader
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/com/cefriel/template/utils/Util.java | Adds helper method for RML to MTL conversion and updates Velocity engine configuration |
| src/main/java/com/cefriel/template/utils/RMLCompilerUtils.java | Refactors base IRI extraction to support both string and path inputs |
| src/test/java/com/cefriel/template/RMLTests.java | Updates tests to use new helper method and InputStream-based validation |
| src/main/java/com/cefriel/template/Main.java | Updates to use InputStream-based RML validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import org.apache.velocity.tools.generic.*; | ||
| import org.eclipse.rdf4j.common.exception.ValidationException; | ||
| import org.eclipse.rdf4j.model.Model; | ||
| import org.eclipse.rdf4j.model.base.CoreDatatype; |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import appears to be unused. Consider removing it to keep the imports clean.
| import org.eclipse.rdf4j.model.base.CoreDatatype; |
| * @throws Exception if validation or compilation fails. | ||
| */ | ||
| public static Path compiledMTLMapping(InputStream mappingRML, String baseIri, Path basePath, boolean trimTemplate, boolean verbose) throws Exception { |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method throws a generic Exception. Consider documenting the specific exceptions that can be thrown or using more specific exception types in the throws clause.
| * @throws Exception if validation or compilation fails. | |
| */ | |
| public static Path compiledMTLMapping(InputStream mappingRML, String baseIri, Path basePath, boolean trimTemplate, boolean verbose) throws Exception { | |
| * @throws IOException if an I/O error occurs during reading or writing files. | |
| * @throws ValidationException if RML validation fails. | |
| * @throws RepositoryException if an RDF repository error occurs. | |
| */ | |
| public static Path compiledMTLMapping(InputStream mappingRML, String baseIri, Path basePath, boolean trimTemplate, boolean verbose) | |
| throws IOException, ValidationException, RepositoryException { |
|
|
||
| Map<String,String> rmlMap = new HashMap<>(); | ||
| rmlMap.put("basePath", FOLDER); | ||
| rmlMap.put("basePath", null); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting basePath to null might cause issues downstream. Consider using an empty string or a default value instead of null.
| rmlMap.put("basePath", null); | |
| rmlMap.put("basePath", ""); |
Introduces a helper method to handle the conversion logic from an RML mapping to an MTL template. This enables code reuse across both the mapping-template and Chimera components.
Updates the root path of the FileResourceLoader from the default "./" to an empty string (""). As a result, paths provided to Velocity no longer need to be relative to "./". However, it remains possible to specify paths relative to the basePath CLI parameter, or to use absolute paths directly. Internally, VTL always resolves paths to absolute locations (ref).