diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ManaTools/Shared/disk_backend.pm | 38 | ||||
| -rw-r--r-- | lib/ManaTools/Shared/disk_backend/Part.pm | 11 | ||||
| -rw-r--r-- | lib/test-diskbe.pl | 15 | 
3 files changed, 58 insertions, 6 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; diff --git a/lib/test-diskbe.pl b/lib/test-diskbe.pl index 1b753f4c..e48f925a 100644 --- a/lib/test-diskbe.pl +++ b/lib/test-diskbe.pl @@ -73,10 +73,17 @@ if ($mode eq 'fs') {  	}  }  else { - -	my @parts = $db_man->findoutnoin(); -	for my $part (@parts) { -		dumppart($db_man, $part, 0); +	if ($mode eq 'old') { +		my @parts = $db_man->findoutnoin(); +		for my $part (@parts) { +			dumppart($db_man, $part, 0); +		} +	} +	else { +		my @parts = $db_man->findnopart(undef, 'parent'); +		for my $part (@parts) { +			dumppart($db_man, $part, 0); +		}  	}  } | 
