Package sk.iway.iwcm.rag.rest
Class EmbeddingChunkRestController
java.lang.Object
sk.iway.iwcm.system.datatable.DatatableRestControllerV2<EmbeddingChunkEntity,Long>
sk.iway.iwcm.rag.rest.EmbeddingChunkRestController
@RestController
@RequestMapping("/admin/rest/settings/embedding-chunks")
@PreAuthorize("@WebjetSecurityService.hasPermission(\'embeddingChunks\')")
public class EmbeddingChunkRestController
extends DatatableRestControllerV2<EmbeddingChunkEntity,Long>
REST controller for managing RAG embedding chunks via the admin datatable interface.
Provides CRUD operations, document indexing actions, and statistics endpoints.
Requires 'embeddingChunks' permission.
-
Constructor Summary
ConstructorsConstructorDescriptionEmbeddingChunkRestController(EmbeddingChunkRepository chunkRepository, IndexQueueService indexQueueService, VectorStore vectorStore, RagEmbeddingStatService ragEmbeddingStatService, MarkdownQueueService markdownQueueService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSpecSearch(Map<String, String> params, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.Root<EmbeddingChunkEntity> root, jakarta.persistence.criteria.CriteriaBuilder builder) Adds document-group or shared Markdown path constraints before applying base search predicates.org.springframework.data.domain.Page<EmbeddingChunkEntity>findByColumns(Map<String, String> params, org.springframework.data.domain.Pageable pageable, EmbeddingChunkEntity search) Applies column filtering in the shared configuration context for Markdown chunks.org.springframework.data.domain.Page<EmbeddingChunkEntity>getAllItems(org.springframework.data.domain.Pageable pageable) Loads chunks for the requested source type after preparing the vector schema.getCurrentEmbeddingConfiguration(String entityType) Returns the provider and model configured for RAG indexing in the current domain.getDocumentStat(int rootDir, boolean includeSubfolders, String action) Returns statistics about document indexing status for the specified folder.protected intUses shared domain zero for the Markdown tab and the current domain for other entity types.Returns globally configured documentation roots for the shared Markdown tab.getMarkdownFolderTree(Map<String, String> request) Supplies the shared folder picker with configured roots and lazily loaded child directories.getMarkdownStat(String folder, String action, String directory, boolean includeSubfolders) Returns file, index, and queue counts for a selected Markdown directory scope.voidAdds source types and languages appropriate to document or shared Markdown storage.org.springframework.data.domain.ExampleMatchergetSearchProperties(Map<String, String> params, Map<String, String> searchProperties, org.springframework.beans.BeanWrapperImpl searchWrapped, org.springframework.data.domain.ExampleMatcher matcher, boolean isExampleSearch) Leaves Markdown root and directory constraints to specification filtering.intperformDocumentAction(int rootDir, boolean includeSubfolders, String action) Queues an indexing or deletion action for searchable documents in an authorized folder scope.intperformMarkdownAction(String folder, String action, String directory, boolean includeSubfolders) Enqueues indexing or deletion for the selected documentation scope for later processing.processFromEntity(EmbeddingChunkEntity entity, ProcessItemAction action) Adds pending or error row styling when chunks are returned for listing or searching.Methods inherited from class sk.iway.iwcm.system.datatable.DatatableRestControllerV2
action, add, addNotify, addNotify, addSpecSort, afterDelete, afterDuplicate, afterImportChunk, afterSave, allowGeneratedIdOnCreate, beforeDelete, beforeDuplicate, beforeDuplicate, beforeSave, checkAccessAllowed, checkItemPerms, checkRowReorderScope, copyEntityIntoOriginal, delete, deleteItem, edit, editItem, findItemBy, getAll, getAllItemsIncludeSpecSearch, getCleanKey, getCleanValue, getCustomFieldsSearchDto, getImportedColumns, getImportMode, getInvalidImportedRows, getLastImportedRow, getOne, getOneItem, getParamsMap, getProp, getRepo, getRequest, getSearchConditions, getSum, getUpdateByColumn, getUser, handleEditor, hasNotify, initBinder, insertItem, isDuplicate, isExporting, isForceReload, isImporting, isSkipWrongData, jpaToBoolean, preImportDataEdit, processAction, processFromEntity, processFromEntity, processFromEntity, processToEntity, rowReorder, searchItem, setForceReload, setRedirect, setRequest, setValidator, sumItems, throwConstraintViolation, throwError, throwError, throwError, throwError, throwError, throwError, validateEditor, validateEditorForCustomFields
-
Constructor Details
-
EmbeddingChunkRestController
@Autowired public EmbeddingChunkRestController(EmbeddingChunkRepository chunkRepository, IndexQueueService indexQueueService, VectorStore vectorStore, RagEmbeddingStatService ragEmbeddingStatService, MarkdownQueueService markdownQueueService)
-
-
Method Details
-
getDomainId
protected int getDomainId()Uses shared domain zero for the Markdown tab and the current domain for other entity types.- Overrides:
getDomainIdin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Returns:
- storage domain selected by the request entity type
-
getAllItems
public org.springframework.data.domain.Page<EmbeddingChunkEntity> getAllItems(org.springframework.data.domain.Pageable pageable) Loads chunks for the requested source type after preparing the vector schema. Markdown retrieval uses shared configuration and storage.- Overrides:
getAllItemsin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
pageable- requested page and sort order- Returns:
- matching chunks, or an empty page when the type is invalid or the vector store is unavailable
-
findByColumns
public org.springframework.data.domain.Page<EmbeddingChunkEntity> findByColumns(Map<String, String> params, org.springframework.data.domain.Pageable pageable, EmbeddingChunkEntity search) Applies column filtering in the shared configuration context for Markdown chunks.- Overrides:
findByColumnsin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
params- request parameters including the source entity typepageable- requested page and sort ordersearch- entity holding example-search values- Returns:
- matching chunks, or an empty page for an invalid source type
-
getSearchProperties
public org.springframework.data.domain.ExampleMatcher getSearchProperties(Map<String, String> params, Map<String, String> searchProperties, org.springframework.beans.BeanWrapperImpl searchWrapped, org.springframework.data.domain.ExampleMatcher matcher, boolean isExampleSearch) Leaves Markdown root and directory constraints to specification filtering.- Overrides:
getSearchPropertiesin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
params- request search parameterssearchProperties- column properties populated by the base controllersearchWrapped- wrapper for the example-search entitymatcher- current example matcherisExampleSearch- whether example-based matching is active- Returns:
- base matcher after excluding root and directory parameters
-
addSpecSearch
public void addSpecSearch(Map<String, String> params, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.Root<EmbeddingChunkEntity> root, jakarta.persistence.criteria.CriteriaBuilder builder) Adds document-group or shared Markdown path constraints before applying base search predicates.- Overrides:
addSpecSearchin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
params- request parameters defining source type and folder selectionpredicates- mutable collection receiving search predicatesroot- embedding chunk query rootbuilder- criteria builder used to construct predicates
-
getMarkdownFolders
Returns globally configured documentation roots for the shared Markdown tab.- Returns:
- normalized configured documentation roots
-
getMarkdownFolderTree
@PostMapping("/markdown-folders/tree") public Map<String,Object> getMarkdownFolderTree(@RequestBody Map<String, String> request) Supplies the shared folder picker with configured roots and lazily loaded child directories.- Parameters:
request- tree request containing a root marker or an encoded node ID inid- Returns:
- success flag and child items, or a localized scan error
- Throws:
org.springframework.web.server.ResponseStatusException- if the node ID or directory selection is invalid
-
getMarkdownStat
@GetMapping("/markdown-stat") public Map<String,Object> getMarkdownStat(@RequestParam("folder") String folder, @RequestParam("action") String action, @RequestParam(value="directory",defaultValue="") String directory, @RequestParam(value="includeSubfolders",defaultValue="true") boolean includeSubfolders) Returns file, index, and queue counts for a selected Markdown directory scope.- Parameters:
folder- configured documentation rootaction- requestedINDEXorDELETEactiondirectory- root-relative directory, empty for the rootincludeSubfolders- whether to include descendant directories- Returns:
- counts keyed by
totalDocuments,indexedDocuments, andqueuedDocuments
-
performMarkdownAction
@PostMapping("/markdown-action") public int performMarkdownAction(@RequestParam("folder") String folder, @RequestParam("action") String action, @RequestParam(value="directory",defaultValue="") String directory, @RequestParam(value="includeSubfolders",defaultValue="true") boolean includeSubfolders) Enqueues indexing or deletion for the selected documentation scope for later processing.- Parameters:
folder- configured documentation rootaction- requestedINDEXorDELETEactiondirectory- root-relative directory, empty for the rootincludeSubfolders- whether to include descendant directories- Returns:
- number of unique source files queued
-
getOptions
Adds source types and languages appropriate to document or shared Markdown storage.- Overrides:
getOptionsin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
page- datatable response receiving select options
-
processFromEntity
public EmbeddingChunkEntity processFromEntity(EmbeddingChunkEntity entity, ProcessItemAction action) Adds pending or error row styling when chunks are returned for listing or searching.- Overrides:
processFromEntityin classDatatableRestControllerV2<EmbeddingChunkEntity,Long> - Parameters:
entity- chunk whose row styling may be updatedaction- datatable operation producing the chunk- Returns:
- the supplied chunk with any applicable row class
-
getCurrentEmbeddingConfiguration
@GetMapping("/current-embedding-configuration") public Map<String,String> getCurrentEmbeddingConfiguration(@RequestParam(value="entityType",defaultValue="DOCUMENT") String entityType) Returns the provider and model configured for RAG indexing in the current domain.- Parameters:
entityType- source type; both document and shared Markdown indexing use the current domain's assistant- Returns:
- configuration map containing
providerandmodel, or an empty map when no complete indexing assistant is configured
-
performDocumentAction
@PostMapping("/document-action") public int performDocumentAction(@RequestParam("rootDir") int rootDir, @RequestParam("includeSubfolders") boolean includeSubfolders, @RequestParam("action") String action) Queues an indexing or deletion action for searchable documents in an authorized folder scope.- Parameters:
rootDir- root group ID, or-1for all documents in the current domainincludeSubfolders- whether documents in descendant groups should be includedaction- action to perform, expected to beINDEXorDELETE- Returns:
- number of matched documents considered for queueing,
0when none match, or-1when queueing fails - Throws:
org.springframework.security.access.AccessDeniedException- if the requested group scope is invalid, not editable, or belongs to another domain
-
getDocumentStat
@GetMapping("/document-stat") public Map<String,Object> getDocumentStat(@RequestParam("rootDir") int rootDir, @RequestParam("includeSubfolders") boolean includeSubfolders, @RequestParam("action") String action) Returns statistics about document indexing status for the specified folder. Returns total groups, total documents, already indexed count, and currently queued count.- Parameters:
rootDir- the root directory group ID (-1 for all domain documents)includeSubfolders- whether to include documents from subfoldersaction- the action to check queue status for- Returns:
- map with keys: totalGroups, totalDocuments, indexedDocuments, queuedDocuments
- Throws:
org.springframework.security.access.AccessDeniedException- if the requested group scope is invalid, not editable, or belongs to another domain
-