<commit_before>package EnsEMBL::Web::Command::Account::ShareRecord;

use strict;
use warnings;

use Class::Std;

use EnsEMBL::Web::RegObj;
use EnsEMBL::Web::Data::Group;

use base 'EnsEMBL::Web::Command';

{

sub process {
  my $self = shift;
  my $object = $self->object;

  my $user = $EnsEMBL::Web::RegObj::ENSEMBL_WEB_REGISTRY->get_user;
  my $accessor = lc($object->param('type')).'s';

  my ($records_accessor) = grep { $_ eq $accessor } keys %{ $user->relations };
  ## TODO: this should use abstraction limiting facility rather then grep

  my ($user_record)      = grep { $_->id == $object->param('id') } $user->$records_accessor;

  my $group = EnsEMBL::Web::Data::Group->new($object->param('webgroup_id'));

  if ($user_record && $group) {
    my $add_to_accessor = 'add_to_'. $records_accessor;
    my $clone = $user_record->clone;
    $group->$add_to_accessor($user_record->clone);
  } 
  #else {
  #  ## TODO: error exception
  #}
  my $url;
  my $param = {
    'id' => $group->id,
    '_referer' => $object->param('_referer'),
    'x_requested_with' => $object->param('x_requested_with'),
  };
  if ($user->is_administrator_of($group)) {
    $url = '/Account/Group/List';<commit_msg>* new way of cloning record from user to grup (share)<commit_after>package EnsEMBL::Web::Command::Account::ShareRecord;

use strict;
use warnings;

use Class::Std;

use EnsEMBL::Web::RegObj;
use EnsEMBL::Web::Data::Group;

use base 'EnsEMBL::Web::Command';

{

sub process {
  my $self = shift;
  my $object = $self->object;

  my $user = $EnsEMBL::Web::RegObj::ENSEMBL_WEB_REGISTRY->get_user;

  my ($records_accessor) = grep { $_ eq $accessor } keys %{ $user->relations };
  ## TODO: this should use abstraction limiting facility rather then grep

  my ($user_record) = $user->records($object->param('id'));
  my $group = EnsEMBL::Web::Data::Group->new($object->param('webgroup_id'));

  if ($user_record && $group) {
    my $clone = $user_record->clone;
    $clone->owner($group);
    $clone->save;
  }
  #else {
  #  ## TODO: error exception
  #}

  my $url;
  my $param = {
    'id' => $group->id,
    '_referer' => $object->param('_referer'),
    'x_requested_with' => $object->param('x_requested_with'),
  };
  if ($user->is_administrator_of($group)) {
    $url = '/Account/Group/List';
{'fraction_non_alphanumeric': 0.19030990833697076, 'fraction_numerical': 0.0, 'mean_word_length': 4.418439716312057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, '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': '5930283', 'n_tokens_mistral': 873, 'n_tokens_neox': 828, 'n_words': 168}