Interface QueryTemplate
-
- 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 Summary
Fields Modifier and Type Field Description static StringCHANGELOG_PROPERTYThe property name for the template's changelog.static StringDESCRIPTION_PROPERTYThe property name for the template's description.static StringNAMEThe name of the QueryTemplate entity type.static StringNAME_PROPERTYThe property name for the template's name.static StringTEMPLATE_PROPERTYThe property name for the template's body.static StringTEMPLATE_VARIABLES_PROPERTYThe property name for the template's variables.static StringVERSION_PROPERTYThe property name for the template's version.-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, REDACTED, TYPE_PROPERTY, UNKNOWN_USER
-
Fields inherited from interface org.gcube.informationsystem.base.reference.IdentifiableElement
ID_PROPERTY, METADATA_PROPERTY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddTemplateVariable(TemplateVariable templateVariable)Adds a variable to the template.Map<Version,String>getChangelog()Returns the changelog of the query template.Map<String,String>getChangelogWithVersionAsString()Returns the changelog with versions represented as strings.StringgetDescription()Returns the description of the query template.org.gcube.com.fasterxml.jackson.databind.JsonNodegetJsonQuery()Generates a runnable query by substituting variables with their default values.org.gcube.com.fasterxml.jackson.databind.JsonNodegetJsonQuery(org.gcube.com.fasterxml.jackson.databind.JsonNode values)Generates a runnable query by substituting variables with the provided values.StringgetName()Returns the name of the query template.org.gcube.com.fasterxml.jackson.databind.node.ObjectNodegetParamsFromDefaultValues()Creates anObjectNodecontaining the default values of all template variables.org.gcube.com.fasterxml.jackson.databind.JsonNodegetTemplate()Returns the template body as aJsonNode.StringgetTemplateAsString()Returns the template body as a string.Map<String,TemplateVariable>getTemplateVariables()Returns the variables defined in this template.VersiongetVersion()Returns the version of the query template.StringgetVersionAsString()Returns the version of the query template as a string.voidsetChangelog(Map<String,String> changelog)Sets the changelog of the query template.voidsetDescription(String description)Sets the description of the query template.voidsetName(String name)Sets the name of the query template.voidsetTemplate(String template)Sets the template body from a string.voidsetTemplate(org.gcube.com.fasterxml.jackson.databind.JsonNode template)Sets the template body from aJsonNode.voidsetVersion(String version)Sets the version of the query template.-
Methods inherited from interface org.gcube.informationsystem.base.reference.Element
getTypeName
-
Methods inherited from interface org.gcube.informationsystem.base.reference.entities.EntityElement
getID, getMetadata, setID, setMetadata
-
-
-
-
Field Detail
-
NAME
static final String NAME
The name of the QueryTemplate entity type.- See Also:
- Constant Field Values
-
NAME_PROPERTY
static final String NAME_PROPERTY
The property name for the template's name.- See Also:
- Constant Field Values
-
DESCRIPTION_PROPERTY
static final String DESCRIPTION_PROPERTY
The property name for the template's description.- See Also:
- Constant Field Values
-
VERSION_PROPERTY
static final String VERSION_PROPERTY
The property name for the template's version.- See Also:
- Constant Field Values
-
CHANGELOG_PROPERTY
static final String CHANGELOG_PROPERTY
The property name for the template's changelog.- See Also:
- Constant Field Values
-
TEMPLATE_PROPERTY
static final String TEMPLATE_PROPERTY
The property name for the template's body.- See Also:
- Constant Field Values
-
TEMPLATE_VARIABLES_PROPERTY
static final String TEMPLATE_VARIABLES_PROPERTY
The property name for the template's variables.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
nullwhen 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
nullwhen 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
nullwhen 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
nullwhen 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 aJsonNode.- Parameters:
template- The template as aJsonNode.
-
getTemplate
org.gcube.com.fasterxml.jackson.databind.JsonNode getTemplate()
Returns the template body as aJsonNode.- 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 anObjectNodecontaining the default values of all template variables.- Returns:
- An
ObjectNodewith default parameter values.
-
getJsonQuery
org.gcube.com.fasterxml.jackson.databind.JsonNode getJsonQuery() throws ExceptionGenerates 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 ExceptionGenerates a runnable query by substituting variables with the provided values.- Parameters:
values- AJsonNodecontaining the values to substitute.- Returns:
- The generated query as a
JsonNode. - Throws:
Exception- if an error occurs during query generation.
-
-