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