Class AliasComputer

  • Direct Known Subclasses:
    AliasComputerDcs

    public class AliasComputer
    extends Object
    Handler for aliases in select query
    • Constructor Detail

      • AliasComputer

        public AliasComputer()
    • Method Detail

      • getDefaultFieldName

        public static String getDefaultFieldName​(boolean isRussian)
        Gets default field name
        Parameters:
        isRussian - true if actual script variant is Russian, false otherwise
        Returns:
        default field name, never null
      • getAliasWithoutRepeat

        public static CaseInsensitiveString getAliasWithoutRepeat​(CaseInsensitiveString alias,
                                                                  Set<CaseInsensitiveString> announcesAlias,
                                                                  boolean isExpr,
                                                                  boolean isRussian)
        Compute unique alias
        Parameters:
        alias - original alias
        announcesAlias - aliases which have been created earlier
        isExpr - if alias for AbstractExpression
        Returns:
        unique alias: 1) isExpr == false then return the first element isn't contained in announcesAlias from [ alias, alias1, alias2, ...] 2) isExpr == true then return the first element isn't contained in announcesAlias from [ DefaultColumnName1, DefaultColumnName2, DefaultColumnName3, ...]
      • fillAliasForSelectFields

        public Set<CaseInsensitiveString> fillAliasForSelectFields​(List<QuerySchemaExpression> allFields,
                                                                   List<QuerySchemaSource> allSources,
                                                                   IDynamicDbViewFieldComputer dynamicDbViewComputer,
                                                                   boolean isRussian)
        Fills alias for select fields, if they don't have it
        Parameters:
        allFields - all select fields, can't be null
        allSources - all sources, can be null
        dynamicDbViewComputer - IDynamicDbViewFieldComputer, can be null, in this case aliases will be computed by string representation of expressions
        isRussian - true if aliases computing for Russian script variant, false otherwise
        Returns:
        all aliases, never null
      • fillAliasForFromSection

        public void fillAliasForFromSection​(QuerySchemaOperator operator)
        Fills alias for 'from' section, if they don't have it
        Parameters:
        operator - processing QuerySchemaOperator, can't be null
      • getNameAliasCommonExpression

        public String getNameAliasCommonExpression​(CommonExpression expr,
                                                   IDynamicDbViewFieldComputer dynamicDbViewComputer,
                                                   boolean isRussian)
        Gets name alias from CommonExpression - split by '.' and get last
        Parameters:
        expr - processing CommonExpression, can be null
        dynamicDbViewComputer - IDynamicDbViewFieldComputer, can be null, in this case aliases will be computed by string representation of expressions
        isRussian - true if aliases computing for Russian script variant, false otherwise
        Returns:
        if expr == null returns null, else returns last part of common expression
      • getNameAliasTableExpression

        public String getNameAliasTableExpression​(AbstractQuerySchemaTable table,
                                                  String alias)
        Gets name alias from AbstractTable - split by '.' and get last
        Parameters:
        table - processing table, can be null
        alias - current alias, can be null
        Returns:
        if table == null returns null, if alias != null returns alias, if alias == null returns last part of table name
      • getAlias

        public CaseInsensitiveString getAlias​(CaseInsensitiveString name,
                                              Set<CaseInsensitiveString> announcesAlias,
                                              boolean isExpr,
                                              boolean isRussian)
        Getting actual alias for name
        Parameters:
        name - of expression, can't be null
        announcesAlias - aliases which have been used, can't be null
        isExpr - true, if this name corresponding to expression not instance of CommonExpression
        isRussian - true if actual script variant is Russian, false otherwise
        Returns:
        alias
      • getQSExpressionName

        public AliasComputer.PairAliasIsExpr getQSExpressionName​(QuerySchemaExpression expression,
                                                                 IDynamicDbViewFieldComputer dynamicDbViewComputer,
                                                                 boolean isRussian)
        Gets name field by it expression
        Parameters:
        expression - processing expression, can't be null
        isRussian - true if actual script variant is Russian, false otherwise
        Returns:
        QlDerivedStateComputer.PairAliasIsExpr
      • readAllFillAliasFrom

        public Set<CaseInsensitiveString> readAllFillAliasFrom​(QuerySchemaSource source)
        Read all alias from 1 source in section 'from' (including 'join' section)
        Parameters:
        source - processing source, can't be null
        Returns:
        set of string with all aliases
      • getNameAliasCommonExpressionForFieldOfNestedTable

        public String getNameAliasCommonExpressionForFieldOfNestedTable​(CommonExpression expr,
                                                                        IDynamicDbViewFieldComputer dynamicDbViewComputer,
                                                                        boolean isRussian)
        Computes alias for field from nested table represented as CommonExpression
        Parameters:
        expr - processing expression, can't be null
        dynamicDbViewComputer - IDynamicDbViewFieldComputer, can be null, in this case aliases will be computed by string representation of expressions
        isRussian - true if aliases computing for Russian script variant, false otherwise
        Returns:
        computed alias, can be null if model of the query is not valid