Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d41162bc

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID d41162bc35f9555f6bb40f45b18e52ed8824b2fc
  • Vorgänger 9cddaf37
  • Nachfolger 76105d15

Pflichnhefttextblöcke: Kopieren/Einfügen mit Bildern gefixt

Unterschiede anzeigen:

SL/Clipboard/Base.pm
69 69
  }
70 70
}
71 71

  
72
sub _binary_column_names {
73
  my ($self, $class) = @_;
74
  return map  { $_->name }
75
         grep { ref($_) =~ m/Pg::Bytea$/i }
76
         @{ $class->meta->columns };
77
}
78

  
72 79
1;
73 80
__END__
74 81

  
......
187 194
Returns the actual clipped type (e.g. C<RequirementSpecItem>). This is
188 195
derived from the actual class name of C<$self>.
189 196

  
197
=item C<_binary_column_names $class>
198

  
199
Returns an array of column names that have a binary type. Useful for
200
sub-classes which need to encode binary content in Base64 during
201
C<dump>.
202

  
190 203
=item C<_fix_object $object>
191 204

  
192 205
This function is called by L</to_object> before the object is passed
SL/Clipboard/RequirementSpecPicture.pm
1
package SL::Clipboard::RequirementSpecPicture;
2

  
3
use strict;
4

  
5
use parent qw(SL::Clipboard::Base);
6

  
7
use SL::Common;
8
use SL::Locale::String;
9
use MIME::Base64;
10

  
11
sub dump {
12
  my ($self, $object) = @_;
13

  
14
  $self->reload_object($object);
15

  
16
  my $tree    = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecPicture$/ });
17
  $tree->{$_} = encode_base64($tree->{$_}, '') for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
18

  
19
  return $tree;
20
}
21

  
22
sub describe {
23
  my ($self) = @_;
24

  
25
  return t8('Requirement spec picture "#1"', $self->content->{description} ? $self->content->{description} . ' (' . $self->content->{picture_file_name} . ')' : $self->content->{picture_file_name});
26
}
27

  
28
sub _fix_object {
29
  my ($self, $object) = @_;
30

  
31
  $object->$_(undef) for qw(number);
32
  $object->$_(decode_base64($object->$_)) for $self->_binary_column_names('SL::DB::RequirementSpecPicture');
33

  
34
  return $object;
35
}
36

  
37
1;
38
__END__
39

  
40
=pod
41

  
42
=encoding utf8
43

  
44
=head1 NAME
45

  
46
SL::Clipboard::RequirementSpecPicture - Clipboard specialization for
47
SL::DB::RequirementSpecPicture
48

  
49
=head1 NOTES
50

  
51
The underlying RDBO model contains binary columns, but binary data
52
cannot be dumped as YAML. Therefore the binary content is encoded in
53
Base64 in L</dump> and decoded back to binary form in L</_fix_object>.
54

  
55
=head1 FUNCTIONS
56

  
57
=over 4
58

  
59
=item C<describe>
60

  
61
Returns a human-readable description including the title and an
62
excerpt of its content.
63

  
64
=item C<dump $object>
65

  
66
This specialization reloads C<$object> from the database, and dumps
67
it. Binary columns are dumped encoded in Base64.
68

  
69
=item C<_fix_object $object>
70

  
71
Fixes C<$object> by clearing certain columns like the number. Also
72
decodes binary columns from Base64 back to binary.
73

  
74
=back
75

  
76
=head1 BUGS
77

  
78
Nothing here yet.
79

  
80
=head1 AUTHOR
81

  
82
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
83

  
84
=cut
SL/Clipboard/RequirementSpecTextBlock.pm
4 4

  
5 5
use parent qw(SL::Clipboard::Base);
6 6

  
7
use SL::Clipboard::RequirementSpecPicture;
7 8
use SL::Common;
8 9
use SL::Locale::String;
9 10

  
11
sub dump {
12
  my ($self, $object) = @_;
13

  
14
  $self->reload_object($object);
15

  
16
  my $tree          = $self->as_tree($object, exclude => sub { ref($_[0]) !~ m/::RequirementSpecTextBlock$/ });
17
  $tree->{pictures} = [ map { SL::Clipboard::RequirementSpecPicture->new->dump($_) } @{ $object->pictures } ];
18

  
19
  return $tree;
20
}
21

  
10 22
sub describe {
11 23
  my ($self) = @_;
12 24

  
......
18 30

  
19 31
  $object->$_(undef) for qw(output_position position requirement_spec_id);
20 32

  
33
  SL::Clipboard::RequirementSpecPicture->new->_fix_object($_) for @{ $object->pictures || [] };
34

  
21 35
  return $object;
22 36
}
23 37

  
......
42 56
Returns a human-readable description including the title and an
43 57
excerpt of its content.
44 58

  
59
=item C<dump $object>
60

  
61
This specialization reloads C<$object> from the database, loads all of
62
its pictures and dumps it. The pictures are dumped using the clipboard
63
specialization for it, L<SL::Clipboard::RequirementSpecPicture/dump>.
64

  
45 65
=item C<_fix_object $object>
46 66

  
47
Fixes C<$object> by clearing certain columns like the position.
67
Fixes C<$object> by clearing certain columns like the position. Lets
68
pictures be fixed by the clipboard specialization for it,
69
L<SL::Clipboard::RequirementSpecPicture/_fix_object>.
48 70

  
49 71
=back
50 72

  
locale/de/all
1918 1918
  'Requirement Specs'           => 'Pflichtenhefte',
1919 1919
  'Requirement spec actions'    => 'Pflichtenheftaktionen',
1920 1920
  'Requirement spec function block #1 with #2 sub function blocks; description: "#3"' => 'Pflichtenheft-Funktionsblock #1 mit #2 Unterfunktionsblöcken; Beschreibung: "#3"',
1921
  'Requirement spec picture "#1"' => 'Pflichtenheftbild "#1"',
1921 1922
  '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"',
1922 1923
  'Requirement spec sub function block #1; description: "#2"' => 'Pflichtenheft-Unterfunktionsblock #1; Beschreibung: "#2"',
1923 1924
  'Requirement spec template \'#1\'' => 'Pflichtenheftvorlage \'#1\'',

Auch abrufbar als: Unified diff