add stack backtrace to fatal problems in virtual field check
[freeside.git] / FS / FS / queue_depend.pm
1 package FS::queue_depend;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::queue;
7
8 @ISA = qw(FS::Record);
9
10 =head1 NAME
11
12 FS::queue_depend - Object methods for queue_depend records
13
14 =head1 SYNOPSIS
15
16   use FS::queue_depend;
17
18   $record = new FS::queue_depend \%hash;
19   $record = new FS::queue_depend { 'column' => 'value' };
20
21   $error = $record->insert;
22
23   $error = $new_record->replace($old_record);
24
25   $error = $record->delete;
26
27   $error = $record->check;
28
29 =head1 DESCRIPTION
30
31 An FS::queue_depend object represents an job dependancy.  FS::queue_depend
32 inherits from FS::Record.  The following fields are currently supported:
33
34 =over 4
35
36 =item dependnum - primary key
37
38 =item jobnum - source jobnum (see L<FS::queue>).
39
40 =item depend_jobnum - dependancy jobnum (see L<FS::queue>)
41
42 =back
43
44 The job specified by B<jobnum> depends on the job specified B<depend_jobnum> -
45 the B<jobnum> job will not be run until the B<depend_jobnum> job has completed
46 sucessfully (or manually removed).
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new dependancy.  To add the dependancy to the database, see
55 L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 # the new method can be inherited from FS::Record, if a table method is defined
63
64 sub table { 'queue_depend'; }
65
66 =item insert
67
68 Adds this record to the database.  If there is an error, returns the error,
69 otherwise returns false.
70
71 =cut
72
73 # the insert method can be inherited from FS::Record
74
75 =item delete
76
77 Delete this record from the database.
78
79 =cut
80
81 # the delete method can be inherited from FS::Record
82
83 =item replace OLD_RECORD
84
85 Replaces the OLD_RECORD with this one in the database.  If there is an error,
86 returns the error, otherwise returns false.
87
88 =cut
89
90 # the replace method can be inherited from FS::Record
91
92 =item check
93
94 Checks all fields to make sure this is a valid dependancy.  If there is
95 an error, returns the error, otherwise returns false.  Called by the insert
96 and replace methods.
97
98 =cut
99
100 sub check {
101   my $self = shift;
102
103   $self->ut_numbern('dependnum')
104     || $self->ut_foreign_key('jobnum',        'queue', 'jobnum')
105     || $self->ut_foreign_key('depend_jobnum', 'queue', 'jobnum')
106     || $self->SUPER::check
107   ;
108 }
109
110 =back
111
112 =head1 BUGS
113
114 =head1 SEE ALSO
115
116 L<FS::queue>, L<FS::Record>, schema.html from the base documentation.
117
118 =cut
119
120 1;
121