line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::DatabaseThing; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::DatabaseThing.pm |
11
|
|
|
|
|
|
|
# Description: Like a "Thing" but it's found in the database. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 19/10/2005 Added method: getColumns |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
############################################################################### |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
6
|
use Goo::Thing; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
22
|
1
|
|
|
1
|
|
6
|
use Goo::Database; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
23
|
1
|
|
|
1
|
|
509
|
use Goo::DatabaseObject; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
5
|
use base qw(Goo::Thing); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
305
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# new - construct a DatabaseThing |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
############################################################################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
my ($class, $handle) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# grab the conf |
39
|
0
|
|
|
|
|
|
my $this = $class->SUPER::new($handle); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# map the filename to the database (12.bug => bug table with bugid 12) |
42
|
0
|
|
|
|
|
|
$this->{id} = $this->get_prefix(); |
43
|
0
|
|
|
|
|
|
$this->{table} = $this->get_suffix(); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# if the key is specified in (.goo) otherwise assume |
46
|
|
|
|
|
|
|
# the primary key column is the table name with id appended |
47
|
0
|
|
0
|
|
|
|
$this->{key} = $this->{key} || $this->{table} . "id"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# add fields found in the database |
50
|
0
|
|
|
|
|
|
$this->add_fields(Goo::Database::get_row($this->{table}, $this->{key}, $this->{id})); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $this; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
############################################################################### |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
# get_database_object - return an object for this thing |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
############################################################################### |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_database_object { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# bail out if we don't have these thing |
68
|
0
|
0
|
0
|
|
|
|
unless ($this->{table} && $this->{id}) { |
69
|
0
|
|
|
|
|
|
die("Missing table or id " . $this->to_string()); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return Goo::DatabaseObject->new($this->{table}, $this->{id}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
############################################################################### |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
# get_location - all Database Things are located in the database |
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
############################################################################### |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_location { |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
return "database"; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
############################################################################### |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# get_columns - return the columns in display order |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
############################################################################### |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub get_columns { |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# this should be set in the .goo config file |
101
|
0
|
|
|
|
|
|
return split(/\s+/, $this->{column_display_order}); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Goo::DatabaseThing - A "Thing" that is found in the database. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SYNOPSIS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Goo::DatabaseThing; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 METHODS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item new |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
constructor |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item get_database_object |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
return an object for this Thing |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item get_location |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return the table where this DatabaseThing is located. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item get_columns |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
return the columns in display order |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 SEE ALSO |
148
|
|
|
|
|
|
|
|