def cleanup_parameter_values
        abandoned_parameter_values = Discerner::ParameterValue.order(:id).to_a - updated_parameter_values - blank_parameter_values

        if self.options[:prune_dictionaries].blank?
          notification_message "if option --prune_dictionaries is not specified, parameter values for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
          abandoned_parameter_values = abandoned_parameter_values.reject{|v| abandoned_dictionaries.include?(v.parameter.parameter_category.dictionary)}
        end

        used_parameter_values      = abandoned_parameter_values.select{|p| p.used_in_search?}
        not_used_parameter_values  = abandoned_parameter_values - used_parameter_values

        used_parameter_values.each do |r|
          notification_message("marking parameter value #{r.name} as deleted");
          r.deleted_at = Time.now
          error_message "parameter value could not be marked as deleted: #{r.errors.full_messages}", r.name unless r.save
        end

        unless not_used_parameter_values.blank?
          notification_message("permanently deleting parameter values #{not_used_parameter_values.map{|r| r.name}.join(', ')}");
          not_used_parameter_values.each{|r| r.destroy}
        end
      end
def cleanup_parameter_values
        abandoned_parameter_values = Discerner::ParameterValue.order(:id).to_a - updated_parameter_values - blank_parameter_values

        if self.options[:prune_dictionaries].blank?
          notification_message "if option --prune_dictionaries is not specified, parameter values for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
          abandoned_parameter_values = abandoned_parameter_values.reject{|v| abandoned_dictionaries.include?(v.parameter.parameter_category.dictionary)}
        end

        used_parameter_values      = abandoned_parameter_values.select{|p| p.used_in_search?}
        not_used_parameter_values  = abandoned_parameter_values - used_parameter_values

        used_parameter_values.each do |r|
          notification_message("marking parameter value #{r.name} as deleted");
          r.deleted_at = Time.now
          error_message "parameter value could not be marked as deleted: #{r.errors.full_messages}", r.name unless r.save
        end

        unless not_used_parameter_values.blank?
          notification_message("permanently deleting parameter values #{not_used_parameter_values.map{|r| r.name}.join(', ')}");
          not_used_parameter_values.each{|r| r.destroy}
        end
      end
this also marks search_parameter_values that reference this value and are chosen as deleted
 and destroys search_parameter_values that reference this value but are not chosen (list options)