Interface IPromptQueryDao


public interface IPromptQueryDao
Data access object for creating, updating, and deleting PromptQueryEntity entities.
Since:
8.5.0
Author:
XIMA MEDIA GmbH
  • Method Details

    • createOrUpdate

      PromptQueryEntity createOrUpdate(PromptQueryEntity entity)
      Creates the entity if it does not exist yet in the database, or updates it otherwise.
      Parameters:
      entity - The entity to create or update.
      Returns:
      The created or updated entity.
    • delete

      void delete(PromptQueryEntity entity)
      Deletes the given prompt query entity.
      Parameters:
      entity - The prompt query entity to delete.
    • deleteAllByScope

      @CanIgnoreReturnValue long deleteAllByScope(String scopeKind, long scopeId)
      Deletes all prompt connections that belong to the specified scope.
      Parameters:
      scopeKind - The kind of the scope whose prompt queries are to be deleted.
      scopeId - The ID of the scope whose prompt queries are to be.
      Returns:
      The number of deleted prompt connections.
    • findUniqueName

      String findUniqueName(String scopeKind, long scopeId, String candidateName, PromptQueryEntity exclude)
      Finds a new unique name for a (new) given prompt query. The returned name is unique amongst all prompt queries of the given scope. The returned name is based on the given candidate name. If no query with the candidate name exists, the candidate name is returned.
      Parameters:
      scopeKind - The kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to ensure name uniqueness
      candidateName - A candidate name to make unique.
      exclude - Optional. When given, the name of this prompt query is excluded from the uniqueness check.
      Returns:
      A unique name based on the candidate name.
    • getAllByConnection

      List<PromptQueryEntity> getAllByConnection(String scopeKind, long scopeId, UUID connection)
      Gets all prompt queries that have the given connection selected.
      Parameters:
      scopeKind - The kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt queries.
      connection - The UUID of the connection entity.
      Returns:
      A list of all prompt queries associated with the specified connection.
    • getAllByConnection

      List<PromptQueryEntity> getAllByConnection(PromptConnectionEntity connection)
      Gets all prompt queries that have the given connection selected.
      Parameters:
      connection - The connection entity.
      Returns:
      A list of all prompt queries associated with the specified connection.
    • getAllByScope

      List<PromptQueryEntity> getAllByScope(String scopeKind, long scopeId)
      Gets all prompt queries that belong to the specified scope.
      Parameters:
      scopeKind - The kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt queries.
      Returns:
      A list of all prompt queries associated with the specified scope.
    • getAllByScopeIncludeChildren

      List<PromptQueryEntity> getAllByScopeIncludeChildren(String scopeKind, long scopeId)
      Gets all prompt queries that belong to the specified scope, or a child of the specified scope.
      Parameters:
      scopeKind - The scope kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt queries.
      Returns:
      A list of all prompt queries associated with the specified scope.
    • getAllByScopeIncludeParents

      List<PromptQueryEntity> getAllByScopeIncludeParents(String scopeKind, long scopeId)
      Gets all prompt queries that belong to the specified scope, or a parent of the specified scope.
      Parameters:
      scopeKind - The scope kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt queries.
      Returns:
      A list of all prompt queries associated with the specified scope.
    • getByName

      PromptQueryEntity getByName(String scopeKind, long scopeId, String name)
      Gets a prompt query with a given name that belongs to the specified scope.
      Parameters:
      scopeKind - The kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt query
      name - The name of the prompt query to retrieve.
      Returns:
      The prompt query entity with the specified name, or null if not found.
    • getByUuid

      PromptQueryEntity getByUuid(String scopeKind, long scopeId, UUID query)
      Gets a prompt query by its UUID. Requires a tenant scope as the UUID is unique only within a specific tenant.
      Parameters:
      scopeKind - The kind of the scope, e.g. "tenant" or "project".
      scopeId - The ID of the scope for which to retrieve the prompt query
      query - The UUID of the prompt query to retrieve.
      Returns:
      The prompt query entity with the specified UUID, or null if not found.
    • openFile

      InputStream openFile(Long file) throws IOException
      Opens a stream to access the data of a prompt query file.
      Parameters:
      file - The UUID of the prompt query file entity for which to open the stream.
      Returns:
      An input stream to read the file's data.
      Throws:
      IOException - If an error occurs while opening the file stream.
    • updatePromptFileData

      void updatePromptFileData(IUser user, Long file, InputStream input) throws IOException
      Updates the prompt query file with the data from the provided input stream. Does not read the prompt query file data entity into memory.
      Parameters:
      file - The UUID of the prompt query file to update.
      input - The input stream containing the new data for the prompt query file.
      Throws:
      IOException - If an I/O error occurs while reading from the input stream.
    • writeFileTo

      void writeFileTo(String scopeKind, long scopeId, UUID query, String fileKey, int fileIndex, OutputStream outputStream) throws IOException
      Writes the data of a particular file of a prompt query to the output stream. The file is identified by the ID of the prompt query + the file key and file index of the file in the file map (Map<String, List<File>>) of the query.
      Parameters:
      scopeKind - The kind of the scope that contains the prompt query.
      scopeId - The ID of the scope that contains the prompt query.
      query - The UUID of the query.
      fileKey - The key of the file to write to the output stream.
      fileIndex - The index of the file to write to the output stream.
      outputStream - Output stream to write to.
      Throws:
      IOException