1 package SL::Clipboard::RequirementSpecItem;
 
   5 use parent qw(SL::Clipboard::Base);
 
   7 use List::Util qw(sum);
 
  10 use SL::Locale::String;
 
  13   my ($self, $object) = @_;
 
  15   return $self->as_tree(_load_children($self->reload_object($object)), exclude => sub { ref($_[0]) !~ m/::RequirementSpecItem$/ });
 
  21   my $item              = $self->content;
 
  22   my $num_children      = @{ $item->{children} || [] };
 
  23   my $num_grandchildren = sum map { scalar(@{ $_->{children} || [] }) } @{ $item->{children} || [] };
 
  25   if ($item->{item_type} eq 'section') {
 
  26     return t8('Requirement spec section #1 "#2" with #3 function blocks and a total of #4 sub function blocks; preamble: "#5"',
 
  27               $item->{fb_number}, $item->{title}, $num_children, $num_grandchildren, Common::truncate($item->{description}, strip => 'full'));
 
  28   } elsif ($item->{item_type} eq 'function-block') {
 
  29     return t8('Requirement spec function block #1 with #2 sub function blocks; description: "#3"',
 
  30               $item->{fb_number}, $num_children, Common::truncate($item->{description}, strip => 'full'));
 
  32     return t8('Requirement spec sub function block #1; description: "#2"',
 
  33               $item->{fb_number}, Common::truncate($item->{description}, strip => 'full'));
 
  40   _load_children($_) for @{ $object->children };
 
  46   my ($self, $object) = @_;
 
  48   $object->$_(undef)     for qw(fb_number);
 
  49   $self->_fix_object($_) for @{ $object->children || [] };
 
  53   my ($self, $tree, $object) = @_;
 
  55   delete @{ $tree }{ qw(id itime mtime parent_id position requirement_spec_id) };
 
  56   $self->_fix_tree($_) for @{ $tree->{children} || [] };
 
  68 SL::Clipboard::RequirementSpecItem - Clipboard specialization for
 
  69 SL::DB::RequirementSpecItem
 
  77 Returns a human-readable description depending on the copied type
 
  78 (section, function block or sub function block).
 
  82 This specialization reloads C<$object> from the database, loads all of
 
  83 its children (but only the other requirement spec items, no other
 
  84 relationships) and dumps it.
 
  86 =item C<_fix_object $object>
 
  88 Fixes C<$object> and all of its children by clearing certain columns
 
  89 like the position or function block numbers.
 
  99 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>