1 package SL::DB::RequirementSpec;
7 use SL::DB::MetaSetup::RequirementSpec;
8 use SL::DB::Manager::RequirementSpec;
9 use SL::Locale::String;
11 __PACKAGE__->meta->add_relationship(
13 type => 'one to many',
14 class => 'SL::DB::RequirementSpecItem',
15 column_map => { id => 'requirement_spec_id' },
18 type => 'one to many',
19 class => 'SL::DB::RequirementSpecTextBlock',
20 column_map => { id => 'requirement_spec_id' },
24 __PACKAGE__->meta->initialize;
26 __PACKAGE__->before_save('_before_save_initialize_not_null_columns');
32 push @errors, t8('The title is missing.') if !$self->title;
37 sub _before_save_initialize_not_null_columns {
40 $self->previous_section_number(0) if !defined $self->previous_section_number;
41 $self->previous_fb_number(0) if !defined $self->previous_fb_number;
46 sub text_blocks_for_position {
47 my ($self, $output_position) = @_;
49 return [ sort { $a->position <=> $b->position } grep { $_->output_position == $output_position } @{ $self->text_blocks } ];
53 my ($self, @rest) = @_;
55 croak "This sub is not a writer" if @rest;
57 return [ sort { $a->position <=> $b->position } grep { !$_->parent_id } @{ $self->items } ];
60 sub displayable_name {
63 return sprintf('%s: "%s"', $self->type->description, $self->title);