Skip to content

Conversation

@AuPath
Copy link
Collaborator

@AuPath AuPath commented Oct 6, 2025

  • 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).

Marco Grassi added 9 commits July 25, 2025 09:52
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.
Copy link
Member

@marioscrock marioscrock left a 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.

@marioscrock marioscrock requested a review from Copilot October 7, 2025 09:49
Copy link

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 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 compiledMTLMapping method in Util class to handle RML to MTL conversion logic
  • Refactors validateRML to accept InputStream instead of Path for 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;
Copy link

Copilot AI Oct 7, 2025

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.

Suggested change
import org.eclipse.rdf4j.model.base.CoreDatatype;

Copilot uses AI. Check for mistakes.
Comment on lines +346 to +348
* @throws Exception if validation or compilation fails.
*/
public static Path compiledMTLMapping(InputStream mappingRML, String baseIri, Path basePath, boolean trimTemplate, boolean verbose) throws Exception {
Copy link

Copilot AI Oct 7, 2025

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.

Suggested change
* @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 {

Copilot uses AI. Check for mistakes.

Map<String,String> rmlMap = new HashMap<>();
rmlMap.put("basePath", FOLDER);
rmlMap.put("basePath", null);
Copy link

Copilot AI Oct 7, 2025

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.

Suggested change
rmlMap.put("basePath", null);
rmlMap.put("basePath", "");

Copilot uses AI. Check for mistakes.
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