comparison Lib/IMPL/ORM/Object.pm @ 30:dd4d72600c69

ORM in works
author Sergey
date Tue, 03 Nov 2009 16:31:47 +0300
parents 37160f7c8edb
children d59526f6310e
comparison
equal deleted inserted replaced
29:37160f7c8edb 30:dd4d72600c69
40 my ($this,$class,$prop,$value) = @_; 40 my ($this,$class,$prop,$value) = @_;
41 41
42 return $this->{$_entities}{$class} ? $this->{$_entities}{$class}->Get($prop,$value) : undef; 42 return $this->{$_entities}{$class} ? $this->{$_entities}{$class}->Get($prop,$value) : undef;
43 } 43 }
44 44
45 #sub _PropertyImplementor { 45 sub _PropertyImplementor {
46 # 'IMPL::ORM::Property' 46 'IMPL::ORM::PropertyImplementor'
47 #} 47 }
48 48
49 sub entityName { 49 sub entityName {
50 (my $self = ref $_[0] || $_[0]) =~ s/::/_/g; 50 (my $self = ref $_[0] || $_[0]) =~ s/::/_/g;
51 return $self; 51 return $self;
52 } 52 }
53 53
54 sub ormGetSchema { 54 sub ormGetSchema {
55 my ($self,$dataSchema) = @_; 55 my ($self,$dataSchema,$surrogate) = @_;
56 56
57 my $schema = IMPL::ORM::Schema::Entity->new($self->entityName); 57 my $schema = $surrogate || IMPL::ORM::Schema::Entity->new($self->entityName);
58 58
59 # для текущего класса, проходим по всем свойствам 59 # для текущего класса, проходим по всем свойствам
60 foreach my $ormProp ( 60 foreach my $ormProp (
61 $self->get_meta( 61 $self->get_meta(
62 'IMPL::Class::PropertyInfo', 62 'IMPL::Class::PropertyInfo',
63 sub { 63 sub {
64 UNIVERSAL::isa($_->Implementor, 'IMPL::ORM::Property' ) 64 UNIVERSAL::isa($_->Implementor, 'IMPL::ORM::PropertyImplementor' )
65 }, 65 },
66 0 66 0
67 ) 67 )
68 ){ 68 ){
69 if ($ormProp->Mutators & prop_list) { 69 if ($ormProp->Mutators & prop_list) {
90 my $class = ref $self || $self; 90 my $class = ref $self || $self;
91 91
92 # по всем классам 92 # по всем классам
93 foreach my $super (grep $_->isa(__PACKAGE__), @{"${class}::ISA"}) { 93 foreach my $super (grep $_->isa(__PACKAGE__), @{"${class}::ISA"}) {
94 my $type = $dataSchema->resolveType($super) or die new IMPL::InvalidOperationException("Failed to resolve a super class due building schema for a class", $class, $super); 94 my $type = $dataSchema->resolveType($super) or die new IMPL::InvalidOperationException("Failed to resolve a super class due building schema for a class", $class, $super);
95 $schema->appentChild(new IMPL::ORM::Schema::Relation::Subclass($type)); 95 $schema->appendChild(new IMPL::ORM::Schema::Relation::Subclass($type));
96 } 96 }
97 } 97 }
98 98
99 return $schema; 99 return $schema;
100 } 100 }