Test Failed
Push — main ( 16fa93...92cbf8 )
by Bingo
06:44
created

HistoryEvent::setCaseDefinitionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Jabe\Engine\Impl\History\Event;
4
5
use Jabe\Engine\Impl\Db\{
6
    DbEntityInterface,
7
    HistoricEntityInterface
8
};
9
use Jabe\Engine\Impl\Util\ClassNameUtil;
10
11
class HistoryEvent implements \Serializable, DbEntityInterface, HistoricEntityInterface
12
{
13
    private static $IDENTITY_LINK_ADD;
14
15
    private static $IDENTITY_LINK_DELETE;
16
17
    public static function identityLinkAdd(): string
18
    {
19
        if (self::$IDENTITY_LINK_ADD === null) {
20
            self::$IDENTITY_LINK_ADD = HistoryEventTypes::identityLinkAdd()->getEventName();
21
        }
22
        return self::$IDENTITY_LINK_ADD;
23
    }
24
25
    public static function identityLinkDelete(): string
26
    {
27
        if (self::$IDENTITY_LINK_DELETE === null) {
28
            self::$IDENTITY_LINK_DELETE = HistoryEventTypes::identityLinkDelete()->getEventName();
29
        }
30
        return self::$IDENTITY_LINK_DELETE;
31
    }
32
33
    /** each {@link HistoryEvent} has a unique id */
34
    protected $id;
35
36
    /** the root process instance in which the event has happened */
37
    protected $rootProcessInstanceId;
38
39
    /** the process instance in which the event has happened */
40
    protected $processInstanceId;
41
42
    /** the id of the execution in which the event has happened */
43
    protected $executionId;
44
45
    /** the id of the process definition */
46
    protected $processDefinitionId;
47
48
    /** the key of the process definition */
49
    protected $processDefinitionKey;
50
51
    /** the name of the process definition */
52
    protected $processDefinitionName;
53
54
    /** the version of the process definition */
55
    protected $processDefinitionVersion;
56
57
    /** the case instance in which the event has happened */
58
    protected $caseInstanceId;
59
60
    /** the id of the case execution in which the event has happened */
61
    protected $caseExecutionId;
62
63
    /** the id of the case definition */
64
    protected $caseDefinitionId;
65
66
    /** the key of the case definition */
67
    protected $caseDefinitionKey;
68
69
    /** the name of the case definition */
70
    protected $caseDefinitionName;
71
72
    /**
73
     * The type of the activity audit event.
74
     * @see HistoryEventType#getEventName()
75
     * */
76
    protected $eventType;
77
78
    protected $sequenceCounter;
79
80
    /* the time when the history event will be deleted */
81
    protected $removalTime;
82
83
    // getters / setters ///////////////////////////////////
84
85
    public function getProcessInstanceId(): string
86
    {
87
        return $this->processInstanceId;
88
    }
89
90
    public function setProcessInstanceId(string $processInstanceId): void
91
    {
92
        $this->processInstanceId = $processInstanceId;
93
    }
94
95
    public function getRootProcessInstanceId(): string
96
    {
97
        return $this->rootProcessInstanceId;
98
    }
99
100
    public function setRootProcessInstanceId(string $rootProcessInstanceId): void
101
    {
102
        $this->rootProcessInstanceId = $rootProcessInstanceId;
103
    }
104
105
    public function getExecutionId(): string
106
    {
107
        return $this->executionId;
108
    }
109
110
    public function setExecutionId(string $executionId): void
111
    {
112
        $this->executionId = $executionId;
113
    }
114
115
    public function getProcessDefinitionId(): string
116
    {
117
        return $this->processDefinitionId;
118
    }
119
120
    public function setProcessDefinitionId(string $processDefinitionId): void
121
    {
122
        $this->processDefinitionId = $processDefinitionId;
123
    }
124
125
    public function getProcessDefinitionKey(): string
126
    {
127
        return $this->processDefinitionKey;
128
    }
129
130
    public function setProcessDefinitionKey(string $processDefinitionKey): void
131
    {
132
        $this->processDefinitionKey = $processDefinitionKey;
133
    }
134
135
    public function getProcessDefinitionName(): string
136
    {
137
        return $this->processDefinitionName;
138
    }
139
140
    public function setProcessDefinitionName(string $processDefinitionName): void
141
    {
142
        $this->processDefinitionName = $processDefinitionName;
143
    }
144
145
    public function getProcessDefinitionVersion(): int
146
    {
147
        return $this->processDefinitionVersion;
148
    }
149
150
    public function setProcessDefinitionVersion(int $processDefinitionVersion): void
151
    {
152
        $this->processDefinitionVersion = $processDefinitionVersion;
153
    }
154
155
    /*public function getCaseDefinitionName(): string
156
    {
157
        return $this->caseDefinitionName;
158
    }*/
159
160
    /*public function setCaseDefinitionName(string $caseDefinitionName): void
161
    {
162
        $this->caseDefinitionName = $caseDefinitionName;
163
    }*/
164
165
    /*public function getCaseDefinitionKey(): string
166
    {
167
        return $this->caseDefinitionKey;
168
    }*/
169
170
    /*public function setCaseDefinitionKey(string $caseDefinitionKey): void
171
    {
172
        $this->caseDefinitionKey = $caseDefinitionKey;
173
    }*/
174
175
    /*public function getCaseDefinitionId(): string
176
    {
177
        return $this->caseDefinitionId;
178
    }*/
179
180
    /*public function setCaseDefinitionId(string $caseDefinitionId): void
181
    {
182
        $this->caseDefinitionId = $caseDefinitionId;
183
    }*/
184
185
    /*public function getCaseInstanceId(): string
186
    {
187
        return $this->caseInstanceId;
188
    }
189
190
    public function setCaseInstanceId(string $caseInstanceId): void
191
    {
192
        $this->caseInstanceId = $caseInstanceId;
193
    }
194
195
    public function getCaseExecutionId(): string
196
    {
197
        return $this->caseExecutionId;
198
    }
199
200
    public function setCaseExecutionId(string $caseExecutionId): void
201
    {
202
        $this->caseExecutionId = $caseExecutionId;
203
    }*/
204
205
    public function setId(string $id): void
206
    {
207
        $this->id = $id;
208
    }
209
210
    public function getId(): string
211
    {
212
        return $this->id;
213
    }
214
215
    public function getEventType(): string
216
    {
217
        return $this->eventType;
218
    }
219
220
    public function setEventType(string $eventType): void
221
    {
222
        $this->eventType = $eventType;
223
    }
224
225
    public function getSequenceCounter(): int
226
    {
227
        return $this->sequenceCounter;
228
    }
229
230
    public function setSequenceCounter(int $sequenceCounter): void
231
    {
232
        $this->sequenceCounter = $sequenceCounter;
233
    }
234
235
    public function getRemovalTime(): string
236
    {
237
        return $this->removalTime;
238
    }
239
240
    public function setRemovalTime(string $removalTime): void
241
    {
242
        $this->removalTime = $removalTime;
243
    }
244
245
    // persistent object implementation ///////////////
246
247
    public function getPersistentState(): string
248
    {
249
        // events are immutable
250
        return HistoryEvent::class;
251
    }
252
253
    // state inspection
254
255
    public function isEventOfType(HistoryEventTypeInterface $type): bool
256
    {
257
        return $type->getEventName() == $this->eventType;
258
    }
259
260
    public function serialize()
261
    {
262
        return json_encode([
263
            'id' => $this->id,
264
            'eventType' => $this->eventType,
265
            'executionId' => $this->executionId,
266
            'processDefinitionId' => $this->processDefinitionId,
267
            'processInstanceId' => $this->processInstanceId,
268
            'rootProcessInstanceId' => $this->rootProcessInstanceId,
269
            'removalTime' => $this->removalTime
270
        ]);
271
    }
272
273
    public function unserialize($data)
274
    {
275
        $json = json_decode($data);
276
        $this->id = $json->id;
277
        $this->eventType = $json->eventType;
278
        $this->executionId = $json->executionId;
279
        $this->processDefinitionId = $json->processDefinitionId;
280
        $this->processInstanceId = $json->processInstanceId;
281
        $this->rootProcessInstanceId = $json->rootProcessInstanceId;
282
        $this->removalTime = $json->removalTime;
283
    }
284
285
    public function __toString()
286
    {
287
        $className = ClassNameUtil::getClassNameWithoutPackage(get_class($this));
288
        return $className
289
            . "[id=" . $this->id
290
            . ", eventType=" . $this->eventType
291
            . ", executionId=" . $this->executionId
292
            . ", processDefinitionId=" . $this->processDefinitionId
293
            . ", processInstanceId=" . $this->processInstanceId
294
            . ", rootProcessInstanceId=" . $this->rootProcessInstanceId
295
            . ", removalTime=" . $this->removalTime
296
            . "]";
297
    }
298
}
299