Commit 5e8c8d86 authored by Simon Gadient's avatar Simon Gadient

[IMP] Import status Draft

refs KIME-4583
parent aaae15ae
......@@ -54,7 +54,7 @@ class SpreadsheetImportCommandController extends CommandController {
$this->quit();
}
/** @var SpreadsheetImport $spreadsheetImport */
$spreadsheetImport = $this->spreadsheetImportRepository->findPreviousOneInQueue();
$spreadsheetImport = $this->spreadsheetImportRepository->findNextInQueue();
if ($spreadsheetImport instanceof SpreadsheetImport) {
// mark importing status as "Progressing" before continuing the importing
$spreadsheetImport->setImportingStatus(SpreadsheetImport::IMPORTING_STATUS_IN_PROGRESS);
......
......@@ -19,10 +19,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
class SpreadsheetImport {
const IMPORTING_STATUS_IN_QUEUE = 0;
const IMPORTING_STATUS_IN_PROGRESS = 1;
const IMPORTING_STATUS_COMPLETED = 2;
const IMPORTING_STATUS_FAILED = 3;
const IMPORTING_STATUS_DRAFT = 0;
const IMPORTING_STATUS_IN_QUEUE = 1;
const IMPORTING_STATUS_IN_PROGRESS = 2;
const IMPORTING_STATUS_COMPLETED = 3;
const IMPORTING_STATUS_FAILED = 4;
/**
* @var string
......@@ -72,7 +73,7 @@ class SpreadsheetImport {
* @var int
* @ORM\Column(options={"default": 0})
*/
protected $importingStatus = self::IMPORTING_STATUS_IN_QUEUE;
protected $importingStatus = self::IMPORTING_STATUS_DRAFT;
/**
* @var int
......
......@@ -29,10 +29,10 @@ class SpreadsheetImportRepository extends Repository {
/**
* @return SpreadsheetImport
*/
public function findPreviousOneInQueue() {
public function findNextInQueue() {
$query = $this->createQuery();
$constraint = $query->logicalAnd(
$query->equals('importingStatus', SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE),
$query->lessThanOrEqual('importingStatus', SpreadsheetImport::IMPORTING_STATUS_IN_QUEUE),
$query->lessThanOrEqual('scheduleDate', new \DateTime())
);
return $query->matching($constraint)
......@@ -51,4 +51,18 @@ class SpreadsheetImportRepository extends Repository {
return $query->matching($constraint)->execute();
}
/**
* @param string $context
* @param array $arguments
*
* @return \TYPO3\Flow\Persistence\QueryResultInterface
*/
public function findByContextAndArguments($context, $arguments = array()) {
$query = $this->createQuery();
$constraint = $query->logicalAnd(
$query->equals('context', $context),
$query->equals('arguments', serialize($arguments))
);
return $query->matching($constraint)->execute();
}
}
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