Class JpqlExecutionService
java.lang.Object
io.jmix.aitools.dataload.execution.JpqlExecutionService
Validates, repairs and executes a generated JPQL query, returning the fetched rows.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordRows fetched for a query plus a flag telling whether more results are available beyond them. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AccessManagerprotected AiToolsDataLoadPropertiesprotected DataManagerprotected JpqlParameterConversionServiceprotected Metadataprotected QueryTransformerFactoryprotected JpqlValidationAndRepairService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JpqlExecutionService.ExecutionRowscreateExecutionRows(List<Map<String, Object>> rows, boolean hasMore) execute(JpqlExecutionRequest request) Validates, repairs if needed and executes the query described by the request.protected JpqlExecutionService.ExecutionRowsexecuteQuery(JpqlExecutionRequest request, GeneratedJpqlResult generatedJpqlResult, Map<String, Object> executionParameters, Integer maxResults, @Nullable Integer firstResult) protected IntegergetEffectiveMaxResult(@Nullable Integer maxResults) resolveDeniedSelectedIndexes(String jpqlQuery) Resolves the positions of the selected columns the current user is not allowed to read.retainPermittedProperties(List<String> resultProperties, List<Integer> deniedSelectedIndexes) Returns the result properties that stay readable, dropping the ones at the denied select positions so the inaccessible columns are omitted from the result.retainProperties(List<Map<String, Object>> rows, List<String> resultProperties, List<String> retainedProperties) Rebuilds each row keeping only the retained properties, in their original order.protected List<JpqlExecutionParameter> toExecutionParameters(GeneratedJpqlResult generatedJpqlResult) toValueRow(KeyValueEntity keyValueEntity, List<String> resultProperties)
-
Field Details
-
validateAndRepair
-
jpqlParameterConversionService
-
dataLoadProperties
-
dataManager
-
accessManager
-
queryTransformerFactory
-
metadata
-
-
Constructor Details
-
JpqlExecutionService
public JpqlExecutionService()
-
-
Method Details
-
execute
Validates, repairs if needed and executes the query described by the request.This method runs the full pipeline: it validates and (if needed) repairs the query, enforces data-access constraints, converts the parameters to their Java types and runs the query through
UnconstrainedDataManager.loadValues(io.jmix.core.ValueLoadContext). One extra row is fetched to detect whether more results are available.- Parameters:
request- query to execute together with its parameters and paging hints- Returns:
- result with the fetched rows on success, or with validation/execution failure details
-
toExecutionParameters
protected List<JpqlExecutionParameter> toExecutionParameters(GeneratedJpqlResult generatedJpqlResult) -
resolveDeniedSelectedIndexes
Resolves the positions of the selected columns the current user is not allowed to read.- Parameters:
jpqlQuery- query whose data access is being checked- Returns:
- positions (in select-clause order) of the denied columns, or an empty list if access checking is unavailable or all selected columns are readable
- Throws:
AccessDeniedException- if the current user cannot read the queried entity
-
retainPermittedProperties
protected List<String> retainPermittedProperties(List<String> resultProperties, List<Integer> deniedSelectedIndexes) Returns the result properties that stay readable, dropping the ones at the denied select positions so the inaccessible columns are omitted from the result.- Parameters:
resultProperties- result property names in select-clause orderdeniedSelectedIndexes- positions of the denied columns- Returns:
- the retained property names, in their original order
-
retainProperties
protected List<Map<String,Object>> retainProperties(List<Map<String, Object>> rows, List<String> resultProperties, List<String> retainedProperties) Rebuilds each row keeping only the retained properties, in their original order.- Parameters:
rows- fetched rows keyed by all result propertiesresultProperties- all result property names the rows are keyed byretainedProperties- property names to keep in the output rows- Returns:
- rows containing only the retained properties, or the original rows if nothing is dropped
-
executeQuery
protected JpqlExecutionService.ExecutionRows executeQuery(JpqlExecutionRequest request, GeneratedJpqlResult generatedJpqlResult, Map<String, Object> executionParameters, Integer maxResults, @Nullable Integer firstResult) -
toValueRow
-
getEffectiveMaxResult
-
createExecutionRows
protected JpqlExecutionService.ExecutionRows createExecutionRows(List<Map<String, Object>> rows, boolean hasMore)
-