All Data Structures Functions Variables Pages
JobLog.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
40  class JobLog extends Item
41  {
46  const STATUS_COMPLETE_WITHOUT_ERROR = 1;
47 
52  const STATUS_COMPLETE_WITH_ERROR = 2;
53 
58  protected $isAudited = false;
59 
60  public function __toString()
61  {
62  if ($this->type == null)
63  {
64  return null;
65  }
66  return JobsUtil::resolveStringContentByType($this->type);
67  }
68 
75  public static function getByType($type, $pageSize = null, $orderBy = null)
76  {
77  assert('is_string($type)');
78  assert('is_string($orderBy) || $orderBy == null');
79  $searchAttributeData = array();
80  $searchAttributeData['clauses'] = array(
81  1 => array(
82  'attributeName' => 'type',
83  'operatorType' => 'equals',
84  'value' => $type,
85  ),
86  );
87  $searchAttributeData['structure'] = '1';
88  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
89  $where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
90  return self::getSubset($joinTablesAdapter, null, $pageSize, $where, $orderBy);
91  }
92 
93  public static function getDefaultMetadata()
94  {
95  $metadata = parent::getDefaultMetadata();
96  $metadata[__CLASS__] = array(
97  'members' => array(
98  'endDateTime',
99  'isProcessed',
100  'message',
101  'startDateTime',
102  'status',
103  'type'
104  ),
105  'rules' => array(
106  array('endDateTime', 'required'),
107  array('endDateTime', 'type', 'type' => 'datetime'),
108  array('isProcessed', 'boolean'),
109  array('isProcessed', 'validateIsProcessedIsSet'),
110  array('message', 'type', 'type' => 'string'),
111  array('startDateTime', 'required'),
112  array('status', 'required'),
113  array('status', 'type', 'type' => 'integer'),
114  array('startDateTime', 'type', 'type' => 'datetime'),
115  array('type', 'required'),
116  array('type', 'type', 'type' => 'string'),
117  array('type', 'length', 'min' => 1, 'max' => 64),
118  ),
119  'defaultSortAttribute' => 'type',
120  'elements' => array(
121  'description' => 'TextArea',
122  'endDateTime' => 'DateTime',
123  'startDateTime' => 'DateTime',
124  ),
125  );
126  return $metadata;
127  }
128 
133  public function validateIsProcessedIsSet()
134  {
135  if ($this->isProcessed == null)
136  {
137  $this->addError('isProcessed', Zurmo::t('JobsManagerModule', 'Is Processed must be set as true or false, not null.'));
138  }
139  }
140 
141  public static function isTypeDeletable()
142  {
143  return true;
144  }
145 
151  protected static function getLabel($language = null)
152  {
153  return Zurmo::t('JobsManagerModule', 'Job Log', array(), null, $language);
154  }
155 
161  protected static function getPluralLabel($language = null)
162  {
163  return Zurmo::t('JobsManagerModule', 'Job Logs', array(), null, $language);
164  }
165 
166  protected static function translatedAttributeLabels($language)
167  {
168  return array_merge(parent::translatedAttributeLabels($language),
169  array(
170  'endDateTime' => Zurmo::t('ZurmoModule', 'End Date Time', array(), null, $language),
171  'isProcessed' => Zurmo::t('JobsManagerModule', 'Is Processed', array(), null, $language),
172  'message' => Zurmo::t('JobsManagerModule', 'Message', array(), null, $language),
173  'startDateTIme' => Zurmo::t('ZurmoModule', 'Start Date Time', array(), null, $language),
174  'status' => Zurmo::t('ZurmoModule', 'Status', array(), null, $language),
175  'type' => Zurmo::t('Core', 'Type', array(), null, $language),
176  )
177  );
178  }
179  }
180 ?>
static getLabel($language=null)
Definition: JobLog.php:151
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
validateIsProcessedIsSet()
Definition: JobLog.php:133
Definition: Item.php:37
static resolveStringContentByType($type)
Definition: JobsUtil.php:48
static getPluralLabel($language=null)
Definition: JobLog.php:161
addError($attributeName, $errorMessage)
static getByType($type, $pageSize=null, $orderBy=null)
Definition: JobLog.php:75
Generated on Thu Apr 9 2020 07:10:42