Merge pull request #22631 from braders/calculateBaseScheduleDate-docblock
[civicrm-core.git] / CRM / Core / DAO / Job.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Job.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:75ec772bec625c1d315df0abadd2fca6)
10 */
11
12 /**
13 * Database access object for the Job entity.
14 */
15 class CRM_Core_DAO_Job extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_job';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Job ID
35 *
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
39 */
40 public $id;
41
42 /**
43 * Which Domain is this scheduled job for
44 *
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $domain_id;
50
51 /**
52 * Scheduled job run frequency.
53 *
54 * @var string|null
55 * (SQL type: varchar(8))
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $run_frequency;
59
60 /**
61 * When was this cron entry last run
62 *
63 * @var string
64 * (SQL type: timestamp)
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $last_run;
68
69 /**
70 * When is this cron entry scheduled to run
71 *
72 * @var string
73 * (SQL type: timestamp)
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $scheduled_run_date;
77
78 /**
79 * Title of the job
80 *
81 * @var string|null
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $name;
86
87 /**
88 * Description of the job
89 *
90 * @var string|null
91 * (SQL type: varchar(255))
92 * Note that values will be retrieved from the database as a string.
93 */
94 public $description;
95
96 /**
97 * Entity of the job api call
98 *
99 * @var string|null
100 * (SQL type: varchar(255))
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $api_entity;
104
105 /**
106 * Action of the job api call
107 *
108 * @var string|null
109 * (SQL type: varchar(255))
110 * Note that values will be retrieved from the database as a string.
111 */
112 public $api_action;
113
114 /**
115 * List of parameters to the command.
116 *
117 * @var string|null
118 * (SQL type: text)
119 * Note that values will be retrieved from the database as a string.
120 */
121 public $parameters;
122
123 /**
124 * Is this job active?
125 *
126 * @var bool|string|null
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
129 */
130 public $is_active;
131
132 /**
133 * Class constructor.
134 */
135 public function __construct() {
136 $this->__table = 'civicrm_job';
137 parent::__construct();
138 }
139
140 /**
141 * Returns localized title of this entity.
142 *
143 * @param bool $plural
144 * Whether to return the plural version of the title.
145 */
146 public static function getEntityTitle($plural = FALSE) {
147 return $plural ? ts('Jobs') : ts('Job');
148 }
149
150 /**
151 * Returns foreign keys and entity references.
152 *
153 * @return array
154 * [CRM_Core_Reference_Interface]
155 */
156 public static function getReferenceColumns() {
157 if (!isset(Civi::$statics[__CLASS__]['links'])) {
158 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
159 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
160 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
161 }
162 return Civi::$statics[__CLASS__]['links'];
163 }
164
165 /**
166 * Returns all the column names of this table
167 *
168 * @return array
169 */
170 public static function &fields() {
171 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
172 Civi::$statics[__CLASS__]['fields'] = [
173 'id' => [
174 'name' => 'id',
175 'type' => CRM_Utils_Type::T_INT,
176 'title' => ts('Job ID'),
177 'description' => ts('Job ID'),
178 'required' => TRUE,
179 'where' => 'civicrm_job.id',
180 'table_name' => 'civicrm_job',
181 'entity' => 'Job',
182 'bao' => 'CRM_Core_BAO_Job',
183 'localizable' => 0,
184 'html' => [
185 'type' => 'Number',
186 ],
187 'readonly' => TRUE,
188 'add' => '4.1',
189 ],
190 'domain_id' => [
191 'name' => 'domain_id',
192 'type' => CRM_Utils_Type::T_INT,
193 'title' => ts('Domain ID'),
194 'description' => ts('Which Domain is this scheduled job for'),
195 'required' => TRUE,
196 'where' => 'civicrm_job.domain_id',
197 'table_name' => 'civicrm_job',
198 'entity' => 'Job',
199 'bao' => 'CRM_Core_BAO_Job',
200 'localizable' => 0,
201 'FKClassName' => 'CRM_Core_DAO_Domain',
202 'html' => [
203 'label' => ts("Domain"),
204 ],
205 'pseudoconstant' => [
206 'table' => 'civicrm_domain',
207 'keyColumn' => 'id',
208 'labelColumn' => 'name',
209 ],
210 'add' => '4.1',
211 ],
212 'run_frequency' => [
213 'name' => 'run_frequency',
214 'type' => CRM_Utils_Type::T_STRING,
215 'title' => ts('Job Frequency'),
216 'description' => ts('Scheduled job run frequency.'),
217 'maxlength' => 8,
218 'size' => CRM_Utils_Type::EIGHT,
219 'where' => 'civicrm_job.run_frequency',
220 'default' => 'Daily',
221 'table_name' => 'civicrm_job',
222 'entity' => 'Job',
223 'bao' => 'CRM_Core_BAO_Job',
224 'localizable' => 0,
225 'html' => [
226 'type' => 'Select',
227 ],
228 'pseudoconstant' => [
229 'callback' => 'CRM_Core_SelectValues::getJobFrequency',
230 ],
231 'add' => '4.1',
232 ],
233 'last_run' => [
234 'name' => 'last_run',
235 'type' => CRM_Utils_Type::T_TIMESTAMP,
236 'title' => ts('Last Run'),
237 'description' => ts('When was this cron entry last run'),
238 'required' => FALSE,
239 'where' => 'civicrm_job.last_run',
240 'default' => NULL,
241 'table_name' => 'civicrm_job',
242 'entity' => 'Job',
243 'bao' => 'CRM_Core_BAO_Job',
244 'localizable' => 0,
245 'html' => [
246 'label' => ts("Last Run"),
247 ],
248 'add' => '4.1',
249 ],
250 'scheduled_run_date' => [
251 'name' => 'scheduled_run_date',
252 'type' => CRM_Utils_Type::T_TIMESTAMP,
253 'title' => ts('Scheduled Run Date'),
254 'description' => ts('When is this cron entry scheduled to run'),
255 'required' => FALSE,
256 'where' => 'civicrm_job.scheduled_run_date',
257 'default' => NULL,
258 'table_name' => 'civicrm_job',
259 'entity' => 'Job',
260 'bao' => 'CRM_Core_BAO_Job',
261 'localizable' => 0,
262 'html' => [
263 'label' => ts("Scheduled Run Date"),
264 ],
265 'add' => '4.7',
266 ],
267 'name' => [
268 'name' => 'name',
269 'type' => CRM_Utils_Type::T_STRING,
270 'title' => ts('Job Name'),
271 'description' => ts('Title of the job'),
272 'maxlength' => 255,
273 'size' => CRM_Utils_Type::HUGE,
274 'where' => 'civicrm_job.name',
275 'table_name' => 'civicrm_job',
276 'entity' => 'Job',
277 'bao' => 'CRM_Core_BAO_Job',
278 'localizable' => 0,
279 'add' => '4.1',
280 ],
281 'description' => [
282 'name' => 'description',
283 'type' => CRM_Utils_Type::T_STRING,
284 'title' => ts('Job Description'),
285 'description' => ts('Description of the job'),
286 'maxlength' => 255,
287 'size' => CRM_Utils_Type::HUGE,
288 'where' => 'civicrm_job.description',
289 'table_name' => 'civicrm_job',
290 'entity' => 'Job',
291 'bao' => 'CRM_Core_BAO_Job',
292 'localizable' => 0,
293 'add' => '4.1',
294 ],
295 'api_entity' => [
296 'name' => 'api_entity',
297 'type' => CRM_Utils_Type::T_STRING,
298 'title' => ts('API Entity'),
299 'description' => ts('Entity of the job api call'),
300 'maxlength' => 255,
301 'size' => CRM_Utils_Type::HUGE,
302 'where' => 'civicrm_job.api_entity',
303 'table_name' => 'civicrm_job',
304 'entity' => 'Job',
305 'bao' => 'CRM_Core_BAO_Job',
306 'localizable' => 0,
307 'add' => '4.1',
308 ],
309 'api_action' => [
310 'name' => 'api_action',
311 'type' => CRM_Utils_Type::T_STRING,
312 'title' => ts('API Action'),
313 'description' => ts('Action of the job api call'),
314 'maxlength' => 255,
315 'size' => CRM_Utils_Type::HUGE,
316 'where' => 'civicrm_job.api_action',
317 'table_name' => 'civicrm_job',
318 'entity' => 'Job',
319 'bao' => 'CRM_Core_BAO_Job',
320 'localizable' => 0,
321 'add' => '4.1',
322 ],
323 'parameters' => [
324 'name' => 'parameters',
325 'type' => CRM_Utils_Type::T_TEXT,
326 'title' => ts('API Parameters'),
327 'description' => ts('List of parameters to the command.'),
328 'rows' => 4,
329 'cols' => 60,
330 'where' => 'civicrm_job.parameters',
331 'table_name' => 'civicrm_job',
332 'entity' => 'Job',
333 'bao' => 'CRM_Core_BAO_Job',
334 'localizable' => 0,
335 'html' => [
336 'type' => 'TextArea',
337 ],
338 'add' => '4.1',
339 ],
340 'is_active' => [
341 'name' => 'is_active',
342 'type' => CRM_Utils_Type::T_BOOLEAN,
343 'title' => ts('Job Is Active?'),
344 'description' => ts('Is this job active?'),
345 'where' => 'civicrm_job.is_active',
346 'table_name' => 'civicrm_job',
347 'entity' => 'Job',
348 'bao' => 'CRM_Core_BAO_Job',
349 'localizable' => 0,
350 'add' => '4.1',
351 ],
352 ];
353 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
354 }
355 return Civi::$statics[__CLASS__]['fields'];
356 }
357
358 /**
359 * Return a mapping from field-name to the corresponding key (as used in fields()).
360 *
361 * @return array
362 * Array(string $name => string $uniqueName).
363 */
364 public static function &fieldKeys() {
365 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
366 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
367 }
368 return Civi::$statics[__CLASS__]['fieldKeys'];
369 }
370
371 /**
372 * Returns the names of this table
373 *
374 * @return string
375 */
376 public static function getTableName() {
377 return self::$_tableName;
378 }
379
380 /**
381 * Returns if this table needs to be logged
382 *
383 * @return bool
384 */
385 public function getLog() {
386 return self::$_log;
387 }
388
389 /**
390 * Returns the list of fields that can be imported
391 *
392 * @param bool $prefix
393 *
394 * @return array
395 */
396 public static function &import($prefix = FALSE) {
397 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'job', $prefix, []);
398 return $r;
399 }
400
401 /**
402 * Returns the list of fields that can be exported
403 *
404 * @param bool $prefix
405 *
406 * @return array
407 */
408 public static function &export($prefix = FALSE) {
409 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'job', $prefix, []);
410 return $r;
411 }
412
413 /**
414 * Returns the list of indices
415 *
416 * @param bool $localize
417 *
418 * @return array
419 */
420 public static function indices($localize = TRUE) {
421 $indices = [];
422 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
423 }
424
425 }