File

projects/netgrif-components-core/src/lib/pfql/pfql-visitor.ts

Description

Visitor implementation for traversing and processing PFQL (Process Filter Query Language) parse trees. This visitor converts parsed PFQL queries into executable query items that can be used to filter cases and tasks.

The visitor supports:

  • Case queries with various search criteria (title, author, creation date, process, data fields)
  • Task queries with assignee and transition filters
  • Complex boolean expressions with AND, OR operations and parenthesized groups
  • Multiple comparison operators (equality, ranges, null checks, like patterns)
  • Data field queries with type-specific comparisons

Extends

QueryLangVisitor

Index

Properties
Methods

Constructor

Public constructor(_logger: LoggerService, _operatorService: OperatorService, _userResourceService: UserResourceService, _userService: UserService, _categoryFactory: CategoryFactory, _allowedNetsService: AllowedNetsService, ignoreNetsOnAutocompleteCategory: boolean)
Parameters :
Name Type Optional
_logger LoggerService No
_operatorService OperatorService No
_userResourceService UserResourceService No
_userService UserService No
_categoryFactory CategoryFactory No
_allowedNetsService AllowedNetsService No
ignoreNetsOnAutocompleteCategory boolean No

Methods

Protected extractStringValueFromStringComparisonContext
extractStringValueFromStringComparisonContext(ctx: StringComparisonContext)

Extracts the string value from a string comparison context, handling both logged user attributes and literal strings.

Parameters :
Name Type Optional Description
ctx StringComparisonContext No
  • The string comparison parse tree context
Returns : string

The extracted string value, either from logged user attributes or from a quoted string literal

Protected handleBooleanComparisonContext
handleBooleanComparisonContext(ctx: BooleanComparisonContext)

Handles a boolean comparison context and creates a simple expression with the appropriate operator and boolean value.

Parameters :
Name Type Optional Description
ctx BooleanComparisonContext No
  • The boolean comparison parse tree context
Returns : SimpleExpression

A simple expression with the extracted operator, boolean value, and negation flag

Protected handleCaseRawQuery
handleCaseRawQuery(query: string)

Handles a case raw query by wrapping it in a case plain query expression.

This method is used when the query contains complex expressions that cannot be parsed into structured query items (e.g., complex OR expressions with multiple branches or negations). The raw query text is preserved and processed as a plain text query.

Parameters :
Name Type Optional Description
query string No
  • The raw query string to be wrapped
Returns : RawExpression

A raw expression containing the case plain query category and the original query text

Protected handleDateComparisonContext
handleDateComparisonContext(ctx: DateComparisonContext)

Handles a date comparison context and creates a simple expression with the appropriate date operator and date value.

Parameters :
Name Type Optional Description
ctx DateComparisonContext No
  • The date comparison parse tree context
Returns : SimpleExpression

A simple expression with the date operator, extracted date value, and negation flag

Protected handleDateRangeContext
handleDateRangeContext(ctx: DateRangeContext)

Handles a date range context and creates a simple expression with the InRangeDate operator and date range values.

Parameters :
Name Type Optional Description
ctx DateRangeContext No
  • The date range parse tree context
Returns : SimpleExpression

A simple expression with the InRangeDate operator, and array of date values

Protected handleDateTimeComparisonContext
handleDateTimeComparisonContext(ctx: DateTimeComparisonContext)

Handles a datetime comparison context and creates a simple expression with the appropriate datetime operator and datetime value.

Parameters :
Name Type Optional Description
ctx DateTimeComparisonContext No
  • The datetime comparison parse tree context
Returns : SimpleExpression

A simple expression with the datetime operator, extracted datetime value, and negation flag

Protected handleDateTimeRangeContext
handleDateTimeRangeContext(ctx: DateTimeRangeContext)

Handles a datetime range context and creates a simple expression with the InRangeDateTime operator and datetime range values.

Parameters :
Name Type Optional Description
ctx DateTimeRangeContext No
  • The datetime range parse tree context
Returns : SimpleExpression

A simple expression with the InRangeDateTime operator, and array of datetime values

Protected handleInRangeNumberComparisonContext
handleInRangeNumberComparisonContext(ctx: InRangeNumberComparisonContext)

Handles a number range comparison context and creates a simple expression with the InRange operator and numeric range values.

Parameters :
Name Type Optional Description
ctx InRangeNumberComparisonContext No
  • The in-range number comparison parse tree context
Returns : SimpleExpression

A simple expression with the InRange operator, array of numeric values (integer or double range), and negation flag

Protected handleNullComparisonContext
handleNullComparisonContext()

Handles a null comparison context and creates a simple expression with the IsNull operator.

Returns : SimpleExpression

A simple expression with the IsNull operator

Protected handleNumberComparisonContext
handleNumberComparisonContext(ctx: NumberComparisonContext)

Handles a number comparison context and creates a simple expression with the appropriate operator and numeric value.

Parameters :
Name Type Optional Description
ctx NumberComparisonContext No
  • The number comparison parse tree context
Returns : SimpleExpression

A simple expression with the extracted operator, numeric value (integer or double), and negation flag

Protected handleObjectIdComparisonContext
handleObjectIdComparisonContext(ctx: ObjectIdComparisonContext)

Handles an object ID comparison context and creates a simple expression with the appropriate operator and ID value.

Parameters :
Name Type Optional Description
ctx ObjectIdComparisonContext No
  • The object ID comparison parse tree context
Returns : SimpleExpression

A simple expression with the extracted operator, object ID value (either logged user ID or string literal), and negation flag

Protected handleStringComparisonContext
handleStringComparisonContext(ctx: StringComparisonContext)

Handles a string comparison context and creates a simple expression with the appropriate operator and value.

Parameters :
Name Type Optional Description
ctx StringComparisonContext No
  • The string comparison parse tree context
Returns : SimpleExpression

A simple expression with the extracted operator, string value, and negation flag

Protected handleStringLikeComparisonContext
handleStringLikeComparisonContext(ctx: StringLikeComparisonContext)

Handles a string LIKE comparison context and creates a simple expression with the LIKE operator.

Parameters :
Name Type Optional Description
ctx StringLikeComparisonContext No
  • The string LIKE comparison parse tree context
Returns : SimpleExpression

A simple expression with the LIKE operator, extracted string value, and negation flag

Protected handleTaskRawQuery
handleTaskRawQuery(query: string)

Handles a task raw query by wrapping it in a task plain query expression.

This method is used when the query contains complex expressions that cannot be parsed into structured query items (e.g., complex OR expressions with multiple branches or negations). The raw query text is preserved and processed as a plain text query.

Parameters :
Name Type Optional Description
query string No
  • The raw query string to be wrapped
Returns : RawExpression

