Package com.complexible.stardog

# Interface StoredQuery

public interface StoredQuery
Represents a query stored in the server. Stored queries can be executed directly by using their name. `Shared queries` can be executed by any user. Private queries can only be executed by their `creator` or super users. Stored queries can be executed over the `getDatabase()` database} associated with the query. The special value "*" indicates a query can be executed over any database.

Since:
  4.2
Version:
  4.2
Author:
  Evren Sirin

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `StoredQuery.Builder`
  Builder interface for creating instances of StoredQuery.
  `static enum`
  `StoredQuery.TriggerPayloadType`
  Enum representing the payload type for triggers.
  `static class`
  `StoredQuery.TriggerStatus`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ALL_DATABASES`
  Special value indicating a stored query can be executed over all databases.
  `static final int`
  `DEFAULT_TRIGGER_LIMIT`
  The default trigger query result limit to watch.
  `static final String`
  `PATH_SEPARATOR`
  `static final Pattern`
  `VALID_NAME_PATTERN`
  Regex for validating stored query names

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  After this call the query can no longer be used.
  `com.google.common.collect.Multimap<IRI,Value>`
  `getAnnotations()`
  Returns the additional annotations associated with the stored query.
  `String`
  `getCreator()`
  Returns the name of the user who stored the query.
  `String`
  `getDatabase()`
  Returns the name of the database for this query.
  `String`
  `getDescription()`
  Returns the description of the stored query.
  `static String`
  `getFullPath(StoredQuery theQuery)`
  Returns the full path of the stored query The full path is composed of both directory and name.
  `String`
  `getName()`
  Returns the name of the stored query.
  `default List<String>`
  `getPath()`
  Returns the path (directory) of the stored query.
  `String`
  `getQuery()`
  Returns the query string.
  `String`
  `getSchema()`
  Returns the reasoning schema that will be used by this query or `null schema` if reasoning is not used.
  `int`
  `getTriggerLimit()`
  Returns the limit on the number of query tuples which will be observerd
  `StoredQuery.TriggerPayloadType`
  `getTriggerPayloadType()`
  Returns the payload type for the trigger.
  `int`
  `getTriggerSchedule()`
  The frequency at which the query will be executed
  `StoredQuery.TriggerStatus`
  `getTriggerStatus()`
  `int`
  `getTriggerTimeout()`
  `boolean`
  `isAvailable()`
  true, if not closed.
  `boolean`
  `isReasoning()`
  Returns `true` if this query is going to be executed with reasoning enabled.
  `boolean`
  `isShared()`
  Returns `true` if this query is shared by all the users.
  `boolean`
  `isTrigger()`
  Returns `true` if the results of this query are watched by the system, and notifications are sent when the results change.
  `static boolean`
  `isValidName(String name)`
  Returns `true` if the given name is a valid stored query name.
  `void`
  `setTriggerStatus(StoredQuery.TriggerStatus status)`
  `static List<String>`
  `subPaths(List<String> path)`
  Returns all subpaths of a given path, represented as strings delimited with `PATH_SEPARATOR`, up to and including the path itself (but not including an empty path).
  `StoredQuery.Builder`
  `toBuilder()`
  `default StoredQuery`
  `withFullPath(String theFullPath)`
  Creates a copy of this query with a different name and path.
  `default StoredQuery`
  `withName(String theNewName)`
  Creates a copy of this query with a different name.
  `default StoredQuery`
  `withPath(List<String> thewNewPath)`
  Creates a copy of this query with a different path.

- ## Field Details

  - ### PATH_SEPARATOR

    static final String PATH_SEPARATOR
    See Also:
      - Constant Field Values

  - ### DEFAULT_TRIGGER_LIMIT

    static final int DEFAULT_TRIGGER_LIMIT
    The default trigger query result limit to watch. If the query does not have an ORDER BY as the top plan node, then we will impose an ordering on the query.
    See Also:
      - Constant Field Values

  - ### ALL_DATABASES

    static final String ALL_DATABASES
    Special value indicating a stored query can be executed over all databases.
    See Also:
      - Constant Field Values

  - ### VALID_NAME_PATTERN

    static final Pattern VALID_NAME_PATTERN
    Regex for validating stored query names

- ## Method Details

  - ### getName

    String getName()
    Returns the name of the stored query.
    Returns:
      the name of the stored query.

  - ### getPath

    default List<String> getPath()
    Returns the path (directory) of the stored query. The path is represented as a list of components. Empty list means root directory.
    Returns:
      the path of the stored query.

  - ### getDescription

    String getDescription()
    Returns the description of the stored query.
    Returns:
      the description of the stored query.

  - ### getQuery

    String getQuery()
    Returns the query string.
    Returns:
      the query string

  - ### getCreator

    String getCreator()
    Returns the name of the user who stored the query.
    Returns:
      the name of the user who stored the query.

  - ### getDatabase

    String getDatabase()
    Returns the name of the database for this query. The special value "*" can be used to indicate a query can be executed over any database.
    Returns:
      the name of the database for this query.

  - ### isShared

    boolean isShared()
    Returns `true` if this query is shared by all the users. Shared queries can be executed by any user.
    Returns:
      `true` if this query is shared by all the users

  - ### isReasoning

    boolean isReasoning()
    Returns `true` if this query is going to be executed with reasoning enabled.
    Returns:
      `true` if this query is going to be executed with reasoning enabled

  - ### isTrigger

    boolean isTrigger()
    Returns `true` if the results of this query are watched by the system, and notifications are sent when the results change.
    Returns:
      `true` if this query is a query trigger

  - ### getTriggerLimit

    int getTriggerLimit()
    Returns the limit on the number of query tuples which will be observerd
    Returns:
      number of rows

  - ### getTriggerSchedule

    int getTriggerSchedule()
    The frequency at which the query will be executed
    Returns:
      frequency in milliseconds

  - ### getTriggerTimeout

    int getTriggerTimeout()
    Returns:
      trigger timeout in seconds

  - ### getSchema

    String getSchema()
    Returns the reasoning schema that will be used by this query or `null schema` if reasoning is not used. If the schema is set to anything other than `null` then that schema wil lbe used for execution regardless of the schema specified for the connection. If the schema is set to `null` then schema settings of the connection will be used for execution.
    Returns:
      the name of the reasoning schema

  - ### getAnnotations

    com.google.common.collect.Multimap<IRI,Value> getAnnotations()
    Returns the additional annotations associated with the stored query.
    Returns:
      the additional annotations associated with the stored query.

  - ### close

    void close()
    After this call the query can no longer be used.

  - ### isAvailable

    boolean isAvailable()
    true, if not closed.

  - ### getTriggerStatus

    @Nullable StoredQuery.TriggerStatus getTriggerStatus()
    Returns:
      ephemeral trigger status, not immutable

  - ### setTriggerStatus

    void setTriggerStatus(StoredQuery.TriggerStatus status)
    Parameters:
      `status` - to set

  - ### withName

    default StoredQuery withName(String theNewName)
    Creates a copy of this query with a different name.
    Parameters:
      `theNewName` - new name
    Returns:
      a query with specified name

  - ### withPath

    default StoredQuery withPath(List<String> thewNewPath)
    Creates a copy of this query with a different path.
    Parameters:
      `thewNewPath` - new path
    Returns:
      a query with specified path

  - ### withFullPath

    default StoredQuery withFullPath(String theFullPath)
    Creates a copy of this query with a different name and path. Name and path are parsed out of full path.
    Parameters:
      `theFullPath` - the new full path
    Returns:
      a query with specified full path

  - ### isValidName

    static boolean isValidName(String name)
    Returns `true` if the given name is a valid stored query name.
    Parameters:
      `name` - query name to validate
    Returns:
      `true` if the given name is a valid stored query name.

  - ### getFullPath

    static String getFullPath(StoredQuery theQuery)
    Returns the full path of the stored query The full path is composed of both directory and name.
    Parameters:
      `theQuery` - the stored query
    Returns:
      the full path of the stored query.

  - ### subPaths

    static List<String> subPaths(List<String> path)
    Returns all subpaths of a given path, represented as strings delimited with `PATH_SEPARATOR`, up to and including the path itself (but not including an empty path). For example, subpaths of ["a", "b", "c"] are "a", "a/b", "a/b/c"
    Parameters:
      `path` - a path
    Returns:
      list of subpath strings

  - ### toBuilder

    StoredQuery.Builder toBuilder()
    Returns:
      builder object with the contents of this object

  - ### getTriggerPayloadType

    StoredQuery.TriggerPayloadType getTriggerPayloadType()
    Returns the payload type for the trigger.
    Returns:
      the trigger payload type