1 |
8 |
ahitrov@rambler.ru |
<%args> |
2 |
|
|
$object |
3 |
|
|
$name => undef |
4 |
|
|
$SETS => undef |
5 |
|
|
</%args> |
6 |
|
|
<%init> |
7 |
|
|
|
8 |
|
|
return undef unless ref $SETS; |
9 |
|
|
return undef unless $name; |
10 |
|
|
|
11 |
|
|
my @props = $object->structure(); |
12 |
|
|
my ($prop) = grep { $_->{attr} eq $name } @props; |
13 |
|
|
return undef unless ref $prop; |
14 |
|
|
|
15 |
389 |
ahitrov |
my @values; |
16 |
|
|
if ( $prop && ref $prop ) { |
17 |
|
|
if ( exists $prop->{lookup_opts} && ref $prop->{lookup_opts} eq 'HASH' ) { |
18 |
|
|
@values = $keeper->get_documents ( |
19 |
|
|
%{$prop->{lookup_opts}}, |
20 |
|
|
names => 1, |
21 |
|
|
); |
22 |
|
|
} elsif ( exists $prop->{values} && ref $prop->{values} eq 'ARRAY' ) { |
23 |
|
|
@values = @{ $prop->{values} }; |
24 |
|
|
} elsif ( exists $prop->{cases} && ref $prop->{cases} eq 'ARRAY' ) { |
25 |
|
|
@values = @{ $prop->{cases} }; |
26 |
|
|
} |
27 |
|
|
} |
28 |
8 |
ahitrov@rambler.ru |
|
29 |
|
|
return undef unless @values; |
30 |
|
|
|
31 |
|
|
my @ids; |
32 |
|
|
foreach my $val ( @values ) { |
33 |
|
|
if ( ref $val eq 'ARRAY' && scalar @$val == 2 ) { |
34 |
|
|
if ( exists $SETS->{$name."_".$val->[0]} && $SETS->{$name."_".$val->[0]} ) { |
35 |
|
|
push @ids, $val->[0]; |
36 |
|
|
} |
37 |
|
|
} else { |
38 |
|
|
if ( exists $SETS->{$name."_".$val} && $SETS->{$name."_".$val} ) { |
39 |
|
|
push @ids, $val; |
40 |
|
|
} |
41 |
|
|
} |
42 |
|
|
} |
43 |
|
|
return \@ids; |
44 |
|
|
|
45 |
|
|
</%init> |