A raw expression containing the task plain query category and the original query text

Protected removeSingleQuotesFromString
removeSingleQuotesFromString(value: string)

Removes single quotes from the beginning and end of a string if they are present.

Parameters :
Name Type Optional Description
value string No
  • The string value that may be enclosed in single quotes
Returns : string

The string with single quotes removed, or the original string if not enclosed in quotes

Properties

Protected _categoryOptionalDependencies
Type : OptionalDependencies
visitAuthorBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic author comparison and creates a case author search expression.

Parameters :
Name Description
ctx
  • The author basic parse tree context
visitCaseAndExpression
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a case AND expression and combines multiple condition groups with AND logical operators.

Parameters :
Name Description
ctx
  • The case AND expression parse tree context
visitCaseConditionGroupParenthesis
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a parenthesized case condition group and wraps the inner conditions in a complex expression.

Parameters :
Name Description
ctx
  • The case condition group parenthesis parse tree context
visitCaseConditionsAndPaging
Default value : () => {...}
Inherited from QueryLangVisitor

Visits the case conditions and paging context and extracts the case conditions.

Parameters :
Name Description
ctx
  • The case conditions and paging parse tree context
visitCaseOrExpression
Default value : () => {...}
Inherited from QueryLangVisitor

/** Visits a case OR expression and processes multiple AND expressions joined by OR operators.

When multiple AND expressions are connected with OR operators, the entire expression is treated as a raw query string and wrapped in a case plain query, since complex OR logic requires special handling beyond simple query composition.

Example :
     or a single raw expression wrapping the entire query text if multiple OR-connected expressions exist
Parameters :
Name Description
ctx
  • The case OR expression parse tree context
visitCaseQuery
Default value : () => {...}
Inherited from QueryLangVisitor

Visits the root case query context and extracts query items from case conditions.

Parameters :
Name Description
ctx
  • The case query parse tree context
visitCdDateBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic creation date comparison and creates a case creation date search expression.

Parameters :
Name Description
ctx
  • The creation date basic parse tree context
visitCdDateRange
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a creation date range comparison and creates either a date or datetime range search expression.

Parameters :
Name Description
ctx
  • The creation date range parse tree context
visitCdDateTimeBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic creation datetime comparison and creates a case creation datetime search expression.

Parameters :
Name Description
ctx
  • The creation datetime basic parse tree context
visitDataBoolean
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data boolean comparison and creates a data field search expression for boolean values.

Parameters :
Name Description
ctx
  • The data boolean parse tree context
visitDataDate
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data date comparison and creates a data field search expression for date values.

Parameters :
Name Description
ctx
  • The data date parse tree context
visitDataDateRange
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data date range comparison and creates a data field search expression for date or datetime range values.

Parameters :
Name Description
ctx
  • The data date range parse tree context
visitDataDatetime
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data datetime comparison and creates a data field search expression for datetime values.

Parameters :
Name Description
ctx
  • The data datetime parse tree context
visitDataNull
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data null comparison and creates a data field search expression for null checks.

Parameters :
Name Description
ctx
  • The data null parse tree context
visitDataNumber
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data number comparison and creates a data field search expression for numeric values.

Parameters :
Name Description
ctx
  • The data number parse tree context
visitDataNumberRange
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data number range comparison and creates a data field search expression for numeric range values.

Parameters :
Name Description
ctx
  • The data number range parse tree context
visitDataString
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data string comparison and creates a data field search expression for string values.

Parameters :
Name Description
ctx
  • The data string parse tree context
visitDataStringLike
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a data string LIKE comparison and creates a data field search expression with pattern matching for string values.

Parameters :
Name Description
ctx
  • The data string LIKE parse tree context
visitIdBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic ID comparison and creates a case string ID search expression.

Parameters :
Name Description
ctx
  • The ID basic parse tree context
visitProcessIdBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic process ID comparison for tasks and creates a task process search expression.

Parameters :
Name Description
ctx
  • The process ID basic parse tree context
visitProcessIdentifierBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic process identifier comparison and creates a case process search expression.

Parameters :
Name Description
ctx
  • The process identifier basic parse tree context
visitTaskAndExpression
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a task AND expression and combines multiple condition groups with AND logical operators.

Parameters :
Name Description
ctx
  • The task AND expression parse tree context
visitTaskConditionGroupParenthesis
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a parenthesized task condition group and wraps the inner conditions in a complex expression. Supports negation with the NOT keyword.

Parameters :
Name Description
ctx
  • The task condition group parenthesis parse tree context
visitTaskConditionsAndPaging
Default value : () => {...}
Inherited from QueryLangVisitor

Visits the task conditions and paging context and extracts the task conditions.

Parameters :
Name Description
ctx
  • The task conditions and paging parse tree context
visitTaskOrExpression
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a task OR expression and processes multiple AND expressions joined by OR operators.

When multiple AND expressions are connected with OR operators, the entire expression is treated as a raw query string and wrapped in a task plain query, since complex OR logic requires special handling beyond simple query composition.

Example :
     or a single raw expression wrapping the entire query text if multiple OR-connected expressions exist
Parameters :
Name Description
ctx
  • The task OR expression parse tree context
visitTaskQuery
Default value : () => {...}
Inherited from QueryLangVisitor

Visits the root task query context and extracts query items from task conditions.

Parameters :
Name Description
ctx
  • The task query parse tree context
visitTitleBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic title comparison and creates a case title search expression.

Parameters :
Name Description
ctx
  • The title basic parse tree context
visitTitleLike
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a LIKE title comparison and creates a case title search expression with pattern matching.

Parameters :
Name Description
ctx
  • The title LIKE parse tree context
visitTransitionIdBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic transition ID comparison and creates a task task search expression.

Parameters :
Name Description
ctx
  • The transition ID basic parse tree context
visitUserIdBasic
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a basic user ID comparison and creates a task assignee search expression.

Parameters :
Name Description
ctx
  • The user ID basic parse tree context
visitUserIdNull
Default value : () => {...}
Inherited from QueryLangVisitor

Visits a user ID null comparison and creates a task assignee search expression for null checks.

Parameters :
Name Description
ctx
  • The user ID null parse tree context
Optional visitAuthorList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the authorList labeled alternative in QueryLangParser.authorComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitAuthorNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the authorNull labeled alternative in QueryLangParser.authorComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitBooleanComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.booleanComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseAttribute
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseAttribute.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseAttributeOrdering
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseAttributeOrdering.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseComparisons
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseComparisons.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseCondition
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseCondition.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseConditionGroupBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the caseConditionGroupBasic labeled alternative in QueryLangParser.caseConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseConditions
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseConditions.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseIdBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the caseIdBasic labeled alternative in QueryLangParser.caseIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the caseIdList labeled alternative in QueryLangParser.caseIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseIdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the caseIdNull labeled alternative in QueryLangParser.caseIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitCaseSorting
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.caseSorting.

Parameters :
Name Description
ctx

the parse tree

Optional visitCdDateList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the cdDateList labeled alternative in QueryLangParser.creationDateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitCdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the cdNull labeled alternative in QueryLangParser.creationDateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataDateList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataDateList labeled alternative in QueryLangParser.dataValueComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataNumberList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataNumberList labeled alternative in QueryLangParser.dataValueComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataOptions
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dataOptions.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataOptionsBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataOptionsBasic labeled alternative in QueryLangParser.dataOptionsComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataOptionsList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataOptionsList labeled alternative in QueryLangParser.dataOptionsComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataOptionsNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataOptionsNull labeled alternative in QueryLangParser.dataOptionsComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataOptionsRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataOptionsRange labeled alternative in QueryLangParser.dataOptionsComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataStringList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataStringList labeled alternative in QueryLangParser.dataValueComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataStringRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the dataStringRange labeled alternative in QueryLangParser.dataValueComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDataValue
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dataValue.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateList.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateTimeComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateTimeComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateTimeList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateTimeList.

Parameters :
Name Description
ctx

the parse tree

Optional visitDateTimeRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.dateTimeRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitDelimeter
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.delimeter.

Parameters :
Name Description
ctx

the parse tree

Optional visitDoubleList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.doubleList.

Parameters :
Name Description
ctx

the parse tree

Optional visitDoubleRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.doubleRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitEmailBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the emailBasic labeled alternative in QueryLangParser.emailComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitEmailList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the emailList labeled alternative in QueryLangParser.emailComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitEmailNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the emailNull labeled alternative in QueryLangParser.emailComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitEmailRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the emailRange labeled alternative in QueryLangParser.emailComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdentifierBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the identifierBasic labeled alternative in QueryLangParser.identifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdentifierList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the identifierList labeled alternative in QueryLangParser.identifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdentifierNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the identifierNull labeled alternative in QueryLangParser.identifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdentifierRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the identifierRange labeled alternative in QueryLangParser.identifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the idList labeled alternative in QueryLangParser.idComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the idNull labeled alternative in QueryLangParser.idComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInListDateComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inListDateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInListNumberComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inListNumberComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInListStringComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inListStringComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInListVersionComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inListVersionComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInRangeDateComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inRangeDateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInRangeNumberComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inRangeNumberComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInRangeStringComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inRangeStringComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitInRangeVersionComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.inRangeVersionComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitIntList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.intList.

Parameters :
Name Description
ctx

the parse tree

Optional visitIntRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.intRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitJavaId
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.javaId.

Parameters :
Name Description
ctx

the parse tree

Optional visitLaDateBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the laDateBasic labeled alternative in QueryLangParser.lastAssignComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLaDateList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the laDateList labeled alternative in QueryLangParser.lastAssignComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLaDateRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the laDateRange labeled alternative in QueryLangParser.lastAssignComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLaDateTimeBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the laDateTimeBasic labeled alternative in QueryLangParser.lastAssignComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLaNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the laNull labeled alternative in QueryLangParser.lastAssignComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLfDateBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the lfDateBasic labeled alternative in QueryLangParser.lastFinishComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLfDateList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the lfDateList labeled alternative in QueryLangParser.lastFinishComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLfDateRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the lfDateRange labeled alternative in QueryLangParser.lastFinishComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLfDateTimeBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the lfDateTimeBasic labeled alternative in QueryLangParser.lastFinishComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLfNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the lfNull labeled alternative in QueryLangParser.lastFinishComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitLoggedUserStringAttribute
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.loggedUserStringAttribute.

Parameters :
Name Description
ctx

the parse tree

Optional visitNameBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the nameBasic labeled alternative in QueryLangParser.nameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitNameList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the nameList labeled alternative in QueryLangParser.nameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitNameNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the nameNull labeled alternative in QueryLangParser.nameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitNameRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the nameRange labeled alternative in QueryLangParser.nameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitNullComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.nullComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitNumberComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.numberComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitObjectIdComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.objectIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitPaging
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.paging.

Parameters :
Name Description
ctx

the parse tree

Optional visitPlaces
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.places.

Parameters :
Name Description
ctx

the parse tree

Optional visitPlacesBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the placesBasic labeled alternative in QueryLangParser.placesComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitPlacesList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the placesList labeled alternative in QueryLangParser.placesComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitPlacesNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the placesNull labeled alternative in QueryLangParser.placesComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitPlacesRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the placesRange labeled alternative in QueryLangParser.placesComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessAndExpression
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processAndExpression.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessAttribute
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processAttribute.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessAttributeOrdering
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processAttributeOrdering.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessComparisons
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processComparisons.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessCondition
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processCondition.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessConditionGroupBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processConditionGroupBasic labeled alternative in QueryLangParser.processConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessConditionGroupParenthesis
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processConditionGroupParenthesis labeled alternative in QueryLangParser.processConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessConditions
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processConditions.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessConditionsAndPaging
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processConditionsAndPaging.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdentifierList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdentifierList labeled alternative in QueryLangParser.processIdentifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdentifierNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdentifierNull labeled alternative in QueryLangParser.processIdentifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdentifierRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdentifierRange labeled alternative in QueryLangParser.processIdentifierComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdList labeled alternative in QueryLangParser.processIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdNull labeled alternative in QueryLangParser.processIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdObjIdBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdObjIdBasic labeled alternative in QueryLangParser.processIdObjIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdObjIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdObjIdList labeled alternative in QueryLangParser.processIdObjIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessIdObjNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processIdObjNull labeled alternative in QueryLangParser.processIdObjIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessOrExpression
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processOrExpression.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessQuery
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the processQuery labeled alternative in QueryLangParser.query.

Parameters :
Name Description
ctx

the parse tree

Optional visitProcessSorting
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.processSorting.

Parameters :
Name Description
ctx

the parse tree

Optional visitStateComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.stateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitStringComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.stringComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitStringLikeComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.stringLikeComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitStringList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.stringList.

Parameters :
Name Description
ctx

the parse tree

Optional visitStringRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.stringRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitSurnameBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the surnameBasic labeled alternative in QueryLangParser.surnameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitSurnameList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the surnameList labeled alternative in QueryLangParser.surnameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitSurnameNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the surnameNull labeled alternative in QueryLangParser.surnameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitSurnameRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the surnameRange labeled alternative in QueryLangParser.surnameComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskAttribute
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskAttribute.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskAttributeOrdering
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskAttributeOrdering.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskComparisons
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskComparisons.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskCondition
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskCondition.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskConditionGroupBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the taskConditionGroupBasic labeled alternative in QueryLangParser.taskConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskConditions
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskConditions.

Parameters :
Name Description
ctx

the parse tree

Optional visitTaskSorting
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.taskSorting.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksState
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.tasksState.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksStateComparison
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.tasksStateComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksUserId
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.tasksUserId.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksUserIdBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the tasksUserIdBasic labeled alternative in QueryLangParser.tasksUserIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksUserIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the tasksUserIdList labeled alternative in QueryLangParser.tasksUserIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTasksUserIdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the tasksUserIdNull labeled alternative in QueryLangParser.tasksUserIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTitleList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the titleList labeled alternative in QueryLangParser.titleComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTitleNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the titleNull labeled alternative in QueryLangParser.titleComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTitleRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the titleRange labeled alternative in QueryLangParser.titleComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTransitionIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the transitionIdList labeled alternative in QueryLangParser.transitionIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTransitionIdNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the transitionIdNull labeled alternative in QueryLangParser.transitionIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitTransitionIdRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the transitionIdRange labeled alternative in QueryLangParser.transitionIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserAndExpression
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userAndExpression.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserAttribute
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userAttribute.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserAttributeOrdering
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userAttributeOrdering.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserComparisons
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userComparisons.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserCondition
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userCondition.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserConditionGroupBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the userConditionGroupBasic labeled alternative in QueryLangParser.userConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserConditionGroupParenthesis
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the userConditionGroupParenthesis labeled alternative in QueryLangParser.userConditionGroup.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserConditions
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userConditions.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserConditionsAndPaging
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userConditionsAndPaging.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserIdList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the userIdList labeled alternative in QueryLangParser.userIdComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserOrExpression
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userOrExpression.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserQuery
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the userQuery labeled alternative in QueryLangParser.query.

Parameters :
Name Description
ctx

the parse tree

Optional visitUserSorting
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.userSorting.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionBasic
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the versionBasic labeled alternative in QueryLangParser.versionComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionList
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.versionList.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionListCmp
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the versionListCmp labeled alternative in QueryLangParser.versionComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionNull
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the versionNull labeled alternative in QueryLangParser.versionComparison.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionRange
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by QueryLangParser.versionRange.

Parameters :
Name Description
ctx

the parse tree

Optional visitVersionRangeCmp
Type : function
Inherited from QueryLangVisitor

Visit a parse tree produced by the versionRangeCmp labeled alternative in QueryLangParser.versionComparison.

Parameters :
Name Description
ctx

the parse tree

import {QueryLangVisitor} from "./generated/QueryLangVisitor";
import {
    AuthorBasicContext,
    BooleanComparisonContext,
    CaseAndExpressionContext,
    CaseComparisonsContext,
    CaseConditionGroupParenthesisContext,
    CaseConditionsAndPagingContext,
    CaseOrExpressionContext,
    CaseQueryContext,
    CdDateBasicContext,
    CdDateRangeContext,
    CdDateTimeBasicContext,
    DataBooleanContext,
    DataDateContext,
    DataDateRangeContext,
    DataDatetimeContext,
    DataNullContext,
    DataNumberContext,
    DataNumberRangeContext,
    DataStringContext,
    DataStringLikeContext,
    DateComparisonContext,
    DateRangeContext,
    DateTimeComparisonContext,
    DateTimeRangeContext,
    IdBasicContext,
    InRangeNumberComparisonContext,
    NumberComparisonContext,
    ObjectIdComparisonContext,
    ProcessIdBasicContext,
    ProcessIdentifierBasicContext,
    StringComparisonContext,
    StringLikeComparisonContext,
    TaskAndExpressionContext,
    TaskConditionGroupParenthesisContext,
    TaskConditionsAndPagingContext,
    TaskOrExpressionContext,
    TaskQueryContext,
    TitleBasicContext,
    TitleLikeContext,
    TransitionIdBasicContext,
    UserIdBasicContext,
    UserIdNullContext,
} from "./generated/QueryLangParser";
import {LoggerService} from "../logger/services/logger.service";
import {CaseTitle} from "../search/models/category/case/case-title";
import {Injectable, Inject, Optional} from "@angular/core";
import {OperatorService} from "../search/operator-service/operator.service";
import {QueryItem} from "./model/query-item-type";
import {LogicalOperator} from "./model/logical-operator";
import {ComplexExpression} from "./model/complex-expression";
import {SimpleExpression} from "./model/simple-expression";
import {getDateOperatorFromToken, getDateTimeOperatorFromToken, getOperatorFromToken} from "./pfql-utils";
import {Like} from "../search/models/operator/like";
import {Operator} from "../search/models/operator/operator";
import {BooleanOperator} from "../search/models/boolean-operator";
import {CaseStringId} from "../search/models/category/case/case-string-id";
import {CaseAuthor} from "../search/models/category/case/case-author";
import {UserResourceService} from "../resources/engine-endpoint/user-resource.service";
import {CaseCreationDate} from "../search/models/category/case/case-creation-date";
import {CaseCreationDateTime} from "../search/models/category/case/case-creation-date-time";
import {InRangeDate} from "../search/models/operator/in-range-date";
import {InRangeDateTime} from "../search/models/operator/in-range-date-time";
import {CaseDataset} from "../search/models/category/case/case-dataset";
import {CategoryFactory} from "../search/category-factory/category-factory";
import {AllowedNetsService} from "../allowed-nets/services/allowed-nets.service";
import {OptionalDependencies} from "../search/category-factory/optional-dependencies";
import {CaseProcess} from "../search/models/category/case/case-process";
import {DataSimpleExpression} from "./model/data-simple-expression";
import {InRange} from "../search/models/operator/in-range";
import {IsNull} from "../search/models/operator/is-null";
import {TaskTask} from "../search/models/category/task/task-task";
import {TaskAssignee} from "../search/models/category/task/task-assignee";
import {TaskProcess} from "../search/models/category/task/task-process";
import {UserService} from "../user/services/user.service";
import {CasePlainQuery} from "../search/models/category/case/case-plain-query";
import {RawExpression} from "./model/raw-expression";
import {TaskPlainQuery} from "../search/models/category/task/task-plain-query";
import {NAE_IGNORE_NETS_ON_AUTOCOMPLETE_CATEGORY} from "../search/category-factory/search-categories-injection-token";


/**
 * Visitor implementation for traversing and processing PFQL (Process Filter Query Language) parse trees.
 * This visitor converts parsed PFQL queries into executable query items that can be used to filter cases and tasks.
 *
 * The visitor supports:
 * - Case queries with various search criteria (title, author, creation date, process, data fields)
 * - Task queries with assignee and transition filters
 * - Complex boolean expressions with AND, OR operations and parenthesized groups
 * - Multiple comparison operators (equality, ranges, null checks, like patterns)
 * - Data field queries with type-specific comparisons
 */
@Injectable()
export class PfqlVisitor extends QueryLangVisitor<Array<QueryItem>> {

    protected _categoryOptionalDependencies: OptionalDependencies;

    public constructor(protected _logger: LoggerService,
                       protected _operatorService: OperatorService,
                       protected _userResourceService: UserResourceService,
                       protected _userService: UserService,
                       protected _categoryFactory: CategoryFactory,
                       protected _allowedNetsService: AllowedNetsService,
                       @Optional() @Inject(NAE_IGNORE_NETS_ON_AUTOCOMPLETE_CATEGORY) ignoreNetsOnAutocompleteCategory: boolean) {
        super();
        this._categoryOptionalDependencies = {
            categoryFactory: this._categoryFactory,
            searchIndexResolver: undefined,
            allowedNetsService: this._allowedNetsService,
            userResourceService: this._userResourceService,
            ignoreNetsOnAutocompleteCategories: ignoreNetsOnAutocompleteCategory,
        };
    }

    /**
     * Visits the root case query context and extracts query items from case conditions.
     *
     * @param ctx - The case query parse tree context
     * @returns An array of query items representing the case search criteria, or an empty array if no conditions are present
     */
    override visitCaseQuery = (ctx: CaseQueryContext): Array<QueryItem> => {
        const conditionsAndPaging = ctx.caseConditionsAndPaging();
        if (!conditionsAndPaging) {
            return [];
        }
        return this.visit(conditionsAndPaging);
    };

    /**
     * Visits the case conditions and paging context and extracts the case conditions.
     *
     * @param ctx - The case conditions and paging parse tree context
     * @returns An array of query items representing the case conditions, or an empty array if no conditions are present
     */
    override visitCaseConditionsAndPaging = (ctx: CaseConditionsAndPagingContext): Array<QueryItem> => {
        const conditions = ctx.caseConditions();
        if (!conditions) {
            return [];
        }
        return this.visit(conditions);
    };

    /**
     * Visits the root task query context and extracts query items from task conditions.
     *
     * @param ctx - The task query parse tree context
     * @returns An array of query items representing the task search criteria, or an empty array if no conditions are present
     */
    override visitTaskQuery = (ctx: TaskQueryContext): Array<QueryItem> => {
        const conditionsAndPaging = ctx.taskConditionsAndPaging();
        if (!conditionsAndPaging) {
            return [];
        }
        return this.visit(conditionsAndPaging);
    };

    /**
     * Visits the task conditions and paging context and extracts the task conditions.
     *
     * @param ctx - The task conditions and paging parse tree context
     * @returns An array of query items representing the task conditions, or an empty array if no conditions are present
     */
    override visitTaskConditionsAndPaging = (ctx: TaskConditionsAndPagingContext): Array<QueryItem> => {
        const conditions = ctx.taskConditions();
        if (!conditions) {
            return [];
        }
        return this.visit(conditions);
    };

    /**
     /**
     * Visits a case OR expression and processes multiple AND expressions joined by OR operators.
     *
     * When multiple AND expressions are connected with OR operators, the entire expression is treated
     * as a raw query string and wrapped in a case plain query, since complex OR logic requires
     * special handling beyond simple query composition.
     *
     * @param ctx - The case OR expression parse tree context
     * @returns An array containing either the visited AND expression items if there's only one,
     *          or a single raw expression wrapping the entire query text if multiple OR-connected expressions exist
     */
    override visitCaseOrExpression = (ctx: CaseOrExpressionContext): Array<QueryItem> => {
        const andExpressionContexts = ctx.caseAndExpression();
        return andExpressionContexts.length === 1 ? [...this.visit(andExpressionContexts[0])] : [this.handleCaseRawQuery(ctx.getText())]
    };

    /**
     * Visits a case AND expression and combines multiple condition groups with AND logical operators.
     *
     * @param ctx - The case AND expression parse tree context
     * @returns An array of query items with condition groups joined by AND operators
     */
    override visitCaseAndExpression = (ctx: CaseAndExpressionContext): Array<QueryItem> => {
        const conditionGroupContexts = ctx.caseConditionGroup();
        const items: Array<QueryItem> = [...this.visit(conditionGroupContexts[0])];
        for (let i = 1; i < conditionGroupContexts.length; i++) {
            items.push(new LogicalOperator(BooleanOperator.AND));
            items.push(...this.visit(conditionGroupContexts[i]));
        }
        return items;
    };

