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

working on the metadata model
author sergey
date Mon, 02 Dec 2013 02:13:12 +0400
parents 715b9959b207
children
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::ObjectProvider;
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
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
4 use IMPL::lang;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
5 use IMPL::declare {
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
6 require => {
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
7 Exception => 'IMPL::Exception',
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
8 ArgException => '-IMPL::InvalidArgumentException',
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
9 Meta => 'IMPL::Web::View::Metadata',
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
10 PropertyInfo => 'IMPL::Class::PropertyInfo'
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
11 },
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
12 base => [
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
13 'IMPL::Object' => undef
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
14 ]
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
15 };
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
16
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
17 sub GetMetadata {
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
18 my ($this,$model) = @_;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
19
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
20 my $class = typeof($model) || $model;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
21
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
22 return Meta->new(
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
23 type => $class,
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
24 provider => $this
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
25 );
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
26 }
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
27
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
28 # returns array of metadata
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
29 sub GetFields {
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
30 my ($this,$class) = @_;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
31
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
32 my %seen;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
33
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
34 return map {
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
35 my %meta = (
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
36 provider => $this
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
37 );
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
38
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
39 $meta{type} = $_->type if $_->type;
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
40
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
41 # TODO extend from metadata and external providers
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
42
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
43 return Meta->new(%meta);
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
44 } $class->GetMeta(PropertyInfo, sub { $seen{$_->name} ? 0 : ($seen{$_->name} = 1) } , 1);
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
45
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
46 }
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
47
715b9959b207 WebView: initial work on metadata providers
cin
parents:
diff changeset
48 1;