annotate Lib/IMPL/ORM/Entity.pm @ 31:d59526f6310e

Small fixes to Test framework (correct handlinf of the compilation errors in the test units) Imported and refactored SQL DB schema from the old project
author Sergey
date Mon, 09 Nov 2009 01:39:16 +0300
parents 6d33f75c6e1f
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package IMPL::ORM::Entity;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use warnings;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
5 use base qw(IMPL::Object);
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 use IMPL::Class::Property;
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
7 use IMPL::Class::Property::Direct;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
8
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
9 BEGIN {
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
10 public _direct property Name => prop_get;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
11 public _direct property Class => prop_get;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
12 public _direct property Values => prop_get;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
13 public _direct property Schema => prop_get;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
14 }
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
15
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
16 sub CTOR {
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
17 my ($this,$class,$schema) = @_;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
18
28
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
19 $this->{$Class} = $class;
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
20 (my $name = $class) =~ s/::/_/g;
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
21 $this->{$Name} = $name;
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
22 $this->Schema = $schema;
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
23 $this->{$Values} = {
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
24 map {$_->{name},{type => $_->{type}, virtual => $_->{virtual}}} @$schema
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
25 };
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
26 }
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
28 sub Store;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
29 *Store = \&dbgStore;
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
31 sub dbgStore {
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
32 my ($this,$prop,$value) = @_;
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
33
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
34 if ( my $container = $this->{$Values}{$prop} ) {
28
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
35 $container->{oldValue} = $container->{value};
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
36 $container->{value} = $value;
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
37 } else {
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
38 die new IMPL::InvalidOperationException("Property not found",$this->Name,$prop);
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
39 }
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
40 }
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
41
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
42 sub Get {
28
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
43 my ($this,$prop) = @_;
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
44
28
6d33f75c6e1f ORM in works
Sergey
parents: 27
diff changeset
45 return $this->{$Values}{$prop}{value};
27
b544a772b654 ORM in progress
Sergey
parents: 0
diff changeset
46 }
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
47
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
48 1;