Interface IPromptQueryDao
public interface IPromptQueryDao
Data access object for creating, updating, and deleting
PromptQueryEntity entities.- Since:
- 8.5.0
- Author:
- XIMA MEDIA GmbH
-
Method Summary
Modifier and TypeMethodDescriptioncreateOrUpdate(PromptQueryEntity entity) Creates the entity if it does not exist yet in the database, or updates it otherwise.voiddelete(PromptQueryEntity entity) Deletes the given prompt query entity.longdeleteAllByScope(String scopeKind, long scopeId) Deletes all prompt connections that belong to the specified scope.findUniqueName(String scopeKind, long scopeId, String candidateName, PromptQueryEntity exclude) Finds a new unique name for a (new) given prompt query.getAllByConnection(PromptConnectionEntity connection) Gets all prompt queries that have the givenconnection selected.getAllByConnection(String scopeKind, long scopeId, UUID connection) Gets all prompt queries that have the givenconnection selected.getAllByScope(String scopeKind, long scopeId) Gets all prompt queries that belong to the specified scope.getAllByScopeIncludeChildren(String scopeKind, long scopeId) Gets all prompt queries that belong to the specified scope, or a child of the specified scope.getAllByScopeIncludeParents(String scopeKind, long scopeId) Gets all prompt queries that belong to the specified scope, or a parent of the specified scope.Gets a prompt query with a given name that belongs to the specified scope.Gets a prompt query by its UUID.Opens a stream to access the data of a prompt query file.voidupdatePromptFileData(IUser user, Long file, InputStream input) Updates the prompt query file with the data from the provided input stream.voidwriteFileTo(String scopeKind, long scopeId, UUID query, String fileKey, int fileIndex, OutputStream outputStream) Writes the data of a particular file of a prompt query to the output stream.
-
Method Details
-
createOrUpdate
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
Deletes the given prompt query entity.- Parameters:
entity- The prompt query entity to delete.
-
deleteAllByScope
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 uniquenesscandidateName- 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
Gets all prompt queries that have the givenconnection 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
Gets all prompt queries that have the givenconnection selected.- Parameters:
connection- The connection entity.- Returns:
- A list of all prompt queries associated with the specified connection.
-
getAllByScope
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
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
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
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 queryname- The name of the prompt query to retrieve.- Returns:
- The prompt query entity with the specified name, or null if not found.
-
getByUuid
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 queryquery- The UUID of the prompt query to retrieve.- Returns:
- The prompt query entity with the specified UUID, or null if not found.
-
openFile
Opens a stream to access the data of a prompt query file.- Parameters:
file- The UUID of theprompt query file entityfor 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
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
-