| 1 | package UR::Object::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 266 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 266 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 266 | require UR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 266 | our $VERSION = "0.47"; # UR $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 266 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 266 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 266 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 266 | ▶ | use Sub::Name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 266 | our %meta_classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 266 | our $bootstrapping = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 266 | our @partially_defined_classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 266 | our $pwd_at_compile_time = cwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # each method which caches data on the class for properties stores its hash key here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # when properties mutate this is cleared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 266 | our @cache_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub property_metas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_metas: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my @a = map { $self->property_meta_for_name($_) } $self->all_property_names(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # Some accessor methods drawn from properties need to be overridden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # Some times because they need to operate during bootstrapping. Sometimes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # because the method needs some special behavior like sorting or filtering. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Sometimes to optimize performance or cache data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # This needs to remain overridden to enforce the restriction on callers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub data_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_source: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $ds = $self->data_source_id(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return undef unless $ds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $obj = eval { UR::DataSource->get($ds) || $ds->get() }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
'UR::DataSource'->get($ds) || $ds->get
MC/DC0%0/2
'UR::DataSource'->get($ds) || $ds->get
'UR::DataSource'->get($ds)
$ds->get
Truth table0%0/3
A || B
A= 'UR::DataSource'->get($ds)B= $ds->get
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 532 | ▶ | sub ancestry_class_metas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ancestry_class_metas: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | #my $rule_template = UR::BoolExpr::Template->resolve(__PACKAGE__,'id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Can't use the speed optimization of getting a template here. Using the Context to get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # objects here causes endless recursion during bootstrapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 532 | map { __PACKAGE__->get($_) } shift->ancestry_class_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #return map { $UR::Context::current->get_objects_for_class_and_rule(__PACKAGE__, $_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # map { $rule_template->get_rule_for_values($_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # shift->ancestry_class_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 266 | our $PROPERTY_META_FOR_NAME_TEMPLATE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 266 | push @cache_keys, '_property_meta_for_name'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub property_meta_for_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_meta_for_name: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my ($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return unless $property_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (index($property_name,'.') != -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my @chain = split(/\./,$property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $last_class_meta = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $last_class_name = $self->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my @pmeta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | for my $full_link (@chain) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my ($link) = ($full_link =~ /^([^\-\?]+)/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $property_meta = $last_class_meta->property_meta_for_name($link); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | push @pmeta, $property_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | last if $link eq $chain[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my @joins = UR::Object::Join->resolve_chain($last_class_name, $link); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return unless @joins; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $last_class_name = $joins[-1]{foreign_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $last_class_meta = $last_class_name->__meta__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return unless (@pmeta and $pmeta[-1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@pmeta and $pmeta[-1]
MC/DC0%0/2
@pmeta and $pmeta[-1]
@pmeta
$pmeta[-1]
Truth table0%0/3
A and B
A= @pmetaB= $pmeta[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return @pmeta if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | return $pmeta[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $pos = index($property_name,'-'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ($pos != -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $property_name = substr($property_name,0,$pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (exists($self->{'_property_meta_for_name'}) and $self->{'_property_meta_for_name'}->{$property_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"_property_meta_for_name"} and $self->{"_property_meta_for_name"}{$property_name}
MC/DC0%0/2
exists $self->{"_property_meta_for_name"} and $self->{"_property_meta_for_name"}{$property_name}
exists $self->{"_property_meta_for_name"}
$self->{"_property_meta_for_name"}{$property_name}
Truth table0%0/3
A and B
A= exists $self->{"_property_meta_for_name"}B= $self->{"_property_meta_for_name"}{$property_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return $self->{'_property_meta_for_name'}->{$property_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $PROPERTY_META_FOR_NAME_TEMPLATE ||= UR::BoolExpr::Template->resolve('UR::Object::Property', 'class_name', 'property_name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$UR::Object::Type::PROPERTY_META_FOR_NAME_TEMPLATE ||= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name")
MC/DC0%0/2
$UR::Object::Type::PROPERTY_META_FOR_NAME_TEMPLATE ||= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name")
$UR::Object::Type::PROPERTY_META_FOR_NAME_TEMPLATE
"UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name")
Truth table0%0/3
A ||= B
A= $UR::Object::Type::PROPERTY_META_FOR_NAME_TEMPLATEB= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | for my $class ($self->class_name, $self->ancestry_class_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $rule = $PROPERTY_META_FOR_NAME_TEMPLATE->get_rule_for_values($class, $property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $property = $UR::Context::current->get_objects_for_class_and_rule('UR::Object::Property', $rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($property) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return $self->{'_property_meta_for_name'}->{$property_name} = $property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # A front-end for property_meta_for_name, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # will translate the generic 'id' property into the class' real ID property, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # if it's not called 'id' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub _concrete_property_meta_for_class_and_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_concrete_property_meta_for_class_and_name: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my($self,$property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my @property_metas = $self->property_meta_for_name($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | for (my $i = 0; $i < @property_metas; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($property_metas[$i]->id eq "UR::Object\tid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$property_metas[$i]->id eq "UR::Object\tid" and not $property_name =~ /\./
MC/DC0%0/2
$property_metas[$i]->id eq "UR::Object\tid" and not $property_name =~ /\./
$property_metas[$i]->id eq "UR::Object\tid"
not $property_name =~ /\./
Truth table0%0/3
A and not(B)
A= $property_metas[$i]->id eq "UR::Object\tid"B= not $property_name =~ /\./
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | and $property_name !~ /\./) #If we're looking at a foreign object's id, can't replace with our own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # This is the generic id property. Remap it to the class' real ID property name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my @id_properties = $self->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if (@id_properties == 1 and $id_properties[0] eq 'id') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@id_properties == 1 and $id_properties[0] eq "id"
MC/DC0%0/2
@id_properties == 1 and $id_properties[0] eq "id"
@id_properties == 1
$id_properties[0] eq "id"
Truth table0%0/3
A and B
A= @id_properties == 1B= $id_properties[0] eq "id"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | next; # this class doesn't have any other ID properties | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | #return map { $self->_concrete_property_meta_for_class_and_name($_) } @id_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my @remapped = map { $self->_concrete_property_meta_for_class_and_name($_) } @id_properties; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | splice(@property_metas, $i, 1, @remapped); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return @property_metas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub _flatten_property_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flatten_property_name: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $flattened_name = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my @add_keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | my @add_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my @meta = $self->property_meta_for_name($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | for my $meta (@meta) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my @joins = $meta->_resolve_join_chain(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | for my $join (@joins) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($flattened_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $flattened_name .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $flattened_name .= $join->{source_name_for_foreign}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if (my $where = $join->{where}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $flattened_name .= '-' . $join->sub_group_label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $join_class = $join->{foreign_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $bx2 = UR::BoolExpr->resolve($join_class,@$where); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $bx2_flat = $bx2->flatten(); # recurses through this | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my ($bx2_flat_template, @values) = $bx2_flat->template_and_values(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @keys = @{ $bx2_flat_template->{_keys} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | for my $key (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | next if substr($key,0,1) eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $full_key = $flattened_name . '?.' . $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | push @add_keys, $full_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | push @add_values, shift @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (@values) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | Carp:confess("Unexpected mismatch in count of keys and values!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return ($flattened_name, \@add_keys, \@add_values); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 266 | our $DIRECT_ID_PROPERTY_METAS_TEMPLATE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub direct_id_property_metas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
direct_id_property_metas: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $DIRECT_ID_PROPERTY_METAS_TEMPLATE ||= UR::BoolExpr::Template->resolve('UR::Object::Property', 'class_name', 'property_name', 'is_id >='); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$UR::Object::Type::DIRECT_ID_PROPERTY_METAS_TEMPLATE ||= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name", "is_id >=")
MC/DC0%0/2
$UR::Object::Type::DIRECT_ID_PROPERTY_METAS_TEMPLATE ||= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name", "is_id >=")
$UR::Object::Type::DIRECT_ID_PROPERTY_METAS_TEMPLATE
"UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name", "is_id >=")
Truth table0%0/3
A ||= B
A= $UR::Object::Type::DIRECT_ID_PROPERTY_METAS_TEMPLATEB= "UR::BoolExpr::Template"->resolve("UR::Object::Property", "class_name", "property_name", "is_id >=")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | my @id_property_objects = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | map { $UR::Context::current->get_objects_for_class_and_rule('UR::Object::Property', $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | map { $DIRECT_ID_PROPERTY_METAS_TEMPLATE->get_rule_for_values($class_name, $_, 0) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | @{$self->{'id_by'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | my $sort_sub = sub ($$) { return $_[0]->is_id cmp $_[1]->is_id }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | @id_property_objects = sort $sort_sub @id_property_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (@id_property_objects == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | @id_property_objects = $self->property_meta_for_name("id"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return @id_property_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 266 | ▶ | sub parent_class_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent_class_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 266 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 266 | return @{ $self->{is} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # If $property_name represents an alias-type property (via => '__self__'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # then return a string with all the aliases removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 266 | push @cache_keys, '_resolve_property_aliases'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub resolve_property_aliases { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_property_aliases: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my($self,$property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return unless $property_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | unless ($self->{'_resolve_property_aliases'} && $self->{'_resolve_property_aliases'}->{$property_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_resolve_property_aliases"} and $self->{"_resolve_property_aliases"}{$property_name}
MC/DC0%0/2
$self->{"_resolve_property_aliases"} and $self->{"_resolve_property_aliases"}{$property_name}
$self->{"_resolve_property_aliases"}
$self->{"_resolve_property_aliases"}{$property_name}
Truth table0%0/3
A and B
A= $self->{"_resolve_property_aliases"}B= $self->{"_resolve_property_aliases"}{$property_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $self->{'_resolve_property_aliases'} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"_resolve_property_aliases"} ||= {}
MC/DC0%0/1
$self->{"_resolve_property_aliases"} ||= {}
$self->{"_resolve_property_aliases"}
Truth table0%0/2
A
A= $self->{"_resolve_property_aliases"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my @property_metas = $self->property_meta_for_name($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (@property_metas) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | @property_names = map { $_->alias_for } @property_metas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # there was a problem resolving the chain of properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # This happens in the case of an object accessor (is => 'Some::Class') without an id_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my @split_names = split(/\./,$property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $name_count = @split_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $prop_meta = $self->property_meta_for_name(shift @split_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return unless $prop_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $foreign_class = $prop_meta->data_type && eval { $prop_meta->data_type->__meta__}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$prop_meta->data_type && eval {
do {
$prop_meta->data_type->__meta__
}
}
MC/DC0%0/2
$prop_meta->data_type && eval {
do {
$prop_meta->data_type->__meta__
}
}
$prop_meta->data_type
eval {
do {
$prop_meta->data_type->__meta__
}
}
Truth table0%0/3
A && B
A= $prop_meta->data_typeB= eval {
do {
$prop_meta->data_type->__meta__
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return unless $foreign_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | @property_names = ( $prop_meta->alias_for, $foreign_class->resolve_property_aliases(join('.', @split_names))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | unless (@property_names >= $name_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | Carp::croak("Some parts from property '$property_name' of class ".$self->class_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | . " didn't resolve"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->{'_resolve_property_aliases'}->{$property_name} = join('.', @property_names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $self->{'_resolve_property_aliases'}->{$property_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 266 | push @cache_keys, '_id_property_names'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 798 | ▶ | sub id_property_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id_property_names: called CC=7 SCAR=27.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # FIXME Take a look at id_property_names and all_id_property_names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # They look extremely similar, but tests start dying if you replace one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # with the other, or remove both and rely on the property's accessor method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 798 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 798 | ▶ | unless ($self->{'_id_property_names'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 798 | my @id_by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 798 | ▶ | unless ($self->{id_by} and @id_by = @{ $self->{id_by} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"id_by"} and @id_by = @{$self->{"id_by"};}
MC/DC0%0/2
$self->{"id_by"} and @id_by = @{$self->{"id_by"};}
$self->{"id_by"}
@id_by = @{$self->{"id_by"};}
Truth table33%1/3
A and B
A= $self->{"id_by"}B= @id_by = @{$self->{"id_by"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | foreach my $parent ( @{ $self->{'is'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $parent_class = $parent->class->__meta__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | next unless $parent_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | @id_by = $parent_class->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | last if @id_by; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 798 | $self->{'_id_property_names'} = \@id_by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 798 | return @{$self->{'_id_property_names'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 266 | push @cache_keys, '_all_id_property_names'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | sub all_id_property_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_id_property_names: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # return shift->id_property_names(@_); This makes URT/t/99_transaction.t fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | unless ($self->{_all_id_property_names}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my ($tmp,$last) = ('',''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | $self->{_all_id_property_names} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | grep { $tmp = $last; $last = $_; $tmp ne $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | sort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | map { @{ $_->{id_by} } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | map { __PACKAGE__->get($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ($self->class_name, $self->ancestry_class_names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | return @{ $self->{_all_id_property_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub direct_id_column_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
direct_id_column_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | my @id_column_names = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | map { $_->column_name } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | $self->direct_id_property_metas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | return @id_column_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub ancestry_table_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ancestry_table_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | my @inherited_table_names = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | grep { defined($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | map { $_->table_name } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $self->ancestry_class_metas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return @inherited_table_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub all_table_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_table_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | my @table_names = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | grep { defined($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ( $self->table_name, $self->ancestry_table_names ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | return @table_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub first_table_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_table_name: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($self->{_first_table_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return $self->{first_table_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my @classes = ($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | while(@classes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $co = shift @classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if (my $table_name = $co->table_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->{first_table_name} = $table_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return $table_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my @parents = map { $_->__meta__ } @{$co->{'is'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | push @classes, @parents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1330 | ▶ | sub ancestry_class_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ancestry_class_names: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1330 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1330 | ▶ | if ($self->{_ordered_inherited_class_names}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 532 | return @{ $self->{_ordered_inherited_class_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 798 | my $ordered_inherited_class_names = $self->{_ordered_inherited_class_names} = [ @{ $self->{is} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 798 | my @unchecked = @$ordered_inherited_class_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 798 | my %seen = ( $self->{class_name} => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 798 | ▶ | while (my $ancestor_class_name = shift @unchecked) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 798 | ▶ | next if $seen{$ancestor_class_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 798 | $seen{$ancestor_class_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 798 | my $class_meta = $ancestor_class_name->__meta__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 798 | ▶ | Carp::confess("Can't find meta for $ancestor_class_name!") unless $class_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 798 | ▶ | next unless $class_meta->{is}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 798 | push @$ordered_inherited_class_names, @{ $class_meta->{is} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 798 | unshift @unchecked, $_ for reverse @{ $class_meta->{is} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 798 | return @$ordered_inherited_class_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 266 | push @cache_keys, '_all_property_names'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub all_property_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_property_names: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ($self->{_all_property_names}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return @{ $self->{_all_property_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my %seen = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $all_property_names = $self->{_all_property_names} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | for my $class_name ($self->class_name, $self->ancestry_class_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | next if $class_name eq 'UR::Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $class_meta = UR::Object::Type->get($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if (my $has = $class_meta->{has}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | push @$all_property_names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | not exists $has->{$_}{id_by} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | grep { !exists $seen{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | sort keys %$has; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | foreach (@$all_property_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $seen{$_} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return @$all_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # End of overridden property methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 11966 | ▶ | sub _resolve_meta_class_name_for_class_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_meta_class_name_for_class_name: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 11966 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 11966 | my $class_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | #if ($class_name->isa("UR::Object::Type") or $meta_classes{$class_name} or $class_name =~ '::Type') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 11966 | ▶ | if ($meta_classes{$class_name} or $class_name =~ '::Type') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$UR::Object::Type::meta_classes{$class_name} or $class_name =~ /::Type/
MC/DC100%2/2
$UR::Object::Type::meta_classes{$class_name} or $class_name =~ /::Type/
$UR::Object::Type::meta_classes{$class_name}
$class_name =~ /::Type/
Truth table100%3/3
A or B
A= $UR::Object::Type::meta_classes{$class_name}B= $class_name =~ /::Type/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6382 | return "UR::Object::Type" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 5584 | return $class_name . "::Type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub _resolve_meta_class_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_meta_class_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my ($rule,%extra) = UR::BoolExpr->resolve_normalized($class, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my %params = $rule->params_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $class_name = $params{class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | return unless $class_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return $class->_resolve_meta_class_name_for_class_name($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # This method can go away when we have the is_cached meta-property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | sub first_sub_classification_method_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_sub_classification_method_name: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # This may be one of many things which class meta-data should "inherit" from classes which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # its instances inherit from. This value is set to the value found on the most concrete class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # in the inheritance tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | return $self->{___first_sub_classification_method_name} if exists $self->{___first_sub_classification_method_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $self->{___first_sub_classification_method_name} = $self->sub_classification_method_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | unless ($self->{___first_sub_classification_method_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | for my $parent_class ($self->ancestry_class_metas) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | last if ($self->{___first_sub_classification_method_name} = $parent_class->sub_classification_method_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return $self->{___first_sub_classification_method_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # Another thing that is "inherited" from parent class metas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 266 | ▶ | sub subclassify_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subclassify_by: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 266 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 266 | ▶ | return $self->{'__subclassify_by'} if exists $self->{'__subclassify_by'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 266 | $self->{'__subclassify_by'} = $self->__subclassify_by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 266 | ▶ | unless ($self->{'__subclassify_by'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 266 | for my $parent_class ($self->ancestry_class_metas) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 266 | ▶ | last if ($self->{'__subclassify_by'} = $parent_class->__subclassify_by); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 266 | return $self->{'__subclassify_by'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 798 | ▶ | sub resolve_composite_id_from_ordered_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_composite_id_from_ordered_values: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 798 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 798 | my $resolver = $self->get_composite_id_resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 798 | return $resolver->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | sub resolve_ordered_values_from_composite_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_ordered_values_from_composite_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $decomposer = $self->get_composite_id_decomposer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return $decomposer->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub get_composite_id_decomposer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_composite_id_decomposer: not called CC=3 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $decomposer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | unless ($decomposer = $self->{get_composite_id_decomposer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my @id_property_names = $self->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if (@id_property_names == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | $decomposer = sub { $_[0] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $separator = $self->_resolve_composite_id_separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | $decomposer = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=37.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if (ref($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # ID is an arrayref, or we'll throw an exception. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $id = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $underlying_id_count = scalar(@$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # Handle each underlying ID, turning each into an arrayref divided by property value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my @decomposed_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | for my $underlying_id (@$id) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | push @decomposed_ids, [map { $_ eq '' ? undef : $_ } split($separator,$underlying_id)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Count the property values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | my $underlying_property_count = scalar(@{$decomposed_ids[0]}) if @decomposed_ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | $underlying_property_count ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$underlying_property_count ||= 0
MC/DC0%0/1
$underlying_property_count ||= 0
$underlying_property_count
Truth table0%0/2
A
A= $underlying_property_count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # Make a list of property values, but each value will be an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # arrayref of a set of values instead of a single value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my @property_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | for (my $n = 0; $n < $underlying_property_count; $n++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $property_values[$n] = [ map { $_->[$n] } @decomposed_ids ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | return @property_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # Regular scalar ID. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 266 | ▶ | no warnings 'uninitialized'; # $_[0] can be undef in some cases... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | return split($separator,$_[0]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | Sub::Name::subname('UR::Object::Type::InternalAPI::composite_id_decomposer(closure)',$decomposer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $self->{get_composite_id_decomposer} = $decomposer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return $decomposer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 266 | ▶ | sub _resolve_composite_id_separator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_composite_id_separator: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # TODO: make the class pull this from its parent at creation time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # and only have it dump it if it differs from its parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 266 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 266 | my $separator = "\t"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 266 | for my $class_meta ($self, $self->ancestry_class_metas) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 266 | ▶ | if ($class_meta->composite_id_separator) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 266 | $separator = $class_meta->composite_id_separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 266 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 266 | return $separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1064 | ▶ | sub get_composite_id_resolver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_composite_id_resolver: called CC=3 SCAR=13.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1064 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1064 | my $resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1064 | ▶ | unless($resolver = $self->{get_composite_id_resolver}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 266 | my @id_property_names = $self->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 266 | ▶ | if (@id_property_names == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | $resolver = sub { $_[0] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 266 | my $separator = $self->_resolve_composite_id_separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 798 | ▶ | $resolver = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 798 | ▶ | if (ref($_[0]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # Determine how big the arrayrefs are. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $underlying_id_count = scalar(@{$_[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # We presume that, if one value is an arrayref, the others are also, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # and are of equal length. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my @id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | for (my $id_num = 0; $id_num < $underlying_id_count; $id_num++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # One value per id_property on the class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # Each value is an arrayref in this case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | for my $value (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 266 | ▶ | no warnings 'uninitialized'; # Some values in the list might be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | $id[$id_num] .= $separator if $id[$id_num]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $id[$id_num] .= $value->[$id_num]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return \@id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 266 | ▶ | no warnings 'uninitialized'; # Some values in the list might be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 798 | return join($separator,@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 266 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 266 | Sub::Name::subname('UR::Object::Type::InternalAPI::composite_id_resolver(closure)',$resolver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 266 | $self->{get_composite_id_resolver} = $resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1064 | return $resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # UNUSED, BUT BETTER FOR MULTI-COLUMN FK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | sub composite_id_list_scalar_mix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
composite_id_list_scalar_mix: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # This is like the above, but handles the case of arrayrefs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # mixing with scalar values in a multi-property id. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my ($self, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my @id_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | for my $value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | if (@id_sets == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if (not ref $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | @id_sets = ($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | @id_sets = @$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if (not ref $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | for my $id_set (@id_sets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $id_set .= "\t" . $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | for my $new_id (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | for my $id_set (@id_sets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $id_set .= "\t" . $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if (@id_sets == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | return $id_sets[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | return \@id_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub id_property_sorter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id_property_sorter: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Return a closure that sort can use to sort objects by all their ID properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # This should be the same order that an SQL query with 'order by ...' would return them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | return $self->{'_id_property_sorter'} ||= $self->sorter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_id_property_sorter"} ||= $self->sorter
MC/DC0%0/2
$self->{"_id_property_sorter"} ||= $self->sorter
$self->{"_id_property_sorter"}
$self->sorter
Truth table0%0/3
A ||= B
A= $self->{"_id_property_sorter"}B= $self->sorter
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub sorter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sorter: not called CC=8 SCAR=41.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my ($self,@properties) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | push @properties, $self->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $key = join("__",@properties); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my $sorter = $self->{_sorter}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | unless ($sorter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my @is_numeric; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | my @is_descending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | for my $property (@properties) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ($property =~ m/^(-|\+)(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | push @is_descending, $1 eq '-'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $property = $2; # yes, we're manipulating the original list element | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | push @is_descending, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my ($pmeta,@extra) = $self->_concrete_property_meta_for_class_and_name($property); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if(@extra) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # maybe a composite property (typically ID), or a chained property (prop.other_prop) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $pmeta = $self->property_meta_for_name($property); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | if ($pmeta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $is_numeric = $pmeta->is_numeric; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | push @is_numeric, $is_numeric; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | elsif ($UR::initialized) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | Carp::cluck("Failed to find property meta for $property on $self? Cannot produce a sorter for @properties"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | push @is_numeric, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | push @is_numeric, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 266 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | $sorter = $self->{_sorter}{$key} ||= sub($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | for (my $n = 0; $n < @properties; $n++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $property = $properties[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my @property_string = split('\.',$property); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | my($first,$second) = $is_descending[$n] ? ($_[1], $_[0]) : ($_[0], $_[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | for my $current (@property_string) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $first = $first->$current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $second = $second->$current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | if (!defined($second)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } elsif (!defined($first)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | my $cmp = $is_numeric[$n] ? $first <=> $second : $first cmp $second; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | return $cmp if $cmp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_sorter"}{$key} ||= sub ($$) {
for (my $n = 0; $n < @properties; ++$n) {
my $property = $properties[$n];
my @property_string = split(/\./, $property, 0);
my($first, $second) = $is_descending[$n] ? ($_[1], $_[0]) : ($_[0], $_[1]);
foreach my $current (@property_string) {
$first = $first->$current;
$second = $second->$current;
if (not defined $second) {
return -1;
}
elsif (not defined $first) {
return 1;
};
};
my $cmp = $is_numeric[$n] ? $first <=> $second : $first cmp $second;
return $cmp if $cmp;
};
return 0;
}
MC/DC0%0/2
$self->{"_sorter"}{$key} ||= sub ($$) {
for (my $n = 0; $n < @properties; ++$n) {
my $property = $properties[$n];
my @property_string = split(/\./, $property, 0);
my($first, $second) = $is_descending[$n] ? ($_[1], $_[0]) : ($_[0], $_[1]);
foreach my $current (@property_string) {
$first = $first->$current;
$second = $second->$current;
if (not defined $second) {
return -1;
}
elsif (not defined $first) {
return 1;
};
};
my $cmp = $is_numeric[$n] ? $first <=> $second : $first cmp $second;
return $cmp if $cmp;
};
return 0;
}
$self->{"_sorter"}{$key}
sub ($$) {
for (my $n = 0; $n < @properties; ++$n) {
my $property = $properties[$n];
my @property_string = split(/\./, $property, 0);
my($first, $second) = $is_descending[$n] ? ($_[1], $_[0]) : ($_[0], $_[1]);
foreach my $current (@property_string) {
$first = $first->$current;
$second = $second->$current;
if (not defined $second) {
return -1;
}
elsif (not defined $first) {
return 1;
};
};
my $cmp = $is_numeric[$n] ? $first <=> $second : $first cmp $second;
return $cmp if $cmp;
};
return 0;
}
Truth table0%0/3
A ||= B
A= $self->{"_sorter"}{$key}B= sub ($$) {
for (my $n = 0; $n < @properties; ++$n) {
my $property = $properties[$n];
my @property_string = split(/\./, $property, 0);
my($first, $second) = $is_descending[$n] ? ($_[1], $_[0]) : ($_[0], $_[1]);
foreach my $current (@property_string) {
$first = $first->$current;
$second = $second->$current;
if (not defined $second) {
return -1;
}
elsif (not defined $first) {
return 1;
};
};
my $cmp = $is_numeric[$n] ? $first <=> $second : $first cmp $second;
return $cmp if $cmp;
};
return 0;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | Sub::Name::subname("UR::Object::Type::sorter__" . $self->class_name . '__' . $key, $sorter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | return $sorter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | sub is_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_meta: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | return grep { $_ ne 'UR::Object' and $class_name->isa($_) } keys %meta_classes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_ ne 'UR::Object' && $class_name->isa($_)
MC/DC0%0/2
$_ ne 'UR::Object' && $class_name->isa($_)
$_ ne 'UR::Object'
$class_name->isa($_)
Truth table0%0/3
A && B
A= $_ ne 'UR::Object'B= $class_name->isa($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | sub is_meta_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_meta_meta: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my $class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | return 1 if $meta_classes{$class_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # Things that can't safely be removed from the object cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | our %uncachable_types = ( ( map { $_ => 0 } keys %UR::Object::Type::meta_classes), # meta-classes are locked in the cache... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 'UR::Object' => 1, # .. except for UR::Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 'UR::Object::Ghost' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 'UR::DataSource' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 'UR::Context' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 'UR::Object::Index' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | sub is_uncachable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_uncachable: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # setting the is_uncachable value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return $uncachable_types{$class_name} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | unless (exists $uncachable_types{$class_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my $is_uncachable = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | foreach my $type ( keys %uncachable_types ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | if ($class_name->isa($type) and ! $uncachable_types{$type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class_name->isa($type) and not $UR::Object::Type::uncachable_types{$type}
MC/DC0%0/2
$class_name->isa($type) and not $UR::Object::Type::uncachable_types{$type}
$class_name->isa($type)
not $UR::Object::Type::uncachable_types{$type}
Truth table0%0/3
A and not(B)
A= $class_name->isa($type)B= not $UR::Object::Type::uncachable_types{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $is_uncachable = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $uncachable_types{$class_name} = $is_uncachable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | unless (exists $uncachable_types{$class_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | die "Couldn't determine is_uncachable() for $class_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return $uncachable_types{$class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # Mechanisms for generating object IDs when none were specified at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # creation time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 266 | ▶ | sub autogenerate_new_object_id_uuid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autogenerate_new_object_id_uuid: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 266 | require Data::UUID; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 266 | my $uuid = Data::UUID->new->create_hex(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 266 | $uuid =~ s/^0x//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 266 | return $uuid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 266 | our $autogenerate_id_base_format = join(" ",Sys::Hostname::hostname(), "%s", time); # the %s gets $$ when needed | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 266 | our $autogenerate_id_iter = 10000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | sub autogenerate_new_object_id_urinternal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autogenerate_new_object_id_urinternal: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my($self, $rule) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my @id_property_names = $self->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | if (@id_property_names > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # we really could, but it seems like if you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # asked to do it, it _has_ to be a mistake. If there's a legitimate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # reason, this check should be removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $self->error_message("Can't autogenerate ID property values for multiple ID property class " . $self->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | return sprintf($autogenerate_id_base_format, $$) . " " . (++$autogenerate_id_iter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | sub autogenerate_new_object_id_datasource { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autogenerate_new_object_id_datasource: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my($self,$rule) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my ($data_source) = $UR::Context::current->resolve_data_sources_for_class_meta_and_rule($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | if ($data_source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | return $data_source->autogenerate_new_object_id_for_class_name_and_rule( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | $self->class_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | Carp::croak("Class ".$self->class." has id_generator '-datasource', but the class has no data source to delegate to"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | # Support the autogeneration of unique IDs for objects which require them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | sub autogenerate_new_object_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autogenerate_new_object_id: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $self = _object($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | #my $rule = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | unless ($self->{'_resolved_id_generator'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my $id_generator = $self->id_generator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if (ref($id_generator) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $self->{'_resolved_id_generator'} = $id_generator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ▶ | } elsif ($id_generator and $id_generator =~ m/^\-(\S+)/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$id_generator and $id_generator =~ /^\-(\S+)/
MC/DC0%0/2
$id_generator and $id_generator =~ /^\-(\S+)/
$id_generator
$id_generator =~ /^\-(\S+)/
Truth table0%0/3
A and B
A= $id_generatorB= $id_generator =~ /^\-(\S+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $id_method = 'autogenerate_new_object_id_' . $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | my $subref = $self->can($id_method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | unless ($subref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | Carp::croak("'$id_generator' is an invalid id_generator for class " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | . $self->class_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | . ": Can't locate object method '$id_method' via package ".ref($self)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | $self->{'_resolved_id_generator'} = $subref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # delegate to the data source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my ($data_source) = $UR::Context::current->resolve_data_sources_for_class_meta_and_rule($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | if ($data_source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | $self->{'_resolved_id_generator'} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $data_source->autogenerate_new_object_id_for_class_name_and_rule( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | shift->class_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | goto $self->{'_resolved_id_generator'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # from ::Object->generate_support_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 266 | our %support_class_suffixes = map { $_ => 1 } qw/Set View Viewer Ghost Iterator Value/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | sub generate_support_class_for_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_support_class_for_extension: not called CC=15 SCAR=52.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | my $extension_for_support_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my $subject_class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | unless ($subject_class_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | Carp::confess("No subject class name for $self?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | return unless defined $extension_for_support_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | if ($subject_class_name eq "UR::Object") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | # Carp::cluck("can't generate $extension_for_support_class for UR::Object!\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | # NOTE: we hit this a bunch of times when "getting" meta-data objects during boostrap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | unless ($support_class_suffixes{$extension_for_support_class}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | #$self->debug_message("Cannot generate a class with extension $extension_for_support_class."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my $subject_class_obj = UR::Object::Type->get(class_name => $subject_class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | unless ($subject_class_obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $self->debug_message("Cannot autogenerate $extension_for_support_class because $subject_class_name does not exist."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $new_class_name = $subject_class_name . "::" . $extension_for_support_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $class_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | if ($class_obj = UR::Object::Type->is_loaded($new_class_name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # getting the subject class autogenerated the support class automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | # shortcut out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | return $class_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 266 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my @subject_parent_class_names = @{ $subject_class_name . "::ISA" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | my @parent_class_names = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | grep { UR::Object::Type->get(class_name => $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | map { $_ . "::" . $extension_for_support_class } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | grep { $_->isa("UR::Object") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | grep { $_ !~ /^UR::/ or $extension_for_support_class eq "Ghost" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
!($_ =~ /^UR::/) || $extension_for_support_class eq 'Ghost'
MC/DC0%0/2
!($_ =~ /^UR::/) || $extension_for_support_class eq 'Ghost'
!($_ =~ /^UR::/)
$extension_for_support_class eq 'Ghost'
Truth table0%0/3
not(A) || B
A= !($_ =~ /^UR::/)B= $extension_for_support_class eq 'Ghost'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | @subject_parent_class_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 266 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | unless (@parent_class_names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | if (UR::Object::Type->get(class_name => ("UR::Object::" . $extension_for_support_class))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | @parent_class_names = "UR::Object::" . $extension_for_support_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | unless (@parent_class_names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | #print Carp::longmess(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | #$self->error_message("Cannot autogenerate $extension_for_support_class for $subject_class_name because parent classes (@subject_parent_class_names) do not have classes with that extension."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | my @id_property_names = $subject_class_obj->id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | my %id_property_names = map { $_ => 1 } @id_property_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | if ($extension_for_support_class eq 'Ghost') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | my $subject_class_metaobj = UR::Object::Type->get($self->meta_class_name); # Class object for the subject_class | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my %class_params = map { $_ => $subject_class_obj->$_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | grep { my $p = $subject_class_metaobj->property_meta_for_name($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$subject_class_metaobj->property_meta_for_name($_) || Carp::croak("Can't no metadata for property '${_}' of class " . $self->meta_class_name)
MC/DC0%0/1
$subject_class_metaobj->property_meta_for_name($_) || Carp::croak("Can't no metadata for property '${_}' of class " . $self->meta_class_name)
$subject_class_metaobj->property_meta_for_name($_)
Truth table0%0/2
A
A= $subject_class_metaobj->property_meta_for_name($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | || Carp::croak("Can't no metadata for property '$_' of class ".$self->meta_class_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | ! $p->is_delegated and ! $p->is_calculated } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$p->is_delegated || $p->is_calculated
MC/DC0%0/2
$p->is_delegated || $p->is_calculated
$p->is_delegated
$p->is_calculated
Truth table0%0/3
A || B
A= $p->is_delegatedB= $p->is_calculated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | $subject_class_obj->__meta__->all_property_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | delete $class_params{generated}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | delete $class_params{meta_class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | delete $class_params{subclassify_by}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | delete $class_params{sub_classification_meta_class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | delete $class_params{id_generator}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | delete $class_params{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | delete $class_params{is}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | delete $class_params{roles}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | my $attributes_have = UR::Util::deep_copy($subject_class_obj->{attributes_have}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | my $class_props = UR::Util::deep_copy($subject_class_obj->{has}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | for (values %$class_props) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | delete $_->{class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | delete $_->{property_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | %class_params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | %class_params, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | class_name => $new_class_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | is => \@parent_class_names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | is_abstract => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | has => [%$class_props], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | attributes_have => $attributes_have, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | id_properties => \@id_property_names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | $class_obj = UR::Object::Type->define(%class_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $class_obj = UR::Object::Type->define( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | class_name => $subject_class_name . "::" . $extension_for_support_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | is => \@parent_class_names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | return $class_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | sub has_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_table: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | if ($bootstrapping) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | return 1 if $self->table_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | # FIXME - shouldn't this call inheritance() instead of parent_classes()? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my @parent_classes = $self->parent_classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | for my $class_name (@parent_classes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | next if $class_name eq "UR::Object"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my $class_obj = UR::Object::Type->get(class_name => $class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | if ($class_obj->has_direct_table) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | sub has_direct_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_direct_table: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | return 1 if $self->table_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | if ($self->data_source_id and $self->data_source_id->isa('UR::DataSource::Default')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->data_source_id and $self->data_source_id->isa("UR::DataSource::Default")
MC/DC0%0/2
$self->data_source_id and $self->data_source_id->isa("UR::DataSource::Default")
$self->data_source_id
$self->data_source_id->isa("UR::DataSource::Default")
Truth table0%0/3
A and B
A= $self->data_source_idB= $self->data_source_id->isa("UR::DataSource::Default")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | my $load_function_name = join('::', $self->class_name, '__load__'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | return 1 if exists &$load_function_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | ▶ | sub most_specific_subclass_with_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
most_specific_subclass_with_table: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | return $self->class_name if $self->table_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | foreach my $class_name ( $self->class_name->inheritance ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | my $class_obj = UR::Object::Type->get(class_name => $class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | return $class_name if ($class_obj and $class_obj->has_direct_table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class_obj and $class_obj->has_direct_table
MC/DC0%0/2
$class_obj and $class_obj->has_direct_table
$class_obj
$class_obj->has_direct_table
Truth table0%0/3
A and B
A= $class_objB= $class_obj->has_direct_table
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | sub most_general_subclass_with_table { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
most_general_subclass_with_table: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my @subclass_list = reverse ( $self->class_name, $self->class_name->inheritance ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | foreach my $class_name ( $self->inheritance ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | my $class_obj = UR::Object::Type->get(class_name => $class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | return $class_name if ($class_obj && $class_obj->has_direct_table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class_obj and $class_obj->has_direct_table
MC/DC0%0/2
$class_obj and $class_obj->has_direct_table
$class_obj
$class_obj->has_direct_table
Truth table0%0/3
A and B
A= $class_objB= $class_obj->has_direct_table
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 266 | ▶ | sub _load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load: called CC=22 SCAR=57.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 266 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 266 | my $rule = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 266 | $rule = $rule->normalize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 266 | my $params = $rule->legacy_params_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # While core entity classes are actually loaded, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # support classes dynamically generate for them as needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # Examples are Acme::Employee::View::emp_id, and Acme::Equipment::Ghost | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # Try to parse the class name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 266 | my $class_name = $params->{class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # See if the class autogenerates from another class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | # i.e.: Acme::Foo::Bar might be generated by Acme::Foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 266 | ▶ | unless ($class_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 266 | my $namespace = $params->{namespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 266 | ▶ | if (my $data_source = $params->{data_source_id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $namespace = $data_source->get_namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 266 | ▶ | if ($namespace) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # FIXME This chunk seems to be getting called each time there's a new table/class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | #Carp::cluck("Getting all classes for namespace $namespace from the filesystem..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | my @classes = $namespace->get_material_classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | return $class->is_loaded($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | Carp::confess("Non-class_name used to find a class object: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 266 | ▶ | . join(', ', map { "$_ => " . (defined $params->{$_} ? "'" . $params->{$_} . "'" : 'undef') } keys %$params)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | # Besides the common case of asking for a class by its name, the next most | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | # common thing is asking for multiple classes by their names. Rather than doing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # hard work of doing it "right" right here, just recursively call myself with each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | # item in that list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | if (ref $class_name eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | # FIXME is there a more efficient way to add/remove class_name from the rule? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | my $rule_without_class_name = $rule->remove_filter('class_name'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | $rule_without_class_name = $rule_without_class_name->remove_filter('id'); # id is a synonym for class_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | my @objs = map { $class->_load($rule_without_class_name->add_filter(class_name => $_)) } @$class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | return $class->context_return(@objs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # If the class is loaded, we're done. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # This is an un-documented unique constraint right now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my $class_obj = $class->is_loaded(class_name => $class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | ▶ | return $class_obj if $class_obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # Handle deleted classes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | # This is written in non-oo notation for bootstrapping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 266 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$class_name ne "UR::Object::Type::Ghost" and "UR::Object::Type::Ghost"->can("class") and $UR::Context::current->get_objects_for_class_and_rule("UR::Object::Type::Ghost", $rule, 0)
$class_name ne "UR::Object::Type::Ghost" and "UR::Object::Type::Ghost"->can("class")
MC/DC0%0/3
$class_name ne "UR::Object::Type::Ghost" and "UR::Object::Type::Ghost"->can("class") and $UR::Context::current->get_objects_for_class_and_rule("UR::Object::Type::Ghost", $rule, 0)
$class_name ne "UR::Object::Type::Ghost"
"UR::Object::Type::Ghost"->can("class")
$UR::Context::current->get_objects_for_class_and_rule("UR::Object::Type::Ghost", $rule, 0)
Truth table0%0/4
A and B and C
A= $class_name ne "UR::Object::Type::Ghost"B= "UR::Object::Type::Ghost"->can("class")C= $UR::Context::current->get_objects_for_class_and_rule("UR::Object::Type::Ghost", $rule, 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | $class_name ne "UR::Object::Type::Ghost" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | UR::Object::Type::Ghost->can("class") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | $UR::Context::current->get_objects_for_class_and_rule("UR::Object::Type::Ghost",$rule,0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | # Check the filesystem. The file may create its metadata object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my $exception = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | eval "use $class_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | unless ($exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # If the above module was loaded, and is an UR::Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # this will find the object. If not, it will return nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | $class_obj = $UR::Context::current->get_objects_for_class_and_rule($class,$rule,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | ▶ | return $class_obj if $class_obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | if ($exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | # We need to handle $@ here otherwise we'll see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # "Can't locate UR/Object/Type/Ghost.pm in @INC" error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # We want to fall through "in the right circumstances". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | (my $module_path = $class_name . '.pm') =~ s/::/\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | unless ($exception =~ /Can't locate $module_path in \@INC/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | die "Error while autoloading with 'use $class_name': $exception"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # Parse the specified class name to check for a suffix. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my ($prefix, $base, $suffix) = ($class_name =~ /^([^\:]+)::(.*)::([^:]+)/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | ($prefix, @parts) = split(/::/,$class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | for (my $suffix_pos = $#parts; $suffix_pos >= 0; $suffix_pos--) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | $class_obj = $UR::Context::current->get_objects_for_class_and_rule($class,$rule,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | if ($class_obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # the class was somehow generated while we were checking other classes for it and failing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | # this can happen b/c some class with a name which is a subset of the one we're looking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | # for might "use" the one we want. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | return $class_obj if $class_obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | my $base = join("::", @parts[0 .. $suffix_pos-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | my $suffix = join("::", @parts[$suffix_pos..$#parts]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # See if a class exists for the same name w/o the suffix. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | # This may cause this function to be called recursively for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | # classes like Acme::Equipment::Set::View::upc_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | # which would fire recursively for three extensions of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | # Acme::Equipment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | ▶ | my $full_base_class_name = $prefix . ($base ? "::" . $base : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $base_class_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $exception = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | $base_class_obj = eval { $full_base_class_name->__meta__ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | ▶ | if ($exception && $exception =~ m/^Error while autoloading/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exception and $exception =~ /^Error while autoloading/
MC/DC0%0/2
$exception and $exception =~ /^Error while autoloading/
$exception
$exception =~ /^Error while autoloading/
Truth table0%0/3
A and B
A= $exceptionB= $exception =~ /^Error while autoloading/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | die $exception; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | if ($base_class_obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | # If so, that class may be able to generate a support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | # class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $class_obj = $full_base_class_name->__extend_namespace__($suffix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | if ($class_obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | # Autogeneration worked. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | # We still defer to is_loaded, since other parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | # may prevent the newly "loaded" class from being | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | # returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | return $UR::Context::current->get_objects_for_class_and_rule($class,$rule,0) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # If we fall-through to this point, no class was found and no module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 266 | ▶ | sub use_module_with_namespace_constraints { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_module_with_namespace_constraints: called CC=8 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 266 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 266 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 266 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 266 | my $target_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # If you do "use Acme; $o = Acme::Rocket->new();", and Perl finds Acme.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # at "/foo/bar/Acme.pm", Acme::Rocket must be under /foo/bar/Acme/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | # in order to be dynamically loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 266 | my @words = split("::",$target_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 266 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 266 | ▶ | while (@words > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 266 | my $namespace_name = join("::",@words[0..$#words-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 266 | my $namespace_expected_module = join("/",@words[0..$#words-1]) . ".pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 266 | ▶ | if ($path = $INC{$namespace_expected_module}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | #print "got mod $namespace_expected_module at $path for $target_class\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 266 | $path =~ s/\/*$namespace_expected_module//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | my $namespace_obj = UR::Object::Type->is_loaded(class_name => $namespace_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | if ($namespace_obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | eval { $path = $namespace_obj->module_directory }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # non-module class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # don't auto-use, but don't make a lot of noise about it either | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 266 | ▶ | last if $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | pop @words; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 266 | ▶ | unless ($path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | #Carp::cluck("No module_directory found for namespace $namespace_name." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | # . " Cannot dynamically load $target_class."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 266 | $self->_use_safe($target_class,$path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 266 | my $meta = UR::Object::Type->is_loaded(class_name => $target_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 266 | ▶ | if ($meta) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 266 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 266 | ▶ | sub _use_safe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_use_safe: called CC=13 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 266 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 266 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 266 | my ($self, $target_class, $expected_directory) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | # TODO: use some smart module to determine whether the path is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | # relative on the current system. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 266 | ▶ | if (defined($expected_directory) and $expected_directory !~ /^[\/\\]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $expected_directory and not $expected_directory =~ m(^[/\\])
MC/DC0%0/2
defined $expected_directory and not $expected_directory =~ m(^[/\\])
defined $expected_directory
not $expected_directory =~ m(^[/\\])
Truth table33%1/3
A and not(B)
A= defined $expected_directoryB= not $expected_directory =~ m(^[/\\])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $expected_directory = $pwd_at_compile_time . "/" . $expected_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 266 | my $class_path = $target_class . ".pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 266 | $class_path =~ s/\:\:/\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 266 | my @INC_COPY = @INC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 266 | ▶ | if ($expected_directory) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 266 | unshift @INC, $expected_directory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 266 | my $found = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 266 | for my $dir (@INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 266 | ▶ | if ($dir and (-e $dir . "/" . $class_path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dir and -e $dir . '/' . $class_path
MC/DC0%0/2
$dir and -e $dir . '/' . $class_path
$dir
-e $dir . '/' . $class_path
Truth table33%1/3
A and B
A= $dirB= -e $dir . '/' . $class_path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 266 | $found = $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 266 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 266 | ▶ | if (!$found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # not found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | @INC = @INC_COPY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 266 | ▶ | if ($expected_directory and $expected_directory ne $found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$expected_directory and $expected_directory ne $found
MC/DC0%0/2
$expected_directory and $expected_directory ne $found
$expected_directory
$expected_directory ne $found
Truth table33%1/3
A and B
A= $expected_directoryB= $expected_directory ne $found
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | # not found in the specified location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | @INC = @INC_COPY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 266 | do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 266 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 266 | local $SIG{__WARN__}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 266 | ▶ | eval "use $target_class"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | # FIXME - if the use above failed because of a compilation error in the module we're trying to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | # load, then the error message below just tells the user that "Compilation failed in require" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # and isn't propogating the error message about what caused the compile to fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 266 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | #local $SIG{__DIE__}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | @INC = @INC_COPY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | die ("ERROR DYNAMICALLY LOADING CLASS $target_class\n$@"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 266 | for (0..$#INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 266 | ▶ | if ($INC[$_] eq $expected_directory) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 266 | splice @INC, $_, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 266 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 266 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | # sub _object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | # This is used to make sure that methods are called | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | # as object methods and not class methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | # The typical case that's important is when something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | # like UR::Object::Type->method(...) is called. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | # If an object is expected in a method and it gets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | # a class instead, well, unpredictable things can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | # happen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | # For many methods on UR::Objects, the implementation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | # is in UR::Object. However, some of those methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | # have the same name as methods in here (purposefully), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | # and those UR::Object methods often get the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # UR::Object::Type object and call the same method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # which ends up in this file. The problem is when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | # those methods are called on UR::Object::Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # itself it come directly here, without getting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # the UR::Object::Type object for UR::Object::Type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | # (confused yet?). So to fix this, we use _object to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | # make sure we have an object and not a class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # Basically, we make sure we're working with a class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | # object and not a class name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 798 | ▶ | sub _object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 798 | ▶ | return ref($_[0]) ? $_[0] : $_[0]->__meta__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | # new version gets everything, including "id" itself and object ref properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 266 | push @cache_keys, '_all_property_type_names'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 266 | ▶ | sub all_property_type_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_property_type_names: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 266 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 266 | ▶ | if ($self->{_all_property_type_names}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | return @{ $self->{_all_property_type_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | #my $rule_template = UR::BoolExpr::Template->resolve('UR::Object::Type', 'id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 266 | my $all_property_type_names = $self->{_all_property_type_names} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 266 | for my $class_name ($self->class_name, $self->ancestry_class_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 532 | my $class_meta = UR::Object::Type->get($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | #my $rule = $rule_template->get_rule_for_values($class_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | #my $class_meta = $UR::Context::current->get_objects_for_class_and_rule('UR::Object::Type',$rule); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 532 | ▶ | if (my $has = $class_meta->{has}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 532 | push @$all_property_type_names, sort keys %$has; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 266 | return @$all_property_type_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | sub table_for_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_for_property: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | ▶ | Carp::croak('must pass a property_name to table_for_property') unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | my $property_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | for my $class_object ( $self, $self->ancestry_class_metas ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | my $property_object = UR::Object::Property->get( class_name => $class_object->class_name, property_name => $property_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | ▶ | if ( $property_object ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | next unless $property_object->column_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | return $class_object->table_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | ▶ | sub column_for_property { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
column_for_property: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | ▶ | Carp::croak('must pass a property_name to column_for_property') unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | my $property_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | my($properties,$columns) = @{$self->{'_all_properties_columns'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | for (my $i = 0; $i < @$properties; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | ▶ | if ($properties->[$i] eq $property_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | return $columns->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | for my $class_object ( $self->ancestry_class_metas ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $column_name = $class_object->column_for_property($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | return $column_name if $column_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | sub property_for_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property_for_column: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | my $self = _object(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | ▶ | Carp::croak('must pass a column_name to property_for_column') unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | my $column_name = lc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | ▶ | my $data_source = $self->data_source || 'UR::DataSource'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->data_source || 'UR::DataSource'
MC/DC0%0/1
$self->data_source || 'UR::DataSource'
$self->data_source
Truth table0%0/2
A
A= $self->data_source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | my($table_name,$self_table_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | ($table_name, $column_name) = $data_source->_resolve_table_and_column_from_column_name($column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | (undef, $self_table_name) = $data_source->_resolve_owner_and_table_from_table_name($self->table_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | ▶ | if (! $table_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | my($properties,$columns) = @{$self->{'_all_properties_columns'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | ▶ | for (my $i = 0; $i < @$columns; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | ▶ | if (lc($columns->[$i]) eq $column_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | return $properties->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | ▶ | } elsif ($table_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$table_name and $self_table_name and lc $self_table_name eq lc $table_name
$table_name and $self_table_name
MC/DC0%0/3
$table_name and $self_table_name and lc $self_table_name eq lc $table_name
$table_name
$self_table_name
lc $self_table_name eq lc $table_name
Truth table0%0/4
A and B and C
A= $table_nameB= $self_table_nameC= lc $self_table_name eq lc $table_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | $self_table_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | and lc($self_table_name) eq lc($table_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | # @$properties and @$columns contain items inherited from parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # make sure the property we find with that name goes to this class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | my $property_name = $self->property_for_column($column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | return undef unless $property_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | my $prop_meta = $self->property_meta_for_name($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | ▶ | if ($prop_meta->class_name eq $self->class_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$prop_meta->class_name eq $self->class_name and lc $prop_meta->column_name eq $column_name
MC/DC0%0/2
$prop_meta->class_name eq $self->class_name and lc $prop_meta->column_name eq $column_name
$prop_meta->class_name eq $self->class_name
lc $prop_meta->column_name eq $column_name
Truth table0%0/3
A and B
A= $prop_meta->class_name eq $self->class_nameB= lc $prop_meta->column_name eq $column_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | lc($prop_meta->column_name) eq $column_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | return $property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } elsif ($table_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | for my $class_object ( $self, $self->ancestry_class_metas ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | ▶ | next unless $class_object->data_source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | my $class_object_table_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | (undef, $class_object_table_name) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | = $class_object->data_source->_resolve_owner_and_table_from_table_name($class_object->table_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | if (! $class_object_table_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $class_object_table_name or $table_name ne lc $class_object_table_name
MC/DC0%0/2
not $class_object_table_name or $table_name ne lc $class_object_table_name
not $class_object_table_name
$table_name ne lc $class_object_table_name
Truth table0%0/3
not(A) or B
A= not $class_object_table_nameB= $table_name ne lc $class_object_table_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | $table_name ne lc($class_object_table_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | (undef, $class_object_table_name) = $class_object->data_source->parse_view_and_alias_from_inline_view($class_object->table_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | ▶ | next if (! $class_object_table_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $class_object_table_name or $table_name ne lc $class_object_table_name
MC/DC0%0/2
not $class_object_table_name or $table_name ne lc $class_object_table_name
not $class_object_table_name
$table_name ne lc $class_object_table_name
Truth table0%0/3
not(A) or B
A= not $class_object_table_nameB= $table_name ne lc $class_object_table_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | $table_name ne lc($class_object_table_name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | my $property_name = $class_object->property_for_column($column_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | return $property_name if $property_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | # Methods for maintaining unique constraints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | # This is primarily used by the class re-writer (ur update classes-from-db), but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # BoolExprs use them,too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # Adds a constraint by name and property list to the class metadata. The class initializer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # fills this data in via the 'constraints' key, so it shouldn't call add_unique_constraint() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # directly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | ▶ | sub add_unique_constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_unique_constraint: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | Carp::croak('method add_unique_constraint requires a constraint name as a parameter'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | my $constraint_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | my $constraints = $self->unique_property_set_hashref(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | if (exists $constraints->{$constraint_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | Carp::croak("A constraint named '$constraint_name' already exists for class ".$self->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | Carp::croak('method add_unique_constraint requires one or more property names as parameters'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | my @property_names = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | # Add a new constraint record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | push @{ $self->{'constraints'} } , { sql => $constraint_name, properties => \@property_names }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | # invalidate the other cached data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | $self->_invalidate_cached_data_for_subclasses('_unique_property_sets', '_unique_property_set_hashref'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | sub remove_unique_constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_unique_constraint: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | Carp::croak("method remove_unique_constraint requires a constraint name as a parameter"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | my $constraint_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | my $constraints = $self->unique_property_set_hashref(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | ▶ | unless (exists $constraints->{$constraint_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | Carp::croak("There is no constraint named '$constraint_name' for class ".$self->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | # Remove the constraint record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | for (my $i = 0; $i < @{$self->{'constraints'}}; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | ▶ | if ($self->{'constraints'}->[$i]->{'sql'} = $constraint_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | splice(@{$self->{'constraints'}}, $i, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | $self->_invalidate_cached_data_for_subclasses('_unique_property_sets', '_unique_property_set_hashref'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # This returns a list of lists. Each inner list is the properties/columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | # involved in the constraint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | ▶ | sub unique_property_sets { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unique_property_sets: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | ▶ | if ($self->{_unique_property_sets}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | return @{ $self->{_unique_property_sets} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $unique_property_sets = $self->{_unique_property_sets} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | for my $class_name ($self->class_name, $self->ancestry_class_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | my $class_meta = UR::Object::Type->get($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | ▶ | if ($class_meta->{constraints}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | for my $spec (@{ $class_meta->{constraints} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | push @$unique_property_sets, [ @{ $spec->{properties} } ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | return @$unique_property_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # Return the constraint information as a hashref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # keys are the SQL constraint name, values are a listref of property/column names involved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | ▶ | sub unique_property_set_hashref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unique_property_set_hashref: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | if ($self->{_unique_property_set_hashref}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | return $self->{_unique_property_set_hashref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my $unique_property_set_hashref = $self->{_unique_property_set_hashref} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | for my $class_name ($self->class_name, $self->ancestry_class_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | my $class_meta = UR::Object::Type->get($class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | ▶ | if ($class_meta->{'constraints'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | for my $spec (@{ $class_meta->{'constraints'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | my $unique_group = $spec->{'sql'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | ▶ | next if ($unique_property_set_hashref->{$unique_group}); # child classes override parents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | $unique_property_set_hashref->{$unique_group} = [ @{$spec->{properties}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | return $unique_property_set_hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # Used by the class meta meta data constructors to make changes in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | # raw data stored in the class object's hash. These should really | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | # only matter while running ur update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | # Args are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | # 1) An UR::Object::Property object with attribute_name, class_name, id, property_name, type_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | # 2) The method called: _construct_object, load, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | # 3) An id? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 0 | ▶ | sub _property_change_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_property_change_callback: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | my($property_obj,$method, $old_val, $new_val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | ▶ | return if ($method eq 'load' || $method eq 'unload'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$method eq "load" or $method eq "unload"
MC/DC0%0/2
$method eq "load" or $method eq "unload"
$method eq "load"
$method eq "unload"
Truth table0%0/3
A or B
A= $method eq "load"B= $method eq "unload"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | ▶ | return unless ref($property_obj); # happens when, say, error_message is called on the UR::Object::Property class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | my $class_obj = UR::Object::Type->get(class_name => $property_obj->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | my $property_name = $property_obj->property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | ▶ | $old_val = '' unless(defined $old_val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | ▶ | $new_val = '' unless(defined $new_val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | ▶ | if ($method eq 'create') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | ▶ | unless ($class_obj->{'has'}->{$property_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | my @attr = qw( class_name data_length data_type is_delegated is_optional property_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | my %new_property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | foreach my $attr_name (@attr ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | $new_property{$attr_name} = $property_obj->$attr_name(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | $class_obj->{'has'}->{$property_name} = \%new_property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | ▶ | if (defined $property_obj->is_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | &_id_property_change_callback($property_obj, 'create'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } elsif ($method eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | ▶ | if (defined $property_obj->is_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 0 | &_id_property_change_callback($property_obj, 'delete'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | delete $class_obj->{'has'}->{$property_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | ▶ | } elsif ($method eq 'is_id' and $new_val ne $old_val) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$method eq "is_id" and $new_val ne $old_val
MC/DC0%0/2
$method eq "is_id" and $new_val ne $old_val
$method eq "is_id"
$new_val ne $old_val
Truth table0%0/3
A and B
A= $method eq "is_id"B= $new_val ne $old_val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | ▶ | my $change = $new_val ? 'create' : 'delete'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | &_id_property_change_callback($property_obj, $change); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | ▶ | if (exists $class_obj->{'has'}->{$property_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $class_obj->{"has"}{$property_name} and exists $class_obj->{"has"}{$property_name}{$method}
MC/DC0%0/2
exists $class_obj->{"has"}{$property_name} and exists $class_obj->{"has"}{$property_name}{$method}
exists $class_obj->{"has"}{$property_name}
exists $class_obj->{"has"}{$property_name}{$method}
Truth table0%0/3
A and B
A= exists $class_obj->{"has"}{$property_name}B= exists $class_obj->{"has"}{$property_name}{$method}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | && exists $class_obj->{'has'}->{$property_name}->{$method}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | $class_obj->{'has'}->{$property_name}->{$method} = $new_val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | # Invalidate the cache used by all_property_names() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | for my $key (@cache_keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | $class_obj->_invalidate_cached_data_for_subclasses($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | # Some expensive-to-calculate data gets stored in the class meta hashref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | # and needs to be removed for all the existing subclasses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | ▶ | sub _invalidate_cached_data_for_subclasses { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invalidate_cached_data_for_subclasses: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | my($class_meta, @cache_keys) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | delete @$class_meta{@cache_keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | my @subclasses = @{$UR::Object::Type::_init_subclasses_loaded{$class_meta->class_name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | while (my $subclass = shift @subclasses) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | next if ($seen{$subclass}++); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | my $sub_meta = UR::Object::Type->get(class_name => $subclass); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | delete @$sub_meta{@cache_keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | push @subclasses, @{$UR::Object::Type::_init_subclasses_loaded{$sub_meta->class_name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | # A streamlined version of the method just below that dosen't check that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | # data in both places is the same before a delete operation. What was happening | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | # was that an ID property got deleted and the position checks out ok, but then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | # a second ID property gets deleted and now the position dosen't match because we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | # aren't able to update the object's position property 'cause it's an ID property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | # and can't be changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | # The short story is that we've lowered the bar for making sure it's safe to delete info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | ▶ | sub _id_property_change_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_id_property_change_callback: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my $property_obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | ▶ | return if ($method eq 'load' || $method eq 'unload'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$method eq "load" or $method eq "unload"
MC/DC0%0/2
$method eq "load" or $method eq "unload"
$method eq "load"
$method eq "unload"
Truth table0%0/3
A or B
A= $method eq "load"B= $method eq "unload"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | my $class = UR::Object::Type->get(class_name => $property_obj->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | ▶ | if ($method eq 'create') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | my $pos = $property_obj->id_by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | $pos += 0; # make sure it's a number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | ▶ | if ($pos <= @{$class->{'id_by'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | splice(@{$class->{'id_by'}}, $pos, 0, $property_obj->property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | # $pos is past the end... probably an id property was deleted and another added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | push @{$class->{'id_by'}}, $property_obj->property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | } elsif ($method eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | my $property_name = $property_obj->property_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | for (my $i = 0; $i < @{$class->{'id_by'}}; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | ▶ | if ($class->{'id_by'}->[$i] eq $property_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | splice(@{$class->{'id_by'}}, $i, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | #$DB::single = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | Carp::confess("Internal data consistancy problem: could not find property named $property_name in id_by list for class meta " . $class->class_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | # Shouldn't get here since ID properties can't be changed, right? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | #$DB::single = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | Carp::confess("Shouldn't be here as ID properties can't change"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | $class->{'_all_id_property_names'} = undef; # Invalidate the cache used by all_id_property_names | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | # BOOTSTRAP CODE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 0 | ▶ | sub get_with_special_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_with_special_parameters: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | my $rule = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | my %extra = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | ▶ | if (my $namespace = delete $extra{'namespace'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | ▶ | unless (keys %extra) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | my @c = $namespace->get_material_classes(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | @c = grep { $_->namespace eq $namespace } $class->is_loaded($rule->params_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | return $class->context_return(@c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | return $class->SUPER::get_with_special_parameters($rule,@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | ▶ | sub __signal_change__ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__signal_change__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | my @rv = $self->SUPER::__signal_change__(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | ▶ | if ($_[0] eq "delete") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | my $class_name = $self->{class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | $self->ungenerate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | return @rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 266 | my @default_valid_signals = qw(create delete commit rollback load unload load_external subclass_loaded); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 266 | our %STANDARD_VALID_SIGNALS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 266 | @STANDARD_VALID_SIGNALS{@default_valid_signals} = (1) x @default_valid_signals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | ▶ | sub _is_valid_signal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_valid_signal: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my $aspect = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | # An aspect of empty string (or undef) means all aspects are being observed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | ▶ | return 1 unless (defined($aspect) and length($aspect)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $aspect and length $aspect
MC/DC0%0/2
defined $aspect and length $aspect
defined $aspect
length $aspect
Truth table0%0/3
A and B
A= defined $aspectB= length $aspect
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | # All standard creation and destruction methods emit a signal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | ▶ | return 1 if ($STANDARD_VALID_SIGNALS{$aspect}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | for my $property ($self->all_property_names) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | return 1 if $property eq $aspect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | ▶ | if (!exists $self->{'_is_valid_signal'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | $self->{'_is_valid_signal'} = { map { $_ => 1 } @{$self->{'valid_signals'}} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | ▶ | return 1 if ($self->{'_is_valid_signal'}->{$aspect}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | foreach my $parent_meta ( $self->parent_class_metas ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | ▶ | if ($parent_meta->_is_valid_signal($aspect)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | $self->{'_is_valid_signal'}->{$aspect} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 798 | ▶ | sub generated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generated: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 798 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 798 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | $self->{'generated'} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 798 | return $self->{'generated'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | ▶ | sub ungenerate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ungenerate: not called CC=1 SCAR=3.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | my $class_name = $self->class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | delete $UR::Object::_init_subclass->{$class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | delete $UR::Object::Type::_inform_all_parent_classes_of_newly_loaded_subclass{$class_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 266 | ▶ | no strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 266 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | my @symbols_which_are_not_subordinate_namespaces = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | grep { substr($_,-2) ne '::' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | keys %{ $class_name . "::" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | my $hr = \%{ $class_name . "::" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | delete @$hr{@symbols_which_are_not_subordinate_namespaces}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | my $module_name = $class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | $module_name =~ s/::/\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | $module_name .= ".pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | delete $INC{$module_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | $self->{'generated'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 5586 | ▶ | sub singular_accessor_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
singular_accessor_name_for_is_many_accessor: called CC=7 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 5586 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 5586 | ▶ | unless (exists $self->{_accessor_singular_names}->{$property_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 798 | ▶ | my $property_meta = $self->property_meta_for_name($property_name) if ($self->generated); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 798 | ▶ | if ($bootstrapping # trust the caller when bootstrapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
$UR::Object::Type::bootstrapping or not $self->generated or $property_meta and $property_meta->is_many
$UR::Object::Type::bootstrapping or not $self->generated
$property_meta and $property_meta->is_many
MC/DC0%0/4
$UR::Object::Type::bootstrapping or not $self->generated or $property_meta and $property_meta->is_many
$UR::Object::Type::bootstrapping
not $self->generated
$property_meta
$property_meta->is_many
Truth table20%1/5
A or not(B) or C and D
A= $UR::Object::Type::bootstrappingB= not $self->generatedC= $property_metaD= $property_meta->is_many
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | ! $self->generated # when called from UR::Object::Type::AccessorWriter and the property isn't created yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | ($property_meta && $property_meta->is_many) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 798 | require Lingua::EN::Inflect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 798 | $self->{_accessor_singular_names}->{$property_name} = Lingua::EN::Inflect::PL_V($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | $self->{_accessor_singular_names}->{$property_name} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 5586 | return $self->{_accessor_singular_names}->{$property_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 798 | ▶ | sub iterator_accessor_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iterator_accessor_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 798 | ▶ | return $singular && "${singular}_iterator"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "${singular}_iterator"
MC/DC0%0/1
$singular && "${singular}_iterator"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 798 | ▶ | sub set_accessor_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_accessor_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 798 | ▶ | return $singular && "${singular}_set"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "${singular}_set"
MC/DC0%0/1
$singular && "${singular}_set"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 798 | ▶ | sub rule_accessor_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rule_accessor_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 798 | ▶ | return $singular && "__${singular}_rule"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "__${singular}_rule"
MC/DC0%0/1
$singular && "__${singular}_rule"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 798 | ▶ | sub arrayref_accessor_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arrayref_accessor_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 798 | ▶ | return $singular && "${singular}_arrayref"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "${singular}_arrayref"
MC/DC0%0/1
$singular && "${singular}_arrayref"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 798 | ▶ | sub adder_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
adder_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 798 | ▶ | return $singular && "add_${singular}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "add_$singular"
MC/DC0%0/1
$singular && "add_$singular"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 798 | ▶ | sub remover_name_for_is_many_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remover_name_for_is_many_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 798 | my($self, $property_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 798 | my $singular = $self->singular_accessor_name_for_is_many_accessor($property_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 798 | ▶ | return $singular && "remove_${singular}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$singular && "remove_$singular"
MC/DC0%0/1
$singular && "remove_$singular"
$singular
Truth table50%1/2
A
A= $singular
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 266 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||