line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::DatabaseThing::Editor; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::DatabaseThing::Editor.pm |
11
|
|
|
|
|
|
|
# Description: Edit a Table |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 16/10/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 16/10/2005 Need to create a Table |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
############################################################################### |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
3654
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
7
|
use Goo::Object; |
|
1
|
|
|
|
|
218
|
|
|
1
|
|
|
|
|
24
|
|
23
|
1
|
|
|
1
|
|
5
|
use Goo::Prompter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
24
|
1
|
|
|
1
|
|
5
|
use Goo::Database; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
25
|
1
|
|
|
1
|
|
18
|
use Goo::TextEditor; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
5
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
248
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
############################################################################### |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# run - edit a task |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
############################################################################### |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub run { |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
my ($this, $thing, $field) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
unless ($field) { |
41
|
0
|
|
|
|
|
|
$field = Goo::Prompter::pick_one("Edit which field?", $thing->get_columns()); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# grab the task |
45
|
0
|
|
|
|
|
|
my $dbo = $thing->get_database_object(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# create a filename |
48
|
0
|
|
|
|
|
|
my $temp_filename = "/tmp/" . $thing->{table} . "-" . $field . ".tmp"; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# write database value to a file |
51
|
0
|
|
|
|
|
|
Goo::FileUtilities::write_file($temp_filename, $dbo->{$field}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# edit the value |
54
|
0
|
|
|
|
|
|
Goo::TextEditor::edit($temp_filename); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# slurp the file back into RAM |
57
|
0
|
|
|
|
|
|
$dbo->{$field} = Goo::FileUtilities::slurp($temp_filename); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# update the database |
60
|
0
|
|
|
|
|
|
$dbo->replace(); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# remove the temporary file |
63
|
0
|
|
|
|
|
|
unlink($temp_filename); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Goo::DatabaseThing::Editor - Edit a row in a database table |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Goo::DatabaseThing::Editor; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item run |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
edit a row in a database table |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|