Skip to content

Commit 7253313

Browse files
committed
Add filter and writer warning in step execution and update doExecute of
item step to allow to skip a line
1 parent 472247a commit 7253313

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

Entity/StepExecution.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ class StepExecution
137137
*/
138138
private $readerWarnings = array();
139139

140+
/**
141+
* @var array
142+
*
143+
* @ORM\Column(name="filter_warnings", type="array", nullable=true)
144+
*/
145+
private $filterWarnings = array();
146+
147+
/**
148+
* @var array
149+
*
150+
* @ORM\Column(name="writer_warnings", type="array", nullable=true)
151+
*/
152+
private $writerWarnings = array();
153+
140154
/**
141155
* Constructor with mandatory properties.
142156
*
@@ -310,6 +324,32 @@ public function incrementWriteCount()
310324
$this->writeCount++;
311325
}
312326

327+
/**
328+
* Add a writer warning
329+
*
330+
* @param string $writer
331+
* @param string $message
332+
* @param mixed $data
333+
*/
334+
public function addWriterWarning($writer, $message, $data)
335+
{
336+
$this->writerWarnings[] = array(
337+
'writer' => $writer,
338+
'reason' => $message,
339+
'data' => $data,
340+
);
341+
}
342+
343+
/**
344+
* Get the writer warnings
345+
*
346+
* @return array[]
347+
*/
348+
public function getWriterWarnings()
349+
{
350+
return $this->writerWarnings;
351+
}
352+
313353
/**
314354
* Returns the current number of items filtered out of this execution
315355
*
@@ -320,6 +360,32 @@ public function getFilterCount()
320360
return $this->readCount - $this->writeCount;
321361
}
322362

363+
/**
364+
* Add a filter warning
365+
*
366+
* @param string $filter
367+
* @param string $message
368+
* @param mixed $data
369+
*/
370+
public function addFilterWarning($filter, $message, $data)
371+
{
372+
$this->filterWarnings[] = array(
373+
'filter' => $filter,
374+
'reason' => $message,
375+
'data' => $data,
376+
);
377+
}
378+
379+
/**
380+
* Get the filter warnings
381+
*
382+
* @return array[]
383+
*/
384+
public function getFilterWarnings()
385+
{
386+
return $this->filterWarnings;
387+
}
388+
323389
/**
324390
* @return flag to indicate that an execution should halt
325391
*/

Step/ItemStep.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ public function doExecute(StepExecution $stepExecution)
173173
}
174174

175175
if (null !== $processedItem = $this->processor->process($item)) {
176+
if (false === $processedItem) {
177+
continue;
178+
}
176179
$itemsToWrite[] = $processedItem;
177180
$writeCount++;
178181
if (0 === $writeCount % $this->batchSize) {

0 commit comments

Comments
 (0)