dev/core#3719 fix inconistent handling of job_type:label
[civicrm-core.git] / CRM / Core / DAO / UserJob.php
CommitLineData
a082d2df
EM
1<?php
2
3/**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/UserJob.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
d2b81f5a 9 * (GenCodeChecksum:4976da6332cddd37dbae0071e2319611)
a082d2df
EM
10 */
11
12/**
13 * Database access object for the UserJob entity.
14 */
15class CRM_Core_DAO_UserJob extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '5.50';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_user_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
b91685f5
EM
33 /**
34 * Paths for accessing this entity in the UI.
35 *
36 * @var string[]
37 */
38 protected static $_paths = [
39 'view' => 'civicrm/import/contact/summary?reset=1&user_job_id=[id]',
40 ];
41
a082d2df
EM
42 /**
43 * Job ID
44 *
45 * @var int|string|null
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $id;
50
51 /**
52 * Unique name for job.
53 *
54 * @var string|null
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $name;
59
60 /**
61 * FK to contact table.
62 *
63 * @var int|string|null
64 * (SQL type: int unsigned)
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $created_id;
68
69 /**
70 * Date and time this job was created.
71 *
72 * @var string
73 * (SQL type: timestamp)
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $created_date;
77
78 /**
79 * Date and time this import job started.
80 *
81 * @var string
82 * (SQL type: timestamp)
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $start_date;
86
87 /**
88 * Date and time this import job ended.
89 *
90 * @var string
91 * (SQL type: timestamp)
92 * Note that values will be retrieved from the database as a string.
93 */
94 public $end_date;
95
96 /**
97 * Date and time to clean up after this import job (temp table deletion date).
98 *
99 * @var string
100 * (SQL type: timestamp)
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $expires_date;
104
105 /**
106 * @var int|string
107 * (SQL type: int unsigned)
108 * Note that values will be retrieved from the database as a string.
109 */
110 public $status_id;
111
112 /**
d2b81f5a
EM
113 * Name of the job type, which will allow finding the correct class
114 *
115 * @var string
116 * (SQL type: varchar(64))
a082d2df
EM
117 * Note that values will be retrieved from the database as a string.
118 */
d2b81f5a 119 public $job_type;
a082d2df
EM
120
121 /**
122 * FK to Queue
123 *
124 * @var int|string|null
125 * (SQL type: int unsigned)
126 * Note that values will be retrieved from the database as a string.
127 */
128 public $queue_id;
129
130 /**
131 * Data pertaining to job configuration
132 *
133 * @var string|null
134 * (SQL type: text)
135 * Note that values will be retrieved from the database as a string.
136 */
137 public $metadata;
138
77b7441a
TO
139 /**
140 * Is this a template configuration (for use by other/future jobs)?
141 *
142 * @var bool|string
143 * (SQL type: tinyint)
144 * Note that values will be retrieved from the database as a string.
145 */
146 public $is_template;
147
a082d2df
EM
148 /**
149 * Class constructor.
150 */
151 public function __construct() {
152 $this->__table = 'civicrm_user_job';
153 parent::__construct();
154 }
155
156 /**
157 * Returns localized title of this entity.
158 *
159 * @param bool $plural
160 * Whether to return the plural version of the title.
161 */
162 public static function getEntityTitle($plural = FALSE) {
163 return $plural ? ts('User Jobs') : ts('User Job');
164 }
165
166 /**
167 * Returns foreign keys and entity references.
168 *
169 * @return array
170 * [CRM_Core_Reference_Interface]
171 */
172 public static function getReferenceColumns() {
173 if (!isset(Civi::$statics[__CLASS__]['links'])) {
174 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
175 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
176 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'queue_id', 'civicrm_queue', 'id');
177 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
178 }
179 return Civi::$statics[__CLASS__]['links'];
180 }
181
182 /**
183 * Returns all the column names of this table
184 *
185 * @return array
186 */
187 public static function &fields() {
188 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
189 Civi::$statics[__CLASS__]['fields'] = [
190 'id' => [
191 'name' => 'id',
192 'type' => CRM_Utils_Type::T_INT,
193 'title' => ts('User Job ID'),
194 'description' => ts('Job ID'),
195 'required' => TRUE,
196 'where' => 'civicrm_user_job.id',
197 'table_name' => 'civicrm_user_job',
198 'entity' => 'UserJob',
199 'bao' => 'CRM_Core_BAO_UserJob',
200 'localizable' => 0,
201 'html' => [
202 'type' => 'Number',
203 ],
204 'readonly' => TRUE,
205 'add' => '5.50',
206 ],
207 'name' => [
208 'name' => 'name',
209 'type' => CRM_Utils_Type::T_STRING,
210 'title' => ts('User job name'),
211 'description' => ts('Unique name for job.'),
212 'maxlength' => 64,
213 'size' => CRM_Utils_Type::BIG,
214 'where' => 'civicrm_user_job.name',
215 'table_name' => 'civicrm_user_job',
216 'entity' => 'UserJob',
217 'bao' => 'CRM_Core_BAO_UserJob',
218 'localizable' => 0,
219 'add' => '5.50',
220 ],
221 'created_id' => [
222 'name' => 'created_id',
223 'type' => CRM_Utils_Type::T_INT,
224 'title' => ts('Created By Contact ID'),
225 'description' => ts('FK to contact table.'),
226 'where' => 'civicrm_user_job.created_id',
227 'table_name' => 'civicrm_user_job',
228 'entity' => 'UserJob',
229 'bao' => 'CRM_Core_BAO_UserJob',
230 'localizable' => 0,
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 'html' => [
233 'label' => ts("Created By"),
234 ],
235 'add' => '5.50',
236 ],
237 'created_date' => [
238 'name' => 'created_date',
239 'type' => CRM_Utils_Type::T_TIMESTAMP,
240 'title' => ts('Import Job Created Date'),
241 'description' => ts('Date and time this job was created.'),
242 'required' => TRUE,
243 'where' => 'civicrm_user_job.created_date',
244 'default' => 'CURRENT_TIMESTAMP',
245 'table_name' => 'civicrm_user_job',
246 'entity' => 'UserJob',
247 'bao' => 'CRM_Core_BAO_UserJob',
248 'localizable' => 0,
249 'html' => [
250 'type' => 'Select Date',
251 'formatType' => 'activityDateTime',
252 ],
253 'readonly' => TRUE,
254 'add' => '5.50',
255 ],
256 'start_date' => [
257 'name' => 'start_date',
258 'type' => CRM_Utils_Type::T_TIMESTAMP,
259 'title' => ts('Import Job Started Date'),
260 'description' => ts('Date and time this import job started.'),
261 'required' => FALSE,
262 'where' => 'civicrm_user_job.start_date',
263 'table_name' => 'civicrm_user_job',
264 'entity' => 'UserJob',
265 'bao' => 'CRM_Core_BAO_UserJob',
266 'localizable' => 0,
267 'html' => [
268 'type' => 'Select Date',
269 'formatType' => 'activityDateTime',
270 ],
271 'readonly' => TRUE,
272 'add' => '5.50',
273 ],
274 'end_date' => [
275 'name' => 'end_date',
276 'type' => CRM_Utils_Type::T_TIMESTAMP,
277 'title' => ts('Job Ended Date'),
278 'description' => ts('Date and time this import job ended.'),
279 'required' => FALSE,
280 'where' => 'civicrm_user_job.end_date',
281 'table_name' => 'civicrm_user_job',
282 'entity' => 'UserJob',
283 'bao' => 'CRM_Core_BAO_UserJob',
284 'localizable' => 0,
285 'html' => [
286 'type' => 'Select Date',
287 'formatType' => 'activityDateTime',
288 ],
289 'add' => '5.50',
290 ],
291 'expires_date' => [
292 'name' => 'expires_date',
293 'type' => CRM_Utils_Type::T_TIMESTAMP,
294 'title' => ts('Import Job Expires Date'),
295 'description' => ts('Date and time to clean up after this import job (temp table deletion date).'),
296 'required' => FALSE,
297 'where' => 'civicrm_user_job.expires_date',
298 'table_name' => 'civicrm_user_job',
299 'entity' => 'UserJob',
300 'bao' => 'CRM_Core_BAO_UserJob',
301 'localizable' => 0,
302 'html' => [
303 'type' => 'Select Date',
304 'formatType' => 'activityDateTime',
305 ],
306 'add' => '5.50',
307 ],
308 'status_id' => [
309 'name' => 'status_id',
310 'type' => CRM_Utils_Type::T_INT,
311 'title' => ts('User Job Status ID'),
312 'required' => TRUE,
313 'where' => 'civicrm_user_job.status_id',
314 'table_name' => 'civicrm_user_job',
315 'entity' => 'UserJob',
316 'bao' => 'CRM_Core_BAO_UserJob',
317 'localizable' => 0,
318 'html' => [
319 'label' => ts("Job Status"),
320 ],
321 'pseudoconstant' => [
322 'callback' => 'CRM_Core_BAO_UserJob::getStatuses',
323 ],
324 'add' => '5.50',
325 ],
d2b81f5a
EM
326 'job_type' => [
327 'name' => 'job_type',
328 'type' => CRM_Utils_Type::T_STRING,
329 'title' => ts('User Job Type'),
330 'description' => ts('Name of the job type, which will allow finding the correct class'),
a082d2df 331 'required' => TRUE,
d2b81f5a
EM
332 'maxlength' => 64,
333 'size' => CRM_Utils_Type::BIG,
334 'where' => 'civicrm_user_job.job_type',
a082d2df
EM
335 'table_name' => 'civicrm_user_job',
336 'entity' => 'UserJob',
337 'bao' => 'CRM_Core_BAO_UserJob',
338 'localizable' => 0,
339 'html' => [
340 'label' => ts("Job Type"),
341 ],
342 'pseudoconstant' => [
343 'callback' => 'CRM_Core_BAO_UserJob::getTypes',
344 ],
345 'add' => '5.50',
346 ],
347 'queue_id' => [
348 'name' => 'queue_id',
349 'type' => CRM_Utils_Type::T_INT,
350 'title' => ts('Queue ID'),
351 'description' => ts('FK to Queue'),
352 'where' => 'civicrm_user_job.queue_id',
353 'table_name' => 'civicrm_user_job',
354 'entity' => 'UserJob',
355 'bao' => 'CRM_Core_BAO_UserJob',
356 'localizable' => 0,
357 'FKClassName' => 'CRM_Queue_DAO_Queue',
358 'html' => [
359 'label' => ts("Queue"),
360 ],
361 'add' => NULL,
362 ],
363 'metadata' => [
364 'name' => 'metadata',
365 'type' => CRM_Utils_Type::T_TEXT,
366 'title' => ts('Job metadata'),
367 'description' => ts('Data pertaining to job configuration'),
368 'where' => 'civicrm_user_job.metadata',
369 'table_name' => 'civicrm_user_job',
370 'entity' => 'UserJob',
371 'bao' => 'CRM_Core_BAO_UserJob',
372 'localizable' => 0,
373 'serialize' => self::SERIALIZE_JSON,
374 'add' => '5.50',
375 ],
77b7441a
TO
376 'is_template' => [
377 'name' => 'is_template',
378 'type' => CRM_Utils_Type::T_BOOLEAN,
379 'title' => ts('Is Template'),
380 'description' => ts('Is this a template configuration (for use by other/future jobs)?'),
381 'required' => TRUE,
382 'where' => 'civicrm_user_job.is_template',
383 'default' => '0',
384 'table_name' => 'civicrm_user_job',
385 'entity' => 'UserJob',
386 'bao' => 'CRM_Core_BAO_UserJob',
387 'localizable' => 0,
388 'html' => [
389 'type' => 'CheckBox',
390 'label' => ts("Is Template"),
391 ],
392 'add' => '5.51',
393 ],
a082d2df
EM
394 ];
395 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
396 }
397 return Civi::$statics[__CLASS__]['fields'];
398 }
399
400 /**
401 * Return a mapping from field-name to the corresponding key (as used in fields()).
402 *
403 * @return array
404 * Array(string $name => string $uniqueName).
405 */
406 public static function &fieldKeys() {
407 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
408 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
409 }
410 return Civi::$statics[__CLASS__]['fieldKeys'];
411 }
412
413 /**
414 * Returns the names of this table
415 *
416 * @return string
417 */
418 public static function getTableName() {
419 return self::$_tableName;
420 }
421
422 /**
423 * Returns if this table needs to be logged
424 *
425 * @return bool
426 */
427 public function getLog() {
428 return self::$_log;
429 }
430
431 /**
432 * Returns the list of fields that can be imported
433 *
434 * @param bool $prefix
435 *
436 * @return array
437 */
438 public static function &import($prefix = FALSE) {
439 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'user_job', $prefix, []);
440 return $r;
441 }
442
443 /**
444 * Returns the list of fields that can be exported
445 *
446 * @param bool $prefix
447 *
448 * @return array
449 */
450 public static function &export($prefix = FALSE) {
451 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'user_job', $prefix, []);
452 return $r;
453 }
454
455 /**
456 * Returns the list of indices
457 *
458 * @param bool $localize
459 *
460 * @return array
461 */
462 public static function indices($localize = TRUE) {
463 $indices = [
464 'UI_name' => [
465 'name' => 'UI_name',
466 'field' => [
467 0 => 'name',
468 ],
469 'localizable' => FALSE,
470 'unique' => TRUE,
471 'sig' => 'civicrm_user_job::1::name',
472 ],
473 ];
474 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
475 }
476
477}