1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace HDNET\Importr\Domain\Model; |
4
|
|
|
|
5
|
|
|
use HDNET\Importr\Service\Targets\TargetInterface; |
6
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Description of Strategy |
10
|
|
|
* |
11
|
|
|
* @author timlochmueller |
12
|
|
|
*/ |
13
|
|
|
class Import extends AbstractEntity |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var \HDNET\Importr\Domain\Model\Strategy |
18
|
|
|
*/ |
19
|
|
|
protected $strategy; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $filepath; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \DateTime |
28
|
|
|
*/ |
29
|
|
|
protected $starttime; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \DateTime |
33
|
|
|
*/ |
34
|
|
|
protected $endtime; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var integer |
38
|
|
|
*/ |
39
|
|
|
protected $pointer; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var integer |
43
|
|
|
*/ |
44
|
|
|
protected $amount; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var integer |
48
|
|
|
*/ |
49
|
|
|
protected $inserted; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var integer |
53
|
|
|
*/ |
54
|
|
|
protected $updated; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var integer |
58
|
|
|
*/ |
59
|
|
|
protected $ignored; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var integer |
63
|
|
|
*/ |
64
|
|
|
protected $unknowns; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var integer |
68
|
|
|
*/ |
69
|
|
|
protected $errors; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return \HDNET\Importr\Domain\Model\Strategy |
73
|
|
|
*/ |
74
|
|
|
public function getStrategy() |
75
|
|
|
{ |
76
|
|
|
return $this->strategy; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getFilepath() |
83
|
|
|
{ |
84
|
|
|
return $this->filepath; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return \DateTime |
89
|
|
|
*/ |
90
|
|
|
public function getStarttime() |
91
|
|
|
{ |
92
|
|
|
return $this->starttime; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return \DateTime |
97
|
|
|
*/ |
98
|
|
|
public function getEndtime() |
99
|
|
|
{ |
100
|
|
|
return $this->endtime; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return integer |
105
|
|
|
*/ |
106
|
|
|
public function getPointer() |
107
|
|
|
{ |
108
|
|
|
return $this->pointer; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return integer |
113
|
|
|
*/ |
114
|
|
|
public function getAmount() |
115
|
|
|
{ |
116
|
|
|
return $this->amount; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param \HDNET\Importr\Domain\Model\Strategy $strategy |
121
|
|
|
*/ |
122
|
|
|
public function setStrategy(Strategy $strategy) |
123
|
|
|
{ |
124
|
|
|
$this->strategy = $strategy; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param string $filepath |
129
|
|
|
*/ |
130
|
|
|
public function setFilepath($filepath) |
131
|
|
|
{ |
132
|
|
|
$this->filepath = $filepath; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param \DateTime $starttime |
137
|
|
|
*/ |
138
|
|
|
public function setStarttime($starttime) |
139
|
|
|
{ |
140
|
|
|
$this->starttime = $starttime; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param \DateTime $endtime |
145
|
|
|
*/ |
146
|
|
|
public function setEndtime($endtime) |
147
|
|
|
{ |
148
|
|
|
$this->endtime = $endtime; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param integer $pointer |
153
|
|
|
*/ |
154
|
|
|
public function setPointer($pointer) |
155
|
|
|
{ |
156
|
|
|
$this->pointer = $pointer; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param integer $amount |
161
|
|
|
*/ |
162
|
|
|
public function setAmount($amount) |
163
|
|
|
{ |
164
|
|
|
$this->amount = $amount; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return float|int |
169
|
|
|
*/ |
170
|
|
|
public function getPercentage() |
171
|
|
|
{ |
172
|
|
|
if ($this->getAmount() == 0) { |
173
|
|
|
return 100; |
174
|
|
|
} |
175
|
|
|
return $this->getPointer() / $this->getAmount() * 100; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param int $errors |
180
|
|
|
*/ |
181
|
1 |
|
public function setErrors($errors) |
182
|
|
|
{ |
183
|
1 |
|
$this->errors = $errors; |
184
|
1 |
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return int |
188
|
|
|
*/ |
189
|
1 |
|
public function getErrors() |
190
|
|
|
{ |
191
|
1 |
|
return (int)$this->errors; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return float|int |
196
|
|
|
*/ |
197
|
|
|
public function getErrorsPercentage() |
198
|
|
|
{ |
199
|
|
|
if ($this->getAmount() == 0) { |
200
|
|
|
return 0; |
201
|
|
|
} |
202
|
|
|
return $this->getErrors() / $this->getAmount() * 100; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @param int $ignored |
207
|
|
|
*/ |
208
|
1 |
|
public function setIgnored($ignored) |
209
|
|
|
{ |
210
|
1 |
|
$this->ignored = $ignored; |
211
|
1 |
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @return int |
215
|
|
|
*/ |
216
|
1 |
|
public function getIgnored() |
217
|
|
|
{ |
218
|
1 |
|
return (int)$this->ignored; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @return float|int |
223
|
|
|
*/ |
224
|
|
|
public function getIgnoredPercentage() |
225
|
|
|
{ |
226
|
|
|
if ($this->getAmount() == 0) { |
227
|
|
|
return 0; |
228
|
|
|
} |
229
|
|
|
return $this->getIgnored() / $this->getAmount() * 100; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @param int $inserted |
234
|
|
|
*/ |
235
|
1 |
|
public function setInserted($inserted) |
236
|
|
|
{ |
237
|
1 |
|
$this->inserted = $inserted; |
238
|
1 |
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @return int |
242
|
|
|
*/ |
243
|
1 |
|
public function getInserted() |
244
|
|
|
{ |
245
|
1 |
|
return (int)$this->inserted; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* @param int $unknowns |
250
|
|
|
*/ |
251
|
1 |
|
public function setUnknowns($unknowns) |
252
|
|
|
{ |
253
|
1 |
|
$this->unknowns = $unknowns; |
254
|
1 |
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @return int |
258
|
|
|
*/ |
259
|
1 |
|
public function getUnknowns() |
260
|
|
|
{ |
261
|
1 |
|
return (int)$this->unknowns; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @return float|int |
266
|
|
|
*/ |
267
|
|
|
public function getUnknownsPercentage() |
268
|
|
|
{ |
269
|
|
|
if ($this->getAmount() == 0) { |
270
|
|
|
return 0; |
271
|
|
|
} |
272
|
|
|
return $this->getUnknowns() / $this->getAmount() * 100; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @return float|int |
277
|
|
|
*/ |
278
|
|
|
public function getInsertedPercentage() |
279
|
|
|
{ |
280
|
|
|
if ($this->getAmount() == 0) { |
281
|
|
|
return 0; |
282
|
|
|
} |
283
|
|
|
return $this->getInserted() / $this->getAmount() * 100; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @param int $updated |
288
|
|
|
*/ |
289
|
1 |
|
public function setUpdated($updated) |
290
|
|
|
{ |
291
|
1 |
|
$this->updated = $updated; |
292
|
1 |
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* @return int |
296
|
|
|
*/ |
297
|
1 |
|
public function getUpdated() |
298
|
|
|
{ |
299
|
1 |
|
return (int)$this->updated; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @return float|int |
304
|
|
|
*/ |
305
|
|
|
public function getUpdatedPercentage() |
306
|
|
|
{ |
307
|
|
|
if ($this->getAmount() == 0) { |
308
|
|
|
return 0; |
309
|
|
|
} |
310
|
|
|
return $this->getUpdated() / $this->getAmount() * 100; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* @param int $type |
315
|
|
|
*/ |
316
|
1 |
|
public function increaseCount($type) |
317
|
|
|
{ |
318
|
|
|
switch ($type) { |
319
|
1 |
|
case TargetInterface::RESULT_INSERT: |
320
|
1 |
|
$this->setInserted($this->getInserted() + 1); |
321
|
1 |
|
break; |
322
|
1 |
|
case TargetInterface::RESULT_UPDATE: |
323
|
1 |
|
$this->setUpdated($this->getUpdated() + 1); |
324
|
1 |
|
break; |
325
|
1 |
|
case TargetInterface::RESULT_IGNORED: |
326
|
1 |
|
$this->setIgnored($this->getIgnored() + 1); |
327
|
1 |
|
break; |
328
|
1 |
|
case TargetInterface::RESULT_UNSURE: |
329
|
1 |
|
$this->setUnknowns($this->getUnknowns() + 1); |
330
|
1 |
|
break; |
331
|
1 |
|
case TargetInterface::RESULT_ERROR: |
332
|
1 |
|
$this->setErrors($this->getErrors() + 1); |
333
|
1 |
|
break; |
334
|
|
|
} |
335
|
1 |
|
} |
336
|
|
|
|
337
|
|
|
public function reset() |
338
|
|
|
{ |
339
|
|
|
$this->endtime = 0; |
|
|
|
|
340
|
|
|
$this->amount = 0; |
341
|
|
|
$this->errors = 0; |
342
|
|
|
$this->ignored = 0; |
343
|
|
|
$this->inserted = 0; |
344
|
|
|
$this->updated = 0; |
345
|
|
|
$this->unknowns = 0; |
346
|
|
|
$this->pointer = 0; |
347
|
|
|
} |
348
|
|
|
} |
349
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..