1 | <?php |
||
40 | class QueuedJobDescriptor extends DataObject |
||
41 | { |
||
42 | /** |
||
43 | * {@inheritDoc} |
||
44 | * @var string |
||
45 | */ |
||
46 | private static $table_name = 'QueuedJobDescriptor'; |
||
47 | |||
48 | /** |
||
49 | * @var array |
||
50 | */ |
||
51 | private static $db = array( |
||
52 | 'JobTitle' => 'Varchar(255)', |
||
53 | 'Signature' => 'Varchar(64)', |
||
54 | 'Implementation' => 'Varchar(255)', |
||
55 | 'StartAfter' => 'DBDatetime', |
||
56 | 'JobStarted' => 'DBDatetime', |
||
57 | 'JobRestarted' => 'DBDatetime', |
||
58 | 'JobFinished' => 'DBDatetime', |
||
59 | 'TotalSteps' => 'Int', |
||
60 | 'StepsProcessed' => 'Int', |
||
61 | 'LastProcessedCount' => 'Int(-1)', // -1 means never checked, 0 means checked but no work is done |
||
62 | 'ResumeCounts' => 'Int', |
||
63 | 'SavedJobData' => 'Text', |
||
64 | 'SavedJobMessages' => 'Text', |
||
65 | 'JobStatus' => 'Varchar(16)', |
||
66 | 'JobType' => 'Varchar(16)', |
||
67 | ); |
||
68 | |||
69 | /** |
||
70 | * @var array |
||
71 | */ |
||
72 | private static $has_one = array( |
||
73 | 'RunAs' => 'SilverStripe\\Security\\Member', |
||
74 | ); |
||
75 | |||
76 | /** |
||
77 | * @var array |
||
78 | */ |
||
79 | private static $defaults = array( |
||
80 | 'JobStatus' => 'New', |
||
81 | 'ResumeCounts' => 0, |
||
82 | 'LastProcessedCount' => -1 // -1 means never checked, 0 means checked and none were processed |
||
83 | ); |
||
84 | |||
85 | /** |
||
86 | * @var array |
||
87 | */ |
||
88 | private static $indexes = array( |
||
89 | 'JobStatus' => true, |
||
90 | 'StartAfter' => true, |
||
91 | 'Signature' => true |
||
92 | ); |
||
93 | |||
94 | /** |
||
95 | * @var array |
||
96 | */ |
||
97 | private static $casting = array( |
||
98 | 'Messages' => 'HTMLText' |
||
99 | ); |
||
100 | |||
101 | /** |
||
102 | * @var array |
||
103 | */ |
||
104 | private static $searchable_fields = array( |
||
105 | 'JobTitle', |
||
106 | ); |
||
107 | |||
108 | /** |
||
109 | * @var string |
||
110 | */ |
||
111 | private static $default_sort = 'Created DESC'; |
||
112 | |||
113 | public function requireDefaultRecords() |
||
118 | |||
119 | /** |
||
120 | * @return array |
||
121 | */ |
||
122 | public function summaryFields() |
||
137 | |||
138 | /** |
||
139 | * Pause this job, but only if it is waiting, running, or init |
||
140 | * |
||
141 | * @param bool $force Pause this job even if it's not waiting, running, or init |
||
142 | * @return bool Return true if this job was paused |
||
143 | */ |
||
144 | public function pause($force = false) |
||
156 | |||
157 | /** |
||
158 | * Resume this job and schedules it for execution |
||
159 | * |
||
160 | * @param bool $force Resume this job even if it's not paused or broken |
||
161 | * @return bool Return true if this job was resumed |
||
162 | */ |
||
163 | public function resume($force = false) |
||
174 | |||
175 | /** |
||
176 | * Restarts this job via a forced resume |
||
177 | */ |
||
178 | public function restart() |
||
182 | |||
183 | /** |
||
184 | * Called to indicate that the job is ready to be run on the queue. This is done either as the result of |
||
185 | * creating the job and adding it, or when resuming. |
||
186 | */ |
||
187 | public function activateOnQueue() |
||
196 | |||
197 | /** |
||
198 | * Gets the path to the queuedjob cache directory |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | protected function getJobDir() |
||
215 | |||
216 | public function execute() |
||
221 | |||
222 | /** |
||
223 | * Called when the job has completed and we want to cleanup anything the descriptor has lying around |
||
224 | * in caches or the like. |
||
225 | */ |
||
226 | public function cleanupJob() |
||
234 | |||
235 | public function onBeforeDelete() |
||
240 | |||
241 | /** |
||
242 | * @return string|void |
||
243 | */ |
||
244 | public function getMessages() |
||
251 | |||
252 | /** |
||
253 | * @return string |
||
254 | */ |
||
255 | public function getTitle() |
||
259 | |||
260 | /** |
||
261 | * @return FieldList |
||
262 | */ |
||
263 | public function getCMSFields() |
||
299 | } |
||
300 |