Class WebElementSearchFilterBuilder


  • public class WebElementSearchFilterBuilder
    extends java.lang.Object
    This utility class builds a WebFilter for element browsing based on the following rules:
    • If an WebAttribute has multiple WebAttributeForm, they are OR'ed together to build a filter expression. For example, suppose an attribute named Employee has two attribute forms FirstName and LastName, a search on "Joe" would result in a filter expression like:
      Employee.FirstName Like "*Joe*" OR Employee.LastName Like "*Joe*"
    • Any search string without any wildcard character (the character ‘*’) within it will be treated as: (a) if the BaseAttributeFormDataType is of EnumDSSXMLDataType.DssXmlDataTypeChar, use the Like operator or (b) if the BaseAttributeFormDataType is of type Numerical or Date/Time, use the Equals operator and do not add any wildcard character to the search string.
    • Any search string included within a pair of double-quotes is treated as a string literal and thus always use the Equals operator. If a string begins with a double-quote character but misses the end quote, the rest of the string starting from the double-quote is treated a string literal
    • A date should comform to the following formats in order to be recognized as a date. (a) mm/dd/yy (b) mm/dd/yyyy (c) dd/mm/yy (d) dd/mm/yyyy. Any date which can not be expressed in the above four formats, should be expressed as a string literal (enclosed with a pair of double-quotes).
    • If the search string already contains wildcard characters, we do not add any more. Such a search string can not be parsed into any numerical value or date/time.
    • A blank white space character, a comma, or the word OR indicates a logical OR operator between two conditions. Multiple forms are still OR’ed. The above three operators get ignored if they appear either at the beginning or the end of a search string.
    • An ampersand character ‘&’ or the word AND indicates a logical AND operator between two conditions. Multiple forms are still OR’ed. The above two operators get ignored if they appear either at the beginning or the end of a search string.
    • Search can be qualified on a particular WebAttributeForm if the attribute form name is enclosed within a pair of square brackets (‘[‘ and ‘]‘) and is followed by a colon and a text i.e. [FirstName]:"Joe"
    • A minus-symbol (-) and the word NOT indicates a logical “AND NOT” operator on a condition. If the operator appears at the beginning of a search string, it is taken as a “NOT” operator; if it appears at the end of a searching string, it is simply ignored.
    • Range operators: a value can be preceeded by a range operator to specify a range. The supported range operators are: (a) ‘>’ (b) ‘<’ (c) “>=” and (d) “<=”. Note the range operator must be the first character in an input or be preceeded by blank spaces.
    • AND and OR operators can not co-exist in one search string, although they each can have multiple branches. This is due to the lack of support of opearator precedence.
    Since:
    MicroStrategy Web 7.5.3
    • Method Detail

      • addElementSearchPatternFilter

        public static void addElementSearchPatternFilter​(WebOperatorNode root,
                                                         WebAttribute attr,
                                                         java.lang.String searchStr,
                                                         boolean matchCase,
                                                         java.util.Locale locale)
                                                  throws WebObjectsException,
                                                         WebElementSearchFilterBuilder.ParserException
        Builds a filter expression and appends it to the specified root operator node if it is not null; otherwise, appends the search filter at the root node of the filter expression of the specified WebAttribute.

        The filter is built via qualifying on all browse forms of the specified attribute.

        Parameters:
        root - the root node to append the filter expression built
        attr - the attribute whose elements to be searched
        searchStr - the search string user types in
        matchCase - True means case sensitive searching
        locale - the Locale object
        Throws:
        WebObjectsException - thrown if the specified root does not belong to the filter of the specified attr, or there is data type mismatch between the user inputs and attribute form data type, or there is any exception when accessing to a WebObject.
        WebElementSearchFilterBuilder.ParserException - thrown if there is any error due to conflicts to the search rules.
        See Also:
        WebAttribute.getBrowseForms()
      • addElementSearchPatternFilter

        public static void addElementSearchPatternFilter​(WebOperatorNode root,
                                                         WebExpression expr,
                                                         WebAttribute attr,
                                                         java.lang.String searchStr,
                                                         boolean matchCase,
                                                         java.util.Locale locale)
                                                  throws WebObjectsException,
                                                         WebElementSearchFilterBuilder.ParserException
        Builds a filter expression and appends it to the specified root operator node if it is not null; otherwise, appends the search filter at the root node of the specified WebExpression.

        The filter is built via qualifying on all browse forms of the specified attribute.

        Parameters:
        root - the root node to append the filter expression built
        expr - the WebExpression to which the root node belongs
        attr - the attribute whose elements to be searched
        searchStr - the search string user types in
        matchCase - True means case sensitive searching
        locale - the Locale object
        Throws:
        WebObjectsException - thrown if the specified root does not belong to the filter of the specified attr, or there is data type mismatch between the user inputs and attribute form data type, or there is any exception when accessing to a WebObject.
        WebElementSearchFilterBuilder.ParserException - thrown if there is any error due to conflicts to the search rules.
        See Also:
        WebAttribute.getBrowseForms()
      • addElementSearchPatternFilter

        public static void addElementSearchPatternFilter​(WebOperatorNode root,
                                                         WebExpression expr,
                                                         WebAttribute attr,
                                                         WebAttributeForms forms,
                                                         java.lang.String searchStr,
                                                         boolean matchCase,
                                                         java.util.Locale locale,
                                                         boolean ensureDetails)
                                                  throws WebObjectsException,
                                                         WebElementSearchFilterBuilder.ParserException
        Builds a filter expression and appends it to the specified root operator node if it is not null; otherwise, appends the search filter at the root node of the specified WebExpression.

        If the attribute forms are not specified, the filter is built via qualifying on attribute browse forms.

        Parameters:
        root - the root node to append the filter expression built
        expr - the WebExpression to which the root node belongs
        attr - the attribute whose elements to be searched
        forms - the attribute forms to qualify on
        searchStr - the search string user types in
        matchCase - True means case sensitive searching
        locale - the Locale object
        Throws:
        WebObjectsException - thrown if the specified root does not belong to the filter of the specified attr, or there is data type mismatch between the user inputs and attribute form data type, or there is any exception when accessing to a WebObject.
        WebElementSearchFilterBuilder.ParserException - thrown if there is any error due to conflicts to the search rules.
        Since:
        MicroStrategy Web 8.0.0