annotate Lib/IMPL/ORM/Entity.pm @ 49:16ada169ca75

migrating to the Eclipse IDE
author wizard@linux-odin.local
date Fri, 26 Feb 2010 10:49:21 +0300
parents 6d33f75c6e1f
children 4267a2ac3d46
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: 28
diff changeset
1 package IMPL::ORM::Entity;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
5 use base qw(IMPL::Object);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
7 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
9 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
10 public _direct property Name => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
11 public _direct property Class => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
12 public _direct property Values => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
13 public _direct property Schema => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
14 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
16 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
17 my ($this,$class,$schema) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
19 $this->{$Class} = $class;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
20 (my $name = $class) =~ s/::/_/g;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
21 $this->{$Name} = $name;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
22 $this->Schema = $schema;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
23 $this->{$Values} = {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
24 map {$_->{name},{type => $_->{type}, virtual => $_->{virtual}}} @$schema
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
25 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
26 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
28 sub Store;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
29 *Store = \&dbgStore;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
30
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
31 sub dbgStore {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
32 my ($this,$prop,$value) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
34 if ( my $container = $this->{$Values}{$prop} ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
35 $container->{oldValue} = $container->{value};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
36 $container->{value} = $value;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
37 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
38 die new IMPL::InvalidOperationException("Property not found",$this->Name,$prop);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
39 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
42 sub Get {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
43 my ($this,$prop) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
45 return $this->{$Values}{$prop}{value};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
48 1;