annotate Lib/IMPL/SQL/Schema/Constraint/PrimaryKey.pm @ 35:f25d021780b3

DOM::Navigator::Builder working version
author Sergey
date Tue, 17 Nov 2009 17:46:24 +0300
parents 56cef8e3cda6
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
Sergey
parents:
diff changeset
1 package IMPL::SQL::Schema::Constraint::PrimaryKey;
Sergey
parents:
diff changeset
2 use strict;
Sergey
parents:
diff changeset
3 use base qw(IMPL::SQL::Schema::Constraint::Index);
Sergey
parents:
diff changeset
4 use IMPL::Class::Property;
Sergey
parents:
diff changeset
5 use IMPL::Class::Property::Direct;
Sergey
parents:
diff changeset
6
Sergey
parents:
diff changeset
7 __PACKAGE__->PassThroughArgs;
Sergey
parents:
diff changeset
8
Sergey
parents:
diff changeset
9 BEGIN {
Sergey
parents:
diff changeset
10 public _direct property ConnectedFK => prop_get;
Sergey
parents:
diff changeset
11 }
Sergey
parents:
diff changeset
12
Sergey
parents:
diff changeset
13 sub CTOR {
Sergey
parents:
diff changeset
14 my ($this,%args) = @_;
Sergey
parents:
diff changeset
15
Sergey
parents:
diff changeset
16 $this->SUPER::CTOR(%args);
Sergey
parents:
diff changeset
17
Sergey
parents:
diff changeset
18 $this->{$ConnectedFK} = {};
Sergey
parents:
diff changeset
19 }
Sergey
parents:
diff changeset
20
Sergey
parents:
diff changeset
21 sub ConnectFK {
Sergey
parents:
diff changeset
22 my ($this,$FK) = @_;
Sergey
parents:
diff changeset
23
Sergey
parents:
diff changeset
24 UNIVERSAL::isa($FK,'IMPL::SQL::Schema::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key');
Sergey
parents:
diff changeset
25 not exists $this->{$ConnectedFK}->{$FK->UniqName} or die new Exception('This primary key already conneted with the specified foreing key',$FK->Name,$FK->Table->Name);
Sergey
parents:
diff changeset
26
Sergey
parents:
diff changeset
27 $this->{$ConnectedFK}->{$FK->UniqName} = $FK;
Sergey
parents:
diff changeset
28 }
Sergey
parents:
diff changeset
29
Sergey
parents:
diff changeset
30 sub DisconnectFK {
Sergey
parents:
diff changeset
31 my ($this,$FK) = @_;
Sergey
parents:
diff changeset
32
Sergey
parents:
diff changeset
33 delete $this->{$ConnectedFK}->{$FK->UniqName};
Sergey
parents:
diff changeset
34 }
Sergey
parents:
diff changeset
35
Sergey
parents:
diff changeset
36 sub Dispose {
Sergey
parents:
diff changeset
37 my ($this) = @_;
Sergey
parents:
diff changeset
38
Sergey
parents:
diff changeset
39 delete $this->{$ConnectedFK};
Sergey
parents:
diff changeset
40 $this->SUPER::Dispose;
Sergey
parents:
diff changeset
41 }
Sergey
parents:
diff changeset
42
Sergey
parents:
diff changeset
43 1;