X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/4f5ea8fb2c1a3937b704a17f34d4004aa2d1c473..2eb2bc5583f28aa5f9bb18c2cd314995d0570f8c:/SL/DB/RequirementSpecItem.pm diff --git a/SL/DB/RequirementSpecItem.pm b/SL/DB/RequirementSpecItem.pm index 5ea599f89..5e7d46c91 100644 --- a/SL/DB/RequirementSpecItem.pm +++ b/SL/DB/RequirementSpecItem.pm @@ -42,20 +42,8 @@ __PACKAGE__->attr_duration(qw(time_estimation)); __PACKAGE__->before_save(\&_before_save_create_fb_number); __PACKAGE__->before_save(\ &_before_save_invalidate_requirement_spec_version); -__PACKAGE__->before_delete(\&_before_delete_delete_children); __PACKAGE__->before_delete(\&_before_delete_invalidate_requirement_spec_version); -sub _before_delete_delete_children { - my ($self) = @_; - - foreach my $child (@{ SL::DB::Manager::RequirementSpecItem->get_all(where => [ parent_id => $self->id ]) }) { - my $result = $child->delete; - return $result if !$result; - } - - 1; -} - sub _before_save_create_fb_number { my ($self) = @_; @@ -111,12 +99,13 @@ sub validate { return @errors; } -sub sorted_children { +sub children_sorted { my ($self, @args) = @_; croak "Not a writer" if @args; - return [ sort { $a->position <=> $b->position } @{ $self->children } ]; + my @children = sort { $a->position <=> $b->position } $self->children; + return wantarray ? @children : \@children; } sub section { @@ -137,3 +126,52 @@ sub child_type { } 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::RequirementSpecItem - Items for requirement specs + +=head1 OVERVIEW + +Please see L for the architectual overview. + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns the C for children of C<$self>. + +=item C + +Returns an array (or an array reference depending on context) of +direct children (not of grandchildren) for C<$self> ordered by their +positional column in ascending order. + +=item C
+ +Returns the section this item belongs to. It can be C<$self> if +C<$self> is already a section, its parent or grandparent. + +=item C + +Validates before saving and returns an array of human-readable error +messages in case of an error. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut