Class QueryWizardServiceUtils

java.lang.Object
com._1c.g5.v8.dt.qw.ui.utils.QueryWizardServiceUtils

public final class QueryWizardServiceUtils extends Object
Services methods for query wizard
  • Constructor Details

    • QueryWizardServiceUtils

      public QueryWizardServiceUtils()
  • Method Details

    • getDbViewForQuery

      public static DbViewElement getDbViewForQuery(org.eclipse.emf.ecore.EObject source)
      Get DbView for nested query
      Parameters:
      source - QuerySchemaNestedQuery
      Returns:
      DbViewDef for source. Return null if parent container of nested query expression is not operator
    • computeDbView

      public static DbViewElement computeDbView(org.eclipse.emf.ecore.EObject object)
      Computes DbViewElement by object
      Parameters:
      object - compute DbViewElement for this object
      Returns:
      computed DbViewElement
    • computeDbViewFields

      public static List<DbViewElement> computeDbViewFields(org.eclipse.emf.ecore.EObject object)
      Compute dbView fields
      Parameters:
      object - - fields source
      Returns:
      fields collection
    • getAllSources

      public static Set<QuerySchemaSource> getAllSources(QuerySchemaOperator operator)
      Returns all sources contained in operator
      Parameters:
      operator -
      Returns:
      all sources in operator
    • getJoinPresentation

      public static String getJoinPresentation(QuerySchemaJoinType joinType)
      Get join type string presentation
      Parameters:
      joinType - join type
      Returns:
      string presentation
    • getConditionAndExpressions

      public static void getConditionAndExpressions(AbstractExpression condition, List<AbstractExpression> expressions)
      Break condition on expressions by AND operation
      Parameters:
      condition - contain expression with binary operations. Not null
      expressions - collection for storing expressions from condition (broke by AND operation). Not null
    • expandJoinsToChangedItems

      public static void expandJoinsToChangedItems(QueryWizardTreeViewer tree, List<QuerySchemaSource> changedSources)
      Expand joins tree to changed items
      Parameters:
      tree - tree viewer
      changedSources - list of changed sources
    • handleQueryWizardEditException

      public static void handleQueryWizardEditException(QueryWizardEditProviderException qwException, QueryWizardControl qwControl)
      Processing query wizard exception
      Parameters:
      qwException - query wizard exception
      qwControl - parent query wizard control
    • isNestedTableInOperator

      public static boolean isNestedTableInOperator(QueryWizardSource source, int queryIndex, int operatorIndex)
      If operator have nested table - return true
      Parameters:
      querySchema - QueryWizardSource
      queryIndex - query index
      operatorIndex - operator index in query
      Returns:
      true if is nested table in operator
    • isNestedTableInOperator

      public static boolean isNestedTableInOperator(QuerySchemaOperator operator)
      If operator have nested table - return true
      Parameters:
      operator -
      Returns:
      true if is nested table in operator
    • isNestedTableInGroupings

      public static boolean isNestedTableInGroupings(QuerySchemaOperator operator)
      If groupings have nested table - return true
      Parameters:
      operator -
      Returns:
      true if is nested table in groupings
    • isExpressionsInGroupings

      public static boolean isExpressionsInGroupings(QuerySchemaOperator operator)
      If groupings have expressions - return true
      Parameters:
      operator -
      Returns:
      true if is expression in groupings
    • getSourceFromJoin

      public static QuerySchemaSource getSourceFromJoin(Object source)
      Get source from join
      Parameters:
      source - QuerySchemaSource
      Returns:
      query schema source
    • copyExpression

      public static QuerySchemaExpression copyExpression(QuerySchemaExpression expression)
      Get expression copy
      Parameters:
      expression - query schema expression
      Returns:
      copy of expression
    • copyExpression

      public static QuerySchemaExpression copyExpression(QuerySchemaExpression expression, NestedTableExpression parentNestedTable)
      Make copy of query schema expression. If expression from nested table, expression will be copied with parent nested table.
      Parameters:
      expression - query schema expression
      parentNestedTable - parent nested table
      Returns:
      expression copy
    • isExpressionContainSource

      public static boolean isExpressionContainSource(String sourceAlias, org.eclipse.emf.ecore.EObject expression)
      Is expression contain source alias
      Parameters:
      sourceAlias - source alias
      expression - query schema expression
      Returns:
      if contained - return true
    • replaceSourceAliasInExpression

      public static boolean replaceSourceAliasInExpression(String[] oldAndNewAliases, org.eclipse.emf.ecore.EObject expression)
      Replace source alias in expression
      Parameters:
      oldAndNewAliases - strings array with old and new aliases
      expression - query schema expression
      Returns:
      true if source alias was found
    • replaceSourceAliasInExpression

      public static boolean replaceSourceAliasInExpression(String sourceAlias, String newSourceAlias, org.eclipse.emf.ecore.EObject expression)
      Replace source alias in expression
      Parameters:
      sourceAlias - source alias
      newSourceAlias - new source alias. If null, alias will not be replaced.
      expression - query schema expression
      Returns:
      true if source alias was found
    • getAggregateFromExpressions

      public static FunctionInvocationExpression getAggregateFromExpressions(org.eclipse.emf.common.util.EList<QuerySchemaExpression> fields)
      Is collection of expressions contain aggregate field
      Parameters:
      fields - fields list
      Returns:
      first found aggregate, if contained or null otherwise
    • getTempTablesNames

      public static Set<String> getTempTablesNames(QueryWizardSource source)
      Get temporary tables names used in query
      Parameters:
      source - query wizard source
      Returns:
      temporary tables names
    • getTempTablesNames

      public static List<String> getTempTablesNames(QueryWizardSource source, int endQueryIndex)
      Get temporary tables names available for query by index
      Parameters:
      source - - query wizard source
      endQueryIndex - - query index
      Returns:
      available temporary tables names
    • getTempTables

      public static Map<String,QuerySchemaSelectQuery> getTempTables(QueryWizardSource source)
      Get temporary tables available for current query
      Parameters:
      source - - query wizard source
      Returns:
      available temporary tables
    • getTempTables

      public static Map<String,QuerySchemaSelectQuery> getTempTables(QueryWizardSource source, int queryIndex)
      Get temporary tables available for query by index
      Parameters:
      source - - query wizard source
      queryIndex - - query index
      Returns:
      available temporary tables
    • getContainedAggregate

      public static FunctionInvocationExpression getContainedAggregate(AbstractExpression field)
      Get aggregate from expression
      Parameters:
      field - abstract expression
      Returns:
      aggregate, if contained or null otherwise
    • getTreeItemText

      public static String getTreeItemText(org.eclipse.swt.widgets.TreeItem item)
      Get tree item text, use '.' as separator for fields, and '[]' for nested table part.
      Parameters:
      item - tree item
      Returns:
      text for tree item
    • isTempTableDescription

      public static boolean isTempTableDescription(QuerySchemaSource source, QueryWizardSource qwSource)
      Is source temporary table description
      Parameters:
      source - - query schema source
      Returns:
      true if temporary table description
    • getTempTableDbView

      public static DbViewFromQuery getTempTableDbView(QuerySchemaSource source)
      Is source temporary table
      Parameters:
      source - - query schema source
      Returns:
      true if source is temporary table
    • getLocalName

      public static String getLocalName(Object element, ScriptVariant scriptVariant)
      Get object name, depending of script variant
      Parameters:
      element - - object for getting name
      scriptVariant - - configuration script variant
      Returns:
      object name
    • isContainOrder

      public static boolean isContainOrder(QueryWizardSource source, String value)
      Is order contain given expression
      Parameters:
      source - query wizard source
      value - expression or alias
      Returns:
      true if contain
    • isContainIndex

      public static boolean isContainIndex(QueryWizardSource source, String value)
      Is index contain given expression
      Parameters:
      source - query wizard source
      value - expression or alias
      Returns:
      true if contain
    • isContainTotal

      public static boolean isContainTotal(QueryWizardSource source, String value)
      Returns whether totals contain given expression
      Parameters:
      source - query wizard source
      value - expression or alias
      Returns:
      true if contain
    • isNumberExpression

      public static boolean isNumberExpression(QueryWizardSource source, QuerySchemaExpression expression)
      Returns whether expression have number type
      Parameters:
      source - - query wizard source
      expression - - expression
      Returns:
      is number type
    • getTempTableName

      public static String getTempTableName(QuerySchemaSource tempTable)
      Get temporary table description name
      Parameters:
      tempTable - - temporary table source
      Returns:
      table name
    • getAllJoins

      public static List<QuerySchemaQuerySourceJoin> getAllJoins(QueryWizardSource qwSource)
      Get all joins in operator
      Parameters:
      qwSource - - query wizard source
      Returns:
      all joins in current operator
    • getAllJoins

      public static List<QuerySchemaQuerySourceJoin> getAllJoins(QuerySchemaOperator operator)
      Get all joins in operator
      Parameters:
      operator - - operator
      Returns:
      all joins in current operator
    • getPlacementTable

      public static AbstractQuerySchemaTable getPlacementTable(QueryWizardSource source)
      Get table for placement from query
      Parameters:
      source - - query wizard control
      Returns:
      if query have table for placement - return table, otherwise null
    • validateResource

      public static String validateResource(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.validation.IResourceValidator resourceValidator)
      Checking query schema on errors
      Parameters:
      resource - - checking resource
      resourceValidator - - resource validator
      Returns:
      null if no errors or errors text description
    • validateResource

      public static String validateResource(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.xtext.validation.IResourceValidator resourceValidator, boolean onlyCritical)
      Checking query schema on errors
      Parameters:
      resource - - checking resource
      resourceValidator - - resource validator
      onlyCritical - - check only critical errors
      Returns:
      null if no errors or errors text description
    • addErrorMessage

      public static void addErrorMessage(StringBuilder errorMessage, String message, int lineNumber, int columnNumber)
      Append issue description to errors message
      Parameters:
      errorMessage - - errors messages list
      message - - new error message
      lineNumber - - line number with error
      columnNumber - - column number with error
    • computeDbViewForTempTable

      public static DbViewElement computeDbViewForTempTable(DbViewElement element, QueryWizardSource source)
      Compute DbView for temporary table. My be it from parent query (for nested query)
      Parameters:
      element - - temporary table dbview
      Returns:
      real dbview
    • getEmptyQuery

      public static String getEmptyQuery(ScriptVariant scriptVariant)
      Get empty query text
      Parameters:
      script - variant
      Returns:
      query text
    • getScriptVariant

      public static ScriptVariant getScriptVariant(org.eclipse.emf.ecore.EObject object)
      Get current script variant (English or Russian)
      Returns:
      script variant
    • getV8project

      public static IV8Project getV8project(org.eclipse.emf.ecore.EObject object)
      Get the V8 project by specified object.
      Returns:
      v8project the V8 project, never null
    • getAllNestedTables

      public static List<QuerySchemaExpression> getAllNestedTables(org.eclipse.emf.common.util.EList<QuerySchemaExpression> fields)
      Get all nested tables
      Parameters:
      fields - - fields collection
      Returns:
      nested tables collection
    • setCanMove

      public static void setCanMove(TreeViewer tree, org.eclipse.jface.action.Action moveUpAction, org.eclipse.jface.action.Action moveDownAction)
      Set enabled state for actions move up or move down
      Parameters:
      tree - - tree viewer
      moveUpAction - - move up action
      moveDownAction - - move down action
    • normalizeString

      public static String normalizeString(String text)
      Remove from text special characters and extra spaces
      Parameters:
      text - - text
      Returns:
      normalized text
    • getExpressionAlias

      public static String getExpressionAlias(QueryWizardSource source, QuerySchemaExpression expression)
      Get alias for expression
      Parameters:
      source - - query wizard source
      expression - - expression from select fields
      Returns:
      expression alias
    • getAliasImage

      public static org.eclipse.swt.graphics.Image getAliasImage(QueryWizardSource source, Object element)
      Get image for alias
      Parameters:
      source - query wizard source
      element - expression
      Returns:
      image. Return null if image not found.
    • getDbViewFieldFields

      public static List<DbViewFieldDef> getDbViewFieldFields(DbViewFieldDef sourceItem, QueryWizardSource queryWizardSource)
      Get children fields in field
      Parameters:
      sourceItem - - parent field, cannot be null
      queryWizardSource - - query wizard source, cannot be null
      Returns:
      children fields, never null, can be empty collection
    • getDbViewFieldFields

      public static List<DbViewFieldDef> getDbViewFieldFields(DbViewFieldDef sourceItem, QueryWizardSource queryWizardSource, boolean suppressNotifications)
      Get children fields in field
      Parameters:
      sourceItem - - parent field, cannot be null
      queryWizardSource - - query wizard source, cannot be null
      suppressNotifications - - notifications suppression flag
      Returns:
      children fields, never null, can be empty collection
    • getExpressionText

      public static String getExpressionText(Object element, QueryWizardSource source)
      Get text for expression
      Parameters:
      element - - expression
      source - - query wizard source return text
    • getExpressionText

      public static String getExpressionText(Object element, QueryWizardSource source, boolean removeLinesSeparators)
      Get text for expression
      Parameters:
      element - - expression
      source - - query wizard source
      removeLinesSeparators - - remove lines separators return text
    • getTypeAsString

      public static String getTypeAsString(TypeDescription type, QueryWizardSource source)
      Get TypeDescription as string
      Parameters:
      type - - TypeDescription
      source - - query wizard source
      Returns:
      string presentation
    • getQuerySchemaSourceFields

      public static List<? extends DbViewElement> getQuerySchemaSourceFields(Object sourceItem, QueryWizardSource queryWizardsource)
      Get fields for source or field from source
      Parameters:
      sourceItem - - source or field
      queryWizardsource - - query wizard source
      Returns:
      array of fields
    • getDcsFieldText

      public static String getDcsFieldText(Object element, QueryWizardSource source)
      Get dcs field text
      Parameters:
      element - - dcs expression
      source - - query wizard source
      Returns:
      expression text
    • getTypeAsString

      public static String getTypeAsString(TypeDescription type, QueryWizardSource source, ScriptVariant scriptVariant)
      Get TypeDescription as string
      Parameters:
      type - - TypeDescription
      source - - query wizard source
      scriptVariant - - script variant
      Returns:
      string presentation
    • validateAlias

      public static boolean validateAlias(QueryWizardControl queryWizard, String newAlias, List<String> existAliases)
      Check is valid alias for expression. Will show message dialog if not valid.
      Parameters:
      queryWizard - - query wizard dialog
      newAlias - - new alias
      existAliases - - exist aliases
      Returns:
      true if valid alias
    • getPresentationForRefExpression

      public static QuerySchemaExpression getPresentationForRefExpression(QueryWizardSource source, QuerySchemaExpression field)
      Get presentation for ref expression
      Parameters:
      source - - query wizard source
      field - - expression
      Returns:
      expression presentation or null if field not ref
    • isPresentationExpression

      public static boolean isPresentationExpression(AbstractExpression expression)
      Is expression contain PRESENTATION function
      Parameters:
      expression - - expression
      Returns:
      true if expression contain PRESENTATION function
    • isPresentationAlias

      public static boolean isPresentationAlias(QuerySchemaExpression expression, QueryWizardSource source)
      Is expressions from alias contain PRESENTATION function
      Parameters:
      expression - - expression from alias
      source - - query wizard source
      Returns:
      true if alias contain presentation function
    • isQueriesEquals

      public static boolean isQueriesEquals(String query1, String query2)
      Is queries text equals
      Parameters:
      query1 - - query text
      query2 - - query text
      Returns:
      true if equals otherwise false
    • prepareQueryForTextModule

      public static String prepareQueryForTextModule(String query, String lineFormatter, String lineSeparator)
      Prepare query text for text module
      Parameters:
      query - - query text
      lineFormatter - - line formatter
      lineSeparator - - line separator
      Returns:
      formatted query text for text module
    • createMessageDialog

      public static org.eclipse.jface.dialogs.MessageDialog createMessageDialog(org.eclipse.swt.widgets.Shell shell, String errorMessage, boolean askQuestion)
      Creates message dialog with text of errors and warnings from Query. Dialog will have one "OK" button if askQuestion is false or two buttons Yes and No if askQuestion is true. Also if askQuestion is true dialog will be Question dialog, otherwise Warning
      Parameters:
      shell - active Shell, cannot be null
      errorMessage - string contains all messages of errors and warnings, cannot be null
      Returns:
      created message dialog with text of errors and warnings from Query, never null
    • createMessageDialog

      public static org.eclipse.jface.dialogs.MessageDialog createMessageDialog(org.eclipse.swt.widgets.Shell shell, String errorMessage)
      Creates warning message dialog with text of errors and warnings from Query. Dialog will have one "OK" button.
      Parameters:
      shell - active Shell, cannot be null
      errorMessage - string contains all messages of errors and warnings, cannot be null
      Returns:
      created message dialog with text of errors and warnings from Query, never null
    • getDbViewElementFields

      public static List<DbViewFieldDef> getDbViewElementFields(DbViewElement element, QueryWizardSource source)
      Provides the list of fields for selected DbViewElement
      Parameters:
      element - current DbViewElement, cannot be null
      source - selected QueryWizardSource, cannot be null
      Returns:
      the list of fields, never null, can be empty collection
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(DbViewElement dbView, org.eclipse.core.resources.IProject project, IV8ProjectManager v8ProjectManager)
      Checks whether the DbViewElement belongs to the selected IProject
      Parameters:
      dbView - the dbView element, cannot be null
      project - the project, cannot be null
      v8ProjectManager - the v8 project manager, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(DbViewElement dbView, IV8Project v8Project, IV8ProjectManager v8ProjectManager)
      Checks whether the DbViewElement belongs to the selected IProject
      Parameters:
      dbView - the dbView element, cannot be null
      v8Project - the v8 project, cannot be null
      v8ProjectManager - the v8 project manager, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(org.eclipse.emf.ecore.EObject eObject, org.eclipse.core.resources.IProject project, IV8ProjectManager v8ProjectManager)
      Checks whether the EObject belongs to the selected IProject
      Parameters:
      eObject - the EObject, cannot be null
      project - the project, cannot be null
      v8ProjectManager - the v8 project manager, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(org.eclipse.emf.ecore.EObject eObject, IV8Project v8Project, IV8ProjectManager v8ProjectManager)
      Checks whether the EObject belongs to the selected IProject
      Parameters:
      eObject - the EObject, cannot be null
      v8Project - the v8 project, cannot be null
      v8ProjectManager - the v8 project manager, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(DbViewElement dbView, QueryWizardSource source)
      Checks whether the DbViewElement belongs to the IProject from selected QueryWizardSource
      Parameters:
      eObject - the dbView element, cannot be null
      source - the query wizard source, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isObjectBelongsToCurrentProject

      public static boolean isObjectBelongsToCurrentProject(org.eclipse.emf.ecore.EObject eObject, QueryWizardSource source)
      Checks whether the EObject belongs to the IProject from selected QueryWizardSource
      Parameters:
      eObject - the EObject, cannot be null
      source - the query wizard source, cannot be null
      Returns:
      true if element belongs to the project, false otherwise
    • isExtensionProject

      public static boolean isExtensionProject(org.eclipse.core.resources.IProject project, IV8ProjectManager v8ProjectManager)
      Checks whether the IProject is extension project
      Parameters:
      project - the IProject, cannot be null
      v8ProjectManager - the IV8ProjectManager, cannot be null
      Returns:
      true if the project is the extension, false otherwise
    • getParentProject

      public static org.eclipse.core.resources.IProject getParentProject(org.eclipse.core.resources.IProject project, IV8ProjectManager v8ProjectManager)
      Returns the parent project of IProject if it's extension project or null otherwise
      Parameters:
      project - the IProject, cannot be null
      v8ProjectManager - the IV8ProjectManager, cannot be null
      Returns:
      IProject if the project is the extension, null otherwise