annotate Lib/IMPL/Web/View/Metadata/FormMeta.pm @ 369:7c784144d2f1

Implemented object metadata class, cleanup
author cin
date Mon, 09 Dec 2013 17:35:34 +0400
parents 010ceafd0c5a
children d5c8b955bf8d
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) {
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
112 $model = \@nodes;
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
113 $type = 'ARRAY';
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
114 $args{holdingType} = $schema->type;
367
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;
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
117 $type = $schema->type;
367
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 [
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
135 map $this->_GetItemMeta($_,$i++), @{$this->nodes}
367
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
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
145 my $node = $this->nodes->[$index];
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
146
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
147 return $this->_GetItemMeta($node,$index);
367
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
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
153 my @nodes;
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
154 push @nodes,$node if $node;
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
155
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
156 return Meta->new(
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
157 $node,
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
158 $this->schema->type,
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
159 {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
160 name => $index,
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
161 schema => $this->schema,
368
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
162 errors => [grep _IsErrorRelates([$node],$this->decl,$_), @{$this->errors ||[]} ],
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
163 group => $this,
010ceafd0c5a form metadata + tests
cin
parents: 367
diff changeset
164 nodes => \@nodes
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
165 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
166 );
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
167 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
168
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
169 1;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
170
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
171 __END__
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
172
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
173 =pod
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 NAME
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
176
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
177 =head1 SYNOPSIS
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
178
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
179 =head1 DESCRIPTION
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
180
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
181 Расширенные метаданные модели для элементов формы, помимо стандартных свойств
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
182 сожержит в себе информацию о схеме.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
183
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
184 =head1 MEMBERS
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
185
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
186 =head2 C<[get]errors>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
187
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
188 Ссылка на массив с ошибками при проверке схемы. Ошибки относятся ко всем
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
189 узлам в текущей модели, включая вложенные и т.п.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
190
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
191 =head2 C<[get]model>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
192
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
193 Ссылка на элемент документа, либо на массив с элементами для множественных
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
194 значений (C<isMultiple = true>). В том случае, когда документ был не
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
195 корректен и для не множественного элемента было передено несколько значений,
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 =head2 C<[get]nodes>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
199
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
200 Ссылка на массив с узлами документа. В теории количество узлов может быть
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
201 произвольным, поскольку документ может быть некорректным, т.е. их может
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
202 быть более одного в то время, как C<isMultiple = false> или, напротив, ни
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
203 одного при C<isOptional = false>.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
204
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
205 Как правило для построения формы данное свойство не требуется.
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
206
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
207 =head2 C<[get]modelType>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
208
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
209 Название типа данных из схемы документа (C<< schema->name >>), если тип не имеет название, то это
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
210 C<ComplexNode> для сложных узлов и C<SimpleNode> для простых.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
211
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
212 Для моделей с множественными значениями это свойство не задано. Тип элементов
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
213 храниться в свойстве C<holdingType>
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
214
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
215 =head2 C<[get]decl>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
216
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
217 Объявление элемента формы, объявление может совпадать со схемой в случае,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
218 когда это был C<SimpleNode> или C<ComplexNode>, иначе это C<Node> ссылающийся
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
219 на заранее обпределенный тип.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
220
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
221 =head2 C<[get]schema>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
222
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
223 Схема текущего элемента, C<СomlexType>, C<SimpleType>, C<ComplexNode> или
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
224 C<SimpleNode>.
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]isOptional>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
227
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 =head2 C<[get]isMultiple>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
231
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
232 Данный элемент может иметь более одного значения. Модель с множественными
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
233 значениями является сложным элементом, в котором дочерними моделями являются
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
234 не свойства а сами элементы, в данном случае они их именами будут индексы.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
235
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
236 =begin code
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
237
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
238 for(my $i=0; $i< 10; $i++) {
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
239 display_for($i,'template');
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
240 }
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
241
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
242 sub display_for {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
243 my ($index,$tmpl) = @_;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
244
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
245 if ($index =~ /^\d+$/) {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
246 return render($tmpl, meta => { $meta->GetItem($index) });
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
247 } else {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
248 return render($tmpl, meta => { $meta->GetProperty($index) });
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
249 }
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
250 }
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 =end code
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
253
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
254 =head2 C<GetOwnErrors()>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
255
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
256 Возвращает ошибки относящиеся к самому элементу C<model>, это принципиально
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
257 для контейнеров и в случаях, когда модель не корректна и в ней присутствуют
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
258 лишние значения.
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
259
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
260 =cut