<commit_before>module ApplicationController::CiProcessing
  extend ActiveSupport::Concern

  included do
    self.hide_action(:process_elements)
  end

  # Set Ownership selected db records
  def set_ownership(klass = "VmOrTemplate")
    assert_privileges(params[:pressed])
    @edit = Hash.new
    @edit[:key] = "ownership_edit__new"
    @edit[:current] = Hash.new
    @edit[:new] = Hash.new
    @edit[:klass] = klass.constantize
    # check to see if coming from show_list or drilled into vms from another CI
    if request.parameters[:controller] == "vm" || ["all_vms","vms", "instances", "images"].include?(params[:display])
      rec_cls = "vm"
    elsif ["miq_templates","images"].include?(params[:display]) || params[:pressed].starts_with?("miq_template_")
      rec_cls = "miq_template"
    else
      rec_cls = request.parameters[:controller]
    end
    recs = Array.new
    if !session[:checked_items].nil? && @lastaction == "set_checked_items"
      recs = session[:checked_items]
    else
      recs = find_checked_items
    end
    if recs.blank?
      recs = [params[:id].to_i]
    end
    if recs.length < 1
      add_flash(_("One or more %{model} must be selected to %{task}") % {:model=>Dictionary::gettext(db.to_s, :type=>:model, :notfound=>:titleize).pluralize, :task=>"Set Ownership"}, :error)
      @refresh_div = "flash_msg_div"
      @refresh_partial = "layouts/flash_msg"
      return
    else
      @edit[:ownership_items] = Array.new # Set the array of set ownership items
      recs.each do |r|
        @edit[:ownership_items].push(r.to_i)
      end<commit_msg>Refactor ownership items collection (transferred from ManageIQ/manageiq@b6<PASSWORD>965<PASSWORD>80)<commit_after>module ApplicationController::CiProcessing
  extend ActiveSupport::Concern

  included do
    self.hide_action(:process_elements)
  end

  # Set Ownership selected db records
  def set_ownership(klass = "VmOrTemplate")
    assert_privileges(params[:pressed])
    @edit = Hash.new
    @edit[:key] = "ownership_edit__new"
    @edit[:current] = Hash.new
    @edit[:new] = Hash.new
    @edit[:klass] = klass.constantize
    # check to see if coming from show_list or drilled into vms from another CI
    if request.parameters[:controller] == "vm" || ["all_vms","vms", "instances", "images"].include?(params[:display])
      rec_cls = "vm"
    elsif ["miq_templates","images"].include?(params[:display]) || params[:pressed].starts_with?("miq_template_")
      rec_cls = "miq_template"
    else
      rec_cls = request.parameters[:controller]
    end
    recs = Array.new
    if !session[:checked_items].nil? && @lastaction == "set_checked_items"
      recs = session[:checked_items]
    else
      recs = find_checked_items
    end
    if recs.blank?
      recs = [params[:id].to_i]
    end
    if recs.length < 1
      add_flash(_("One or more %{model} must be selected to %{task}") % {:model=>Dictionary::gettext(db.to_s, :type=>:model, :notfound=>:titleize).pluralize, :task=>"Set Ownership"}, :error)
      @refresh_div = "flash_msg_div"
      @refresh_partial = "layouts/flash_msg"
      return
    else
      @edit[:ownership_items] = recs.collect(&:to_i)
{'fraction_non_alphanumeric': 0.1373852484963596, 'fraction_numerical': 0.0025324469768914213, 'mean_word_length': 3.876543209876543, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '412553', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1030, 'n_words': 219}