Namespace: OpenEdge.BusinessLogic.Query
Type: Class QueryBuilder
Parent Classes:
Inherits: Progress.Lang.Object


/* *************************************************************************************************************************
Copyright (c) 2019-2021 by Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
File:QueryBuilder
Author(s):pjudge & dugrau
Created:Thu May 10 12:38:00 EDT 2018
Notes:ADAS-101
/* Returns a table/buffer handle for a given name from an input schema



Method Summary
  Options Name Purpose
  CHARACTER BuildClause (handle, IQueryPredicate) /* Builds a WHERE clause for a table from a QueryPredicate @param handle The table buffer handle @param QueryPredicate The abstract query predicate @return character A string representation of the where clause */
  CHARACTER BuildGroup (handle, IQueryGroup) /* Builds a query group string from a group @param handle The table/buffer for which the group is being built @param QueryGroup The group @return character A group string */
  HANDLE BuildQuery (IGetDataRequest, handle) /* Builds a query handle (object) from a IGetDataRequest object. This method maps the input names to the input handle's SERIALIZE-NAMEs and uses the 'real' names to build the where clause @param IGetDataRequest A valid queryn definition @param handle a Dataset or buffer (TT or DB) handle @return handle A valid QUERY handle */
  CHARACTER BuildQueryString (IGetDataRequest) /* Builds a query string from a IGetDataRequest object. This method does no name conversions - just takes the names from the input object. @param IGetDataRequest A valid queryn definition @return character A complete WHERE clause , with no name conversions */
  CHARACTER BuildQueryString (IGetDataRequest, handle) /* Builds a query string from a IGetDataRequest object. This method maps the input names to the input handle's SERIALIZE-NAMEs and uses the 'real' names to build the where clause @param IGetDataRequest A valid queryn definition @param handle a Dataset or buffer (TT or DB) handle @return character A complete WHERE clause */
  CHARACTER BuildQueryString (IGetDataTableRequest, logical, logical, handle) /* Builds a query string for a single table from a IGetDataTableRequest object. This method maps the input names to the input handle's SERIALIZE-NAMEs and uses the 'real' names to build the where clause @param IGetDataTableRequest A valid @param handle a Dataset or buffer (TT or DB) handle @param logical TRUE if the FILTER (where) expression must be included, FALSE if not @param logical TRUE if the SORT expression must be included , FALSE if not @return character A complete WHERE clause */
  CHARACTER BuildQueryStrings (IGetDataRequest, handle) /* Builds an array of query strings from a IGetDataRequest object. This method maps the input names to the input dataset's SERIALIZE-NAMEs and uses the 'real' names to build the where clauses. The output array matches the order of the buffers in the dataset, which may differ from the order of the tablerequest array. @param IGetDataRequest A valid query definition @param handle A Dataset or buffer (TT or DB) handle @return character[] An array of WHERE clauses, matching the number of table requests */
  HANDLE GetFieldBuffer (handle, character) /* Returns a fiueld handle for a given name from an input buffer @param handle The input table/buffer @param character The field name. Can be the 'real' name or the serialize-name @return handle A buffer field handle for the given name. */
  HANDLE GetTableBuffer (handle, character) /* Returns a table/buffer handle for a given name from an input schema @param handle The input schema (dataset, buffer, table) @param character The table name. Can be the 'real' name or the serialize-name @return handle A buffer handle for the given name. */
  CHARACTER MapJoin (character, character, JoinEnum) /* Creates a templated join phrase for a clause @param character The current query string @param character The query where clause that's being joined @param JoinEnum The join to apply @return character A new query string, including the join phrase */
  CHARACTER MapOperator (QueryOperatorEnum, character) /* Maps a query operator into a string template @param QueryOperatorEnum The operator @param character The the data type @return character A templated operator map of the form "&1 eq &2" */
  CHARACTER MergeQueryStrings (character, JoinEnum, character) /* Merges 2 query strings with specified join. The resulting query string has the format "WHERE ( <string-1> ) <join> ( <string-2> ) BY <by-1> BY <by-2> " or "WHERE TRUE BY <by-1> BY <by-2>" if only BY clauses are passed in. Each input string is put in parentheses, except when i) the input strings are both ? ii) one or both of the input strings is empty iii) there are no where clauses - Join values - if the join is null, use JoinEnum:And - if the join is NONE, use JoinEnum:And - if the join is NOT, use JoinEnum:AndNot - For other values, use as specified - if both strings are null, then shortcut and return ? and ? = where true ? or ? = where true ? and not ? = where false ? or not ? = where true - No validation (of field/table names) is done; this is a simple string merge routine. - If either string is empty, no join is performed, and the other string is returned (even if empty) - If either query string containd BY clause(s), these are appended @param character The first query string @param JoinEnum The join criteria @param character The second query string @return character The merged query string */
  DATETIME-TZ ParseIsoDate (character) /* Converts a string (ISO, hopefully) into a datetime-tz. This method does not thrown any errors, and will return the UNKNOWN value if the input value cannot be converted into a datetime-tz. @param character A string containing a ISO or ABL formatted date/time/tz @param datetime-tz A datetime-tz value representing the string, or the UNKNOWN value. */

Method Detail
Top

CHARACTER BuildClause (handle, IQueryPredicate)

