annotate Lib/IMPL/SQL/Schema/Constraint/PrimaryKey.pm @ 371:d5c8b955bf8d

refactoring
author cin
date Fri, 13 Dec 2013 16:49:47 +0400
parents 4ddb27ff4a0b
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: 32
diff changeset
1 package IMPL::SQL::Schema::Constraint::PrimaryKey;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
2 use strict;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
3 use parent qw(IMPL::SQL::Schema::Constraint::Index);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
4 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
5
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
6 __PACKAGE__->PassThroughArgs;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 165
diff changeset
7 __PACKAGE__->RegisterAlias('pk');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
9 BEGIN {
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
10 public _direct property connectedFK => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
11 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
13 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
14 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
15
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
16 $this->{$connectedFK} = {};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
19 sub ConnectFK {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
20 my ($this,$FK) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
21
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
22 UNIVERSAL::isa($FK,'IMPL::SQL::Schema::Constraint::ForeignKey') or die new Exception('Aprimary key could be connected only to a foreign key');
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
23 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);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
24
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
25 $this->{$connectedFK}->{$FK->uniqName} = $FK;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
26 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
28 sub DisconnectFK {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
29 my ($this,$FK) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
30
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
31 delete $this->{$connectedFK}->{$FK->uniqName};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
32 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
34 sub Dispose {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
35 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
36
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
37 delete $this->{$connectedFK};
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
38
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
39 $this->SUPER::Dispose;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 32
diff changeset
42 1;