1 |
3 |
ahitrov@rambler.ru |
package @NAME@::SQL::SampleTable; |
2 |
|
|
|
3 |
|
|
use base 'SQL::ProtoTable'; |
4 |
|
|
|
5 |
|
|
sub db_table |
6 |
|
|
{ |
7 |
|
|
return 'sample'; |
8 |
|
|
} |
9 |
|
|
|
10 |
|
|
sub available_filters { |
11 |
|
|
my @available_filters = qw( |
12 |
|
|
_class_filter |
13 |
|
|
_status_filter |
14 |
|
|
_in_id_filter |
15 |
|
|
_id_filter |
16 |
|
|
_class_excludes_filter |
17 |
|
|
|
18 |
|
|
_excludes_filter |
19 |
|
|
); |
20 |
|
|
return \@available_filters; |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
# ---------------------------------------------------------------------------- |
24 |
|
|
# �������� ������ � ��������, ������ ��� ������� �����! |
25 |
|
|
# ��� ����� �������� - ���������� ��� ���� ����������. |
26 |
|
|
# |
27 |
|
|
# attr - ������������ ��������, �������� ��������; |
28 |
|
|
# type - ��� ���������, ��������� ��� ������������; |
29 |
|
|
# rusname - ������� ��������, ����� �� ��������� ��� �����������; |
30 |
|
|
# hidden - ����� 1, ����� |
31 |
|
|
# readonly - ������������� ��� ������ ������ ��� ��������� � ���������� |
32 |
|
|
# db_field - ���� � ������� |
33 |
|
|
# default - �������� �� ��������� (���� ������ ����� ��� ��������) |
34 |
|
|
# ---------------------------------------------------------------------------- |
35 |
|
|
sub required_properties |
36 |
|
|
{ |
37 |
|
|
return ( |
38 |
|
|
{ # ������������� ���������, �������� �� ���� �����... |
39 |
|
|
'attr' => 'id', |
40 |
|
|
'type' => 'integer', |
41 |
|
|
'rusname' => '������������� ���������', |
42 |
|
|
'hidden' => 1, |
43 |
|
|
'auto' => 1, |
44 |
|
|
'readonly' => 1, |
45 |
|
|
'db_field' => 'id', |
46 |
|
|
'db_type' => 'integer', |
47 |
|
|
'db_opts' => "not null default nextval('public.documents_id_seq'::text)", |
48 |
|
|
}, |
49 |
|
|
{ # ����� ���������... |
50 |
|
|
'attr' => 'class', |
51 |
|
|
'type' => 'string', |
52 |
|
|
'rusname' => '����� ���������', |
53 |
|
|
'hidden' => 1, |
54 |
|
|
'readonly' => 1, |
55 |
|
|
'db_field' => 'class', |
56 |
|
|
'db_type' => 'varchar(48)', |
57 |
|
|
'db_opts' => 'not null', |
58 |
|
|
}, |
59 |
|
|
{ # ����� �������� ���������, ��������� ����... |
60 |
|
|
'attr' => 'start', |
61 |
|
|
'type' => 'datetime', |
62 |
|
|
'rusname' => '����/����� ������', |
63 |
|
|
'db_field' => 'start', |
64 |
|
|
'db_type' => 'timestamp', |
65 |
|
|
'db_opts' => 'not null', |
66 |
|
|
}, |
67 |
|
|
{ # ����� ����������� ���������, ��������� ����... |
68 |
|
|
'attr' => 'finish', |
69 |
|
|
'type' => 'datetime', |
70 |
|
|
'rusname' => '����/����� ���������', |
71 |
|
|
'db_field' => 'finish', |
72 |
|
|
'db_type' => 'timestamp', |
73 |
|
|
'db_opts' => 'not null', |
74 |
|
|
}, |
75 |
|
|
{ # ���� ���� ������� �������� ����������... |
76 |
|
|
'attr' => 'external_id', |
77 |
|
|
'type' => 'integer', |
78 |
|
|
'rusname' => '������� id', |
79 |
|
|
'db_field' => 'external_id', |
80 |
|
|
'db_type' => 'integer', |
81 |
|
|
}, |
82 |
|
|
{ # ���� ���� ������� �������� ����������... |
83 |
|
|
'attr' => 'event_id', |
84 |
|
|
'type' => 'integer', |
85 |
|
|
'rusname' => '�������', |
86 |
|
|
'db_field' => 'event_id', |
87 |
|
|
'db_type' => 'integer', |
88 |
|
|
}, |
89 |
|
|
{ # ���� ���� ������� �������� ����������... |
90 |
|
|
'attr' => 'place_id', |
91 |
|
|
'type' => 'integer', |
92 |
|
|
'rusname' => '����� ����������', |
93 |
|
|
'db_field' => 'place_id', |
94 |
|
|
'db_type' => 'integer', |
95 |
|
|
}, |
96 |
|
|
); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
|
100 |
|
|
########### FILTERS DESCRIPTION #################################################################################### |
101 |
|
|
sub _excludes_filter { |
102 |
|
|
my ($self,%opts)=@_; |
103 |
|
|
if (exists $opts{excludes}) { |
104 |
|
|
# - ���������� �� ������ |
105 |
|
|
my @eids = (); |
106 |
|
|
if (ref($opts{excludes}) eq 'ARRAY') { |
107 |
|
|
@eids = @{ $opts{excludes} }; |
108 |
|
|
} elsif ($opts{excludes} =~ /[^\d\,]/) { |
109 |
|
|
warn "Contenido Warning: � ������ ��������������� ��� ���������� ����������� ���������� ��������. �������� excludes ������������ (".$opts{excludes}.").\n"; |
110 |
|
|
} else { |
111 |
|
|
@eids = split(',', $opts{excludes}); |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
my $excludes = join(',', @eids); |
115 |
|
|
|
116 |
|
|
# �������� ������ �������, ���� ��� join-������. |
117 |
|
|
# ������ ��� � ���� ������ ������� ����� ���������� ������� �� ������� links, |
118 |
|
|
# ��� ����������� ������ ������� ������. |
119 |
|
|
if (@eids) { |
120 |
|
|
if (exists($opts{ldest}) || exists($opts{lsource})) { |
121 |
|
|
if (exists($opts{ldest})) { |
122 |
|
|
return " (l.source_id not in ($excludes)) "; |
123 |
|
|
} elsif (exists($opts{lsource})) { |
124 |
|
|
return " (l.dest_id not in ($excludes)) "; |
125 |
|
|
} |
126 |
|
|
} else { |
127 |
|
|
return " (d.id not in ($excludes)) "; |
128 |
|
|
} |
129 |
|
|
} |
130 |
|
|
} |
131 |
|
|
return undef; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
|
135 |
|
|
sub _get_orders { |
136 |
|
|
my ($self, %opts) = @_; |
137 |
|
|
|
138 |
|
|
if ($opts{order_by}) { |
139 |
|
|
return ' order by '.$opts{order_by}; |
140 |
|
|
} else { |
141 |
|
|
return ' order by start desc,finish desc'; |
142 |
|
|
} |
143 |
|
|
return undef; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
1; |