annotate Lib/IMPL/ORM.pm @ 246:2746a8e5a6c4

Fixed regressions in DOM due previous refactorings Fixed ObjectToDOM transformation to handle a schema with mixed node types
author sergey
date Tue, 30 Oct 2012 01:17:31 +0400
parents 4d0e1962161c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
1 package IMPL::ORM;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 79
diff changeset
5 use parent qw(IMPL::Object);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
7 use Scalar::Util qw(weaken refaddr);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
9 use IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
10
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
11 our $Depth = 1; # загружать объект + 1 уровень детей
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
12 our $UseProxy = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
14 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
15 private property _ObjectCache => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
16 private property _MapInstances => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
17 private property _WorkUnit => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
18 public property Schema => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
19 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
21 sub ObjectInfoById {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
22 my ($this,$oid) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
24 return $this->_ObjectCache->{$oid};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
25 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
26
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
27 sub ObjectInfo {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
28 my ($this,$inst) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
30 die new IMPL::InvalidOperationException("This method can be used only for a reference") unless ref $inst;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
32 return $this->_MapInstances->{refaddr $inst};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
33 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
36 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
37 __END__
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
38
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
39 =pod
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
40
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
41 =head1 NAME
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
42
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
43 C<IMPL::ORM> - Object Relational Mapping
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
44
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
45 =head1 SYNOPSIS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
46
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
47 =begin code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
48
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
49 my $ds = IMPL::ORM::Storage::DBIC->new('My::Data',$dsn,$user,$pass,{Autocommit => 1});
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
50
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
51
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
52 my $foo = $ds->Insert(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
53 My::Data::Foo->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
54 'foo class'
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
55 )
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
56 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
57
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
58 my $bar = $ds->Insert(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
59 My::Data::Bar->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
60 'bar class'
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
61 )
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
62 )
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
63
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
64 $bar->fooObject($foo);
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
65
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
66 $ds->Save($bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
67
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
68 my $fooOther = $ds->Retrieve(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
69 'My::Data::Bar',
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
70 {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
71 name => 'bar class',
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
72 fooObject => {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
73 name => 'some foo'
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
74 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
75 }
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
76 )
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
77
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
78 =end code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
79
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
80 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 0
diff changeset
81
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 166
diff changeset
82 =cut