Class QlUtil

java.lang.Object
com._1c.g5.v8.dt.ql.QlUtil

public class QlUtil extends Object
Methods for this class is used in different area of ql and ql.dcs
  • Constructor Details

    • QlUtil

      public QlUtil()
  • Method Details

    • isFloatNumber

      public static boolean isFloatNumber(NumberLiteralExpression number)
      Parameters:
      number -
      Returns:
      if number is float value then true, else return false
    • cleanUpQueryCache

      public static void cleanUpQueryCache(QuerySchema object)
      Clean up query cache than may holds reference to the query schema objects. This method also cleans any cache for nested query schemas.
      Parameters:
      object - the query schema object, cannot be null.
    • cloneTypeDescription

      public static TypeDescription cloneTypeDescription(TypeDescription source)
      Create copy of type description
      Parameters:
      source - source TypeDescription, cannot be null
      Returns:
      created copy, cannot be null
    • isZeroNumber

      public static boolean isZeroNumber(NumberLiteralExpression number)
      Checks NumberLiteralExpression for zero
      Parameters:
      number - NumberLiteralExpression checking number, cannot be null
      Returns:
      if integer and fractional part of number equal zero then true, else return false
    • getTypeName

      public static String getTypeName(TypeDescription type, boolean isRussian)
      return name of the type, language sensetive
      Parameters:
      type -
      isRussian -
      Returns:
      name of the type
    • getTypeName

      public static String getTypeName(TypeDescriptionSource type, boolean isRussian)
      Return name of the type, language sensetive
      Parameters:
      type - the TypeDescriptionSource, may be null
      isRussian - Request russion variant of the name if true
      Returns:
      The type name. Never null
    • isQSExprNestedTable

      public static boolean isQSExprNestedTable(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dbViewComputer)
      Checks that expression contains link to nested table
      Parameters:
      qsExpr - checking QuerySchemaExpression, cannot be null
      dbViewComputer - actual IDynamicDbViewFieldComputer, cannot be null
      Returns:
      if qsExpr corresponding to nested table expression in ql language then true else false
    • isNestedTable

      public static boolean isNestedTable(DbViewElement dbView)
      Checks that dbView is nested table
      Parameters:
      dbView - checking dbView, can be null
      Returns:
      if dbView corresponding to nested table then true else false
    • numberOfFields

      public static int numberOfFields(QuerySchemaExpression qsExpr, IDynamicDbViewFieldComputer dynamicDbViewComputer)
      determine number of fields for qsExpr
      Parameters:
      qsExpr -
      dynamicDbViewComputer - special computer of DbViewElement from CommonExpression or AbstractQuerySchemaTable
      Returns:
      number of fields
    • isUnfixedType

      public static boolean isUnfixedType(TypeDescription type)
      Checks qualifiers of string and binary type for 'fix'
      Parameters:
      type - checking type, cannot be null
      Returns:
      true, if string 'not fix', false otherwise
    • isUnlimitedType

      public static boolean isUnlimitedType(TypeDescription type)
      Checks qualifiers of string and binary type for 'unlimited'
      Parameters:
      type - checking type, cannot be null
      Returns:
      true, if string 'unlimited' false otherwise
    • isUnlimitedType

      public static boolean isUnlimitedType(TypeDescriptionSource type)
      Checks qualifiers of string and binary type for 'unlimited'
      Parameters:
      type - checking type, cannot be null
      Returns:
      true, if string 'unlimited' false otherwise
    • isCompoundType

      public static boolean isCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
      Compound type is the type which has 2 or more TypeItem.
      Parameters:
      type - cannot be null
      Returns:
      true, if it's compound
    • isCompoundType

      public static boolean isCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
      Compound type is the type which has 2 or more TypeItem.
      Parameters:
      type - cannot be null
      Returns:
      true, if it's compound
    • isSpecialCompoundType

      public static boolean isSpecialCompoundType(TypeDescription type, org.eclipse.emf.ecore.EObject context)
      Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types. This method not expand TypeSet from TypeDescription
      Parameters:
      type - checked TypeDescription, cannot be null
      context - context object for expand TypeSet in TypeDescription, cannot be null
      Returns:
      true, if it's compound
    • isSpecialCompoundType

      public static boolean isSpecialCompoundType(TypeDescriptionSource type, org.eclipse.emf.ecore.EObject context)
      Compound type is the type which has 2 or more TypeItem which have different base types and not is ref types. This method not expand TypeSet from TypeDescription
      Parameters:
      type - checked TypeDescription, cannot be null
      context - context object for expand TypeSet in TypeDescription, cannot be null
      Returns:
      true, if it's compound
    • compareValueDateLiteral

      public static int compareValueDateLiteral(DateLiteralExpression dateFt, DateLiteralExpression dateSd)
      compare two date literals
      Parameters:
      dateFt -
      dateSd -
      Returns:
      0 - if dateFt == dateSd, 1 - if dateFt > dateSd, -1 - if dateFt < dateSd, 2 - if dateFt not comparable with dateSd
    • getDbView

      public static DbViewElement getDbView(org.eclipse.emf.ecore.EObject object, IDynamicDbViewFieldComputer dynamicDbViewComputer)
      Try found refer to DbViewElement in object
      Parameters:
      object -
      dynamicDbViewComputer - special computer of DbViewElement from CommonExpression or AbstractQuerySchemaTable
      Returns:
      actual dbView for this object or null
    • getFieldsFromOriginalDbView

      public static List<DbViewFieldDef> getFieldsFromOriginalDbView(DbViewElement dbViewDef, IDynamicDbViewFieldComputer dynamicDbViewComputer)
      Get fields from dbViewDef, when dbViewDef.getMdObject() != null and dbViewDef.getMdObject() was linked with another DbView
      Parameters:
      dbViewDef -
      dynamicDbViewComputer - special computer of DbViewElement from CommonExpression or AbstractQuerySchemaTable
      Returns:
      fields of original dbView for dbViewDef
    • checkForNull

      public static int checkForNull(Object objF, Object objS)
      Parameters:
      objF -
      objS -
      Returns:
      0 - both != null; 1 - both == null; -1 - else
    • isCurrentLangRussian

      @Deprecated public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject)
      Deprecated.
      Use the variant with provided services due to performance reasons
      Check current language of configuration for ScriptVariant.RUSSIAN
      Parameters:
      eObject - actual object
      Returns:
      true, if current language of configuration equal ScriptVariant.RUSSIAN
      See Also:
    • isCurrentLangRussian

      public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.EObject eObject, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
      Check current language of configuration for ScriptVariant.RUSSIAN
      Parameters:
      eObject - actual object
      resourceLookup - IResourceLookup service reference. May not be null
      v8ProjectManager - IV8ProjectManager service reference. May not be null
      Returns:
      true, if current language of configuration equal ScriptVariant.RUSSIAN
      See Also:
    • isCurrentLangRussian

      @Deprecated public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource)
      Deprecated.
      Use the variant with provided services due to performance reasons
      Check current language of configuration for ScriptVariant.RUSSIAN
      Parameters:
      resource - actual resource
      Returns:
      true, if current language of configuration equal ScriptVariant.RUSSIAN
      See Also:
    • isCurrentLangRussian

      public static boolean isCurrentLangRussian(org.eclipse.emf.ecore.resource.Resource resource, IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager)
      Check current language of configuration for ScriptVariant.RUSSIAN
      Parameters:
      resource - actual resource
      resourceLookup - IResourceLookup service reference. May not be null
      v8ProjectManager - IV8ProjectManager service reference. May not be null
      Returns:
      true, if current language of configuration equal ScriptVariant.RUSSIAN
      See Also:
    • getProposalsNameFor

      public static List<String> getProposalsNameFor(org.eclipse.xtext.scoping.IScope scope, boolean isTable)
      Get string proposals from scope (only that instance of Table)
      Parameters:
      scope -
      isTable - define what kind of type proposals we look up - table or field
      Returns:
      list of proposals
    • createUserDataRu

      public static Map<String,String> createUserDataRu()
      Gets user data ru for indexing values
      Returns:
      user data ru for indexing values, never null
    • createUserDataIntnl

      public static Map<String,String> createUserDataIntnl()
      Gets user data intnl for indexing values
      Returns:
      user data intnl for indexing values, never null
    • isPeriodKeyword

      public static boolean isPeriodKeyword(CommonExpression expr, QlTypeDescriptionContainer qlTypeDescr)
      Checks that CommonExpression content corresponding to period keyword
      Parameters:
      expr - checking CommonExpression, cannot be null
      qlTypeDescr - actual QlTypeDescriptionContainer cannot be null</code
      Returns:
      true if CommonExpression content corresponding to period keyword, false otherwise
    • getExpressionOfNestedTable

      public static ACommonExpression getExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
      Gets expression corresponding to the field of nested table
      Parameters:
      expression - checking expression, cannot be null
      dbViewComputer - actual IDynamicDbViewFieldComputer, cannot be null
      Returns:
      expression corresponding to field of nested table or null if field wasn't found
    • getRefExpressionOfNestedTable

      public static CommonExpression getRefExpressionOfNestedTable(CommonExpression expression, IDynamicDbViewFieldComputer dbViewComputer)
      Gets expression corresponding to reference field of nested table
      Parameters:
      expression - checking expression, cannot be null
      dbViewComputer - actual IDynamicDbViewFieldComputer, cannot be null
      Returns:
      expression corresponding to reference field of nested table or null if reference field wasn't found
    • isPartOfBracketCommonExpression

      public static boolean isPartOfBracketCommonExpression(CommonExpression expression)
      Checks that expression corresponding to the {@link QlPackage#Literals#BRACKET_COMMON_EXPRESSION__COMMON_EXPRESSION} part
      Parameters:
      expression - checking expression, cannot be null
      Returns:
      true if expression corresponding to the {@link QlPackage#Literals#BRACKET_COMMON_EXPRESSION__COMMON_EXPRESSION} part, false otherwise
    • expandTypeSet

      public static TypeDescription expandTypeSet(TypeDescription initialType, org.eclipse.emf.ecore.EObject context)
      Parameters:
      initialType - initial TypeDescription checking for containing of TypeSet of DefinedType or ChartOfCharacteristicTypes, cannot be null
      context - actual EObject for resolving, cannot be null
      Returns:
      TypeDescription with types from TypeSet of DefinedType or ChartOfCharacteristicTypes, never null
    • expandTypeSet

      public static TypeDescriptionSource expandTypeSet(TypeDescriptionSource initialType, org.eclipse.emf.ecore.EObject context)
      Parameters:
      initialType - initial TypeDescription checking for containing of TypeSet of DefinedType or ChartOfCharacteristicTypes, cannot be null
      context - actual EObject for resolving, cannot be null
      Returns:
      TypeDescription with types from TypeSet of DefinedType or ChartOfCharacteristicTypes, never null
    • fieldFromCompoundType

      public static boolean fieldFromCompoundType(CommonExpression expr, IExpressionTypeChecker qlChecker)
    • isExternalDataSourceTable

      public static boolean isExternalDataSourceTable(CommonExpression input)
      Checks that CommonExpression corresponding to the field of ExternalDataSource object DbViewElement. Checks for full naming without using alias from query - segments count in CommonExpression should be more than 4, it should be start from EXTERNAL_DATA_SOURCE. See MdUtil.getFullyQualifiedName(com._1c.g5.v8.dt.metadata.mdclass.MdObject) for ExternalDataSource and its objects
      Parameters:
      input - checking CommonExpression, cannot be null
      Returns:
      true if CommonExpression is table of ExternalDataSource objects, false otherwise
    • isExternalDataSourceTable

      public static boolean isExternalDataSourceTable(AbstractQuerySchemaTable input)
      Checks that AbstractQuerySchemaTable corresponding to the table of ExternalDataSource object DbViewElement. Checks for full naming without using alias from query - segments count in AbstractQuerySchemaTable should be more than 4, it should be start from EXTERNAL_DATA_SOURCE. See MdUtil.getFullyQualifiedName(com._1c.g5.v8.dt.metadata.mdclass.MdObject) for ExternalDataSource and its objects
      Parameters:
      input - checking AbstractQuerySchemaTable, cannot be null
      Returns:
      true if AbstractQuerySchemaTable is table of ExternalDataSource objects, false otherwise
    • isExternaldataSourceTemporaryTable

      public static boolean isExternaldataSourceTemporaryTable(AbstractQuerySchemaTable input)
      Checks that AbstractQuerySchemaTable corresponding to the temporary table of ExternalDataSource Checks for full naming without using alias from query - segments count in AbstractQuerySchemaTable should equals 4, it should be start from EXTERNAL_DATA_SOURCE.
      Parameters:
      input - checking AbstractQuerySchemaTable, cannot be null
      Returns:
      true if AbstractQuerySchemaTable is temporary table of ExternalDataSource objects, false otherwise