|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Cli\Configuration |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import-cli-simple |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Cli; |
|
22
|
|
|
|
|
23
|
|
|
use Psr\Log\LogLevel; |
|
24
|
|
|
use JMS\Serializer\Annotation\Type; |
|
25
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
|
26
|
|
|
use TechDivision\Import\ConfigurationInterface; |
|
27
|
|
|
use TechDivision\Import\Cli\Configuration\Operation; |
|
28
|
|
|
use TechDivision\Import\Configuration\DatabaseConfigurationInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* A simple configuration implementation. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Tim Wagner <[email protected]> |
|
34
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
35
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
36
|
|
|
* @link https://github.com/techdivision/import-cli-simple |
|
37
|
|
|
* @link http://www.techdivision.com |
|
38
|
|
|
*/ |
|
39
|
|
|
class Configuration implements ConfigurationInterface |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* The default PID filename to use. |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
const PID_FILENAME = 'importer.pid'; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Mapping for boolean values passed on the console. |
|
51
|
|
|
* |
|
52
|
|
|
* @var array |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $booleanMapping = array( |
|
55
|
|
|
'true' => true, |
|
56
|
|
|
'false' => false, |
|
57
|
|
|
'1' => true, |
|
58
|
|
|
'0' => false, |
|
59
|
|
|
'on' => true, |
|
60
|
|
|
'off' => false |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* The operation name to use. |
|
65
|
|
|
* |
|
66
|
|
|
* @var string |
|
67
|
|
|
* @Type("string") |
|
68
|
|
|
* @SerializedName("operation-name") |
|
69
|
|
|
*/ |
|
70
|
|
|
protected $operationName; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* The Magento edition, EE or CE. |
|
74
|
|
|
* |
|
75
|
|
|
* @var string |
|
76
|
|
|
* @Type("string") |
|
77
|
|
|
* @SerializedName("magento-edition") |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $magentoEdition = 'CE'; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* The Magento version, e. g. 2.1.0. |
|
83
|
|
|
* |
|
84
|
|
|
* @var string |
|
85
|
|
|
* @Type("string") |
|
86
|
|
|
* @SerializedName("magento-version") |
|
87
|
|
|
*/ |
|
88
|
|
|
protected $magentoVersion = '2.1.2'; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* The Magento installation directory. |
|
92
|
|
|
* |
|
93
|
|
|
* @var string |
|
94
|
|
|
* @Type("string") |
|
95
|
|
|
* @SerializedName("installation-dir") |
|
96
|
|
|
*/ |
|
97
|
|
|
protected $installationDir; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* The source directory that has to be watched for new files. |
|
101
|
|
|
* |
|
102
|
|
|
* @var string |
|
103
|
|
|
* @Type("string") |
|
104
|
|
|
* @SerializedName("source-dir") |
|
105
|
|
|
*/ |
|
106
|
|
|
protected $sourceDir; |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* The target directory with the files that has been imported. |
|
110
|
|
|
* |
|
111
|
|
|
* @var string |
|
112
|
|
|
* @Type("string") |
|
113
|
|
|
* @SerializedName("target-dir") |
|
114
|
|
|
*/ |
|
115
|
|
|
protected $targetDir; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* ArrayCollection with the information of the configured databases. |
|
119
|
|
|
* |
|
120
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
121
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Cli\Configuration\Database>") |
|
122
|
|
|
*/ |
|
123
|
|
|
protected $databases; |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* ArrayCollection with the information of the configured loggers. |
|
127
|
|
|
* |
|
128
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
129
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Cli\Configuration\Logger>") |
|
130
|
|
|
*/ |
|
131
|
|
|
protected $loggers; |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* ArrayCollection with the information of the configured operations. |
|
135
|
|
|
* |
|
136
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
|
137
|
|
|
* @Type("ArrayCollection<TechDivision\Import\Cli\Configuration\Operation>") |
|
138
|
|
|
*/ |
|
139
|
|
|
protected $operations; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* The subject's utility class with the SQL statements to use. |
|
143
|
|
|
* |
|
144
|
|
|
* @var string |
|
145
|
|
|
* @Type("string") |
|
146
|
|
|
* @SerializedName("utility-class-name") |
|
147
|
|
|
*/ |
|
148
|
|
|
protected $utilityClassName; |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* The source date format to use in the subject. |
|
152
|
|
|
* |
|
153
|
|
|
* @var string |
|
154
|
|
|
* @Type("string") |
|
155
|
|
|
* @SerializedName("source-date-format") |
|
156
|
|
|
*/ |
|
157
|
|
|
protected $sourceDateFormat = 'n/d/y, g:i A'; |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* The subject's multiple field delimiter character for fields with multiple values, defaults to (,). |
|
161
|
|
|
* |
|
162
|
|
|
* @var string |
|
163
|
|
|
* @Type("string") |
|
164
|
|
|
* @SerializedName("multiple-field-delimiter") |
|
165
|
|
|
*/ |
|
166
|
|
|
protected $multipleFieldDelimiter = ','; |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* The subject's delimiter character for CSV files. |
|
170
|
|
|
* |
|
171
|
|
|
* @var string |
|
172
|
|
|
* @Type("string") |
|
173
|
|
|
*/ |
|
174
|
|
|
protected $delimiter; |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* The subject's enclosure character for CSV files. |
|
178
|
|
|
* |
|
179
|
|
|
* @var string |
|
180
|
|
|
* @Type("string") |
|
181
|
|
|
*/ |
|
182
|
|
|
protected $enclosure; |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* The subject's escape character for CSV files. |
|
186
|
|
|
* |
|
187
|
|
|
* @var string |
|
188
|
|
|
* @Type("string") |
|
189
|
|
|
*/ |
|
190
|
|
|
protected $escape; |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* The subject's source charset for the CSV file. |
|
194
|
|
|
* |
|
195
|
|
|
* @var string |
|
196
|
|
|
* @Type("string") |
|
197
|
|
|
* @SerializedName("from-charset") |
|
198
|
|
|
*/ |
|
199
|
|
|
protected $fromCharset; |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* The subject's target charset for a CSV file. |
|
203
|
|
|
* |
|
204
|
|
|
* @var string |
|
205
|
|
|
* @Type("string") |
|
206
|
|
|
* @SerializedName("to-charset") |
|
207
|
|
|
*/ |
|
208
|
|
|
protected $toCharset; |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* The subject's file mode for a CSV target file. |
|
212
|
|
|
* |
|
213
|
|
|
* @var string |
|
214
|
|
|
* @Type("string") |
|
215
|
|
|
* @SerializedName("file-mode") |
|
216
|
|
|
*/ |
|
217
|
|
|
protected $fileMode; |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* The flag to signal that the subject has to use the strict mode or not. |
|
221
|
|
|
* |
|
222
|
|
|
* @var boolean |
|
223
|
|
|
* @Type("boolean") |
|
224
|
|
|
* @SerializedName("strict-mode") |
|
225
|
|
|
*/ |
|
226
|
|
|
protected $strictMode; |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* The flag whether or not the import artefacts have to be archived. |
|
230
|
|
|
* |
|
231
|
|
|
* @var boolean |
|
232
|
|
|
* @Type("boolean") |
|
233
|
|
|
* @SerializedName("archive-artefacts") |
|
234
|
|
|
*/ |
|
235
|
|
|
protected $archiveArtefacts; |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* The directory where the archives will be stored. |
|
239
|
|
|
* |
|
240
|
|
|
* @var string |
|
241
|
|
|
* @Type("string") |
|
242
|
|
|
* @SerializedName("archive-dir") |
|
243
|
|
|
*/ |
|
244
|
|
|
protected $archiveDir; |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* The flag to signal that the subject has to use the debug mode or not. |
|
248
|
|
|
* |
|
249
|
|
|
* @var boolean |
|
250
|
|
|
* @Type("boolean") |
|
251
|
|
|
* @SerializedName("debug-mode") |
|
252
|
|
|
*/ |
|
253
|
|
|
protected $debugMode = false; |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* The flag to signal that the an existing PID should be ignored, whether or import process is running or not. |
|
257
|
|
|
* |
|
258
|
|
|
* @var boolean |
|
259
|
|
|
* @Type("boolean") |
|
260
|
|
|
* @SerializedName("ignore-pid") |
|
261
|
|
|
*/ |
|
262
|
|
|
protected $ignorePid = false; |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* The log level to use (see Monolog documentation). |
|
266
|
|
|
* |
|
267
|
|
|
* @var string |
|
268
|
|
|
* @Type("string") |
|
269
|
|
|
* @SerializedName("log-level") |
|
270
|
|
|
*/ |
|
271
|
|
|
protected $logLevel = LogLevel::INFO; |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* The explicit DB ID to use. |
|
275
|
|
|
* |
|
276
|
|
|
* @var string |
|
277
|
|
|
* @Type("string") |
|
278
|
|
|
* @SerializedName("use-db-id") |
|
279
|
|
|
*/ |
|
280
|
|
|
protected $useDbId; |
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* The explicit PID filename to use. |
|
284
|
|
|
* |
|
285
|
|
|
* @var string |
|
286
|
|
|
* @Type("string") |
|
287
|
|
|
* @SerializedName("pid-filename") |
|
288
|
|
|
*/ |
|
289
|
|
|
protected $pidFilename; |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* The entity type code to use. |
|
293
|
|
|
* |
|
294
|
|
|
* @var string |
|
295
|
|
|
* @Type("string") |
|
296
|
|
|
* @SerializedName("entity-type-code") |
|
297
|
|
|
*/ |
|
298
|
|
|
protected $entityTypeCode; |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Return's the array with the plugins of the operation to use. |
|
302
|
|
|
* |
|
303
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the plugins |
|
304
|
|
|
* @throws \Exception Is thrown, if no plugins are available for the actual operation |
|
305
|
|
|
*/ |
|
306
|
|
|
public function getPlugins() |
|
307
|
|
|
{ |
|
308
|
|
|
|
|
309
|
|
|
// iterate over the operations and return the subjects of the actual one |
|
310
|
|
|
/** @var TechDivision\Import\Configuration\OperationInterface $operation */ |
|
311
|
|
|
foreach ($this->getOperations() as $operation) { |
|
312
|
|
|
if ($this->getOperation()->equals($operation)) { |
|
313
|
|
|
return $operation->getPlugins(); |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
// throw an exception if no plugins are available |
|
318
|
|
|
throw new \Exception(sprintf('Can\'t find any plugins for operation %s', $this->getOperation())); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Map's the passed value to a boolean. |
|
323
|
|
|
* |
|
324
|
|
|
* @param string $value The value to map |
|
325
|
|
|
* |
|
326
|
|
|
* @return boolean The mapped value |
|
327
|
|
|
* @throws \Exception Is thrown, if the value can't be mapped |
|
328
|
|
|
*/ |
|
329
|
|
|
public function mapBoolean($value) |
|
330
|
|
|
{ |
|
331
|
|
|
|
|
332
|
|
|
// try to map the passed value to a boolean |
|
333
|
|
|
if (isset($this->booleanMapping[$value])) { |
|
334
|
|
|
return $this->booleanMapping[$value]; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
// throw an exception if we can't convert the passed value |
|
338
|
|
|
throw new \Exception(sprintf('Can\'t convert %s to boolean', $value)); |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* Return's the operation, initialize from the actual operation name. |
|
343
|
|
|
* |
|
344
|
|
|
* @return \TechDivision\Import\Configuration\OperationInterface The operation instance |
|
345
|
|
|
*/ |
|
346
|
|
|
protected function getOperation() |
|
347
|
|
|
{ |
|
348
|
|
|
return new Operation($this->getOperationName()); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
/** |
|
352
|
|
|
* Return's the operation name that has to be used. |
|
353
|
|
|
* |
|
354
|
|
|
* @param string $operationName The operation name that has to be used |
|
355
|
|
|
* |
|
356
|
|
|
* @return void |
|
357
|
|
|
*/ |
|
358
|
|
|
public function setOperationName($operationName) |
|
359
|
|
|
{ |
|
360
|
|
|
return $this->operationName = $operationName; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Return's the operation name that has to be used. |
|
365
|
|
|
* |
|
366
|
|
|
* @return string The operation name that has to be used |
|
367
|
|
|
*/ |
|
368
|
|
|
public function getOperationName() |
|
369
|
|
|
{ |
|
370
|
|
|
return $this->operationName; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* Set's the Magento installation directory. |
|
375
|
|
|
* |
|
376
|
|
|
* @param string $installationDir The Magento installation directory |
|
377
|
|
|
* |
|
378
|
|
|
* @return void |
|
379
|
|
|
*/ |
|
380
|
|
|
public function setInstallationDir($installationDir) |
|
381
|
|
|
{ |
|
382
|
|
|
$this->installationDir = $installationDir; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* Return's the Magento installation directory. |
|
387
|
|
|
* |
|
388
|
|
|
* @return string The Magento installation directory |
|
389
|
|
|
*/ |
|
390
|
|
|
public function getInstallationDir() |
|
391
|
|
|
{ |
|
392
|
|
|
return $this->installationDir; |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* Set's the source directory that has to be watched for new files. |
|
397
|
|
|
* |
|
398
|
|
|
* @param string $sourceDir The source directory |
|
399
|
|
|
* |
|
400
|
|
|
* @return void |
|
401
|
|
|
*/ |
|
402
|
|
|
public function setSourceDir($sourceDir) |
|
403
|
|
|
{ |
|
404
|
|
|
$this->sourceDir = $sourceDir; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* Return's the source directory that has to be watched for new files. |
|
409
|
|
|
* |
|
410
|
|
|
* @return string The source directory |
|
411
|
|
|
*/ |
|
412
|
|
|
public function getSourceDir() |
|
413
|
|
|
{ |
|
414
|
|
|
return $this->sourceDir; |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
/** |
|
418
|
|
|
* Return's the target directory with the files that has been imported. |
|
419
|
|
|
* |
|
420
|
|
|
* @return string The target directory |
|
421
|
|
|
*/ |
|
422
|
|
|
public function getTargetDir() |
|
423
|
|
|
{ |
|
424
|
|
|
return $this->targetDir; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
/** |
|
428
|
|
|
* Set's the target directory with the files that has been imported. |
|
429
|
|
|
* |
|
430
|
|
|
* @param string $targetDir The target directory |
|
431
|
|
|
* |
|
432
|
|
|
* @return void |
|
433
|
|
|
*/ |
|
434
|
|
|
public function setTargetDir($targetDir) |
|
435
|
|
|
{ |
|
436
|
|
|
$this->targetDir = $targetDir; |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* Return's the utility class with the SQL statements to use. |
|
441
|
|
|
* |
|
442
|
|
|
* @param string $utilityClassName The utility class name |
|
443
|
|
|
* |
|
444
|
|
|
* @return void |
|
445
|
|
|
*/ |
|
446
|
|
|
public function setUtilityClassName($utilityClassName) |
|
447
|
|
|
{ |
|
448
|
|
|
return $this->utilityClassName = $utilityClassName; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
/** |
|
452
|
|
|
* Return's the utility class with the SQL statements to use. |
|
453
|
|
|
* |
|
454
|
|
|
* @return string The utility class name |
|
455
|
|
|
*/ |
|
456
|
|
|
public function getUtilityClassName() |
|
457
|
|
|
{ |
|
458
|
|
|
return $this->utilityClassName; |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
/** |
|
462
|
|
|
* Set's the Magento edition, EE or CE. |
|
463
|
|
|
* |
|
464
|
|
|
* @param string $magentoEdition The Magento edition |
|
465
|
|
|
* |
|
466
|
|
|
* @return void |
|
467
|
|
|
*/ |
|
468
|
|
|
public function setMagentoEdition($magentoEdition) |
|
469
|
|
|
{ |
|
470
|
|
|
$this->magentoEdition = $magentoEdition; |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
/** |
|
474
|
|
|
* Return's the Magento edition, EE or CE. |
|
475
|
|
|
* |
|
476
|
|
|
* @return string The Magento edition |
|
477
|
|
|
*/ |
|
478
|
|
|
public function getMagentoEdition() |
|
479
|
|
|
{ |
|
480
|
|
|
return $this->magentoEdition; |
|
481
|
|
|
} |
|
482
|
|
|
|
|
483
|
|
|
/** |
|
484
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
|
485
|
|
|
* |
|
486
|
|
|
* @param string $magentoVersion The Magento version |
|
487
|
|
|
* |
|
488
|
|
|
* @return void |
|
489
|
|
|
*/ |
|
490
|
|
|
public function setMagentoVersion($magentoVersion) |
|
491
|
|
|
{ |
|
492
|
|
|
$this->magentoVersion = $magentoVersion; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* Return's the Magento version, e. g. 2.1.0. |
|
497
|
|
|
* |
|
498
|
|
|
* @return string The Magento version |
|
499
|
|
|
*/ |
|
500
|
|
|
public function getMagentoVersion() |
|
501
|
|
|
{ |
|
502
|
|
|
return $this->magentoVersion; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* Return's the subject's source date format to use. |
|
507
|
|
|
* |
|
508
|
|
|
* @return string The source date format |
|
509
|
|
|
*/ |
|
510
|
|
|
public function getSourceDateFormat() |
|
511
|
|
|
{ |
|
512
|
|
|
return $this->sourceDateFormat; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* Set's the subject's source date format to use. |
|
517
|
|
|
* |
|
518
|
|
|
* @param string $sourceDateFormat The source date format |
|
519
|
|
|
* |
|
520
|
|
|
* @return void |
|
521
|
|
|
*/ |
|
522
|
|
|
public function setSourceDateFormat($sourceDateFormat) |
|
523
|
|
|
{ |
|
524
|
|
|
$this->sourceDateFormat = $sourceDateFormat; |
|
525
|
|
|
} |
|
526
|
|
|
|
|
527
|
|
|
/** |
|
528
|
|
|
* Return's the multiple field delimiter character to use, default value is comma (,). |
|
529
|
|
|
* |
|
530
|
|
|
* @return string The multiple field delimiter character |
|
531
|
|
|
*/ |
|
532
|
|
|
public function getMultipleFieldDelimiter() |
|
533
|
|
|
{ |
|
534
|
|
|
return $this->multipleFieldDelimiter; |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* Return's the delimiter character to use, default value is comma (,). |
|
539
|
|
|
* |
|
540
|
|
|
* @return string The delimiter character |
|
541
|
|
|
*/ |
|
542
|
|
|
public function getDelimiter() |
|
543
|
|
|
{ |
|
544
|
|
|
return $this->delimiter; |
|
545
|
|
|
} |
|
546
|
|
|
|
|
547
|
|
|
/** |
|
548
|
|
|
* The enclosure character to use, default value is double quotation ("). |
|
549
|
|
|
* |
|
550
|
|
|
* @return string The enclosure character |
|
551
|
|
|
*/ |
|
552
|
|
|
public function getEnclosure() |
|
553
|
|
|
{ |
|
554
|
|
|
return $this->enclosure; |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
/** |
|
558
|
|
|
* The escape character to use, default value is backslash (\). |
|
559
|
|
|
* |
|
560
|
|
|
* @return string The escape character |
|
561
|
|
|
*/ |
|
562
|
|
|
public function getEscape() |
|
563
|
|
|
{ |
|
564
|
|
|
return $this->escape; |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
/** |
|
568
|
|
|
* The file encoding of the CSV source file, default value is UTF-8. |
|
569
|
|
|
* |
|
570
|
|
|
* @return string The charset used by the CSV source file |
|
571
|
|
|
*/ |
|
572
|
|
|
public function getFromCharset() |
|
573
|
|
|
{ |
|
574
|
|
|
return $this->fromCharset; |
|
575
|
|
|
} |
|
576
|
|
|
|
|
577
|
|
|
/** |
|
578
|
|
|
* The file encoding of the CSV targetfile, default value is UTF-8. |
|
579
|
|
|
* |
|
580
|
|
|
* @return string The charset used by the CSV target file |
|
581
|
|
|
*/ |
|
582
|
|
|
public function getToCharset() |
|
583
|
|
|
{ |
|
584
|
|
|
return $this->toCharset; |
|
585
|
|
|
} |
|
586
|
|
|
|
|
587
|
|
|
/** |
|
588
|
|
|
* The file mode of the CSV target file, either one of write or append, default is write. |
|
589
|
|
|
* |
|
590
|
|
|
* @return string The file mode of the CSV target file |
|
591
|
|
|
*/ |
|
592
|
|
|
public function getFileMode() |
|
593
|
|
|
{ |
|
594
|
|
|
return $this->fileMode; |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
/** |
|
598
|
|
|
* Queries whether or not strict mode is enabled or not, default is TRUE. |
|
599
|
|
|
* |
|
600
|
|
|
* @return boolean TRUE if strict mode is enabled, else FALSE |
|
601
|
|
|
*/ |
|
602
|
|
|
public function isStrictMode() |
|
603
|
|
|
{ |
|
604
|
|
|
return $this->strictMode; |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
/** |
|
608
|
|
|
* Return's the entity type code to be used. |
|
609
|
|
|
* |
|
610
|
|
|
* @return string The entity type code to be used |
|
611
|
|
|
*/ |
|
612
|
|
|
public function getEntityTypeCode() |
|
613
|
|
|
{ |
|
614
|
|
|
return $this->entityTypeCode; |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
/** |
|
618
|
|
|
* Remove's all configured database configuration. |
|
619
|
|
|
* |
|
620
|
|
|
* @return void |
|
621
|
|
|
*/ |
|
622
|
|
|
public function clearDatabases() |
|
623
|
|
|
{ |
|
624
|
|
|
$this->databases->clear(); |
|
625
|
|
|
} |
|
626
|
|
|
|
|
627
|
|
|
/** |
|
628
|
|
|
* Add's the passed database configuration. |
|
629
|
|
|
* |
|
630
|
|
|
* @param \TechDivision\Import\Configuration\DatabaseConfigurationInterface $database The database configuration |
|
631
|
|
|
* |
|
632
|
|
|
* @return void |
|
633
|
|
|
*/ |
|
634
|
|
|
public function addDatabase(DatabaseConfigurationInterface $database) |
|
635
|
|
|
{ |
|
636
|
|
|
$this->databases->add($database); |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* Return's the database configuration. |
|
641
|
|
|
* |
|
642
|
|
|
* If an explicit DB ID is specified, the method tries to return the database with this ID. If |
|
643
|
|
|
* the database configuration is NOT available, an execption is thrown. |
|
644
|
|
|
* |
|
645
|
|
|
* If no explicit DB ID is specified, the method tries to return the default database configuration, |
|
646
|
|
|
* if not available the first one. |
|
647
|
|
|
* |
|
648
|
|
|
* @return \TechDivision\Import\Cli\Configuration\Database The database configuration |
|
649
|
|
|
* @throws \Exception Is thrown, if no database configuration is available |
|
650
|
|
|
*/ |
|
651
|
|
|
public function getDatabase() |
|
652
|
|
|
{ |
|
653
|
|
|
|
|
654
|
|
|
// if a DB ID has been set, try to load the database |
|
655
|
|
|
if ($useDbId = $this->getUseDbId()) { |
|
656
|
|
|
// iterate over the configured databases and return the one with the passed ID |
|
657
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
|
658
|
|
|
foreach ($this->databases as $database) { |
|
659
|
|
|
if ($database->getId() === $useDbId) { |
|
660
|
|
|
return $database; |
|
661
|
|
|
} |
|
662
|
|
|
} |
|
663
|
|
|
|
|
664
|
|
|
// throw an exception, if the database with the passed ID is NOT configured |
|
665
|
|
|
throw new \Exception(sprintf('Database with ID %s can not be found', $useDbId)); |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
// iterate over the configured databases and try return the default database |
|
669
|
|
|
/** @var TechDivision\Import\Configuration\DatabaseInterface $database */ |
|
670
|
|
|
foreach ($this->databases as $database) { |
|
671
|
|
|
if ($database->isDefault()) { |
|
672
|
|
|
return $database; |
|
673
|
|
|
} |
|
674
|
|
|
} |
|
675
|
|
|
|
|
676
|
|
|
// try to return the first database configurtion |
|
677
|
|
|
if ($this->databases->count() > 0) { |
|
678
|
|
|
return $this->databases->first(); |
|
679
|
|
|
} |
|
680
|
|
|
|
|
681
|
|
|
// throw an exception, if no database configuration is available |
|
682
|
|
|
throw new \Exception('There is no database configuration available'); |
|
683
|
|
|
} |
|
684
|
|
|
|
|
685
|
|
|
/** |
|
686
|
|
|
* Return's the ArrayCollection with the configured operations. |
|
687
|
|
|
* |
|
688
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operations |
|
689
|
|
|
*/ |
|
690
|
|
|
public function getOperations() |
|
691
|
|
|
{ |
|
692
|
|
|
return $this->operations; |
|
693
|
|
|
} |
|
694
|
|
|
|
|
695
|
|
|
/** |
|
696
|
|
|
* Return's the ArrayCollection with the configured loggers. |
|
697
|
|
|
* |
|
698
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the loggers |
|
699
|
|
|
*/ |
|
700
|
|
|
public function getLoggers() |
|
701
|
|
|
{ |
|
702
|
|
|
return $this->loggers; |
|
703
|
|
|
} |
|
704
|
|
|
|
|
705
|
|
|
/** |
|
706
|
|
|
* Return's the TRUE if the import artefacts have to be archived. |
|
707
|
|
|
* |
|
708
|
|
|
* @return boolean TRUE if the import artefacts have to be archived |
|
709
|
|
|
*/ |
|
710
|
|
|
public function haveArchiveArtefacts() |
|
711
|
|
|
{ |
|
712
|
|
|
return $this->archiveArtefacts; |
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
|
|
/** |
|
716
|
|
|
* The directory where the archives will be stored. |
|
717
|
|
|
* |
|
718
|
|
|
* @return string The archive directory |
|
719
|
|
|
*/ |
|
720
|
|
|
public function getArchiveDir() |
|
721
|
|
|
{ |
|
722
|
|
|
return $this->archiveDir; |
|
723
|
|
|
} |
|
724
|
|
|
|
|
725
|
|
|
/** |
|
726
|
|
|
* Set's the debug mode. |
|
727
|
|
|
* |
|
728
|
|
|
* @param boolean $debugMode TRUE if debug mode is enabled, else FALSE |
|
729
|
|
|
* |
|
730
|
|
|
* @return void |
|
731
|
|
|
*/ |
|
732
|
|
|
public function setDebugMode($debugMode) |
|
733
|
|
|
{ |
|
734
|
|
|
$this->debugMode = $debugMode; |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* Queries whether or not debug mode is enabled or not, default is TRUE. |
|
739
|
|
|
* |
|
740
|
|
|
* @return boolean TRUE if debug mode is enabled, else FALSE |
|
741
|
|
|
*/ |
|
742
|
|
|
public function isDebugMode() |
|
743
|
|
|
{ |
|
744
|
|
|
return $this->debugMode; |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
/** |
|
748
|
|
|
* Set's the flag to signal that the an existing PID has to be ignored, whether a |
|
749
|
|
|
* import process is running or not. |
|
750
|
|
|
* |
|
751
|
|
|
* @param boolean $ignorePid TRUE if the PID has to be ignored, else FALSE |
|
752
|
|
|
* |
|
753
|
|
|
* @return void |
|
754
|
|
|
*/ |
|
755
|
|
|
public function setIgnorePid($ignorePid) |
|
756
|
|
|
{ |
|
757
|
|
|
$this->ignorePid = $ignorePid; |
|
758
|
|
|
} |
|
759
|
|
|
|
|
760
|
|
|
/** |
|
761
|
|
|
* Queries whether or not that the an existing PID has to be ignored. |
|
762
|
|
|
* |
|
763
|
|
|
* @return boolean TRUE if an existing PID has to be ignored, else FALSE |
|
764
|
|
|
*/ |
|
765
|
|
|
public function isIgnorePid() |
|
766
|
|
|
{ |
|
767
|
|
|
return $this->ignorePid; |
|
768
|
|
|
} |
|
769
|
|
|
|
|
770
|
|
|
/** |
|
771
|
|
|
* Set's the log level to use. |
|
772
|
|
|
* |
|
773
|
|
|
* @param string $logLevel The log level to use |
|
774
|
|
|
* |
|
775
|
|
|
* @return void |
|
776
|
|
|
*/ |
|
777
|
|
|
public function setLogLevel($logLevel) |
|
778
|
|
|
{ |
|
779
|
|
|
$this->logLevel = $logLevel; |
|
780
|
|
|
} |
|
781
|
|
|
|
|
782
|
|
|
/** |
|
783
|
|
|
* Return's the log level to use. |
|
784
|
|
|
* |
|
785
|
|
|
* @return string The log level to use |
|
786
|
|
|
*/ |
|
787
|
|
|
public function getLogLevel() |
|
788
|
|
|
{ |
|
789
|
|
|
return $this->logLevel; |
|
790
|
|
|
} |
|
791
|
|
|
|
|
792
|
|
|
/** |
|
793
|
|
|
* Set's the explicit DB ID to use. |
|
794
|
|
|
* |
|
795
|
|
|
* @param string $useDbId The explicit DB ID to use |
|
796
|
|
|
* |
|
797
|
|
|
* @return void |
|
798
|
|
|
*/ |
|
799
|
|
|
public function setUseDbId($useDbId) |
|
800
|
|
|
{ |
|
801
|
|
|
$this->useDbId = $useDbId; |
|
802
|
|
|
} |
|
803
|
|
|
|
|
804
|
|
|
/** |
|
805
|
|
|
* Return's the explicit DB ID to use. |
|
806
|
|
|
* |
|
807
|
|
|
* @return string The explicit DB ID to use |
|
808
|
|
|
*/ |
|
809
|
|
|
public function getUseDbId() |
|
810
|
|
|
{ |
|
811
|
|
|
return $this->useDbId; |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
/** |
|
815
|
|
|
* Set's the PID filename to use. |
|
816
|
|
|
* |
|
817
|
|
|
* @param string $pidFilename The PID filename to use |
|
818
|
|
|
* |
|
819
|
|
|
* @return void |
|
820
|
|
|
*/ |
|
821
|
|
|
public function setPidFilename($pidFilename) |
|
822
|
|
|
{ |
|
823
|
|
|
$this->pidFilename = $pidFilename; |
|
824
|
|
|
} |
|
825
|
|
|
|
|
826
|
|
|
/** |
|
827
|
|
|
* Return's the PID filename to use. |
|
828
|
|
|
* |
|
829
|
|
|
* @return string The PID filename to use |
|
830
|
|
|
*/ |
|
831
|
|
|
public function getPidFilename() |
|
832
|
|
|
{ |
|
833
|
|
|
return $this->pidFilename; |
|
834
|
|
|
} |
|
835
|
|
|
} |
|
836
|
|
|
|