Revision 4f5ea8fb
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/RequirementSpecItem.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use Carp; |
6 |
use List::MoreUtils qw(any); |
|
7 |
use Rose::DB::Object::Helpers; |
|
8 |
use Rose::DB::Object::Util; |
|
6 | 9 |
|
7 | 10 |
use SL::DB::MetaSetup::RequirementSpecItem; |
8 | 11 |
use SL::DB::Manager::RequirementSpecItem; |
... | ... | |
38 | 41 |
__PACKAGE__->attr_duration(qw(time_estimation)); |
39 | 42 |
|
40 | 43 |
__PACKAGE__->before_save(\&_before_save_create_fb_number); |
44 |
__PACKAGE__->before_save(\ &_before_save_invalidate_requirement_spec_version); |
|
41 | 45 |
__PACKAGE__->before_delete(\&_before_delete_delete_children); |
46 |
__PACKAGE__->before_delete(\&_before_delete_invalidate_requirement_spec_version); |
|
42 | 47 |
|
43 | 48 |
sub _before_delete_delete_children { |
44 | 49 |
my ($self) = @_; |
... | ... | |
70 | 75 |
return 1; |
71 | 76 |
} |
72 | 77 |
|
78 |
sub _before_save_invalidate_requirement_spec_version { |
|
79 |
my ($self, %params) = @_; |
|
80 |
|
|
81 |
return 1 if !$self->requirement_spec_id; |
|
82 |
|
|
83 |
my %changed_columns = map { $_ => 1 } (Rose::DB::Object::Helpers::dirty_columns($self)); |
|
84 |
my $has_changed = !Rose::DB::Object::Util::is_in_db($self); |
|
85 |
$has_changed ||= any { $changed_columns{$_} } qw(requirement_spec_id parent_id position fb_number title description); |
|
86 |
|
|
87 |
if (!$has_changed && $self->id) { |
|
88 |
my $old_item = SL::DB::RequirementSpecItem->new(id => $self->id)->load; |
|
89 |
$has_changed = join(':', sort map { $_->id } @{ $self->dependencies }) ne join(':', sort map { $_->id } @{ $old_item->dependencies }); |
|
90 |
} |
|
91 |
|
|
92 |
$self->requirement_spec->invalidate_version if $has_changed; |
|
93 |
|
|
94 |
return 1; |
|
95 |
} |
|
96 |
|
|
97 |
sub _before_delete_invalidate_requirement_spec_version { |
|
98 |
my ($self, %params) = @_; |
|
99 |
|
|
100 |
$self->requirement_spec->invalidate_version if $self->requirement_spec_id; |
|
101 |
|
|
102 |
return 1; |
|
103 |
} |
|
104 |
|
|
73 | 105 |
sub validate { |
74 | 106 |
my ($self) = @_; |
75 | 107 |
|
Auch abrufbar als: Unified diff
Pflichtenhefversion nach Änderung an Items invalidieren