All Superinterfaces:
Element, EntityElement, IdentifiableElement, Serializable
All Known Implementing Classes:
QueryTemplateImpl

@TypeMetadata(name="QueryTemplate", description="Represents a Query Template that can be used to generate runnable queries by substituting variables.", version="1.0.0") @Change(version="1.0.0", description="First Version") public interface QueryTemplate extends EntityElement
Represents a query template that can be used to generate runnable queries by substituting variables.
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

  • Method Details

    • getName

      @ISProperty(name="name", description="The name of the Query Template. Among UUID univocally identifiy the Query Template.", readonly=true, mandatory=true) String getName()
      Returns the name of the query template.
      Returns:
      The template name.
    • setName

      void setName(String name)
      Sets the name of the query template.
      Parameters:
      name - The name to set.
    • getDescription

      @ISProperty(name="description", description="The description of the Query Template.", readonly=false, mandatory=true) String getDescription()
      Returns the description of the query template.
      Returns:
      The template description.
    • setDescription

      void setDescription(String description)
      Sets the description of the query template.
      Parameters:
      description - The description to set.
    • getVersion

      Version getVersion()
      Returns the version of the query template.
      Returns:
      The template version, or null when not set.
    • getVersionAsString

      @ISProperty(name="version", description="The version of the Query Template, in the form major.minor.patch. It is the highest version listed in the changelog.", readonly=false, mandatory=true) String getVersionAsString()
      Returns the version of the query template as a string.
      Returns:
      The version string, or null when not set.
    • setVersion

      void setVersion(String version)
      Sets the version of the query template.
      Parameters:
      version - The version string, in the form major.minor.patch.
    • getChangelog

      Map<Version,String> getChangelog()
      Returns the changelog of the query template.
      Returns:
      A map of versions to change descriptions, or null when not set.
    • getChangelogWithVersionAsString

      @ISProperty(name="changelog", description="The complete history of the Query Template: each version mapped to the description of its change.", readonly=false, mandatory=true) Map<String,String> getChangelogWithVersionAsString()
      Returns the changelog with versions represented as strings.
      Returns:
      A map of version strings to change descriptions, or null when not set.
    • setChangelog

      void setChangelog(Map<String,String> changelog)
      Sets the changelog of the query template.
      Parameters:
      changelog - A map of version strings to change descriptions.
    • getTemplateAsString

      @ISProperty(name="template", description="The Query Template. It can contains query variables to be replaced to obtain a runnable query.", readonly=false, mandatory=true) String getTemplateAsString() throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      Returns the template body as a string.
      Returns:
      The template as a string.
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during serialization.
    • setTemplate

      void setTemplate(String template) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException, IOException
      Sets the template body from a string.
      Parameters:
      template - The template string.
      Throws:
      IOException - if an error occurs during parsing.
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during JSON processing.
    • setTemplate

      void setTemplate(org.gcube.com.fasterxml.jackson.databind.JsonNode template)
      Sets the template body from a JsonNode.
      Parameters:
      template - The template as a JsonNode.
    • getTemplate

      org.gcube.com.fasterxml.jackson.databind.JsonNode getTemplate()
      Returns the template body as a JsonNode.
      Returns:
      The template as a JsonNode.
    • getTemplateVariables

      @ISProperty(name="templateVariables", description="The Query Template Variables. It can contains Query Template Variable to be replaced to obtain a runnable query.", readonly=false, mandatory=true) Map<String,TemplateVariable> getTemplateVariables()
      Returns the variables defined in this template.
      Returns:
      A map of template variables, with variable names as keys.
    • addTemplateVariable

      void addTemplateVariable(TemplateVariable templateVariable)
      Adds a variable to the template. If a variable with the same name already exists, it will be overridden.
      Parameters:
      templateVariable - The variable to add.
    • getParamsFromDefaultValues

      org.gcube.com.fasterxml.jackson.databind.node.ObjectNode getParamsFromDefaultValues()
      Creates an ObjectNode containing the default values of all template variables.
      Returns:
      An ObjectNode with default parameter values.
    • getJsonQuery

      org.gcube.com.fasterxml.jackson.databind.JsonNode getJsonQuery() throws Exception
      Generates a runnable query by substituting variables with their default values.
      Returns:
      The generated query as a JsonNode.
      Throws:
      Exception - if an error occurs during query generation.
    • getJsonQuery

      org.gcube.com.fasterxml.jackson.databind.JsonNode getJsonQuery(org.gcube.com.fasterxml.jackson.databind.JsonNode values) throws Exception
      Generates a runnable query by substituting variables with the provided values.
      Parameters:
      values - A JsonNode containing the values to substitute.
      Returns:
      The generated query as a JsonNode.
      Throws:
      Exception - if an error occurs during query generation.