| 1 | package Net::Journyx::Project; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | extends 'Net::Journyx::Record'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | with 'Net::Journyx::Object::WithAttrs'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use constant jx_record_class => 'ProjectRecord'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use constant jx_strip_record_suffix => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use constant jx_meta => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=5.4
| |||||||||||||||||||||||||||||
| 10 | load => 'getProject', | ||||||||||||||||||||||||||||
| 11 | update => { | ||||||||||||||||||||||||||||
| 12 | operation => 'modifyProject', | ||||||||||||||||||||||||||||
| 13 | leading => 'id', | ||||||||||||||||||||||||||||
| 14 | leading_argname => 'id', | ||||||||||||||||||||||||||||
| 15 | record_argname => 'rec', | ||||||||||||||||||||||||||||
| 16 | }, | ||||||||||||||||||||||||||||
| 17 | create => { | ||||||||||||||||||||||||||||
| 18 | operation => 'addFullProject', | ||||||||||||||||||||||||||||
| 19 | # XXX: name? #XXX: not yet implemented, but do we want to? | ||||||||||||||||||||||||||||
| 20 | # do we want to add check at all? may be 'defaults' and 'exceptions' | ||||||||||||||||||||||||||||
| 21 | # is enough | ||||||||||||||||||||||||||||
| 22 | mandatory => [qw(parent creator)], | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | defaults => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 26 | $args->{'parent'} = 'root' | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | unless defined $args->{'parent'} && length $args->{'parent'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args->{"parent"} and length $args->{"parent"}
MC/DC0%0/2
defined $args->{"parent"} and length $args->{"parent"}
defined $args->{"parent"}
length $args->{"parent"}
Truth table0%0/3
A and B
A= defined $args->{"parent"}B= length $args->{"parent"}
| |||||||||||||||||||||||||||||
| 28 | $args->{'creator'} = $self->jx->username | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | unless defined $args->{'creator'} && length $args->{'creator'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args->{"creator"} and length $args->{"creator"}
MC/DC0%0/2
defined $args->{"creator"} and length $args->{"creator"}
defined $args->{"creator"}
length $args->{"creator"}
Truth table0%0/3
A and B
A= defined $args->{"creator"}B= length $args->{"creator"}
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # IMPORTANT: | ||||||||||||||||||||||||||||
| 32 | # type shouldn't be 0, either 1 (regular) or | ||||||||||||||||||||||||||||
| 33 | # 2 (subproject, only if you have the subproject | ||||||||||||||||||||||||||||
| 34 | # feature in your Timesheet license | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( defined $args->{'type'} && length $args->{'type'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args->{"type"} and length $args->{"type"}
MC/DC0%0/2
defined $args->{"type"} and length $args->{"type"}
defined $args->{"type"}
length $args->{"type"}
Truth table0%0/3
A and B
A= defined $args->{"type"}B= length $args->{"type"}
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | unless ( $args->{'type'} =~ /^[012]$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | # XXX: use Carp | ||||||||||||||||||||||||||||
| 38 | 0 | warn "Type of a project can be either 1 or 2 when you passed ". $args->{'type'}; | |||||||||||||||||||||||||||
| 39 | 0 | $args->{'type'} = 1; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||
| 42 | 0 | $args->{'type'} = 1; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||
| 46 | 4 | delete => { | |||||||||||||||||||||||||||
| 47 | operation => 'removeProject', | ||||||||||||||||||||||||||||
| 48 | leading => 'id', | ||||||||||||||||||||||||||||
| 49 | leading_argname => 'id', | ||||||||||||||||||||||||||||
| 50 | }, | ||||||||||||||||||||||||||||
| 51 | 4 | }; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # XXX: dependencies and projects are better described | ||||||||||||||||||||||||||||
| 57 | # in the doc for getProjectList JX operation. | ||||||||||||||||||||||||||||
| 58 | # Found types of dependencies there: | ||||||||||||||||||||||||||||
| 59 | # | ||||||||||||||||||||||||||||
| 60 | # * code (task) | ||||||||||||||||||||||||||||
| 61 | # * subcode (paytype) | ||||||||||||||||||||||||||||
| 62 | # * subsubcode (billtype) | ||||||||||||||||||||||||||||
| 63 | # * expense | ||||||||||||||||||||||||||||
| 64 | # * expense_source | ||||||||||||||||||||||||||||
| 65 | # * expense_currency | ||||||||||||||||||||||||||||
| 66 | # * mileage_reason | ||||||||||||||||||||||||||||
| 67 | # * mileage_vehicle | ||||||||||||||||||||||||||||
| 68 | # * mileage_measurement | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub dependencies { | ||||||||||||||||||||||||||
|
Subroutine
dependencies: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 72 | 0 | my $type = shift; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | return unless $self->is_loaded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # case is important, so we lc($type) | ||||||||||||||||||||||||||||
| 76 | 0 | $type = lc($type); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | my $response = $self->jx->soap->basic_call( | |||||||||||||||||||||||||||
| 79 | 'getProjectDependencies', | ||||||||||||||||||||||||||||
| 80 | project_id => $self->id, | ||||||||||||||||||||||||||||
| 81 | code_type => $type, | ||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return unless $response; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | die "Don't know what to do with response: ". Dumper( $response ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | unless ref($response) eq 'HASH'; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return unless my $rec = $response->{ucfirst($type).'Record'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | my $class = 'Net::Journyx::'. ucfirst($type); | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | eval "require $class; 1" or die $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | my $jx = $self->jx; | |||||||||||||||||||||||||||
| 94 | # one record | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | return $class->new(jx => $jx)->load_from_hash( %$rec ) if ref($rec) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | # multiple records | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return map { $class->new(jx => $jx)->load_from_hash( %$_ ) } @$rec | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | if ref($rec) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | die "Don't know what to do with response: ". Dumper( $rec ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub add_dependency { | ||||||||||||||||||||||||||
|
Subroutine
add_dependency: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | 0 | my $type = shift; | |||||||||||||||||||||||||||
| 107 | 0 | my $code = shift; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $code_id = blessed($code)? $code->id : $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my $response = $self->jx->soap->basic_call( | |||||||||||||||||||||||||||
| 112 | 'addProjectDependency', | ||||||||||||||||||||||||||||
| 113 | project_id => $self->id, | ||||||||||||||||||||||||||||
| 114 | code_type => $type, | ||||||||||||||||||||||||||||
| 115 | code_id => $code_id, | ||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||
| 117 | # returns some ID | ||||||||||||||||||||||||||||
| 118 | 0 | return $response; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub delete_dependency { | ||||||||||||||||||||||||||
|
Subroutine
delete_dependency: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 123 | 0 | my $type = shift; | |||||||||||||||||||||||||||
| 124 | 0 | my $code = shift; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $code_id = blessed($code)? $code->id : $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | my $response = $self->jx->soap->basic_call( | |||||||||||||||||||||||||||
| 129 | 'removeProjectDependency', | ||||||||||||||||||||||||||||
| 130 | project_id => $self->id, | ||||||||||||||||||||||||||||
| 131 | code_type => $type, | ||||||||||||||||||||||||||||
| 132 | code_id => $code_id, | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | 0 | print Dumper( $response ); | |||||||||||||||||||||||||||
| 135 | 0 | return $response; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 4 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 139 | 4 | 1; | |||||||||||||||||||||||||||