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

form metadata, mostly done
author cin
date Tue, 03 Dec 2013 17:55:36 +0400
parents 935629bf80df
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
1 package IMPL::Web::View::Metadata::FormProvider;
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
2 use strict;
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
3
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
4 ues IMPL::lang ;
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
5 use IMPL::declare {
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
6 require => {
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
7 Meta => 'IMPL::Web::View::Metadata::FormMeta',
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
8
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
9 Exception => 'IMPL::Exception',
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
10 ArgException => '-IMPL::InvalidArgumentException'
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
11 },
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
12 base => [
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
13 'IMPL::Object' => undef
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
14 ]
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
15 };
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
16
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
17 sub PopulateProperties {
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
18 my ($this,$meta) = @_;
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
19
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
20 die ArgException->new(meta => 'A FormMeta is required')
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
21 unless is($meta,Meta);
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
22
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
23 my @props;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
24
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
25 # return empty list of properties in case of multiple values
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
26 return \@props if $meta->isMultiple;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
27
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
28 my $navi = SchemaNavigator->new($meta->schema);
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
29
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
30 foreach my $decl (@{$meta->schema->content->childNodes}) {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
31
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
32 my $schema = $navi->NavigateName($decl->name);
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
33 $navi->SchemaBack();
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
34
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
35 my @nodes = $meta->model && $meta->model->selectNodes( sub { $_->schemaSource == $decl } );
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
36
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
37 my %args = (
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
38 name => $decl->name,
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
39 decl => $decl,
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
40 schema => $schema,
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
41 nodes => \@nodes,
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
42 errors => [grep _IsErrorRelates(\@nodes,$decl,$_), @{$meta->errors || []}]
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
43 );
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
44
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
45 my ($model,$type);
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
46
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
47 if ($decl->isMultiple) {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
48 $model = \@nodes;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
49 $type = 'ARRAY';
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
50 $args{holdingType} = $decl->type;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
51 } else {
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
52 $model = shift @nodes;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
53 $type = $decl->type;
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
54 }
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
55
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
56 push @props, Meta->new($this,$model,$type,\%args);
366
935629bf80df model metadata, in progress
cin
parents: 365
diff changeset
57 }
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
58 }
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
59
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
60 sub GetItems {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
61 my ($this,$meta) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
62
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
63 if ($meta->isMultiple)
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
64 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
65
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
66 sub GetItem {
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
67 my ($this,$meta,$index) = @_;
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
68 }
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
69
365
7c621bb95e53 working on the metadata model
sergey
parents: 364
diff changeset
70
367
608e74bc309f form metadata, mostly done
cin
parents: 366
diff changeset
71
364
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
72
82b6c967bcf1 sync, working on metadata
cin
parents:
diff changeset
73 1;