annotate Lib/IMPL/Web/View/Metadata/FormMeta.pm @ 365:7c621bb95e53

working on the metadata model
author sergey
date Mon, 02 Dec 2013 02:13:12 +0400
parents 82b6c967bcf1
children 935629bf80df
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',
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
8 ArgException => '-IMPL::InvalidArgumentException'
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
9 },
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
10 base => [
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
11 'IMPL::Web::View::Metadata::BaseMeta' => '@_'
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
12 ],
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
13 props => [
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
14 nodes => PROP_RO,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
15 decl => PROP_RO,
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
16 schema => PROP_RO,
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
17 errors => PROP_RO
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
18 ]
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
19 };
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
20
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
21 sub CTOR {
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
22 my ($this,$provider,$model,$type,$args) = @_;
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
23
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
24 if ($args) {
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
25 $this->$_($args->{$_}) foreach grep $args->{$_}, qw(decl schema nodes errors);
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
26 }
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
27
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
28 $this->$_() || die ArgException->new($_ => "The $_ is required")
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
29 foreach qw(decl schema);
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
30 }
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
31
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
32 sub isMultiple {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
33 shift->decl->isMultiple;
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
34 }
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
35
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
36 sub isOptional {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
37 shift->decl->isOptional;
364
82b6c967bcf1 sync, working on metadata
cin
parents: 363
diff changeset
38 }
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
39
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
40
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
41 sub GetOwnErrors {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
42 my ($this) = @_;
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
43
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
44 my $node = undef;
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
45
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
46 $node = not($this->isMultiple) && $this->nodes ? $this->nodes->[0] : undef;
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
47
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
48 return [
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
49 grep {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
50 ($node && $_->node && $_->node == $node) || (not($node) && $_->schema == $this->decl )
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
51 } @{$this->errors || []}
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
52 ];
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
53 }
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
54
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
55 1;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
56
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
57 __END__
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
58
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
59 =pod
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
60
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
61 =head1 NAME
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
62
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
63 =head1 SYNOPSIS
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
64
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
65 =head1 DESCRIPTION
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
66
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
67 Расширенные метаданные модели для элементов формы, помимо стандартных свойств
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
68 сожержит в себе информацию о схеме.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
69
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
70 =head1 MEMBERS
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
71
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
72 =head2 C<[get]errors>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
73
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
74 Ссылка на массив с ошибками при проверке схемы. Ошибки относятся ко всем
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
75 узлам в текущей модели, включая вложенные и т.п.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
76
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
77 =head2 C<[get]model>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
78
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
79 Ссылка на элемент документа, либо на массив с элементами для множественных
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
80 значений (C<isMultiple = true>). В том случае, когда документ был не
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
81 корректен и для не множественного элемента было передено несколько значений,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
82 данное свойство будет содержать только первое.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
83
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
84 =head2 C<[get]nodes>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
85
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
86 Ссылка на массив с узлами документа. В теории количество узлов может быть
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
87 произвольным, поскольку документ может быть некорректным, т.е. их может
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
88 быть более одного в то время, как C<isMultiple = false> или, напротив, ни
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
89 одного при C<isOptional = false>.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
90
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
91 =head2 C<[get]modelType>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
92
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
93 Название типа данных из схемы документа (C<< schema->name >>), если тип не имеет название, то это
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
94 C<ComplexNode> для сложных узлов и C<SimpleNode> для простых.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
95
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
96 Для моделей с множественными значениями это свойство означает тип элементов.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
97
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
98 =head2 C<[get]decl>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
99
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
100 Объявление элемента формы, объявление может совпадать со схемой в случае,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
101 когда это был C<SimpleNode> или C<ComplexNode>, иначе это C<Node> ссылающийся
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
102 на заранее обпределенный тип.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
103
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
104 =head2 C<[get]schema>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
105
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
106 Схема текущего элемента, C<СomlexType>, C<SimpleType>, C<ComplexNode> или
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
107 C<SimpleNode>.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
108
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
109 =head2 C<[get]isOptional>
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
110
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
111 Данный элемент может не иметь ни одного значения
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
112
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
113 =head2 C<[get]isMultiple>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
114
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
115 Данный элемент может иметь более одного значения. Модель с множественными
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
116 значениями является сложным элементом, в котором дочерними моделями являются
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
117 не свойства а сами элементы, в данном случае они их именами будут индексы.
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
118
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
119 =begin code
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
120
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
121 for(my $i=0; $i< 10; $i++) {
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
122 display_model(
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
123 $meta->model->[$i],
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
124 schema => meta->schema,
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
125 );
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
126 }
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
127
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
128 =end code
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
129
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
130 =head2 C<GetOwnErrors()>
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
131
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
132 Возвращает ошибки относящиеся к самому элементу C<model>, это принципиально
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
133 для контейнеров и в случаях, когда модель не корректна и в ней присутствуют
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
134 лишние значения.
362
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
135
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
136 =cut