Commit 2ac59f82 authored by Chivy Lim's avatar Chivy Lim

[IMP] Ignore broken file resource on importing

refs KIME-4681
parent 94b2bd13
......@@ -13,6 +13,7 @@ namespace WE\SpreadsheetImport\Command;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Cli\CommandController;
use TYPO3\Flow\Exception;
use WE\SpreadsheetImport\Domain\Model\SpreadsheetImport;
/**
......@@ -63,14 +64,16 @@ class SpreadsheetImportCommandController extends CommandController {
// do importing and mark its status as "Completed/Failed"
$this->spreadsheetImportService->init($spreadsheetImport);
$this->spreadsheetImportService->import();
// mark importing status as "Completed"
$spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_COMPLETED);
try {
$this->spreadsheetImportService->import();
$spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_COMPLETED);
$this->outputFormatted('Spreadsheet has been imported. (totalInserted: %d, totalUpdated: %d, totalDeleted: %d, totalSkipped: %d)',
array($spreadsheetImport->getTotalInserted(), $spreadsheetImport->getTotalUpdated(), $spreadsheetImport->getTotalDeleted(), $spreadsheetImport->getTotalSkipped()));
} catch (Exception $e) {
$spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_FAILED);
$this->outputFormatted('Spreadsheet imported failed.');
}
$this->spreadsheetImportRepository->update($spreadsheetImport);
$this->outputFormatted('Spreadsheet has been imported. (totalInserted: %d, totalUpdated: %d, totalDeleted: %d, totalSkipped: %d)',
array($spreadsheetImport->getTotalInserted(), $spreadsheetImport->getTotalUpdated(), $spreadsheetImport->getTotalDeleted(), $spreadsheetImport->getTotalSkipped()));
} else {
$this->outputFormatted('There is no spreadsheet importing in queue.');
}
......
......@@ -32,7 +32,7 @@ class SpreadsheetImportRepository extends Repository {
public function findNextInQueue() {
$query = $this->createQuery();
$constraint = $query->logicalAnd(
$query->lessThanOrEqual('importingStatus', SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE),
$query->equals('importingStatus', SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE),
$query->lessThanOrEqual('scheduleDate', new \DateTime())
);
return $query->matching($constraint)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment