NAME
Kernel::System::Ticket::TicketSearch::Parameters – Ticket search parameter handling.
DESCRIPTION
This class takes care about the parameters, that are passed to the TicketSearch
method, during a search execution.
The main purpose is, to prepare, handle and provide ticket search parameters properly to just hold the data, that is used for a certain search request.
Apart from the bare search parameters, the class provides data like a current timestamp (DateTime
object), to be used by datetime restrictive search filters or boolean flags to indicate, if certain tables are already joined.
Therefore this class is intended to be instantiated for every single search execution, to reset variable data entries and flags at the beginning of a search.
For a detailed description of the possible parameters and their syntax/structure, please refer to the POD
of method TicketSearch
in module Kernel::System::Ticket::TicketSearch.
Guidelines
- Instantiating and initialization
-
The parameters can either be passed to the object during the
instantiation
process as a single hash reference to the constructor, or the parameters can be added after theinstantiation
.If the parameters are passed to the object constructor, they will be implicitly forwarded to the method Prepare, to handle certain default values and validation.
my $Parameters = Kernel::System::Ticket::TicketSearch::Parameters->new( \%SearchParameters );
If the object is instantiated empty, the parameters must be added afterwards to the method Prepare, before the object can be used.
my $Parameters = Kernel::System::Ticket::TicketSearch::Parameters->new(); $Parameters->Prepare(\%SearchParameters);
- Usage
-
After preparation and validation, the parameters are stored in attribute _Parameters, that provides two handles (methods):
Keys
to get a list of parameter keys, that can be used to request the related values andGet
, which has to be called with the corresponding keys.my $Parameters = Kernel::System::Ticket::TicketSearch::Parameters->new( { Result => 'ARRAY', Limit => 25, ConditionInline => 1, FullTextIndex => 1, Fulltext => 'some search query', ContentSearchSuffix => '*', ContentSearchPrefix => '*', SortBy => ['Changed'], OrderBy => ['Down'], UserID => 1, } ); my $CurrentDateTime = $Parameters->CurrentTime()->ToString(); for my $ParameterKey ( $Parameters->Keys() ) { print "Value of key $ParameterKey is " . $Parameters->Get($ParameterKey); } my $DefaultParameters = Kernel::System::Ticket::TicketSearch::Parameters->new(); # UserID or CustomerUserID is required! my $DefaultLimit = $DefaultParameters->Prepare( { UserID => 123 } )->Get('Limit'); # returns 10
PUBLIC INTERFACE
ATTRIBUTES
has CurrentTime
DateTime object of now.
has SortOptionMap
Provides a map of sortable
ticket keys to related database column names.
has DynamicFieldMap
Provides a map of all configured article and ticket dynamic fields.
has ArticleSearchableFieldsList
Provides a map of all searchable article fields.
has SortByOptions
Provides a map of all configured article and ticket dynamic fields.
has ConditionHandlers
Provides a map of parameters and their corresponding handler methods.
has ValidationStaticFields
Prepares and provides validator
definitions for several fields.
has QueueJoined
Indicator if the queue table was joined already.
has ArticleJoined
Indicator if the article table was joined already.
has HistoryJoined
Indicator if certain history tables were joined already.
has HistoryTypeCondition
Indicator if the history_type_id condition was already added to the WHERE clause.
has DynamicFieldJoined
Indicator if certain dynamic field was joined already.
has DynamicFieldJoinIndex
Index for joined dynamic fields, that will be used to generate table aliases.
METHODS
BUILD()
Prepare parameters if they are passed to the constructor.
has BUILDARGS()
If parameters are given as a single argument, we add them to the related key (Parameters).
has MethodParamValidationSchema
Validation schema preparation.
Prepare()
Prepares and validates given parameters. Apart from that, it defines some default values for parameters and ensures uniform type (for params which can be string or array).
Handlers()
Returns an array reference containing the method names, that have to be called, based on the given parameters.
PRIVATE INTERFACE
ATTRIBUTES
has _Parameters
The prepared and validated parameter hash.