# HG changeset patch # User Sergey # Date 1262868109 -10800 # Node ID 009aa9ca2e485909cb4e363be142bd1ffc65839a # Parent 4ff27cd051e34675221812f486bf92296d029882# Parent c442eb67fa22115f0e89c5f41a8bb20d4659f26d merge diff -r c442eb67fa22 -r 009aa9ca2e48 Lib/IMPL/ORM/Schema.pm --- a/Lib/IMPL/ORM/Schema.pm Mon Dec 21 17:40:09 2009 +0300 +++ b/Lib/IMPL/ORM/Schema.pm Thu Jan 07 15:41:49 2010 +0300 @@ -8,13 +8,13 @@ require IMPL::ORM::Schema::ValueType; our %CTOR = ( - 'IMPL::DOM::Document' => sub { nodeName => 'ORMSchema' } + 'IMPL::DOM::Document' => sub { nodeName => 'Schema' } ); BEGIN { - private property mapValueTypes => prop_all; - private property mapReferenceTypes => prop_all; - private property mapPending => prop_all; + public property mapValueTypes => prop_get | owner_set; + public property mapReferenceTypes => prop_get | owner_set; + public property mapPending => prop_get | owner_set; public property prefix => prop_get | owner_set; } @@ -46,9 +46,9 @@ my $entity = new IMPL::ORM::Schema::Entity($typeName); - $this->appendChild($entity); + $this->mapPending->{$typeName} = $entity; - $this->mapPending->{$typeName} = $entity; + $this->appendChild($entity); return $this->mapReferenceTypes->{$typeName} = $entity; } @@ -56,7 +56,12 @@ sub _addReferenceType { my ($this,$className) = @_; - $this->mapReferenceTypes->{$className} = $className->ormGetSchema($this,delete $this->mapPending->{$className} || $this->appendChild(new IMPL::ORM::Schema::Entity($className))); + if ( my $entity = delete $this->mapPending->{$className} ) { + $className->ormGetSchema($this,$entity); + } else { + return $this->appendChild( $this->mapReferenceTypes->{$className} = $className->ormGetSchema($this) ); + } + } # returns valuetype name @@ -68,12 +73,6 @@ return $this->mapValueTypes->{$typeName}; } -sub ReferenceTypes { - my ($this) = @_; - - values %{$this->mapReferenceTypes}; -} - my %instances; sub instance { my ($class) = @_; @@ -86,12 +85,10 @@ $this = ref $this ? $this : $this->instance; - $this->mapValueTypes->{$_} = $this->appendChild( - IMPL::ORM::Schema::ValueType->new( - name => $_, - mapper => $classes{$_} - ) - ) foreach keys %classes; + while ( my ($typeName,$typeReflected) = each %classes ) { + $this->mapValueTypes->{$typeName} = $typeReflected; + $this->appendChild(IMPL::ORM::Schema::ValueType->new($typeName,$typeReflected)); + } } sub Classes { @@ -115,8 +112,7 @@ $this = ref $this ? $this : $this->instance; - $this->mapReferenceTypes->{$_} = $_->ormGetSchema($this,delete $this->mapPending->{$_}) - foreach (keys %{$this->mapPending}); + $_->ormGetSchema($this,delete $this->mapPending->{$_}) foreach (keys %{$this->mapPending}); } 1; @@ -132,4 +128,18 @@ Каждый узел - это описание сущности. + + + + + + + + + + + + + + =cut \ No newline at end of file diff -r c442eb67fa22 -r 009aa9ca2e48 Lib/IMPL/ORM/Schema/ValueType.pm --- a/Lib/IMPL/ORM/Schema/ValueType.pm Mon Dec 21 17:40:09 2009 +0300 +++ b/Lib/IMPL/ORM/Schema/ValueType.pm Thu Jan 07 15:41:49 2010 +0300 @@ -1,22 +1,31 @@ package IMPL::ORM::Schema::ValueType; + use strict; -use warnings; use base qw(IMPL::DOM::Node); + +our %CTOR = ( + 'IMPL::DOM::Node' => sub { nodeName => 'ValueType' } +); + use IMPL::Class::Property; -use IMPL::DOM::Property qw(_dom); BEGIN { - public _dom property name => prop_all; - public _dom property mapper => prop_all; + public property typeName => prop_all; + public property typeReflected => prop_all; } -our %CTOR = ( - 'IMPL::DOM::Node' => sub { - my %args = @_; - $args{nodeName} = 'ValueType'; - %args; - } -); +sub CTOR { + my ($this,$typeName,$typeReflected) = @_; + + $this->typeName($typeName); + $this->typeReflected($typeReflected); +} 1; + +__END__ + +=pod + +=cut \ No newline at end of file