line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package UR::Namespace::Command::Update::RenameClass; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
23
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
3
|
use UR; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
UR::Object::Type->define( |
11
|
|
|
|
|
|
|
class_name => __PACKAGE__, |
12
|
|
|
|
|
|
|
is => "UR::Namespace::Command::Update::RewriteClassHeader", |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Standard methods used to output help. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub shell_args_description { |
18
|
0
|
|
|
0
|
0
|
|
"My::Old My::New"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub help_description { |
22
|
0
|
|
|
0
|
0
|
|
"Updates class descriptions for to correspond with database schema changes." |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Wrap execute since we take different parameters than a standard |
26
|
|
|
|
|
|
|
# "runs on modules in tree" rewrite command. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $old; |
29
|
|
|
|
|
|
|
our $new; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub execute { |
32
|
0
|
|
|
0
|
|
|
my $self = shift; |
33
|
0
|
|
|
|
|
|
$old = shift; |
34
|
0
|
|
|
|
|
|
$new = shift; |
35
|
0
|
|
|
|
|
|
$self->error_message("rename $old to $new not implemented"); |
36
|
0
|
|
|
|
|
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Override "before" to do the class editing. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub before { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my $class_objects = shift; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# By default, no classes are rewritten. |
46
|
|
|
|
|
|
|
# As we find classes with the $old name, in their metadata, |
47
|
|
|
|
|
|
|
# we add them to this list. |
48
|
0
|
|
|
|
|
|
$class_objects = []; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
print "finding properties which seem to refernce a class\n"; |
51
|
0
|
|
|
|
|
|
my @p = UR::Object::Property->is_loaded( |
52
|
|
|
|
|
|
|
property_name => ["class_name","r_class_name","parent_class_name"] |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
print "found " . join("\n",map { $_->class_name . " -> " . $_->property_name } @_) . "\n"; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
print "checking instances of those properties\n"; |
58
|
0
|
|
|
|
|
|
my @changes; |
59
|
0
|
|
|
|
|
|
for my $p (@p) { |
60
|
0
|
|
|
|
|
|
my $class_name = $p->class_name; |
61
|
0
|
|
|
|
|
|
my $property_name = $p->property_name; |
62
|
0
|
|
|
|
|
|
my @obj = $class_name->is_loaded(); |
63
|
0
|
|
|
|
|
|
for my $obj (@obj) { |
64
|
0
|
0
|
|
|
|
|
if ($obj->$property_name eq $new) { |
|
|
0
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Carp::confess("Name $new is already in use on $class_name, " |
66
|
|
|
|
|
|
|
. $obj->{id} |
67
|
0
|
|
|
|
|
|
. $property_name . "!" |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ($obj->$property_name eq $old) { |
71
|
|
|
|
|
|
|
print "Setting $new in place of $old on $class_name, " |
72
|
|
|
|
|
|
|
. $obj->{id} |
73
|
0
|
|
|
|
|
|
. $property_name . ".\n"; |
74
|
0
|
|
|
|
|
|
push @changes, [$obj,$property_name,$new]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return 1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# we implement before() but use the default call to |
83
|
|
|
|
|
|
|
# for_each_class_object() call in UR::Namespace::Command::rewrite |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|