Class JpqlDeclarationSupport
java.lang.Object
io.jmix.aitools.dataload.execution.JpqlDeclarationSupport
Reads the identification variables a JPQL query declares, subqueries included, for the data-load access checks.
The public query parser names one outer alias per entity and no subquery variable, which is not enough to tell
where an entity occurs, so this reads the parser's own syntax tree.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn identification variable the query declares. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable DomainModelprotected DomainModelBuilderprotected Metadataprotected MetadataTools -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDeclaration(List<JpqlDeclarationSupport.Declaration> declarations, Map<String, String> variableEntities, JpqlDeclarationSupport.Declaration declaration) protected voidcheckDeclarationsReadable(org.antlr.runtime.tree.Tree selectionSource) Fails on a declaration that the syntax tree keeps as bare tokens, such as a subquery'sfrom o.lines lor ajoin fetch.protected voidcollectDeclarations(org.antlr.runtime.tree.Tree node, int queryDepth, List<JpqlDeclarationSupport.Declaration> declarations, Map<String, String> variableEntities) protected DomainModelstatic booleanisLeftJoin(JoinVariableNode join) Tells whether the join is aleft join,outeror not.protected JpqlDeclarationSupport.DeclarationjoinDeclaration(BaseJoinNode joinNode, Map<String, String> variableEntities, boolean nested) protected MetaPropertyjoinedProperty(PathNode pathNode, Map<String, String> variableEntities) protected StringreadDeclarations(String jpql) Reads every identification variable the query declares infrom,joinandin (…), including subqueries.
-
Field Details
-
metadata
-
metadataTools
-
domainModelBuilder
-
domainModel
-
-
Constructor Details
-
JpqlDeclarationSupport
public JpqlDeclarationSupport()
-
-
Method Details
-
isLeftJoin
Tells whether the join is aleft join,outeror not.- Parameters:
join- a join declaring a variable- Returns:
- whether it is a left join
-
readDeclarations
Reads every identification variable the query declares infrom,joinandin (…), including subqueries.- Parameters:
jpql- query text- Returns:
- the declarations in the order they appear
- Throws:
JpqlAccessConstraintException- if a variable name is declared more than once in the query, subqueries includedIllegalStateException- if a declaration cannot be read
-
collectDeclarations
protected void collectDeclarations(org.antlr.runtime.tree.Tree node, int queryDepth, List<JpqlDeclarationSupport.Declaration> declarations, Map<String, String> variableEntities) -
checkDeclarationsReadable
protected void checkDeclarationsReadable(org.antlr.runtime.tree.Tree selectionSource) Fails on a declaration that the syntax tree keeps as bare tokens, such as a subquery'sfrom o.lines lor ajoin fetch. Their variables would otherwise go unseen.- Parameters:
selectionSource- afromitem of the tree- Throws:
IllegalStateException- if the item holds something other than declarations
-
joinDeclaration
protected JpqlDeclarationSupport.Declaration joinDeclaration(BaseJoinNode joinNode, Map<String, String> variableEntities, boolean nested) -
addDeclaration
protected void addDeclaration(List<JpqlDeclarationSupport.Declaration> declarations, Map<String, String> variableEntities, JpqlDeclarationSupport.Declaration declaration) -
joinedProperty
-
getDomainModel
-
lowerCase
-