| 1 | # This class presents common functionality between package real parts (OPC::Part), and | ||||||||||||||||||||||||||||
| 2 | # it's root (OPC::Root) | ||||||||||||||||||||||||||||
| 3 | package OPC::Node; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | sub new { | ||||||||||||||||||||||||||||
| 10 | 0 | ▶ | my( $Class, %Params ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | if( !exists($Params{package}) || !defined( $Params{package} )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $Params{"package"} and defined $Params{"package"}
MC/DC0%0/2
exists $Params{"package"} and defined $Params{"package"}
exists $Params{"package"}
defined $Params{"package"}
Truth table0%0/3
A and B
A= exists $Params{"package"}B= defined $Params{"package"}
| |||||||||||||||||||||||||||||
| 13 | 0 | Carp::confess 'Must specify package of the part in argument "package"'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | 0 | my $Package = $Params{package}; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | unless( $Package->isa( 'OPC' )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | Carp::confess 'Package must be instance of OPC'; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if( !exists($Params{name}) || !defined( $Params{name} )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $Params{"name"} and defined $Params{"name"}
MC/DC0%0/2
exists $Params{"name"} and defined $Params{"name"}
exists $Params{"name"}
defined $Params{"name"}
Truth table0%0/3
A and B
A= exists $Params{"name"}B= defined $Params{"name"}
| |||||||||||||||||||||||||||||
| 21 | 0 | Carp::confess 'Must specify name of the node in argument "name"'; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 0 | my $Name = $Params{name}; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | return bless { | |||||||||||||||||||||||||||
| 26 | package => $Package, | ||||||||||||||||||||||||||||
| 27 | name => $Name, | ||||||||||||||||||||||||||||
| 28 | }, $Class; | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub Name { $_[0]->{name} } | ||||||||||||||||||||||||||
|
Subroutine
Name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub Package { $_[0]->{package} } | ||||||||||||||||||||||||||
|
Subroutine
Package: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub RelatedPart { | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
RelatedPart: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my @Parts = $self->RelatedParts( %RelationParams ); | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless( @Parts ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | Carp::confess "No parts with given params found"; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if( @Parts > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | Carp::confess "Requested only part with given params but found ".scalar(@Parts)." parts"; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return @Parts ? $Parts[0] : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub RelatedParts { | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
RelatedParts: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | return | ||||||||||||||||||||||||||||
| 53 | 0 | map $self->{package}->Part( name => $_->{TargetFullName} ), | |||||||||||||||||||||||||||
| 54 | $self->Relations( %RelationParams ); | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | sub Relations { | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
Relations: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 0 | return $self->{package}->Relations( $self->RelsName, %RelationParams ); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub CreateRelationsID { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
CreateRelationsID: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | return $self->{package}->CreateRelationsID( $self->RelsName, %RelationParams ); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub RemoveRelations { | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
RemoveRelations: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | $self->{package}->RemoveRelations( $self->RelsName, %RelationParams ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub AddRelation { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my( $self, %RelationParams ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
AddRelation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | $self->{package}->AddRelation( $self->RelsName, %RelationParams ); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | sub RelsName { | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
RelsName: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | unless( exists $self->{rels_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | my $RelsName = $self->Name; | |||||||||||||||||||||||||||
| 81 | 0 | $RelsName =~ s/^(.*)\/([^\/]*)$/$1\/\_rels\/$2\.rels/; | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | unless( $self->Package->HasPart( $RelsName )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | Carp::confess 'Requested rels part for '.$self->Name.' doesn\'t exist'; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 0 | $self->{rels_name} = $RelsName; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 0 | return $self->{rels_name}; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub RelsXML { | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
RelsXML: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 92 | 0 | return $self->{package}->PartContents( $self->RelsName ); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub Content { | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
Content: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 97 | 0 | return $self->{package}->PartContents( $self->Name ); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | sub ContentType { | ||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
ContentType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 0 | return $self->{package}->PartContentType( $self->Name ); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 1 | 1; | |||||||||||||||||||||||||||