Package com._1c.g5.v8.dt.ql.resource
Class AliasComputer
- java.lang.Object
-
- com._1c.g5.v8.dt.ql.resource.AliasComputer
-
- Direct Known Subclasses:
AliasComputerDcs
public class AliasComputer extends Object
Handler for aliases in select query
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AliasComputer.PairAliasIsExpr
Keep pair value for computing alias
-
Field Summary
Fields Modifier and Type Field Description static String
FIELD
static String
FIELD_RU
static AliasComputer
INSTANCE
static String
PRESENTATION
static String
REFPRESENTATION
-
Constructor Summary
Constructors Constructor Description AliasComputer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fillAliasForFromSection(QuerySchemaOperator operator)
Fills alias for 'from' section, if they don't have itprotected void
fillAliasFormJoins(List<? extends AbstractQuerySchemaQuerySourceJoin> allJoins, Set<CaseInsensitiveString> announcedAlias)
Fills all alias for sources from joinsSet<CaseInsensitiveString>
fillAliasForSelectFields(List<QuerySchemaExpression> allFields, List<QuerySchemaSource> allSources, IDynamicDbViewFieldComputer dynamicDbViewComputer, boolean isRussian)
Fills alias for select fields, if they don't have itCaseInsensitiveString
getAlias(CaseInsensitiveString name, Set<CaseInsensitiveString> announcesAlias, boolean isExpr, boolean isRussian)
Getting actual alias forname
static CaseInsensitiveString
getAliasWithoutRepeat(CaseInsensitiveString alias, Set<CaseInsensitiveString> announcesAlias, boolean isExpr, boolean isRussian)
Compute unique aliasstatic String
getDefaultFieldName(boolean isRussian)
Gets default field nameString
getNameAliasCommonExpression(CommonExpression expr, IDynamicDbViewFieldComputer dynamicDbViewComputer, boolean isRussian)
Gets name alias from CommonExpression - split by '.' and get lastString
getNameAliasCommonExpressionForFieldOfNestedTable(CommonExpression expr, IDynamicDbViewFieldComputer dynamicDbViewComputer, boolean isRussian)
Computes alias for field from nested table represented as CommonExpressionString
getNameAliasTableExpression(AbstractQuerySchemaTable table, String alias)
Gets name alias from AbstractTable - split by '.' and get lastAliasComputer.PairAliasIsExpr
getQSExpressionName(QuerySchemaExpression expression, IDynamicDbViewFieldComputer dynamicDbViewComputer, boolean isRussian)
Gets name field by it expressionSet<CaseInsensitiveString>
readAllFillAliasFrom(QuerySchemaOperator operator)
Read all alias from section 'from' (including 'join' section)Set<CaseInsensitiveString>
readAllFillAliasFrom(QuerySchemaSource source)
Read all alias from 1 source in section 'from' (including 'join' section)protected void
readAllFillAliasFromJoins(List<AbstractQuerySchemaQuerySourceJoin> allJoins, Set<CaseInsensitiveString> announcedAlias)
Read all alias from joins
-
-
-
Field Detail
-
REFPRESENTATION
public static final String REFPRESENTATION
- See Also:
- Constant Field Values
-
PRESENTATION
public static final String PRESENTATION
- See Also:
- Constant Field Values
-
FIELD
public static final String FIELD
- See Also:
- Constant Field Values
-
FIELD_RU
public static final String FIELD_RU
- See Also:
- Constant Field Values
-
INSTANCE
public static AliasComputer INSTANCE
-
-
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 aliasannouncesAlias
- aliases which have been created earlierisExpr
- 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 benull
allSources
- all sources, can benull
dynamicDbViewComputer
-IDynamicDbViewFieldComputer
, can benull
, in this case aliases will be computed by string representation of expressionsisRussian
-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
- processingQuerySchemaOperator
, can't benull
-
getNameAliasCommonExpression
public String getNameAliasCommonExpression(CommonExpression expr, IDynamicDbViewFieldComputer dynamicDbViewComputer, boolean isRussian)
Gets name alias from CommonExpression - split by '.' and get last- Parameters:
expr
- processingCommonExpression
, can benull
dynamicDbViewComputer
-IDynamicDbViewFieldComputer
, can benull
, in this case aliases will be computed by string representation of expressionsisRussian
-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 benull
alias
- current alias, can benull
- Returns:
- if
table == null
returnsnull
, ifalias != null
returnsalias
, ifalias == null
returns last part of table name
-
getAlias
public CaseInsensitiveString getAlias(CaseInsensitiveString name, Set<CaseInsensitiveString> announcesAlias, boolean isExpr, boolean isRussian)
Getting actual alias forname
- Parameters:
name
- of expression, can't benull
announcesAlias
- aliases which have been used, can't benull
isExpr
- true, if this name corresponding to expression not instance of CommonExpressionisRussian
-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 benull
isRussian
-true
if actual script variant is Russian,false
otherwise- Returns:
QlDerivedStateComputer.PairAliasIsExpr
-
readAllFillAliasFrom
public Set<CaseInsensitiveString> readAllFillAliasFrom(QuerySchemaOperator operator)
Read all alias from section 'from' (including 'join' section)- Parameters:
operator
- processingQuerySchemaOperator
, can't benull
- Returns:
- set of string with all aliases
-
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 benull
- 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 benull
dynamicDbViewComputer
-IDynamicDbViewFieldComputer
, can benull
, in this case aliases will be computed by string representation of expressionsisRussian
-true
if aliases computing for Russian script variant,false
otherwise- Returns:
- computed alias, can be
null
if model of the query is not valid
-
readAllFillAliasFromJoins
protected void readAllFillAliasFromJoins(List<AbstractQuerySchemaQuerySourceJoin> allJoins, Set<CaseInsensitiveString> announcedAlias)
Read all alias from joins- Parameters:
allJoins
- - processing joinsAbstractQuerySchemaQuerySourceJoin
announcedAlias
- - container of alias
-
fillAliasFormJoins
protected void fillAliasFormJoins(List<? extends AbstractQuerySchemaQuerySourceJoin> allJoins, Set<CaseInsensitiveString> announcedAlias)
Fills all alias for sources from joins- Parameters:
allJoins
- - processing joinsAbstractQuerySchemaQuerySourceJoin
announcedAlias
- - container of alias
-
-