<commit_before>class TreeBuilder
  include CompressedIds
  attr_reader :name, :type, :tree_nodes

  def self.class_for_type(type)
    case type
    when :filter           then raise('Obsolete tree type.')
    # Catalog explorer trees
    when :configuration_manager_providers then TreeBuilderConfigurationManager
    when :cs_filter                       then TreeBuilderConfigurationManagerConfiguredSystems

    # Catalog explorer trees
    when :ot               then TreeBuilderOrchestrationTemplates
    when :sandt            then TreeBuilderCatalogItems
    when :stcat            then TreeBuilderCatalogs
    when :svccat           then TreeBuilderServiceCatalog

    # Chargeback explorer trees
    when :cb_assignments   then TreeBuilderChargebackAssignments
    when :cb_rates         then TreeBuilderChargebackRates
    when :cb_reports       then TreeBuilderChargebackReports

    when :vandt            then TreeBuilderVandt
    when :vms_filter       then TreeBuilderVmsFilter
    when :templates_filter then TreeBuilderTemplateFilter

    when :instances        then TreeBuilderInstances
    when :images           then TreeBuilderImages
    when :instances_filter then TreeBuilderInstancesFilter
    when :images_filter    then TreeBuilderImagesFilter
    when :vms_instances_filter    then TreeBuilderVmsInstancesFilter
    when :templates_images_filter then TreeBuilderTemplatesImagesFilter

    when :policy_profile   then TreeBuilderPolicyProfile
    when :policy           then TreeBuilderPolicy
    when :event            then TreeBuilderEvent
    when :condition        then TreeBuilderCondition
    when :action           then TreeBuilderAction
    when :alert_profile    then TreeBuilderAlertProfile
    when :alert            then TreeBuilderAlert

    # reports explorer trees
    when :db               then TreeBuilderReportDashboards
    when :export           then TreeBuilderReportExport
    when :reports          then TreeBuilderReportReports
    when :roles            then TreeBuilderReportRoles
    when :savedreports     then TreeBuilderReportSavedReports
    when :schedules        then TreeBuilderReportSchedules
    when :widgets          then TreeBuilderReportWidgets

    # containers explorer tree
    when :containers         then TreeBuilderContainers
    when :containers_filter  then TreeBuilderContainersFilter

    # automate explorer tree
    when :ae               then TreeBuilderAeClass

    # miq_ae_customization explorer trees
    when :ab                    then TreeBuilderButtons
    when :dialogs               then TreeBuilderServiceDialogs
    when :dialog_import_export  then TreeBuilderAeCustomization
    when :old_dialogs           then TreeBuilderProvisioningDialogs

    # OPS explorer trees
    when :analytics             then TreeBuilderOpsAnalytics
    when :diagnostics           then TreeBuilderOpsDiagnostics
    when :rbac                  then TreeBuilderOpsRbac
    when :settings              then TreeBuilderOpsSettings
    when :vmdb                  then TreeBuilderOpsVmdb

    # PXE explorer trees
    when :customization_templates then TreeBuilderPxeCustomizationTemplates
    when :iso_datastores          then TreeBuilderIsoDatastores
    when :pxe_image_types         then TreeBuilderPxeImageTypes
    when :pxe_servers             then TreeBuilderPxeServers

    # Services explorer tree
    when :svcs                    then TreeBuilderServices

    end
  end

  def root_options
    TreeBuilder.root_options(@name)
  end

  # FIXME: need to move this to a subclass (#root_options)
  def self.root_options(tree_name)
    # returns title, tooltip, root icon
    case tree_name
    when :ab_tree                       then [_("Object Types"),                 _("Object Types")]
    when :ae_tree                       then [_("Datastore"),                    _("Datastore")]
    when :automate_tree                 then [_("Datastore"),                    _("Datastore")]
    when :bottlenecks_tree, :utilization_tree then
      if MiqEnterprise.my_enterprise.is_enterprise?
        title = _("Enterprise")
        icon  = "enterprise"
      else # FIXME: string CFME below
        title = _("CFME Region: %{region_description} [%{region}]") %
                {:region_description => MiqRegion.my_region.description, :region => MiqRegion.my_region.region}
        icon  = "miq_region"
      end
      [title, title, icon]
    when :cb_assignments_tree           then [_("Assignments"),                    _("Assignments")]
    when :cb_rates_tree                 then [_("Rates"),                          _("Rates")]
    when :cb_reports_tree               then [_("Saved Chargeback Reports"),       _("Saved Chargeback Reports")]
    when :containers_tree               then [_("All Containers"),                 _("All Containers")]
    when :containers_filter_tree        then [_("All Containers"),                 _("All Containers")]
    when :cs_filter_tree                then [_("All Configured Systems"),         _("All Configured Systems")]
    when :customization_templates_tree  then
      title = "All #{ui_lookup(:models => 'CustomizationTemplate')} - #{ui_lookup(:models => 'PxeImageType')}"
      [title, title]
    when :db_tree                       then [_("All Dashboards"), _("All Dashboards")]
    when :diagnostics_tree, :rbac_tree, :settings_tree     then
      region = MiqRegion.my_region
      ["CFME Region: #{region.description} [#{region.region}]", "CFME Region: #{region.description} [#{region.region}]", "miq_region"]
    when :dialogs_tree                  then [_("All Dialogs"),                  _("All Dialogs")]
    when :dialog_import_export_tree     then [_("Service Dialog Import/Export"), _("Service Dialog Import/Export")]
    when :export_tree                   then [_("Import / Export"),              _("Import / Export"), _("report")]
    when :images_tree                   then [_("Images by Provider"),           _("All Images by Provider that I can see")]
    when :instances_tree                then [_("Instances by Provider"),        _("All Instances by Provider that I can see")]
    when :instances_filter_tree         then [_("All Instances"),                _("All of the Instances that I can see")]
    when :images_filter_tree            then [_("All Images"),                   _("All of the Images that I can see")]
    when :iso_datastores_tree           then [_("All ISO Datastores"),           _("All ISO Datastores")]
    when :old_dialogs_tree              then [_("All Dialogs"),                  _("All Dialogs")]
    when :ot_tree                       then [_("All Orchestration Templates"),  _("All Orchestration Templates")]
    when :configuration_manager_providers_tree        then
      title = "All #{ui_lookup(:ui_title => "configuration_manager")} Providers"
      [title, title]
    when :pxe_image_types_tree          then [_("All System Image Types"),       _("All System Image Types")]
    when :pxe_servers_tree              then [_("All PXE Servers"),              _("All PXE Servers")]
    when :reports_tree                  then [_("All Reports"),                  _("All Reports")]
    when :roles_tree                    then
      user = User.current_user
      if user.super_admin_user?
        title = _("All %{models}") % {:models => ui_lookup(:models => "MiqGroup")}
      else
        title = _("My %{models}") % {:models => ui_lookup(:models => "MiqGroup")}
      end
      [title, title, 'miq_group']
    when :sandt_tree                    then [_("All Catalog Items"),            _("All Catalog Items")]
    when :savedreports_tree             then [_("All Saved Reports"),            _("All Saved Reports")]
    when :schedules_tree                then [_("All Schedules"),                _("All Schedules"), "miq_schedule"]
    when :stcat_tree                    then [_("All Catalogs"),                 _("All Catalogs")]
    when :svccat_tree                   then [_("All Services"),                 _("All Services")]
    when :svcs_tree                     then [_("All Services"),                 _("All Services")]
    when :vandt_tree                    then [_("All VMs & Templates"),          _("All VMs & Templates that I can see")]
    when :vms_filter_tree               then [_("All VMs"),                      _("All of the VMs that I can see")]
    when :templates_filter_tree         then [_("All Templates"),                _("All of the Templates that I can see")]
    when :vms_instances_filter_tree     then [_("All VMs & Instances"),          _("All of the VMs & Instances that I can see")]
    when :templates_images_filter_tree  then [_("All Templates & Images"),       _("All of the Templates & Images that I can see")]
    when :vmdb_tree                     then [_("VMDB"),                         _("VMDB"), "miq_database"]
    when :widgets_tree                  then [_("All Widgets"),                  _("All Widgets")]
    end
  end

  def initialize(name, type, sandbox, build = true)
    @tree_state = TreeState.new(sandbox)
    @sb = sandbox # FIXME: some subclasses still access @sb
