Mercurial > pub > Impl
view Lib/IMPL/Web/View/Metadata/FormProvider.pm @ 368:010ceafd0c5a
form metadata + tests
author | cin |
---|---|
date | Wed, 04 Dec 2013 17:31:53 +0400 |
parents | 608e74bc309f |
children |
line wrap: on
line source
package IMPL::Web::View::Metadata::FormProvider; use strict; ues IMPL::lang ; use IMPL::declare { require => { Meta => 'IMPL::Web::View::Metadata::FormMeta', Exception => 'IMPL::Exception', ArgException => '-IMPL::InvalidArgumentException' }, base => [ 'IMPL::Object' => undef ] }; sub PopulateProperties { my ($this,$meta) = @_; die ArgException->new(meta => 'A FormMeta is required') unless is($meta,Meta); my @props; # return empty list of properties in case of multiple values return \@props if $meta->isMultiple; my $navi = SchemaNavigator->new($meta->schema); foreach my $decl (@{$meta->schema->content->childNodes}) { my $schema = $navi->NavigateName($decl->name); $navi->SchemaBack(); my @nodes = $meta->model && $meta->model->selectNodes( sub { $_->schemaSource == $decl } ); my %args = ( name => $decl->name, decl => $decl, schema => $schema, nodes => \@nodes, errors => [grep _IsErrorRelates(\@nodes,$decl,$_), @{$meta->errors || []}] ); my ($model,$type); if ($decl->isMultiple) { $model = \@nodes; $type = 'ARRAY'; $args{holdingType} = $decl->type; } else { $model = shift @nodes; $type = $decl->type; } push @props, Meta->new($this,$model,$type,\%args); } } sub GetItems { my ($this,$meta) = @_; if ($meta->isMultiple) } sub GetItem { my ($this,$meta,$index) = @_; } 1;