1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Global Trading Technologies Ltd workflow-extension-bundle package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* (c) fduch <[email protected]> |
9
|
|
|
* @date 27.07.16 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gtt\Bundle\WorkflowExtensionsBundle\Entity; |
13
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
15
|
|
|
use JMS\JobQueueBundle\Entity\Job; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Persists information about scheduled transition (as jms Job) for specified workflow and subject |
19
|
|
|
* and allows to fetch it in order to manipulate or re-schedule |
20
|
|
|
* @see Job |
21
|
|
|
* |
22
|
|
|
* @ORM\Entity(repositoryClass = "Gtt\Bundle\WorkflowExtensionsBundle\Entity\Repository\ScheduledJobRepository") |
23
|
|
|
* |
24
|
|
|
* @ORM\Table(name = "gtt_workflow_scheduled_job") |
25
|
|
|
* |
26
|
|
|
* (c) fduch <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class ScheduledJob |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Autogenerated id |
32
|
|
|
* |
33
|
|
|
* @var int |
34
|
|
|
* |
35
|
|
|
* @ORM\Id |
36
|
|
|
* @ORM\GeneratedValue(strategy = "AUTO") |
37
|
|
|
* @ORM\Column(type = "integer", options = {"unsigned": true}) |
38
|
|
|
*/ |
39
|
|
|
private $id; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Reschedulable or not |
43
|
|
|
* |
44
|
|
|
* @var boolean |
45
|
|
|
* |
46
|
|
|
* @ORM\Column(type = "boolean", columnDefinition="COMMENT 'Defines whether related job can be rescheduled or not'") |
47
|
|
|
*/ |
48
|
|
|
private $reschedulable = true; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Related jms Job to be executed later |
52
|
|
|
* |
53
|
|
|
* @var Job |
54
|
|
|
* |
55
|
|
|
* @ORM\OneToOne(targetEntity="JMS\JobQueueBundle\Entity\Job") |
56
|
|
|
* @ORM\JoinColumn(name="jms_job_id", referencedColumnName="id", nullable=false) |
57
|
|
|
*/ |
58
|
|
|
private $job; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* ScheduledJob constructor. |
62
|
|
|
* |
63
|
|
|
* @param Job $transitionTriggerJob transition trigger job |
64
|
|
|
* @param boolean $reschedulable reschedulable or not |
65
|
|
|
*/ |
66
|
|
|
public function __construct(Job $transitionTriggerJob, $reschedulable = true) |
67
|
|
|
{ |
68
|
|
|
$this->reschedulable = $reschedulable; |
69
|
|
|
$this->job = $transitionTriggerJob; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Returns id |
75
|
|
|
* |
76
|
|
|
* @return int |
77
|
|
|
*/ |
78
|
|
|
public function getId() |
79
|
|
|
{ |
80
|
|
|
return $this->id; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Return true if scheduled job can be rescheduled |
85
|
|
|
* |
86
|
|
|
* @return boolean |
87
|
|
|
*/ |
88
|
|
|
public function isReschedulable() |
89
|
|
|
{ |
90
|
|
|
return $this->reschedulable; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Sets reschedulable flag |
95
|
|
|
* |
96
|
|
|
* @param boolean $reschedulable |
97
|
|
|
*/ |
98
|
|
|
public function setReschedulable($reschedulable = true) |
99
|
|
|
{ |
100
|
|
|
$this->reschedulable = $reschedulable; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Returns Job |
105
|
|
|
* |
106
|
|
|
* @return Job |
107
|
|
|
*/ |
108
|
|
|
public function getJob() |
109
|
|
|
{ |
110
|
|
|
return $this->job; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Sets Job |
115
|
|
|
* |
116
|
|
|
* @param Job $job Related jms job |
117
|
|
|
* |
118
|
|
|
* @return ScheduledJob |
119
|
|
|
*/ |
120
|
|
|
public function setJob($job) |
121
|
|
|
{ |
122
|
|
|
$this->job = $job; |
123
|
|
|
|
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
} |