}
}
+sub _binary_column_names {
+ my ($self, $class) = @_;
+ return map { $_->name }
+ grep { ref($_) =~ m/Pg::Bytea$/i }
+ @{ $class->meta->columns };
+}
+
1;
__END__
Returns the actual clipped type (e.g. C<RequirementSpecItem>). This is
derived from the actual class name of C<$self>.
+=item C<_binary_column_names $class>
+
+Returns an array of column names that have a binary type. Useful for
+sub-classes which need to encode binary content in Base64 during
+C<dump>.
+
=item C<_fix_object $object>
This function is called by L</to_object> before the object is passed
--- /dev/null
+package SL::Clipboard::RequirementSpecPicture;
+
+use strict;
+
+use parent qw(SL::Clipboard::Base);
+
+use SL::Common;
+use SL::Locale::String;
+use MIME::Base64;
+
+sub dump {
+ my ($self, $object) = @_;
+
+ $self->reload_object($object);
+
+ my $tree = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecPicture$/ });
+ $tree->{$_} = encode_base64($tree->{$_}, '') for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
+
+ return $tree;
+}
+
+sub describe {
+ my ($self) = @_;
+
+ return t8('Requirement spec picture "#1"', $self->content->{description} ? $self->content->{description} . ' (' . $self->content->{picture_file_name} . ')' : $self->content->{picture_file_name});
+}
+
+sub _fix_object {
+ my ($self, $object) = @_;
+
+ $object->$_(undef) for qw(number);
+ $object->$_(decode_base64($object->$_)) for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
+
+ return $object;
+}
+
+1;
+__END__
+
+=pod
+
+=encoding utf8
+
+=head1 NAME
+
+SL::Clipboard::RequirementSpecPicture - Clipboard specialization for
+SL::DB::RequirementSpecPicture
+
+=head1 NOTES
+
+The underlying RDBO model contains binary columns, but binary data
+cannot be dumped as YAML. Therefore the binary content is encoded in
+Base64 in L</dump> and decoded back to binary form in L</_fix_object>.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item C<describe>
+
+Returns a human-readable description including the title and an
+excerpt of its content.
+
+=item C<dump $object>
+
+This specialization reloads C<$object> from the database, and dumps
+it. Binary columns are dumped encoded in Base64.
+
+=item C<_fix_object $object>
+
+Fixes C<$object> by clearing certain columns like the number. Also
+decodes binary columns from Base64 back to binary.
+
+=back
+
+=head1 BUGS
+
+Nothing here yet.
+
+=head1 AUTHOR
+
+Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
+
+=cut
use parent qw(SL::Clipboard::Base);
+use SL::Clipboard::RequirementSpecPicture;
use SL::Common;
use SL::Locale::String;
+sub dump {
+ my ($self, $object) = @_;
+
+ $self->reload_object($object);
+
+ my $tree = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecTextBlock$/ });
+ $tree->{pictures} = [ map { SL::Clipboard::RequirementSpecPicture->new->dump($_) } @{ $object->pictures } ];
+
+ return $tree;
+}
+
sub describe {
my ($self) = @_;
$object->$_(undef) for qw(output_position position requirement_spec_id);
+ SL::Clipboard::RequirementSpecPicture->new->_fix_object($_) for @{ $object->pictures || [] };
+
return $object;
}
Returns a human-readable description including the title and an
excerpt of its content.
+=item C<dump $object>
+
+This specialization reloads C<$object> from the database, loads all of
+its pictures and dumps it. The pictures are dumped using the clipboard
+specialization for it, L<SL::Clipboard::RequirementSpecPicture/dump>.
+
=item C<_fix_object $object>
-Fixes C<$object> by clearing certain columns like the position.
+Fixes C<$object> by clearing certain columns like the position. Lets
+pictures be fixed by the clipboard specialization for it,
+L<SL::Clipboard::RequirementSpecPicture/_fix_object>.
=back
'Requirement Specs' => 'Pflichtenhefte',
'Requirement spec actions' => 'Pflichtenheftaktionen',
'Requirement spec function block #1 with #2 sub function blocks; description: "#3"' => 'Pflichtenheft-Funktionsblock #1 mit #2 Unterfunktionsblöcken; Beschreibung: "#3"',
+ 'Requirement spec picture "#1"' => 'Pflichtenheftbild "#1"',
'Requirement spec section #1 "#2" with #3 function blocks and a total of #4 sub function blocks; preamble: "#5"' => 'Pflichtenheftabschnitt #1 "#2" mit #3 Funktionsblöcken und insgesamt #4 Unterfunktionsblöcken; Einleitung: "#5"',
'Requirement spec sub function block #1; description: "#2"' => 'Pflichtenheft-Unterfunktionsblock #1; Beschreibung: "#2"',
'Requirement spec template \'#1\'' => 'Pflichtenheftvorlage \'#1\'',