xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Core / DAO / JobLog.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Core/JobLog.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:4b0845059b2070b57b02b8b1c6c9df50)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_job_log';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * Job log entry Id
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Which Domain is this scheduled job for
91 *
92 * @var int unsigned
93 */
94 public $domain_id;
95 /**
96 * Log entry date
97 *
98 * @var timestamp
99 */
100 public $run_time;
101 /**
102 * Pointer to job id - not a FK though, just for logging purposes
103 *
104 * @var int unsigned
105 */
106 public $job_id;
107 /**
108 * Title of the job
109 *
110 * @var string
111 */
112 public $name;
113 /**
114 * Full path to file containing job script
115 *
116 * @var string
117 */
118 public $command;
119 /**
120 * Title line of log entry
121 *
122 * @var string
123 */
124 public $description;
125 /**
126 * Potential extended data for specific job run (e.g. tracebacks).
127 *
128 * @var text
129 */
130 public $data;
131 /**
132 * class constructor
133 *
134 * @return civicrm_job_log
135 */
136 function __construct() {
137 $this->__table = 'civicrm_job_log';
138 parent::__construct();
139 }
140 /**
141 * Returns foreign keys and entity references
142 *
143 * @return array
144 * [CRM_Core_Reference_Interface]
145 */
146 static function getReferenceColumns() {
147 if (!self::$_links) {
148 self::$_links = static ::createReferenceColumns(__CLASS__);
149 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'domain_id', 'civicrm_domain', 'id');
150 }
151 return self::$_links;
152 }
153 /**
154 * Returns all the column names of this table
155 *
156 * @return array
157 */
158 static function &fields() {
159 if (!(self::$_fields)) {
160 self::$_fields = array(
161 'id' => array(
162 'name' => 'id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Job Log ID') ,
165 'description' => 'Job log entry Id',
166 'required' => true,
167 ) ,
168 'domain_id' => array(
169 'name' => 'domain_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Domain ID') ,
172 'description' => 'Which Domain is this scheduled job for',
173 'required' => true,
174 'FKClassName' => 'CRM_Core_DAO_Domain',
175 'pseudoconstant' => array(
176 'table' => 'civicrm_domain',
177 'keyColumn' => 'id',
178 'labelColumn' => 'name',
179 )
180 ) ,
181 'run_time' => array(
182 'name' => 'run_time',
183 'type' => CRM_Utils_Type::T_TIMESTAMP,
184 'title' => ts('Timestamp') ,
185 'description' => 'Log entry date',
186 ) ,
187 'job_id' => array(
188 'name' => 'job_id',
189 'type' => CRM_Utils_Type::T_INT,
190 'title' => ts('Job ID') ,
191 'description' => 'Pointer to job id - not a FK though, just for logging purposes',
192 ) ,
193 'name' => array(
194 'name' => 'name',
195 'type' => CRM_Utils_Type::T_STRING,
196 'title' => ts('Job Name') ,
197 'description' => 'Title of the job',
198 'maxlength' => 255,
199 'size' => CRM_Utils_Type::HUGE,
200 ) ,
201 'command' => array(
202 'name' => 'command',
203 'type' => CRM_Utils_Type::T_STRING,
204 'title' => ts('Command') ,
205 'description' => 'Full path to file containing job script',
206 'maxlength' => 255,
207 'size' => CRM_Utils_Type::HUGE,
208 ) ,
209 'description' => array(
210 'name' => 'description',
211 'type' => CRM_Utils_Type::T_STRING,
212 'title' => ts('Description') ,
213 'description' => 'Title line of log entry',
214 'maxlength' => 255,
215 'size' => CRM_Utils_Type::HUGE,
216 ) ,
217 'data' => array(
218 'name' => 'data',
219 'type' => CRM_Utils_Type::T_TEXT,
220 'title' => ts('Extended Data') ,
221 'description' => 'Potential extended data for specific job run (e.g. tracebacks).',
222 ) ,
223 );
224 }
225 return self::$_fields;
226 }
227 /**
228 * Returns an array containing, for each field, the arary key used for that
229 * field in self::$_fields.
230 *
231 * @return array
232 */
233 static function &fieldKeys() {
234 if (!(self::$_fieldKeys)) {
235 self::$_fieldKeys = array(
236 'id' => 'id',
237 'domain_id' => 'domain_id',
238 'run_time' => 'run_time',
239 'job_id' => 'job_id',
240 'name' => 'name',
241 'command' => 'command',
242 'description' => 'description',
243 'data' => 'data',
244 );
245 }
246 return self::$_fieldKeys;
247 }
248 /**
249 * Returns the names of this table
250 *
251 * @return string
252 */
253 static function getTableName() {
254 return self::$_tableName;
255 }
256 /**
257 * Returns if this table needs to be logged
258 *
259 * @return boolean
260 */
261 function getLog() {
262 return self::$_log;
263 }
264 /**
265 * Returns the list of fields that can be imported
266 *
267 * @param bool $prefix
268 *
269 * @return array
270 */
271 static function &import($prefix = false) {
272 if (!(self::$_import)) {
273 self::$_import = array();
274 $fields = self::fields();
275 foreach($fields as $name => $field) {
276 if (CRM_Utils_Array::value('import', $field)) {
277 if ($prefix) {
278 self::$_import['job_log'] = & $fields[$name];
279 } else {
280 self::$_import[$name] = & $fields[$name];
281 }
282 }
283 }
284 }
285 return self::$_import;
286 }
287 /**
288 * Returns the list of fields that can be exported
289 *
290 * @param bool $prefix
291 *
292 * @return array
293 */
294 static function &export($prefix = false) {
295 if (!(self::$_export)) {
296 self::$_export = array();
297 $fields = self::fields();
298 foreach($fields as $name => $field) {
299 if (CRM_Utils_Array::value('export', $field)) {
300 if ($prefix) {
301 self::$_export['job_log'] = & $fields[$name];
302 } else {
303 self::$_export[$name] = & $fields[$name];
304 }
305 }
306 }
307 }
308 return self::$_export;
309 }
310}