ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
JobEntity.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Cron\Job;
22 
24 
25 class JobEntity
26 {
27  private string $job_id;
28  private string $component;
30  private int $schedule_value;
31  private int $job_status;
32  private int $job_status_usr_id;
33  private int $job_status_type;
34  private int $job_status_timestamp;
35  private int $job_result_status;
36  private int $job_result_usr_id;
37  private string $job_result_code;
38  private string $job_result_message;
39  private int $job_result_type;
40  private int $job_result_timestamp;
41  private string $class;
42  private string $path;
43  private int $running_timestamp;
44  private int $job_result_duration;
45  private int $alive_timestamp;
46 
50  public function __construct(
51  private readonly \ILIAS\Cron\CronJob $job,
52  array $record,
53  private readonly bool $isPlugin = false
54  ) {
55  $this->mapRecord($record);
56  }
57 
61  private function mapRecord(array $record): void
62  {
63  $this->job_id = (string) $record['job_id'];
64  $this->component = (string) $record['component'];
65  $this->schedule_type = is_numeric($record['schedule_type']) ? JobScheduleType::tryFrom(
66  (int) $record['schedule_type']
67  ) : null;
68  $this->schedule_value = (int) $record['schedule_value'];
69  $this->job_status = (int) $record['job_status'];
70  $this->job_status_usr_id = (int) $record['job_status_user_id'];
71  $this->job_status_type = (int) $record['job_status_type'];
72  $this->job_status_timestamp = (int) $record['job_status_ts'];
73  $this->job_result_status = (int) $record['job_result_status'];
74  $this->job_result_usr_id = (int) $record['job_result_user_id'];
75  $this->job_result_code = (string) $record['job_result_code'];
76  $this->job_result_message = (string) $record['job_result_message'];
77  $this->job_result_type = (int) $record['job_result_type'];
78  $this->job_result_timestamp = (int) $record['job_result_ts'];
79  $this->class = (string) $record['class'];
80  $this->path = (string) $record['path'];
81  $this->running_timestamp = (int) $record['running_ts'];
82  $this->job_result_duration = (int) $record['job_result_dur'];
83  $this->alive_timestamp = (int) $record['alive_ts'];
84  }
85 
86  public function getJob(): \ILIAS\Cron\CronJob
87  {
88  return $this->job;
89  }
90 
91  public function getJobId(): string
92  {
93  return $this->job_id;
94  }
95 
96  public function getEffectiveJobId(): string
97  {
98  $job_id = $this->getJobId();
99  if ($this->isPlugin()) {
100  $job_id = 'pl__' . $this->getComponent() . '__' . $job_id;
101  }
102 
103  return $job_id;
104  }
105 
106  public function getComponent(): string
107  {
108  return $this->component;
109  }
110 
111  public function getScheduleType(): ?JobScheduleType
112  {
113  return $this->schedule_type;
114  }
115 
116  public function getScheduleValue(): int
117  {
118  return $this->schedule_value;
119  }
120 
121  public function getJobStatus(): int
122  {
123  return $this->job_status;
124  }
125 
126  public function getJobStatusUsrId(): int
127  {
129  }
130 
131  public function getJobStatusType(): int
132  {
133  return $this->job_status_type;
134  }
135 
136  public function getJobStatusTimestamp(): int
137  {
139  }
140 
141  public function getJobResultStatus(): int
142  {
144  }
145 
146  public function getJobResultUsrId(): int
147  {
149  }
150 
151  public function getJobResultCode(): string
152  {
153  return $this->job_result_code;
154  }
155 
156  public function getJobResultMessage(): string
157  {
159  }
160 
161  public function getJobResultType(): int
162  {
163  return $this->job_result_type;
164  }
165 
166  public function getJobResultTimestamp(): int
167  {
169  }
170 
171  public function getClass(): string
172  {
173  return $this->class;
174  }
175 
176  public function getPath(): string
177  {
178  return $this->path;
179  }
180 
181  public function getRunningTimestamp(): int
182  {
184  }
185 
186  public function getJobResultDuration(): int
187  {
189  }
190 
191  public function getAliveTimestamp(): int
192  {
193  return $this->alive_timestamp;
194  }
195 
196  public function isPlugin(): bool
197  {
198  return $this->isPlugin;
199  }
200 
202  {
203  $type = $this->getScheduleType();
204  if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
205  $type = $this->getJob()->getDefaultScheduleType();
206  }
207 
208  return $type;
209  }
210 
211  public function getEffectiveScheduleValue(): int
212  {
213  $type = $this->getScheduleType();
214  $value = $this->getScheduleValue();
215  if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
216  $value = (int) $this->getJob()->getDefaultScheduleValue();
217  }
218 
219  return $value;
220  }
221 
222  public function getEffectiveTitle(): string
223  {
224  $id = $this->getJobId();
225  if ($this->isPlugin()) {
226  $id = 'pl__' . $this->getComponent() . '__' . $id;
227  }
228 
229  $title = $this->getJob()->getTitle();
230  if ($title === '') {
231  $title = $id;
232  }
233 
234  return $title;
235  }
236 }
__construct(private readonly \ILIAS\Cron\CronJob $job, array $record, private readonly bool $isPlugin=false)
Definition: JobEntity.php:50
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23