diff options
Diffstat (limited to 'lib/ManaTools')
| -rw-r--r-- | lib/ManaTools/Shared/disk_backend.pm | 38 | ||||
| -rw-r--r-- | lib/ManaTools/Shared/disk_backend/Part.pm | 11 | 
2 files changed, 47 insertions, 2 deletions
| diff --git a/lib/ManaTools/Shared/disk_backend.pm b/lib/ManaTools/Shared/disk_backend.pm index 146f79ad..223d8082 100644 --- a/lib/ManaTools/Shared/disk_backend.pm +++ b/lib/ManaTools/Shared/disk_backend.pm @@ -507,13 +507,18 @@ sub findinnoout {  =head2 findpart +=head3 INPUT + +    $type: Str +    @tags: Str +  =head3 OUTPUT      array of Part  =head3 DESCRIPTION -    this method will return all Part that match on a type +    this method will return all Part that match on a type and have all the tags  =cut @@ -521,8 +526,37 @@ sub findinnoout {  sub findpart {      my $self = shift;      my $type = shift; +    my @tags = @_; + +    return grep {(!defined $type || $_->type() eq $type) && $_->has_link(undef, @tags)} @{$self->parts}; +} + +#============================================================= + +=head2 findnopart + +=head3 INPUT + +    $type: Str +    @tags: Str + +=head3 OUTPUT + +    array of Part + +=head3 DESCRIPTION + +    this method will return all Part that match on a type and do not have any of the tags + +=cut + +#============================================================= +sub findnopart { +    my $self = shift; +    my $type = shift; +    my @tags = @_; -    return grep {$_->type() eq $type} @{$self->parts}; +    return grep {(!defined $type || $_->type() eq $type) && !$_->has_link(undef, @tags)} @{$self->parts};  }  #============================================================= diff --git a/lib/ManaTools/Shared/disk_backend/Part.pm b/lib/ManaTools/Shared/disk_backend/Part.pm index 5a88dff9..4c293493 100644 --- a/lib/ManaTools/Shared/disk_backend/Part.pm +++ b/lib/ManaTools/Shared/disk_backend/Part.pm @@ -293,6 +293,17 @@ sub add_taglink {      return ($partlink1, $partlink2);  } +sub has_link { +    my $self = shift; +    my $part = shift; +    my @tags = @_; +    my $links = $self->links(); +    for my $link (@{$links}) { +        return 1 if ($link->check($self, $part, @tags)); +    } +    return 0; +} +  sub find_link {      my $self = shift;      my $part = shift; | 