    /**
     * Visits a parenthesized case condition group and wraps the inner conditions in a complex expression.
     *
     * @param ctx - The case condition group parenthesis parse tree context
     * @returns An array containing a single complex expression with the inner conditions
     */
    override visitCaseConditionGroupParenthesis = (ctx: CaseConditionGroupParenthesisContext): Array<QueryItem> => {
        const innerItems: Array<QueryItem> = [...this.visit(ctx.caseConditions())];
        if (!!ctx.NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        return [new ComplexExpression(innerItems)];
    };

    /**
     * Visits a task OR expression and processes multiple AND expressions joined by OR operators.
     *
     * When multiple AND expressions are connected with OR operators, the entire expression is treated
     * as a raw query string and wrapped in a task plain query, since complex OR logic requires
     * special handling beyond simple query composition.
     *
     * @param ctx - The task OR expression parse tree context
     * @returns An array containing either the visited AND expression items if there's only one,
     *          or a single raw expression wrapping the entire query text if multiple OR-connected expressions exist
     */
    override visitTaskOrExpression = (ctx: TaskOrExpressionContext): Array<QueryItem> => {
        const andExpressionContexts = ctx.taskAndExpression();
        return andExpressionContexts.length === 1 ? [...this.visit(andExpressionContexts[0])] : [this.handleTaskRawQuery(ctx.getText())]
    };

    /**
     * Visits a task AND expression and combines multiple condition groups with AND logical operators.
     *
     * @param ctx - The task AND expression parse tree context
     * @returns An array of query items with condition groups joined by AND operators
     */
    override visitTaskAndExpression = (ctx: TaskAndExpressionContext): Array<QueryItem> => {
        const conditionGroupContexts = ctx.taskConditionGroup();
        const items: Array<QueryItem> = [...this.visit(conditionGroupContexts[0])];
        for (let i = 1; i < conditionGroupContexts.length; i++) {
            items.push(new LogicalOperator(BooleanOperator.AND));
            items.push(...this.visit(conditionGroupContexts[i]));
        }
        return items;
    };

    /**
     * Visits a parenthesized task condition group and wraps the inner conditions in a complex expression.
     * Supports negation with the NOT keyword.
     *
     * @param ctx - The task condition group parenthesis parse tree context
     * @returns An array containing a single complex expression with the inner conditions and negation flag
     */
    override visitTaskConditionGroupParenthesis = (ctx: TaskConditionGroupParenthesisContext): Array<QueryItem> => {
        const innerItems: Array<QueryItem> = [...this.visit(ctx.taskConditions())];
        if (!!ctx.NOT()) {
            return [this.handleTaskRawQuery(ctx.getText())];
        }
        return [new ComplexExpression(innerItems)];
    };

    /**
     * Visits a basic title comparison and creates a case title search expression.
     *
     * @param ctx - The title basic parse tree context
     * @returns An array containing a single simple expression with case title category, or an empty array if no case comparison context exists
     */
    override visitTitleBasic = (ctx: TitleBasicContext): Array<QueryItem> => {
        if (ctx.parent instanceof CaseComparisonsContext) {
            if (!!ctx.stringComparison().NOT()) {
                return [this.handleCaseRawQuery(ctx.getText())];
            }
            const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
            expr.category = new CaseTitle(this._operatorService, this._logger);
            return [expr];
        } else {
            this._logger.warn("There is no dedicated category when visiting title while parsing PFQL query");
            return []
        }
    };

    /**
     * Visits a LIKE title comparison and creates a case title search expression with pattern matching.
     *
     * @param ctx - The title LIKE parse tree context
     * @returns An array containing a single simple expression with case title category and LIKE operator, or an empty array if no case comparison context exists
     */
    override visitTitleLike = (ctx: TitleLikeContext): Array<QueryItem> => {
        if (ctx.parent instanceof CaseComparisonsContext) {
            if (!!ctx.stringLikeComparison().stringComparison().NOT()) {
                return [this.handleCaseRawQuery(ctx.getText())];
            }
            const expr: SimpleExpression = this.handleStringLikeComparisonContext(ctx.stringLikeComparison());
            expr.category = new CaseTitle(this._operatorService, this._logger);
            return [expr];
        } else {
            this._logger.warn("There is no dedicated category when visiting title while parsing PFQL query");
            return [];
        }
    };

    /**
     * Visits a basic ID comparison and creates a case string ID search expression.
     *
     * @param ctx - The ID basic parse tree context
     * @returns An array containing a single simple expression with case string ID category, or an empty array if no case comparison context exists
     */
    override visitIdBasic = (ctx: IdBasicContext): Array<QueryItem> => {
        if (ctx.parent instanceof CaseComparisonsContext) {
            if (!!ctx.objectIdComparison().NOT()) {
                return [this.handleCaseRawQuery(ctx.getText())];
            }
            const expr: SimpleExpression = this.handleObjectIdComparisonContext(ctx.objectIdComparison());
            expr.category = new CaseStringId(this._operatorService, this._logger);
            return [expr];
        } else {
            this._logger.warn("There is no dedicated category when visiting title while parsing PFQL query");
            return [];
        }
    };

    /**
     * Visits a basic author comparison and creates a case author search expression.
     *
     * @param ctx - The author basic parse tree context
     * @returns An array containing a single simple expression with case author category
     */
    override visitAuthorBasic = (ctx: AuthorBasicContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        expr.category = new CaseAuthor(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    };

    /**
     * Visits a basic creation date comparison and creates a case creation date search expression.
     *
     * @param ctx - The creation date basic parse tree context
     * @returns An array containing a single simple expression with case creation date category
     */
    override visitCdDateBasic = (ctx: CdDateBasicContext): Array<QueryItem> => {
        if (!!ctx.dateComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleDateComparisonContext(ctx.dateComparison());
        expr.category = new CaseCreationDate(this._operatorService, this._logger);
        return [expr];
    };

    /**
     * Visits a basic creation datetime comparison and creates a case creation datetime search expression.
     *
     * @param ctx - The creation datetime basic parse tree context
     * @returns An array containing a single simple expression with case creation datetime category
     */
    override visitCdDateTimeBasic = (ctx: CdDateTimeBasicContext): Array<QueryItem> => {
        if (!!ctx.dateTimeComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleDateTimeComparisonContext(ctx.dateTimeComparison());
        expr.category = new CaseCreationDateTime(this._operatorService, this._logger);
        return [expr];
    };

    /**
     * Visits a creation date range comparison and creates either a date or datetime range search expression.
     *
     * @param ctx - The creation date range parse tree context
     * @returns An array containing a single simple expression with either case creation date or datetime category, or an empty array if no range values are provided
     */
    override visitCdDateRange = (ctx: CdDateRangeContext): Array<QueryItem> => {
        const inRangeCtx = ctx.inRangeDateComparison();
        if (!!inRangeCtx.NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        if (!!inRangeCtx.dateRange()) {
            const expr: SimpleExpression = this.handleDateRangeContext(inRangeCtx.dateRange());
            expr.category = new CaseCreationDate(this._operatorService, this._logger);
            return [expr];
        } else if (!!inRangeCtx.dateTimeRange()) {
            const expr: SimpleExpression = this.handleDateTimeRangeContext(inRangeCtx.dateTimeRange());
            expr.category = new CaseCreationDateTime(this._operatorService, this._logger);
            return [expr];
        } else {
            this._logger.error("No range values provided for creationDate range comparison");
            return [];
        }
    };

    /**
     * Visits a data string comparison and creates a data field search expression for string values.
     *
     * @param ctx - The data string parse tree context
     * @returns An array containing a single data simple expression with case dataset category
     */
    override visitDataString = (ctx: DataStringContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data string LIKE comparison and creates a data field search expression with pattern matching for string values.
     *
     * @param ctx - The data string LIKE parse tree context
     * @returns An array containing a single data simple expression with case dataset category and LIKE operator
     */
    override visitDataStringLike = (ctx: DataStringLikeContext): Array<QueryItem> => {
        if (!!ctx.stringLikeComparison().stringComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleStringLikeComparisonContext(ctx.stringLikeComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data number comparison and creates a data field search expression for numeric values.
     *
     * @param ctx - The data number parse tree context
     * @returns An array containing a single data simple expression with case dataset category
     */
    override visitDataNumber = (ctx: DataNumberContext): Array<QueryItem> => {
        if (!!ctx.numberComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleNumberComparisonContext(ctx.numberComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data number range comparison and creates a data field search expression for numeric range values.
     *
     * @param ctx - The data number range parse tree context
     * @returns An array containing a single data simple expression with case dataset category and range operator
     */
    override visitDataNumberRange = (ctx: DataNumberRangeContext): Array<QueryItem> => {
        if (!!ctx.inRangeNumberComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleInRangeNumberComparisonContext(ctx.inRangeNumberComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data date comparison and creates a data field search expression for date values.
     *
     * @param ctx - The data date parse tree context
     * @returns An array containing a single data simple expression with case dataset category
     */
    override visitDataDate = (ctx: DataDateContext): Array<QueryItem> => {
        if (!!ctx.dateComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleDateComparisonContext(ctx.dateComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data date range comparison and creates a data field search expression for date or datetime range values.
     *
     * @param ctx - The data date range parse tree context
     * @returns An array containing a single data simple expression with case dataset category and range operator, or an empty array if no range values are provided
     */
    override visitDataDateRange = (ctx: DataDateRangeContext): Array<QueryItem> => {
        const inRangeCtx = ctx.inRangeDateComparison();
        if (!!inRangeCtx.NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        let simpleExpr: SimpleExpression;
        if (!!inRangeCtx.dateRange()) {
            simpleExpr = this.handleDateRangeContext(inRangeCtx.dateRange());
        } else if (!!inRangeCtx.dateTimeRange()) {
            simpleExpr = this.handleDateTimeRangeContext(inRangeCtx.dateTimeRange());
        } else {
            this._logger.error("No range values provided for creationDate range comparison");
            return [];
        }

        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data datetime comparison and creates a data field search expression for datetime values.
     *
     * @param ctx - The data datetime parse tree context
     * @returns An array containing a single data simple expression with case dataset category
     */
    override visitDataDatetime = (ctx: DataDatetimeContext): Array<QueryItem> => {
        if (!!ctx.dateTimeComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleDateTimeComparisonContext(ctx.dateTimeComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data boolean comparison and creates a data field search expression for boolean values.
     *
     * @param ctx - The data boolean parse tree context
     * @returns An array containing a single data simple expression with case dataset category
     */
    override visitDataBoolean = (ctx: DataBooleanContext): Array<QueryItem> => {
        if (!!ctx.booleanComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleBooleanComparisonContext(ctx.booleanComparison());
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a data null comparison and creates a data field search expression for null checks.
     *
     * @param ctx - The data null parse tree context
     * @returns An array containing a single data simple expression with case dataset category and null operator
     */
    override visitDataNull = (ctx: DataNullContext): Array<QueryItem> => {
        if (!!ctx.nullComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const simpleExpr: SimpleExpression = this.handleNullComparisonContext();
        const dataExpr: DataSimpleExpression = new DataSimpleExpression(ctx.dataValue().getText(), simpleExpr.operator,
            simpleExpr.operandValue);
        dataExpr.category = new CaseDataset(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [dataExpr];
    };

    /**
     * Visits a basic process identifier comparison and creates a case process search expression.
     *
     * @param ctx - The process identifier basic parse tree context
     * @returns An array containing a single simple expression with case process category
     */
    override visitProcessIdentifierBasic = (ctx: ProcessIdentifierBasicContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleCaseRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        expr.category = new CaseProcess(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    };

    /**
     * Visits a basic transition ID comparison and creates a task task search expression.
     *
     * @param ctx - The transition ID basic parse tree context
     * @returns An array containing a single simple expression with task task category
     */
    override visitTransitionIdBasic = (ctx: TransitionIdBasicContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleTaskRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        expr.category = new TaskTask(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    }

    /**
     * Visits a basic user ID comparison and creates a task assignee search expression.
     *
     * @param ctx - The user ID basic parse tree context
     * @returns An array containing a single simple expression with task assignee category
     */
    override visitUserIdBasic = (ctx: UserIdBasicContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleTaskRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        expr.category = new TaskAssignee(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    };

    /**
     * Visits a user ID null comparison and creates a task assignee search expression for null checks.
     *
     * @param ctx - The user ID null parse tree context
     * @returns An array containing a single simple expression with task assignee category and null operator
     */
    override visitUserIdNull = (ctx: UserIdNullContext): Array<QueryItem> => {
        if (!!ctx.nullComparison().NOT()) {
            return [this.handleTaskRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleNullComparisonContext();
        expr.category = new TaskAssignee(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    };

    /**
     * Visits a basic process ID comparison for tasks and creates a task process search expression.
     *
     * @param ctx - The process ID basic parse tree context
     * @returns An array containing a single simple expression with task process category
     */
    override visitProcessIdBasic = (ctx: ProcessIdBasicContext): Array<QueryItem> => {
        if (!!ctx.stringComparison().NOT()) {
            return [this.handleTaskRawQuery(ctx.getText())];
        }
        const expr: SimpleExpression = this.handleStringComparisonContext(ctx.stringComparison());
        expr.category = new TaskProcess(this._operatorService, this._logger, this._categoryOptionalDependencies);
        return [expr];
    };

    /**
     * Handles a string comparison context and creates a simple expression with the appropriate operator and value.
     *
     * @param ctx - The string comparison parse tree context
     * @returns A simple expression with the extracted operator, string value, and negation flag
     */
    protected handleStringComparisonContext(ctx: StringComparisonContext): SimpleExpression {
        const operator: Operator<any> = getOperatorFromToken(ctx._op);
        const value: string = this.extractStringValueFromStringComparisonContext(ctx);
        return new SimpleExpression(operator, value);
    };

    /**
     * Handles a string LIKE comparison context and creates a simple expression with the LIKE operator.
     *
     * @param ctx - The string LIKE comparison parse tree context
     * @returns A simple expression with the LIKE operator, extracted string value, and negation flag
     */
    protected handleStringLikeComparisonContext(ctx: StringLikeComparisonContext): SimpleExpression {
        const operator: Operator<any> = new Like();
        const value: string = this.extractStringValueFromStringComparisonContext(ctx.stringComparison());
        return new SimpleExpression(operator, value);
    };

    /**
     * Extracts the string value from a string comparison context, handling both logged user attributes and literal strings.
     *
     * @param ctx - The string comparison parse tree context
     * @returns The extracted string value, either from logged user attributes or from a quoted string literal
     */
    protected extractStringValueFromStringComparisonContext(ctx: StringComparisonContext): string {
        let value: string;
        if (!!ctx.loggedUserStringAttribute()) {
            const loggedUserCtx = ctx.loggedUserStringAttribute();
            const user = this._userService.user;
            if (!!loggedUserCtx.LOGGED_USER_ID()) {
                value = user?.id;
            } else if (!!loggedUserCtx.LOGGED_USER_FULLNAME()) {
                value = user?.fullName;
            } else if (!!loggedUserCtx.LOGGED_USER_USERNAME()) {
                value = user?.email;
            }
        }
        if (!value) {
            value = this.removeSingleQuotesFromString(ctx.STRING()?.getText());
        }
        return value;
    }

    /**
     * Removes single quotes from the beginning and end of a string if they are present.
     *
     * @param value - The string value that may be enclosed in single quotes
     * @returns The string with single quotes removed, or the original string if not enclosed in quotes
     */
    protected removeSingleQuotesFromString(value: string): string {
        if (value && value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
            return value.substring(1, value.length - 1);
        }
        return value;
    }

    /**
     * Handles an object ID comparison context and creates a simple expression with the appropriate operator and ID value.
     *
     * @param ctx - The object ID comparison parse tree context
     * @returns A simple expression with the extracted operator, object ID value (either logged user ID or string literal), and negation flag
     */
    protected handleObjectIdComparisonContext(ctx: ObjectIdComparisonContext): SimpleExpression {
        const operator: Operator<any> = getOperatorFromToken(ctx._op);
        const value: string = !!ctx.LOGGED_USER_ID() ? this._userService.user?.id
            : this.removeSingleQuotesFromString(ctx.STRING()?.getText());
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a date comparison context and creates a simple expression with the appropriate date operator and date value.
     *
     * @param ctx - The date comparison parse tree context
     * @returns A simple expression with the date operator, extracted date value, and negation flag
     */
    protected handleDateComparisonContext(ctx: DateComparisonContext): SimpleExpression {
        const operator: Operator<any> = getDateOperatorFromToken(ctx._op, this._operatorService);
        const value: string = ctx.DATE()?.getText();
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a datetime comparison context and creates a simple expression with the appropriate datetime operator and datetime value.
     *
     * @param ctx - The datetime comparison parse tree context
     * @returns A simple expression with the datetime operator, extracted datetime value, and negation flag
     */
    protected handleDateTimeComparisonContext(ctx: DateTimeComparisonContext): SimpleExpression {
        const operator: Operator<any> = getDateTimeOperatorFromToken(ctx._op, this._operatorService);
        const value: string = ctx.DATETIME()?.getText();
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a date range context and creates a simple expression with the InRangeDate operator and date range values.
     *
     * @param ctx - The date range parse tree context
     * @returns A simple expression with the InRangeDate operator, and array of date values
     */
    protected handleDateRangeContext(ctx: DateRangeContext): SimpleExpression {
        const operator: Operator<any> = new InRangeDate();
        const value: string[] = ctx.DATE()?.map(terminalNode => terminalNode.getText());
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a datetime range context and creates a simple expression with the InRangeDateTime operator and datetime range values.
     *
     * @param ctx - The datetime range parse tree context
     * @returns A simple expression with the InRangeDateTime operator, and array of datetime values
     */
    protected handleDateTimeRangeContext(ctx: DateTimeRangeContext): SimpleExpression {
        const operator: Operator<any> = new InRangeDateTime();
        const value: string[] = ctx.DATETIME()?.map(terminalNode => terminalNode.getText());
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a number comparison context and creates a simple expression with the appropriate operator and numeric value.
     *
     * @param ctx - The number comparison parse tree context
     * @returns A simple expression with the extracted operator, numeric value (integer or double), and negation flag
     */
    protected handleNumberComparisonContext(ctx: NumberComparisonContext): SimpleExpression {
        const operator: Operator<any> = getOperatorFromToken(ctx._op);
        let value: number;
        if (!!ctx.INT()) {
            value = parseInt(ctx.INT().getText(), 10);
        } else if (!!ctx.DOUBLE()) {
            value = parseFloat(ctx.DOUBLE().getText());
        }
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a number range comparison context and creates a simple expression with the InRange operator and numeric range values.
     *
     * @param ctx - The in-range number comparison parse tree context
     * @returns A simple expression with the InRange operator, array of numeric values (integer or double range), and negation flag
     */
    protected handleInRangeNumberComparisonContext(ctx: InRangeNumberComparisonContext): SimpleExpression {
        const operator: Operator<any> = new InRange();
        let fromValue: number, toValue: number;
        if (!!ctx.intRange()) {
            fromValue = parseInt(ctx.intRange().INT()[0].getText(), 10);
            toValue = parseInt(ctx.intRange().INT()[1].getText(), 10);
        } else if (!!ctx.doubleRange()) {
            fromValue = parseFloat(ctx.doubleRange().DOUBLE()[0].getText());
            toValue = parseFloat(ctx.doubleRange().DOUBLE()[1].getText());
        }
        return new SimpleExpression(operator, [fromValue, toValue]);
    }

    /**
     * Handles a boolean comparison context and creates a simple expression with the appropriate operator and boolean value.
     *
     * @param ctx - The boolean comparison parse tree context
     * @returns A simple expression with the extracted operator, boolean value, and negation flag
     */
    protected handleBooleanComparisonContext(ctx: BooleanComparisonContext): SimpleExpression {
        const operator: Operator<any> = getOperatorFromToken(ctx._op);
        const value: boolean = ctx.BOOLEAN().getText().toLowerCase() === 'true';
        return new SimpleExpression(operator, value);
    }

    /**
     * Handles a null comparison context and creates a simple expression with the IsNull operator.
     *
     * @returns A simple expression with the IsNull operator
     */
    protected handleNullComparisonContext(): SimpleExpression {
        const operator: Operator<any> = new IsNull();
        return new SimpleExpression(operator, undefined);
    }

    /**
     * Handles a case raw query by wrapping it in a case plain query expression.
     *
     * This method is used when the query contains complex expressions that cannot be parsed
     * into structured query items (e.g., complex OR expressions with multiple branches or negations).
     * The raw query text is preserved and processed as a plain text query.
     *
     * @param query - The raw query string to be wrapped
     * @returns A raw expression containing the case plain query category and the original query text
     */
    protected handleCaseRawQuery(query: string): RawExpression {
        const category: CasePlainQuery = new CasePlainQuery(this._operatorService, this._logger);
        return new RawExpression(category, query);
    }

    /**
     * Handles a task raw query by wrapping it in a task plain query expression.
     *
     * This method is used when the query contains complex expressions that cannot be parsed
     * into structured query items (e.g., complex OR expressions with multiple branches or negations).
     * The raw query text is preserved and processed as a plain text query.
     *
     * @param query - The raw query string to be wrapped
     * @returns A raw expression containing the task plain query category and the original query text
     */
    protected handleTaskRawQuery(query: string): RawExpression {
        const category: TaskPlainQuery = new TaskPlainQuery(this._operatorService, this._logger);
        return new RawExpression(category, query);
    }
}

results matching ""

    No results matching ""