28bdc5edc556bc1d208662479af7f27fd0069412
[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:b6077b55d593903b9ab9f673c40dd1b1)
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 'add' => '4.1',
166 ],
167 'domain_id' => [
168 'name' => 'domain_id',
169 'type' => CRM_Utils_Type::T_INT,
170 'title' => ts('Domain ID'),
171 'description' => ts('Which Domain is this scheduled job for'),
172 'required' => TRUE,
173 'where' => 'civicrm_job.domain_id',
174 'table_name' => 'civicrm_job',
175 'entity' => 'Job',
176 'bao' => 'CRM_Core_BAO_Job',
177 'localizable' => 0,
178 'FKClassName' => 'CRM_Core_DAO_Domain',
179 'html' => [
180 'label' => ts("Domain"),
181 ],
182 'pseudoconstant' => [
183 'table' => 'civicrm_domain',
184 'keyColumn' => 'id',
185 'labelColumn' => 'name',
186 ],
187 'add' => '4.1',
188 ],
189 'run_frequency' => [
190 'name' => 'run_frequency',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Job Frequency'),
193 'description' => ts('Scheduled job run frequency.'),
194 'maxlength' => 8,
195 'size' => CRM_Utils_Type::EIGHT,
196 'where' => 'civicrm_job.run_frequency',
197 'default' => 'Daily',
198 'table_name' => 'civicrm_job',
199 'entity' => 'Job',
200 'bao' => 'CRM_Core_BAO_Job',
201 'localizable' => 0,
202 'html' => [
203 'type' => 'Select',
204 ],
205 'pseudoconstant' => [
206 'callback' => 'CRM_Core_SelectValues::getJobFrequency',
207 ],
208 'add' => '4.1',
209 ],
210 'last_run' => [
211 'name' => 'last_run',
212 'type' => CRM_Utils_Type::T_TIMESTAMP,
213 'title' => ts('Last Run'),
214 'description' => ts('When was this cron entry last run'),
215 'required' => FALSE,
216 'where' => 'civicrm_job.last_run',
217 'default' => 'NULL',
218 'table_name' => 'civicrm_job',
219 'entity' => 'Job',
220 'bao' => 'CRM_Core_BAO_Job',
221 'localizable' => 0,
222 'html' => [
223 'label' => ts("Last Run"),
224 ],
225 'add' => '4.1',
226 ],
227 'scheduled_run_date' => [
228 'name' => 'scheduled_run_date',
229 'type' => CRM_Utils_Type::T_TIMESTAMP,
230 'title' => ts('Scheduled Run Date'),
231 'description' => ts('When is this cron entry scheduled to run'),
232 'required' => FALSE,
233 'where' => 'civicrm_job.scheduled_run_date',
234 'default' => 'NULL',
235 'table_name' => 'civicrm_job',
236 'entity' => 'Job',
237 'bao' => 'CRM_Core_BAO_Job',
238 'localizable' => 0,
239 'html' => [
240 'label' => ts("Scheduled Run Date"),
241 ],
242 'add' => '4.7',
243 ],
244 'name' => [
245 'name' => 'name',
246 'type' => CRM_Utils_Type::T_STRING,
247 'title' => ts('Job Name'),
248 'description' => ts('Title of the job'),
249 'maxlength' => 255,
250 'size' => CRM_Utils_Type::HUGE,
251 'where' => 'civicrm_job.name',
252 'table_name' => 'civicrm_job',
253 'entity' => 'Job',
254 'bao' => 'CRM_Core_BAO_Job',
255 'localizable' => 0,
256 'add' => '4.1',
257 ],
258 'description' => [
259 'name' => 'description',
260 'type' => CRM_Utils_Type::T_STRING,
261 'title' => ts('Job Description'),
262 'description' => ts('Description of the job'),
263 'maxlength' => 255,
264 'size' => CRM_Utils_Type::HUGE,
265 'where' => 'civicrm_job.description',
266 'table_name' => 'civicrm_job',
267 'entity' => 'Job',
268 'bao' => 'CRM_Core_BAO_Job',
269 'localizable' => 0,
270 'add' => '4.1',
271 ],
272 'api_entity' => [
273 'name' => 'api_entity',
274 'type' => CRM_Utils_Type::T_STRING,
275 'title' => ts('API Entity'),
276 'description' => ts('Entity of the job api call'),
277 'maxlength' => 255,
278 'size' => CRM_Utils_Type::HUGE,
279 'where' => 'civicrm_job.api_entity',
280 'table_name' => 'civicrm_job',
281 'entity' => 'Job',
282 'bao' => 'CRM_Core_BAO_Job',
283 'localizable' => 0,
284 'add' => '4.1',
285 ],
286 'api_action' => [
287 'name' => 'api_action',
288 'type' => CRM_Utils_Type::T_STRING,
289 'title' => ts('API Action'),
290 'description' => ts('Action of the job api call'),
291 'maxlength' => 255,
292 'size' => CRM_Utils_Type::HUGE,
293 'where' => 'civicrm_job.api_action',
294 'table_name' => 'civicrm_job',
295 'entity' => 'Job',
296 'bao' => 'CRM_Core_BAO_Job',
297 'localizable' => 0,
298 'add' => '4.1',
299 ],
300 'parameters' => [
301 'name' => 'parameters',
302 'type' => CRM_Utils_Type::T_TEXT,
303 'title' => ts('API Parameters'),
304 'description' => ts('List of parameters to the command.'),
305 'rows' => 4,
306 'cols' => 60,
307 'where' => 'civicrm_job.parameters',
308 'table_name' => 'civicrm_job',
309 'entity' => 'Job',
310 'bao' => 'CRM_Core_BAO_Job',
311 'localizable' => 0,
312 'html' => [
313 'type' => 'TextArea',
314 ],
315 'add' => '4.1',
316 ],
317 'is_active' => [
318 'name' => 'is_active',
319 'type' => CRM_Utils_Type::T_BOOLEAN,
320 'title' => ts('Job Is Active?'),
321 'description' => ts('Is this job active?'),
322 'where' => 'civicrm_job.is_active',
323 'table_name' => 'civicrm_job',
324 'entity' => 'Job',
325 'bao' => 'CRM_Core_BAO_Job',
326 'localizable' => 0,
327 'add' => '4.1',
328 ],
329 ];
330 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
331 }
332 return Civi::$statics[__CLASS__]['fields'];
333 }
334
335 /**
336 * Return a mapping from field-name to the corresponding key (as used in fields()).
337 *
338 * @return array
339 * Array(string $name => string $uniqueName).
340 */
341 public static function &fieldKeys() {
342 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
343 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
344 }
345 return Civi::$statics[__CLASS__]['fieldKeys'];
346 }
347
348 /**
349 * Returns the names of this table
350 *
351 * @return string
352 */
353 public static function getTableName() {
354 return self::$_tableName;
355 }
356
357 /**
358 * Returns if this table needs to be logged
359 *
360 * @return bool
361 */
362 public function getLog() {
363 return self::$_log;
364 }
365
366 /**
367 * Returns the list of fields that can be imported
368 *
369 * @param bool $prefix
370 *
371 * @return array
372 */
373 public static function &import($prefix = FALSE) {
374 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'job', $prefix, []);
375 return $r;
376 }
377
378 /**
379 * Returns the list of fields that can be exported
380 *
381 * @param bool $prefix
382 *
383 * @return array
384 */
385 public static function &export($prefix = FALSE) {
386 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'job', $prefix, []);
387 return $r;
388 }
389
390 /**
391 * Returns the list of indices
392 *
393 * @param bool $localize
394 *
395 * @return array
396 */
397 public static function indices($localize = TRUE) {
398 $indices = [];
399 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
400 }
401
402 }