| 1 | package Net::Journyx::Record; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | extends 'Net::Journyx::Object'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | with 'Net::Journyx::Object::Loadable' => { | |||||||||||||||||||||||||||||||||||||||||
| 7 | check_on => [qw(update delete)], | ||||||||||||||||||||||||||||||||||||||||||
| 8 | drop_on => [qw(load_from_hash create delete)], | ||||||||||||||||||||||||||||||||||||||||||
| 9 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use constant jx_strip_record_suffix => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use constant jx_meta => {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # class data implementation via inside out | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | my %jx_columns = (); | |||||||||||||||||||||||||||||||||||||||||
| 18 | has jx_columns => ( | ||||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | default => sub { return $jx_columns{ ref(shift) } || [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$jx_columns{ref shift()} || []
MC/DC0%0/1
$jx_columns{ref shift()} || []
$jx_columns{ref shift()}
Truth table0%0/2
A
A= $jx_columns{ref shift()}
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub _jx_columns { $jx_columns{ ref($_[0]) || $_[0] } = $_[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_jx_columns: not called CC=2 SCAR=17.9
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | my %record_template = (); | |||||||||||||||||||||||||||||||||||||||||
| 28 | has record_template => ( | ||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | default => sub { return $record_template{ ref($_[0]) } ||= $_[0]->_record_template }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$record_template{ref $_[0]} ||= $_[0]->_record_template
MC/DC0%0/2
$record_template{ref $_[0]} ||= $_[0]->_record_template
$record_template{ref $_[0]}
$_[0]->_record_template
Truth table0%0/3
A ||= B
A= $record_template{ref $_[0]}B= $_[0]->_record_template
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return if $self->meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $jx = $args->{'jx'} or die "No JX"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my %columns = $jx->soap->record_columns( $self->jx_record_class ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my %type_map = ( | |||||||||||||||||||||||||||||||||||||||||
| 47 | 'xsd:boolean' => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'xsd:int' => 'Int', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'xsd:double' => 'Math::BigFloat', | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'xsd:string' => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | while (my ($name, $schema_type) = each %columns ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $moose_type = $type_map{ $schema_type } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | or die "No moose type for JX type '$schema_type'"; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | #warn "adding column accessor $name to ". ref($self); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $self->meta->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 58 | $name, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | isa => $moose_type, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | writer => '_'. $name, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->_jx_columns([keys %columns]); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | my $jx_operation = $self->auto_method( | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->jx_meta->{'load'}, | |||||||||||||||||||||||||||||||||||||||||
| 76 | 'get' | ||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $response = $self->jx->soap->basic_call( | |||||||||||||||||||||||||||||||||||||||||
| 80 | $jx_operation => pattern => \%args | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # warn "loaded $jx_class ". Dumper($response) ." using ". Dumper(\%args); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $record = $response->{ $jx_class }; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | unless ( $record ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | die "No '$jx_class' in response ". Dumper($response); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return $self->load_from_hash( %$record ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub load_from_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_from_hash: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | foreach my $k ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( $k =~ /^_+(.*)$/ && !exists $args{ $1 } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$k =~ /^_+(.*)$/ and not exists $args{$1}
MC/DC0%0/2
$k =~ /^_+(.*)$/ and not exists $args{$1}
$k =~ /^_+(.*)$/
not exists $args{$1}
Truth table0%0/3
A and not(B)
A= $k =~ /^_+(.*)$/B= not exists $args{$1}
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $args{ $1 } = delete $args{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my @missing; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | foreach my $column ( @{ $self->jx_columns } ) { | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $method = '_'. $column; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( exists $args{ $column } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->$method( delete $args{ $column } ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push @missing, $column; | |||||||||||||||||||||||||||||||||||||||||
| 111 | # flush as it can be not empty | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->$method( undef ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my @more = keys %args; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ( @missing || @more ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
@missing or @more
MC/DC0%0/2
@missing or @more
@missing
@more
Truth table0%0/3
A or B
A= @missingB= @more
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $msg = "Either during load or load_from_hash of ". $self->jx_record_class | |||||||||||||||||||||||||||||||||||||||||
| 119 | ." incorrect columns have been provided to load_from_hash."; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $msg .= " Missing columns: ". join(', ', map "'$_'", @missing) ."." | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | if @missing; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $msg .= " Superfluous columns: ". join(', ', map "'$_'", @more) ."." | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | if @more; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $msg .= " It can be either API bug or incorrect call to load_from_hash." | |||||||||||||||||||||||||||||||||||||||||
| 125 | ." Record *is not* marked as loaded."; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | warn $msg; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | elsif ( $self->can('id') ) { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # XXX: load may pass us empty record with all defaults | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->_is_loaded(1) if $self->id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->_is_loaded(1); | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my %private_args = map { $_ => delete $args{"__$_"} } | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | grep { s/^__// } # filter and strip leading __ | |||||||||||||||||||||||||||||||||||||||||
| 145 | keys %args; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $jx_meta = $self->jx_meta->{'create'}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ( my $quick = $jx_meta->{'quick'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
my $quick = $jx_meta->{"quick"} and join(",", sort(keys %args)) eq join(",", sort(@{$jx_meta->{"quick"}{"columns"};}))
MC/DC0%0/2
my $quick = $jx_meta->{"quick"} and join(",", sort(keys %args)) eq join(",", sort(@{$jx_meta->{"quick"}{"columns"};}))
my $quick = $jx_meta->{"quick"}
join(",", sort(keys %args)) eq join(",", sort(@{$jx_meta->{"quick"}{"columns"};}))
Truth table0%0/3
A and B
A= my $quick = $jx_meta->{"quick"}B= join(",", sort(keys %args)) eq join(",", sort(@{$jx_meta->{"quick"}{"columns"};}))
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | and join(',', sort keys %args) eq join(',', sort @{$jx_meta->{'quick'}{'columns'}}) | |||||||||||||||||||||||||||||||||||||||||
| 152 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | my $response = $self->jx->soap->basic_call( | ||||||||||||||||||||||||||||||||||||||||||
| 154 | $quick->{'operation'}, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | map { $quick->{'rewrite'} || $_ => $args{$_} } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$quick->{'rewrite'} || $_
MC/DC0%0/2
$quick->{'rewrite'} || $_
$quick->{'rewrite'}
$_
Truth table0%0/3
A || B
A= $quick->{'rewrite'}B= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | @{ $quick->{'columns'} } | |||||||||||||||||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | # load self to get defaults | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return $self->load( id => $response ); | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $defaults = $self->record_template; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $args{$_} = $defaults->{$_} foreach | |||||||||||||||||||||||||||||||||||||||||
| 165 | grep !exists $args{$_}, keys %$defaults; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | $jx_meta->{'defaults'}->( $self, \%args ) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if $jx_meta->{'defaults'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $jx_operation = $self->auto_method( $jx_meta->{'operation'}, 'addFull' ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $response = $self->jx->soap->basic_call( $jx_operation, rec => \%args ); | |||||||||||||||||||||||||||||||||||||||||
| 172 | #warn "created $jx_class #$response using ". Dumper( \%args ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | return $response if $private_args{do_not_load}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | # load self to get defaults | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $self->load( id => $response ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $jx_meta = $self->jx_meta->{'update'}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $leading_column = $jx_meta->{'leading'} || 'id'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$jx_meta->{'leading'} || 'id'
MC/DC0%0/1
$jx_meta->{'leading'} || 'id'
$jx_meta->{'leading'}
Truth table0%0/2
A
A= $jx_meta->{'leading'}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my %op_args = (); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | foreach my $col ( @{ $self->jx_columns } ) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( $col eq $leading_column ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( exists $args{ $col } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $val = $args{ $col }; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( defined $val && length $val && $val eq $self->$col() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $val and length $val and $val eq $self->$col
defined $val and length $val
MC/DC0%0/3
defined $val and length $val and $val eq $self->$col
defined $val
length $val
$val eq $self->$col
Truth table0%0/4
A and B and C
A= defined $valB= length $valC= $val eq $self->$col
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | die "Can not update column '$col' of $jx_class #". $self->$col(); | |||||||||||||||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # just ignore without complain | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | delete $args{ $col }; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # we must pass leading column anyway | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $op_args{ $col } = $self->$col(); | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif ( exists $args{ $col } ) { | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $op_args{ $col } = delete $args{ $col }; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $op_args{ $col } = $self->$col(); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( keys %args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | warn "Ignored ". join( ', ', map "'$_'", keys %args ) | |||||||||||||||||||||||||||||||||||||||||
| 213 | ." arguments on update of $jx_class #". $self->$leading_column() | ||||||||||||||||||||||||||||||||||||||||||
| 214 | ." as these are not columns of the record"; | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $jx_operation = $self->auto_method( $jx_meta->{'operation'}, 'modify' ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | my $response = $self->jx->soap->basic_call( | ||||||||||||||||||||||||||||||||||||||||||
| 219 | $jx_operation, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | $jx_meta->{'leading_argname'} || $leading_column => $self->$leading_column(), | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $jx_meta->{'record_argname'} || 'rec' => \%op_args, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$jx_meta->{'leading_argname'} || $leading_column
$jx_meta->{'record_argname'} || 'rec'
MC/DC0%0/2
$jx_meta->{'leading_argname'} || $leading_column
$jx_meta->{'leading_argname'}
$leading_column
MC/DC0%0/1
$jx_meta->{'record_argname'} || 'rec'
$jx_meta->{'record_argname'}
Truth table0%0/3
A || B
A= $jx_meta->{'leading_argname'}B= $leading_column
Truth table0%0/2
A
A= $jx_meta->{'record_argname'}
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | # reload self just in case Journyx may update values on update | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $self->load( $leading_column => $op_args{ $leading_column } ); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $jx_meta = $self->jx_meta->{'delete'}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $jx_operation = $self->auto_method( $jx_meta->{'operation'}, 'remove' ); | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my $leading_column = $jx_meta->{'leading'} || 'id'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$jx_meta->{'leading'} || 'id'
MC/DC0%0/1
$jx_meta->{'leading'} || 'id'
$jx_meta->{'leading'}
Truth table0%0/2
A
A= $jx_meta->{'leading'}
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $leading_argname = $jx_meta->{'leading_argname'} || 'id'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$jx_meta->{'leading_argname'} || 'id'
MC/DC0%0/1
$jx_meta->{'leading_argname'} || 'id'
$jx_meta->{'leading_argname'}
Truth table0%0/2
A
A= $jx_meta->{'leading_argname'}
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $response = $self->jx->soap->basic_call( | |||||||||||||||||||||||||||||||||||||||||
| 238 | $jx_operation, $leading_argname => $self->$leading_column(), | ||||||||||||||||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | die "not implemented" | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | die "Can get attribute of not loaded record"; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub _record_template { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_template: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 259 | my $jx_operation = $self->auto_method( | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->jx_meta->{'defaults'}, | |||||||||||||||||||||||||||||||||||||||||
| 261 | 'getDefault' | ||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $response = $self->jx->soap->basic_call( $jx_operation ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | or die "Couldn't get default field values for $jx_class"; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $record = $response->{$jx_class}; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | unless ( $record && ref($record) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$record and ref $record eq "HASH"
MC/DC0%0/2
$record and ref $record eq "HASH"
$record
ref $record eq "HASH"
Truth table0%0/3
A and B
A= $recordB= ref $record eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | die "Couldn't get default field values for $jx_class"; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | return $record; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub auto_method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_method: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my ($val, $prefix, $suffix) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | return $val if $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $jx_class = $self->jx_record_class; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $jx_class =~ s/Record$// | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | if $self->jx_strip_record_suffix; | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return join '', grep defined && length, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | $prefix, $jx_class, $suffix; | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 8 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||