Skip to content
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

Freemarker dataGetter directive #440

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

litvinovg
Copy link
Contributor

Mentioned in VIVO GitHub issue

What does this pull request do?

Adds new Freemarker directive to execute DataGetters with provided parameters and save results as Freemarker variables.

What's new?

  • Added new directive to FreemarkerConfiguration
  • Fixed substitutions in SparqlQueryDataGetter
  • New data properties to specify types of substituted variables
  • Added more tests for SparqlQueryDataGetter
  • Removed unreachable case in DataGetterBase
  • Removed SparqlQueryDataGetterTest.java from checkstyle suppressions

How should this be tested?

SparqlQueryDataGetter improvements covered by tests.
New directive could be tested by calling test data getter in Freemarker template:

<@dataGetter uri = "test:dataGetter" var = "labels" parameters = {"object": "http://purl.org/ontology/bibo/AcademicArticle"} />
<#if labels?has_content><p>Label returned by data getter: ${labels[0].label}</p></#if>

Data getter configuration:

<test:dataGetter>
    a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> ;
    display:saveToVar "result" ;
    display:uri "object";
    display:query """
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?label
        WHERE {
          ?object rdfs:label ?label .
        } LIMIT 1
     """ .

Interested parties

@VIVO-project/vivo-committers

Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@litvinovg great work!!! I really like the implementation. I have added a couple of tiny comments/suggestions. I think it is important in the documentation to explain overriding saveToVar property with var attribute in datagetter directive. I needed some time to understand that in the code.

Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@litvinovg I have posted one comment in the review to align a comment with the code.

Regarding testing, I had the issue to test it. It was my fault, but we should consider to clarify that in the documentation. Namely, I defined a datagetter in an n3 file by using a prefix (display), and I also used the prefix in ftl file. So, we should clarify in the documentation that full uri has to be used in the ftl file.

Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@litvinovg thanks.

Code reviewed and the usage of new directive tested.

@chenejac chenejac requested a review from wwelling March 1, 2024 12:57
@chenejac chenejac merged commit ff22e4e into vivo-project:main Mar 21, 2024
1 check passed
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