annotate Lib/Schema/DataSource/TypeMapping.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 package Schema::DataSource::TypeMapping;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 DeclareProperty Mappings => ACCESS_NONE;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 DeclareProperty DBIdentifierType => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 DeclareProperty DBValueType => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 sub MapType {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 my ($this,$Type) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 if (my $mapped = $this->{$Mappings}->{$Type->Name->Canonical}) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 return $mapped;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 } elsif ($Type->Attributes and $Type->GetAttribute('ValueType')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 return $this->{$DBValueType};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 return $this->{$DBIdentifierType};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 package Schema::DataSource::TypeMapping::Std;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 use Schema::DB::Type;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 our @ISA = qw(Schema::DataSource::TypeMapping);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 $this->SUPER::CTOR(
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 Mappings => {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 Identifier => new Schema::DB::Type(Name => 'Integer'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 String => new Schema::DB::Type(Name => 'varchar', MaxLength => 255),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 Integer => new Schema::DB::Type(Name => 'Integer'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 Float => new Schema::DB::Type(Name => 'Real'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36 DateTime => new Schema::DB::Type(Name => 'DateTime'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 Bool => new Schema::DB::Type(Name => 'Tinyint'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 Blob => new Schema::DB::Type(Name => 'Blob'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 Text => new Schema::DB::Type(Name => 'Text')
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 },
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 DBIdentifierType => new Schema::DB::Type(Name => 'Integer'),
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 DBValueType => new Schema::DB::Type(Name => 'varchar', MaxLength => 255)
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 1;