line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Object::Command::Copy; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
2538
|
use strict; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
376
|
|
4
|
11
|
|
|
11
|
|
67
|
use warnings FATAL => 'all'; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
3827
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
class UR::Object::Command::Copy { |
7
|
|
|
|
|
|
|
is => 'Command::V2', |
8
|
|
|
|
|
|
|
is_abstract => 1, |
9
|
|
|
|
|
|
|
has => { |
10
|
|
|
|
|
|
|
changes => { |
11
|
|
|
|
|
|
|
is => 'Text', |
12
|
|
|
|
|
|
|
is_many => 1, |
13
|
|
|
|
|
|
|
doc => 'A name/value comma-separated list of changes', |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub help_detail { |
19
|
0
|
|
|
0
|
0
|
0
|
<
|
20
|
|
|
|
|
|
|
Any non-delegated, non-ID properties may be specified with an operator and a value. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Valid operators are '=', '+=', '-=', and '.='; function is same as in Perl. |
23
|
|
|
|
|
|
|
Example: |
24
|
|
|
|
|
|
|
--changes "name.=-RT101912,foo=bar" |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
A value of 'undef' may be used to pass a Perl undef as the value. Either `foo=` [safer] or `foo=''` can be used to set the value to an empty string. |
27
|
|
|
|
|
|
|
HELP |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub execute { |
31
|
4
|
|
|
4
|
|
171309
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
23
|
my $tx = UR::Context::Transaction->begin; |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
27587
|
my $copy = $self->source->copy(); |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
18529
|
my $failure; |
38
|
4
|
|
|
|
|
23
|
for my $change ($self->changes) { |
39
|
7
|
|
|
|
|
15481
|
my ($key, $op, $value) = $change =~ /^(.+?)(=|\+=|\-=|\.=)(.*)$/; |
40
|
7
|
100
|
50
|
|
|
57
|
$failure = "Invalid change: $change" and last |
|
|
|
66
|
|
|
|
|
41
|
|
|
|
|
|
|
unless $key and defined $op; |
42
|
6
|
100
|
50
|
|
|
35
|
$failure = sprintf('Invalid property %s for %s', $key, $copy->__display_name__) and last |
43
|
|
|
|
|
|
|
if !$copy->can($key); |
44
|
|
|
|
|
|
|
|
45
|
5
|
100
|
|
|
|
64
|
$value = undef if $value eq ''; |
46
|
|
|
|
|
|
|
|
47
|
5
|
100
|
|
|
|
28
|
if ($op eq '=') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
48
|
3
|
|
|
|
|
15
|
$copy->$key($value); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ($op eq '+=') { |
51
|
0
|
|
|
|
|
0
|
$copy->$key($copy->$key + $value); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ($op eq '-=') { |
54
|
0
|
|
|
|
|
0
|
$copy->$key($copy->$key - $value); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ($op eq '.=') { |
57
|
2
|
|
|
|
|
13
|
$copy->$key($copy->$key . $value); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
4
|
100
|
100
|
|
|
1656
|
if ($failure or !$tx->commit ) { |
62
|
3
|
|
|
|
|
5830
|
$tx->rollback; |
63
|
3
|
|
100
|
|
|
8296
|
$self->fatal_message($failure || 'Failed to commit software transaction!'); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
4868
|
$self->status_message("NEW\t%s\t%s", $copy->class, $copy->__display_name__); |
67
|
1
|
|
|
|
|
1853
|
1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |