annotate Lib/IMPL/Web/View/Metadata/FormMeta.pm @ 367:608e74bc309f

form metadata, mostly done
author cin
date Tue, 03 Dec 2013 17:55:36 +0400
parents 935629bf80df
children 010ceafd0c5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
1 package IMPL::Web::View::Metadata::FormMeta;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
2 use strict;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
3
363
d67e45705be5 sync, model metadata
cin
parents: 362
diff changeset
4 use IMPL::Const qw(:prop);
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
5 use IMPL::declare {
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
6 require => {
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
7 Exception => 'IMPL::Exception',
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
8 ArgException => '-IMPL::InvalidArgumentException',
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
9 OpException => '-IMPL::InvalidOperationException',
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
10 SchemaNavigator => 'IMPL::DOM::Navigator::SchemaNavigator'
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
11 },
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
12 base => [
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
13 'IMPL::Web::View::Metadata::BaseMeta' => '@_'
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
14 ],
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
15 props => [
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
16 nodes => PROP_RO,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
17 decl => PROP_RO,
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
18 schema => PROP_RO,
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
19 errors => PROP_RO,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
20 group => PROP_RO
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
21 ]
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
22 };
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
23
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
24 use constant {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
25 Meta => __PACKAGE__
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
26 };
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
27
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
28 sub CTOR {
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
29 my ($this,$model,$type,$args) = @_;
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
30
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
31 if ($args) {
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
32 $this->$_($args->{$_}) foreach grep $args->{$_}, qw(decl schema nodes errors group);
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
33 }
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
34
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
35 $this->$_() || die ArgException->new($_ => "The $_ is required")
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
36 foreach qw(schema);
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
37 }
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
38
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
39 sub isMultiple {
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
40 my ($this) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
41 $this->decl && $this->decl->isMultiple;
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
42 }
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
43
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
44 sub isOptional {
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
45 my ($this) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
46 not($this->decl) || $this->decl->isOptional;
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
47 }
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
48
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
49 sub GetOwnErrors {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
50 my ($this) = @_;
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
51
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
52 my $nodes = $this->nodes;
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
53
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
54 return [
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
55 grep _IsOwnError($nodes,$this->decl,$_), @{$this->errors || []}
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
56 ];
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
57 }
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
58
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
59 sub _IsOwnError {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
60 my ($nodes,$source,$err) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
61
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
62 return 1 if ($err->node && grep($err->node == $_, @$nodes)) || (not(@$nodes) && $err->schema == $source );
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
63
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
64 return 0;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
65 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
66
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
67 sub _IsErrorRelates {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
68 my ($nodes,$source,$err) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
69
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
70 # this is an own error
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
71 return 1 if _IsOwnError($nodes,$source,$err);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
72
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
73 # this error relates to the child control
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
74
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
75 return 0 unless @$nodes;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
76
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
77 for (my $n = $err->parent; $n ; $n = $n->parentNode) {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
78 return 1 if grep($n == $_, @$nodes);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
79 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
80
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
81 return 0;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
82 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
83
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
84 sub PopulateProperties {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
85 my ($this) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
86
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
87 my @props;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
88
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
89 # return empty list of properties in case of multiple values
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
90 return \@props if $this->isMultiple;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
91
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
92 my $navi = SchemaNavigator->new($this->schema);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
93
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
94 foreach my $decl (@{$this->schema->content->childNodes}) {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
95
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
96 my $schema = $navi->NavigateName($decl->name);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
97 $navi->SchemaBack();
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
98
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
99 my @nodes = $this->model && $this->model->selectNodes( sub { $_->schemaSource == $decl } );
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
100
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
101 my %args = (
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
102 name => $decl->name,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
103 decl => $decl,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
104 schema => $schema,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
105 nodes => \@nodes,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
106 errors => [grep _IsErrorRelates(\@nodes,$decl,$_), @{$this->errors || []}]
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
107 );
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
108
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
109 my ($model,$type);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
110
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
111 if ($decl->isMultiple) {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
112 $model = \@nodes;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
113 $type = 'ARRAY';
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
114 $args{holdingType} = $decl->type;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
115 } else {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
116 $model = shift @nodes;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
117 $type = $decl->type;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
118 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
119
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
120 push @props, Meta->new($model,$type,\%args);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
121 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
122
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
123 return \@props;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
124 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
125
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
126 sub GetItems {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
127 my ($this) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
128
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
129 die OpException->new("The operation must be performed on the container")
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
130 unless $this->isMultiple;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
131
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
132 my $i = 0;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
133
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
134 return [
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
135 map $this->_GetItemMeta($_,$i++), @{$this->model || []}
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
136 ];
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
137 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
138
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
139 sub GetItem {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
140 my ($this,$index) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
141
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
142 die OpException->new("The operation must be performed on the container")
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
143 unless $this->isMultiple;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
144
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
145 my $node = $this->model->[$index];
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
146
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
147 return $this->GetItemMeta($node,$index);
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
148 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
149
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
150 sub _GetItemMeta {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
151 my ($this,$node,$index) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
152
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
153 return Meta->new(
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
154 $node,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
155 $this->decl->type,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
156 {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
157 name => $index,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
158 schema => $this->schema,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
159 errors => [grep _IsOwnError([$node],$this->decl,$_), @{$this->errors ||[]} ],
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
160 group => $this
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
161 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
162 );
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
163 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
164
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
165 1;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
166
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
167 __END__
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
168
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
169 =pod
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
170
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
171 =head1 NAME
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
172
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
173 =head1 SYNOPSIS
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
174
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
175 =head1 DESCRIPTION
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
176
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
177 Расширенные метаданные модели для элементов формы, помимо стандартных свойств
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
178 сожержит в себе информацию о схеме.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
179
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
180 =head1 MEMBERS
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
181
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
182 =head2 C<[get]errors>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
183
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
184 Ссылка на массив с ошибками при проверке схемы. Ошибки относятся ко всем
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
185 узлам в текущей модели, включая вложенные и т.п.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
186
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
187 =head2 C<[get]model>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
188
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
189 Ссылка на элемент документа, либо на массив с элементами для множественных
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
190 значений (C<isMultiple = true>). В том случае, когда документ был не
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
191 корректен и для не множественного элемента было передено несколько значений,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
192 данное свойство будет содержать только первое.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
193
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
194 =head2 C<[get]nodes>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
195
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
196 Ссылка на массив с узлами документа. В теории количество узлов может быть
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
197 произвольным, поскольку документ может быть некорректным, т.е. их может
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
198 быть более одного в то время, как C<isMultiple = false> или, напротив, ни
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
199 одного при C<isOptional = false>.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
200
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
201 Как правило для построения формы данное свойство не требуется.
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
202
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
203 =head2 C<[get]modelType>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
204
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
205 Название типа данных из схемы документа (C<< schema->name >>), если тип не имеет название, то это
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
206 C<ComplexNode> для сложных узлов и C<SimpleNode> для простых.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
207
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
208 Для моделей с множественными значениями это свойство не задано. Тип элементов
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
209 храниться в свойстве C<holdingType>
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
210
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
211 =head2 C<[get]decl>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
212
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
213 Объявление элемента формы, объявление может совпадать со схемой в случае,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
214 когда это был C<SimpleNode> или C<ComplexNode>, иначе это C<Node> ссылающийся
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
215 на заранее обпределенный тип.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
216
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
217 =head2 C<[get]schema>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
218
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
219 Схема текущего элемента, C<СomlexType>, C<SimpleType>, C<ComplexNode> или
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
220 C<SimpleNode>.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
221
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
222 =head2 C<[get]isOptional>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
223
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
224 Данный элемент может не иметь ни одного значения
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
225
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
226 =head2 C<[get]isMultiple>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
227
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
228 Данный элемент может иметь более одного значения. Модель с множественными
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
229 значениями является сложным элементом, в котором дочерними моделями являются
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
230 не свойства а сами элементы, в данном случае они их именами будут индексы.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
231
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
232 =begin code
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
233
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
234 for(my $i=0; $i< 10; $i++) {
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
235 display_for($i,'template');
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
236 }
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
237
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
238 sub display_for {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
239 my ($index,$tmpl) = @_;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
240
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
241 if ($index =~ /^\d+$/) {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
242 return render($tmpl, meta => { $meta->GetItem($index) });
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
243 } else {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
244 return render($tmpl, meta => { $meta->GetProperty($index) });
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
245 }
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
246 }
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
247
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
248 =end code
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
249
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
250 =head2 C<GetOwnErrors()>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
251
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
252 Возвращает ошибки относящиеся к самому элементу C<model>, это принципиально
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
253 для контейнеров и в случаях, когда модель не корректна и в ней присутствуют
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
254 лишние значения.
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
255
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
256 =cut