<commit_msg>Convert icon filename in tree builder presenter into a symbol<commit_after>class TreeBuilder
  include CompressedIds
  attr_reader :name, :type, :tree_nodes

  def self.class_for_type(type)
    case type
    when :filter           then raise('Obsolete tree type.')
    # Catalog explorer trees
    when :configuration_manager_providers then TreeBuilderConfigurationManager
    when :cs_filter                       then TreeBuilderConfigurationManagerConfiguredSystems

    # Catalog explorer trees
    when :ot               then TreeBuilderOrchestrationTemplates
    when :sandt            then TreeBuilderCatalogItems
    when :stcat            then TreeBuilderCatalogs
    when :svccat           then TreeBuilderServiceCatalog

    # Chargeback explorer trees
    when :cb_assignments   then TreeBuilderChargebackAssignments
    when :cb_rates         then TreeBuilderChargebackRates
    when :cb_reports       then TreeBuilderChargebackReports

    when :vandt            then TreeBuilderVandt
    when :vms_filter       then TreeBuilderVmsFilter
    when :templates_filter then TreeBuilderTemplateFilter

    when :instances        then TreeBuilderInstances
    when :images           then TreeBuilderImages
    when :instances_filter then TreeBuilderInstancesFilter
    when :images_filter    then TreeBuilderImagesFilter
    when :vms_instances_filter    then TreeBuilderVmsInstancesFilter
    when :templates_images_filter then TreeBuilderTemplatesImagesFilter

    when :policy_profile   then TreeBuilderPolicyProfile
    when :policy           then TreeBuilderPolicy
    when :event            then TreeBuilderEvent
    when :condition        then TreeBuilderCondition
    when :action           then TreeBuilderAction
    when :alert_profile    then TreeBuilderAlertProfile
    when :alert            then TreeBuilderAlert

    # reports explorer trees
    when :db               then TreeBuilderReportDashboards
    when :export           then TreeBuilderReportExport
    when :reports          then TreeBuilderReportReports
    when :roles            then TreeBuilderReportRoles
    when :savedreports     then TreeBuilderReportSavedReports
    when :schedules        then TreeBuilderReportSchedules
    when :widgets          then TreeBuilderReportWidgets

    # containers explorer tree
    when :containers         then TreeBuilderContainers
    when :containers_filter  then TreeBuilderContainersFilter

    # automate explorer tree
    when :ae               then TreeBuilderAeClass

    # miq_ae_customization explorer trees
    when :ab                    then TreeBuilderButtons
    when :dialogs               then TreeBuilderServiceDialogs
    when :dialog_import_export  then TreeBuilderAeCustomization
    when :old_dialogs           then TreeBuilderProvisioningDialogs

    # OPS explorer trees
    when :analytics             then TreeBuilderOpsAnalytics
    when :diagnostics           then TreeBuilderOpsDiagnostics
    when :rbac                  then TreeBuilderOpsRbac
    when :settings              then TreeBuilderOpsSettings
    when :vmdb                  then TreeBuilderOpsVmdb

    # PXE explorer trees
    when :customization_templates then TreeBuilderPxeCustomizationTemplates
    when :iso_datastores          then TreeBuilderIsoDatastores
    when :pxe_image_types         then TreeBuilderPxeImageTypes
    when :pxe_servers             then TreeBuilderPxeServers

    # Services explorer tree
    when :svcs                    then TreeBuilderServices

    end
  end

  def root_options
    TreeBuilder.root_options(@name)
  end

  # FIXME: need to move this to a subclass (#root_options)
  def self.root_options(tree_name)
    # returns title, tooltip, root icon
    case tree_name
    when :ab_tree                       then [_("Object Types"),                 _("Object Types")]
    when :ae_tree                       then [_("Datastore"),                    _("Datastore")]
    when :automate_tree                 then [_("Datastore"),                    _("Datastore")]
    when :bottlenecks_tree, :utilization_tree then
      if MiqEnterprise.my_enterprise.is_enterprise?
        title = _("Enterprise")
        icon  = :enterprise
      else # FIXME: string CFME below
        title = _("CFME Region: %{region_description} [%{region}]") %
                {:region_description => MiqRegion.my_region.description, :region => MiqRegion.my_region.region}
        icon  = :miq_region
      end
      [title, title, icon]
    when :cb_assignments_tree           then [_("Assignments"),                    _("Assignments")]
    when :cb_rates_tree                 then [_("Rates"),                          _("Rates")]
    when :cb_reports_tree               then [_("Saved Chargeback Reports"),       _("Saved Chargeback Reports")]
    when :containers_tree               then [_("All Containers"),                 _("All Containers")]
    when :containers_filter_tree        then [_("All Containers"),                 _("All Containers")]
    when :cs_filter_tree                then [_("All Configured Systems"),         _("All Configured Systems")]
    when :customization_templates_tree  then
      title = "All #{ui_lookup(:models => 'CustomizationTemplate')} - #{ui_lookup(:models => 'PxeImageType')}"
      [title, title]
    when :db_tree                       then [_("All Dashboards"), _("All Dashboards")]
    when :diagnostics_tree, :rbac_tree, :settings_tree     then
      region = MiqRegion.my_region
      [_("CFME Region: %{region_description} [%{region}]") % {:region_description => region.description,
                                                              :region             => region.region},
       _("CFME Region: %{region_description} [%{region}]") % {:region_description => region.description,
                                                              :region             => region.region},
       :miq_region]
    when :dialogs_tree                  then [_("All Dialogs"),                  _("All Dialogs")]
    when :dialog_import_export_tree     then [_("Service Dialog Import/Export"), _("Service Dialog Import/Export")]
    when :export_tree                   then [_("Import / Export"),              _("Import / Export"), :report]
    when :images_tree                   then [_("Images by Provider"),           _("All Images by Provider that I can see")]
    when :instances_tree                then [_("Instances by Provider"),        _("All Instances by Provider that I can see")]
    when :instances_filter_tree         then [_("All Instances"),                _("All of the Instances that I can see")]
    when :images_filter_tree            then [_("All Images"),                   _("All of the Images that I can see")]
    when :iso_datastores_tree           then [_("All ISO Datastores"),           _("All ISO Datastores")]
    when :old_dialogs_tree              then [_("All Dialogs"),                  _("All Dialogs")]
    when :ot_tree                       then [_("All Orchestration Templates"),  _("All Orchestration Templates")]
    when :configuration_manager_providers_tree        then
      title = "All #{ui_lookup(:ui_title => "configuration_manager")} Providers"
      [title, title]
    when :pxe_image_types_tree          then [_("All System Image Types"),       _("All System Image Types")]
    when :pxe_servers_tree              then [_("All PXE Servers"),              _("All PXE Servers")]
    when :reports_tree                  then [_("All Reports"),                  _("All Reports")]
    when :roles_tree                    then
      user = User.current_user
      if user.super_admin_user?
        title = _("All %{models}") % {:models => ui_lookup(:models => "MiqGroup")}
      else
        title = _("My %{models}") % {:models => ui_lookup(:models => "MiqGroup")}
      end
      [title, title, :miq_group]
    when :sandt_tree                    then [_("All Catalog Items"),            _("All Catalog Items")]
    when :savedreports_tree             then [_("All Saved Reports"),            _("All Saved Reports")]
    when :schedules_tree                then [_("All Schedules"),                _("All Schedules"), :miq_schedule]
    when :stcat_tree                    then [_("All Catalogs"),                 _("All Catalogs")]
    when :svccat_tree                   then [_("All Services"),                 _("All Services")]
    when :svcs_tree                     then [_("All Services"),                 _("All Services")]
    when :vandt_tree                    then [_("All VMs & Templates"),          _("All VMs & Templates that I can see")]
    when :vms_filter_tree               then [_("All VMs"),                      _("All of the VMs that I can see")]
    when :templates_filter_tree         then [_("All Templates"),                _("All of the Templates that I can see")]
    when :vms_instances_filter_tree     then [_("All VMs & Instances"),          _("All of the VMs & Instances that I can see")]
    when :templates_images_filter_tree  then [_("All Templates & Images"),       _("All of the Templates & Images that I can see")]
    when :vmdb_tree                     then [_("VMDB"),                         _("VMDB"), :miq_database]
    when :widgets_tree                  then [_("All Widgets"),                  _("All Widgets")]
    end
  end

  def initialize(name, type, sandbox, build = true)
    @tree_state = TreeState.new(sandbox)
    @sb = sandbox # FIXME: some subclasses still access @sb

{'fraction_non_alphanumeric': 0.08128025820333512, 'fraction_numerical': 0.0, 'mean_word_length': 2.145685279187817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1758382', 'n_tokens_mistral': 4941, 'n_tokens_neox': 4667, 'n_words': 1421}