/* Builds a WHERE clause for a table from a QueryPredicate
Parameters:
phTable HANDLE
 
poClause Ccs.BusinessLogic.IQueryPredicate
 
Returns CHARACTER
  character A string representation of the where clause
Top

CHARACTER BuildGroup (handle, IQueryGroup)

/* Builds a query group string from a group
Parameters:
phTable HANDLE
 
poGroup Ccs.BusinessLogic.IQueryGroup
 
Returns CHARACTER
  character A group string
Top

HANDLE BuildQuery (IGetDataRequest, handle)

/* Builds a query handle (object) from a IGetDataRequest object. This method maps
the input names to the input handle's SERIALIZE-NAMEs and uses the 'real'
names to build the where clause
Parameters:
pFilter Ccs.BusinessLogic.IGetDataRequest
 
pSchema HANDLE
 
Returns HANDLE
  handle A valid QUERY handle
Top

CHARACTER BuildQueryString (IGetDataRequest)

/* Builds a query string from a IGetDataRequest object. This method does
no name conversions - just takes the names from the input object.
Parameters:
pFilter Ccs.BusinessLogic.IGetDataRequest
 
Returns CHARACTER
  character A complete WHERE clause , with no name conversions
Top

CHARACTER BuildQueryString (IGetDataRequest, handle)

/* Builds a query string from a IGetDataRequest object. This method maps
the input names to the input handle's SERIALIZE-NAMEs and uses the 'real'
names to build the where clause
Parameters:
pFilter Ccs.BusinessLogic.IGetDataRequest
 
pSchema HANDLE
 
Returns CHARACTER
  character A complete WHERE clause
Top

CHARACTER BuildQueryString (IGetDataTableRequest, logical, logical, handle)

/* Builds a query string for a single table from a IGetDataTableRequest object.
This method maps the input names to the input handle's SERIALIZE-NAMEs and
uses the 'real' names to build the where clause
Parameters:
pFilter Ccs.BusinessLogic.IGetDataTableRequest
 
pInclFilter LOGICAL
 
pInclSort LOGICAL
 
pSchema HANDLE
 
Returns CHARACTER
  character A complete WHERE clause
Top

CHARACTER BuildQueryStrings (IGetDataRequest, handle)

/* Builds an array of query strings from a IGetDataRequest object. This method maps
the input names to the input dataset's SERIALIZE-NAMEs and uses the 'real'
names to build the where clauses. The output array matches the order of the buffers
in the dataset, which may differ from the order of the tablerequest array.
Parameters:
pFilter Ccs.BusinessLogic.IGetDataRequest
 
pSchema HANDLE
 
Returns CHARACTER
  character[] An array of WHERE clauses, matching the number of table requests
Top

HANDLE GetFieldBuffer (handle, character)

/* Returns a fiueld handle for a given name from an input buffer
Parameters:
phTable HANDLE
 
pcFieldName CHARACTER
 
Returns HANDLE
  handle A buffer field handle for the given name.
Top

HANDLE GetTableBuffer (handle, character)

/* Returns a table/buffer handle for a given name from an input schema
Parameters:
phSchema HANDLE
 
pcTableName CHARACTER
 
Returns HANDLE
  handle A buffer handle for the given name.
Top

CHARACTER MapJoin (character, character, JoinEnum)

/* Creates a templated join phrase for a clause
Parameters:
pcQuery CHARACTER
 
pcClause CHARACTER
 
poJoinAs Ccs.BusinessLogic.JoinEnum
 
Returns CHARACTER
  character A new query string, including the join phrase
Top

CHARACTER MapOperator (QueryOperatorEnum, character)

/* Maps a query operator into a string template
Parameters:
poOperator Ccs.BusinessLogic.QueryOperatorEnum
 
pcDataType CHARACTER
 
Returns CHARACTER
  character A templated operator map of the form "&1 eq &2"
Top

CHARACTER MergeQueryStrings (character, JoinEnum, character)

/* Merges 2 query strings with specified join. The resulting query string has the format
"WHERE ( <string-1> ) <join> ( <string-2> ) BY <by-1> BY <by-2> "
or
"WHERE TRUE BY <by-1> BY <by-2>"
if only BY clauses are passed in.
Each input string is put in parentheses, except when
i) the input strings are both ?
ii) one or both of the input strings is empty
iii) there are no where clauses
- Join values
- if the join is null, use JoinEnum:And
- if the join is NONE, use JoinEnum:And
- if the join is NOT, use JoinEnum:AndNot
- For other values, use as specified
- if both strings are null, then shortcut and return
? and ? = where true
? or ? = where true
? and not ? = where false
? or not ? = where true
- No validation (of field/table names) is done; this is a simple string merge routine.
- If either string is empty, no join is performed, and the other string
is returned (even if empty)
- If either query string containd BY clause(s), these are appended
Parameters:
pQueryString1 CHARACTER
 
pJoin Ccs.BusinessLogic.JoinEnum
 
pQueryString2 CHARACTER
 
Returns CHARACTER
  character The merged query string
Top

DATETIME-TZ ParseIsoDate (character)

/* Converts a string (ISO, hopefully) into a datetime-tz.
This method does not thrown any errors, and will return the UNKNOWN value
if the input value cannot be converted into a datetime-tz.
Parameters:
pIso CHARACTER
 
Returns DATETIME-TZ