Merge pull request #23213 from eileenmcnaughton/post
[civicrm-core.git] / CRM / Core / DAO / JobLog.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/JobLog.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:10c668f93f466aa0d49d258b6bc7badd)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the JobLog entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.1';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_job_log';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b 33 /**
2cbbebe8 34 * Job log entry ID
e501603b 35 *
28979d65
CW
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
e501603b
TO
39 */
40 public $id;
c3fc2621 41
e501603b
TO
42 /**
43 * Which Domain is this scheduled job for
44 *
28979d65
CW
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
e501603b
TO
48 */
49 public $domain_id;
c3fc2621 50
e501603b
TO
51 /**
52 * Log entry date
53 *
28979d65
CW
54 * @var string|null
55 * (SQL type: timestamp)
56 * Note that values will be retrieved from the database as a string.
e501603b
TO
57 */
58 public $run_time;
c3fc2621 59
e501603b
TO
60 /**
61 * Pointer to job id - not a FK though, just for logging purposes
62 *
28979d65
CW
63 * @var int|string|null
64 * (SQL type: int unsigned)
65 * Note that values will be retrieved from the database as a string.
e501603b
TO
66 */
67 public $job_id;
c3fc2621 68
e501603b
TO
69 /**
70 * Title of the job
71 *
28979d65
CW
72 * @var string|null
73 * (SQL type: varchar(255))
74 * Note that values will be retrieved from the database as a string.
e501603b
TO
75 */
76 public $name;
c3fc2621 77
e501603b
TO
78 /**
79 * Full path to file containing job script
80 *
28979d65
CW
81 * @var string|null
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
e501603b
TO
84 */
85 public $command;
c3fc2621 86
e501603b
TO
87 /**
88 * Title line of log entry
89 *
28979d65
CW
90 * @var string|null
91 * (SQL type: varchar(255))
92 * Note that values will be retrieved from the database as a string.
e501603b
TO
93 */
94 public $description;
c3fc2621 95
e501603b
TO
96 /**
97 * Potential extended data for specific job run (e.g. tracebacks).
98 *
28979d65
CW
99 * @var string|null
100 * (SQL type: text)
101 * Note that values will be retrieved from the database as a string.
e501603b
TO
102 */
103 public $data;
c3fc2621 104
e501603b 105 /**
f41f0342 106 * Class constructor.
e501603b 107 */
c3fc2621 108 public function __construct() {
e501603b
TO
109 $this->__table = 'civicrm_job_log';
110 parent::__construct();
111 }
c3fc2621 112
449c4e6b
CW
113 /**
114 * Returns localized title of this entity.
7b66c3b5
AH
115 *
116 * @param bool $plural
117 * Whether to return the plural version of the title.
449c4e6b 118 */
7b66c3b5
AH
119 public static function getEntityTitle($plural = FALSE) {
120 return $plural ? ts('Job Logs') : ts('Job Log');
449c4e6b
CW
121 }
122
e501603b 123 /**
f41f0342 124 * Returns foreign keys and entity references.
e501603b
TO
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
c3fc2621 129 public static function getReferenceColumns() {
346aaaba 130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
346aaaba 133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 134 }
346aaaba 135 return Civi::$statics[__CLASS__]['links'];
e501603b 136 }
c3fc2621 137
e501603b
TO
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
c3fc2621 143 public static function &fields() {
346aaaba 144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
e501603b
TO
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
c3fc2621 149 'title' => ts('Job Log ID'),
2cbbebe8 150 'description' => ts('Job log entry ID'),
c3fc2621 151 'required' => TRUE,
a36434b9 152 'where' => 'civicrm_job_log.id',
522a26c9 153 'table_name' => 'civicrm_job_log',
154 'entity' => 'JobLog',
155 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 156 'localizable' => 0,
2cbbebe8
A
157 'html' => [
158 'type' => 'Number',
159 ],
1fe423d6 160 'readonly' => TRUE,
a9d0587b 161 'add' => '4.1',
c3fc2621
CW
162 ],
163 'domain_id' => [
e501603b
TO
164 'name' => 'domain_id',
165 'type' => CRM_Utils_Type::T_INT,
c3fc2621 166 'title' => ts('Domain ID'),
215b423e 167 'description' => ts('Which Domain is this scheduled job for'),
c3fc2621 168 'required' => TRUE,
a36434b9 169 'where' => 'civicrm_job_log.domain_id',
522a26c9 170 'table_name' => 'civicrm_job_log',
171 'entity' => 'JobLog',
172 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 173 'localizable' => 0,
e501603b 174 'FKClassName' => 'CRM_Core_DAO_Domain',
2cbbebe8
A
175 'html' => [
176 'label' => ts("Domain"),
177 ],
c3fc2621 178 'pseudoconstant' => [
e501603b
TO
179 'table' => 'civicrm_domain',
180 'keyColumn' => 'id',
181 'labelColumn' => 'name',
e6ca0a57 182 ],
a9d0587b 183 'add' => '4.1',
c3fc2621
CW
184 ],
185 'run_time' => [
e501603b
TO
186 'name' => 'run_time',
187 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 188 'title' => ts('Timestamp'),
215b423e 189 'description' => ts('Log entry date'),
a36434b9 190 'where' => 'civicrm_job_log.run_time',
522a26c9 191 'table_name' => 'civicrm_job_log',
192 'entity' => 'JobLog',
193 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 194 'localizable' => 0,
a9d0587b 195 'add' => '4.1',
c3fc2621
CW
196 ],
197 'job_id' => [
e501603b
TO
198 'name' => 'job_id',
199 'type' => CRM_Utils_Type::T_INT,
c3fc2621 200 'title' => ts('Job ID'),
215b423e 201 'description' => ts('Pointer to job id - not a FK though, just for logging purposes'),
a36434b9 202 'where' => 'civicrm_job_log.job_id',
522a26c9 203 'table_name' => 'civicrm_job_log',
204 'entity' => 'JobLog',
205 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 206 'localizable' => 0,
a9d0587b 207 'add' => '4.1',
c3fc2621
CW
208 ],
209 'name' => [
e501603b
TO
210 'name' => 'name',
211 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 212 'title' => ts('Job Name'),
215b423e 213 'description' => ts('Title of the job'),
e501603b
TO
214 'maxlength' => 255,
215 'size' => CRM_Utils_Type::HUGE,
a36434b9 216 'where' => 'civicrm_job_log.name',
522a26c9 217 'table_name' => 'civicrm_job_log',
218 'entity' => 'JobLog',
219 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 220 'localizable' => 0,
a9d0587b 221 'add' => '4.1',
c3fc2621
CW
222 ],
223 'command' => [
e501603b
TO
224 'name' => 'command',
225 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 226 'title' => ts('Command'),
215b423e 227 'description' => ts('Full path to file containing job script'),
e501603b
TO
228 'maxlength' => 255,
229 'size' => CRM_Utils_Type::HUGE,
a36434b9 230 'where' => 'civicrm_job_log.command',
522a26c9 231 'table_name' => 'civicrm_job_log',
232 'entity' => 'JobLog',
233 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 234 'localizable' => 0,
a9d0587b 235 'add' => '4.1',
c3fc2621
CW
236 ],
237 'description' => [
e501603b
TO
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 240 'title' => ts('Description'),
215b423e 241 'description' => ts('Title line of log entry'),
e501603b
TO
242 'maxlength' => 255,
243 'size' => CRM_Utils_Type::HUGE,
a36434b9 244 'where' => 'civicrm_job_log.description',
522a26c9 245 'table_name' => 'civicrm_job_log',
246 'entity' => 'JobLog',
247 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 248 'localizable' => 0,
a9d0587b 249 'add' => '4.1',
c3fc2621
CW
250 ],
251 'data' => [
e501603b
TO
252 'name' => 'data',
253 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 254 'title' => ts('Extended Data'),
215b423e 255 'description' => ts('Potential extended data for specific job run (e.g. tracebacks).'),
a36434b9 256 'where' => 'civicrm_job_log.data',
522a26c9 257 'table_name' => 'civicrm_job_log',
258 'entity' => 'JobLog',
259 'bao' => 'CRM_Core_DAO_JobLog',
6a7e5e5d 260 'localizable' => 0,
a9d0587b 261 'add' => '4.1',
c3fc2621
CW
262 ],
263 ];
346aaaba 264 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 265 }
346aaaba 266 return Civi::$statics[__CLASS__]['fields'];
e501603b 267 }
c3fc2621 268
e501603b 269 /**
bd8e0b14 270 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
271 *
272 * @return array
bd8e0b14 273 * Array(string $name => string $uniqueName).
e501603b 274 */
c3fc2621 275 public static function &fieldKeys() {
bd8e0b14
TO
276 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
277 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 278 }
bd8e0b14 279 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 280 }
c3fc2621 281
e501603b
TO
282 /**
283 * Returns the names of this table
284 *
285 * @return string
286 */
c3fc2621 287 public static function getTableName() {
e501603b
TO
288 return self::$_tableName;
289 }
c3fc2621 290
e501603b
TO
291 /**
292 * Returns if this table needs to be logged
293 *
c3fc2621 294 * @return bool
e501603b 295 */
c3fc2621 296 public function getLog() {
e501603b
TO
297 return self::$_log;
298 }
c3fc2621 299
e501603b
TO
300 /**
301 * Returns the list of fields that can be imported
302 *
303 * @param bool $prefix
304 *
305 * @return array
306 */
c3fc2621
CW
307 public static function &import($prefix = FALSE) {
308 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'job_log', $prefix, []);
60808919 309 return $r;
e501603b 310 }
c3fc2621 311
e501603b
TO
312 /**
313 * Returns the list of fields that can be exported
314 *
315 * @param bool $prefix
316 *
317 * @return array
318 */
c3fc2621
CW
319 public static function &export($prefix = FALSE) {
320 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'job_log', $prefix, []);
60808919 321 return $r;
e501603b 322 }
c3fc2621 323
e7a6b91a
AS
324 /**
325 * Returns the list of indices
c3fc2621
CW
326 *
327 * @param bool $localize
328 *
329 * @return array
e7a6b91a
AS
330 */
331 public static function indices($localize = TRUE) {
c3fc2621 332 $indices = [];
e7a6b91a
AS
333 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
334 }
c3fc2621 335
e501603b 336}