2016-06-10 21:00:00 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ImportJobRepositoryInterface.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-06-10 21:00:00 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:44:05 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-06-10 21:00:00 +02:00
|
|
|
*/
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2016-06-10 21:00:00 +02:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\ImportJob;
|
|
|
|
|
2018-05-06 07:09:08 +02:00
|
|
|
use FireflyIII\Exceptions\FireflyException;
|
2016-06-10 21:00:00 +02:00
|
|
|
use FireflyIII\Models\ImportJob;
|
2018-05-03 17:23:16 +02:00
|
|
|
use FireflyIII\Models\Tag;
|
2017-01-30 16:40:49 +01:00
|
|
|
use FireflyIII\User;
|
2018-05-10 23:01:21 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2018-05-06 07:09:08 +02:00
|
|
|
use Illuminate\Support\MessageBag;
|
2017-06-10 15:09:41 +02:00
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
2016-06-10 21:00:00 +02:00
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Interface ImportJobRepositoryInterface.
|
2016-06-10 21:00:00 +02:00
|
|
|
*/
|
|
|
|
interface ImportJobRepositoryInterface
|
|
|
|
{
|
2018-05-10 23:01:21 +02:00
|
|
|
/**
|
2018-05-12 19:09:34 +02:00
|
|
|
* @param ImportJob $job
|
2018-06-06 21:23:00 +02:00
|
|
|
* @param int $index
|
|
|
|
* @param string $error
|
2018-05-03 17:23:16 +02:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-06-06 21:23:00 +02:00
|
|
|
public function addError(ImportJob $job, int $index, string $error): ImportJob;
|
2018-05-03 17:23:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add message to job.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param string $error
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function addErrorMessage(ImportJob $job, string $error): ImportJob;
|
|
|
|
|
2016-06-10 21:00:00 +02:00
|
|
|
/**
|
2018-01-05 17:29:42 +01:00
|
|
|
* @param ImportJob $job
|
|
|
|
* @param int $steps
|
2016-06-10 21:00:00 +02:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-07-22 18:50:27 +02:00
|
|
|
public function addStepsDone(ImportJob $job, int $steps = null): ImportJob;
|
2016-06-10 21:00:00 +02:00
|
|
|
|
2018-01-13 07:36:44 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param int $steps
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-07-22 18:50:27 +02:00
|
|
|
public function addTotalSteps(ImportJob $job, int $steps = null): ImportJob;
|
2018-01-13 07:36:44 +01:00
|
|
|
|
2018-01-04 19:33:16 +01:00
|
|
|
/**
|
2018-01-05 17:29:42 +01:00
|
|
|
* Return number of imported rows with this hash value.
|
2018-01-04 19:33:16 +01:00
|
|
|
*
|
2018-01-05 17:29:42 +01:00
|
|
|
* @param string $hash
|
2018-01-04 19:33:16 +01:00
|
|
|
*
|
2018-01-05 17:29:42 +01:00
|
|
|
* @return int
|
2018-01-04 19:33:16 +01:00
|
|
|
*/
|
2018-01-05 17:29:42 +01:00
|
|
|
public function countByHash(string $hash): int;
|
|
|
|
|
|
|
|
/**
|
2018-04-29 18:07:14 +02:00
|
|
|
* @param string $importProvider
|
2018-01-05 17:29:42 +01:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-04-29 18:07:14 +02:00
|
|
|
public function create(string $importProvider): ImportJob;
|
2018-01-04 19:33:16 +01:00
|
|
|
|
2016-06-10 21:00:00 +02:00
|
|
|
/**
|
|
|
|
* @param string $key
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function findByKey(string $key): ImportJob;
|
2017-01-30 16:46:30 +01:00
|
|
|
|
2018-06-06 21:23:00 +02:00
|
|
|
/**
|
|
|
|
* Return all attachments for job.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getAttachments(ImportJob $job): Collection;
|
|
|
|
|
2018-01-04 18:34:51 +01:00
|
|
|
/**
|
|
|
|
* Return configuration of job.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getConfiguration(ImportJob $job): array;
|
|
|
|
|
2018-01-05 17:29:42 +01:00
|
|
|
/**
|
|
|
|
* Return extended status of job.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getExtendedStatus(ImportJob $job): array;
|
|
|
|
|
2018-01-10 18:18:49 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-07-22 18:50:27 +02:00
|
|
|
public function getStatus(ImportJob $job): string;
|
2018-01-10 18:18:49 +01:00
|
|
|
|
2017-06-10 15:09:41 +02:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param UploadedFile $file
|
|
|
|
*
|
2017-07-07 13:50:15 +02:00
|
|
|
* @return bool
|
2017-06-10 15:09:41 +02:00
|
|
|
*/
|
2017-07-07 13:50:15 +02:00
|
|
|
public function processConfiguration(ImportJob $job, UploadedFile $file): bool;
|
2017-06-10 15:09:41 +02:00
|
|
|
|
|
|
|
/**
|
2017-12-16 17:19:10 +01:00
|
|
|
* @param ImportJob $job
|
|
|
|
* @param null|UploadedFile $file
|
2017-06-10 15:09:41 +02:00
|
|
|
*
|
2017-12-16 17:19:10 +01:00
|
|
|
* @return bool
|
2017-06-10 15:09:41 +02:00
|
|
|
*/
|
2017-12-16 17:19:10 +01:00
|
|
|
public function processFile(ImportJob $job, ?UploadedFile $file): bool;
|
2017-06-10 15:09:41 +02:00
|
|
|
|
2017-03-19 17:54:21 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param array $configuration
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function setConfiguration(ImportJob $job, array $configuration): ImportJob;
|
|
|
|
|
2018-01-05 17:29:42 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param array $array
|
|
|
|
*
|
2018-02-28 21:32:59 +01:00
|
|
|
* @return ImportJob
|
2018-01-05 17:29:42 +01:00
|
|
|
*/
|
|
|
|
public function setExtendedStatus(ImportJob $job, array $array): ImportJob;
|
|
|
|
|
2018-01-10 16:49:32 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
2018-06-06 21:23:00 +02:00
|
|
|
* @param string $stage
|
2018-01-10 16:49:32 +01:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-06-06 21:23:00 +02:00
|
|
|
public function setStage(ImportJob $job, string $stage): ImportJob;
|
2018-01-10 16:49:32 +01:00
|
|
|
|
2018-04-30 06:37:29 +02:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
2018-06-06 21:23:00 +02:00
|
|
|
* @param string $status
|
2018-04-30 06:37:29 +02:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
2018-06-06 21:23:00 +02:00
|
|
|
public function setStatus(ImportJob $job, string $status): ImportJob;
|
2018-04-30 06:37:29 +02:00
|
|
|
|
2018-01-08 20:20:45 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
2018-02-28 21:32:59 +01:00
|
|
|
* @param int $steps
|
2018-01-08 20:20:45 +01:00
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function setStepsDone(ImportJob $job, int $steps): ImportJob;
|
|
|
|
|
2018-06-06 21:23:00 +02:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param Tag $tag
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function setTag(ImportJob $job, Tag $tag): ImportJob;
|
|
|
|
|
2018-01-08 20:20:45 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param int $count
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function setTotalSteps(ImportJob $job, int $count): ImportJob;
|
|
|
|
|
2018-06-06 21:23:00 +02:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param array $transactions
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function setTransactions(ImportJob $job, array $transactions): ImportJob;
|
|
|
|
|
2017-01-30 16:46:30 +01:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
public function setUser(User $user);
|
2017-03-19 17:54:21 +01:00
|
|
|
|
2018-06-06 21:23:00 +02:00
|
|
|
/**
|
|
|
|
* Store file.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param string $name
|
|
|
|
* @param string $fileName
|
|
|
|
*
|
|
|
|
* @return MessageBag
|
|
|
|
*/
|
|
|
|
public function storeCLIUpload(ImportJob $job, string $name, string $fileName): MessageBag;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle upload for job.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param string $name
|
|
|
|
* @param UploadedFile $file
|
|
|
|
*
|
|
|
|
* @return MessageBag
|
|
|
|
* @throws FireflyException
|
|
|
|
*/
|
|
|
|
public function storeFileUpload(ImportJob $job, string $name, UploadedFile $file): MessageBag;
|
|
|
|
|
2017-03-19 17:54:21 +01:00
|
|
|
/**
|
|
|
|
* @param ImportJob $job
|
|
|
|
* @param string $status
|
|
|
|
*
|
|
|
|
* @return ImportJob
|
|
|
|
*/
|
|
|
|
public function updateStatus(ImportJob $job, string $status): ImportJob;
|
2018-01-05 17:29:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return import file content.
|
|
|
|
*
|
|
|
|
* @param ImportJob $job
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function uploadFileContents(ImportJob $job): string;
|
2016-08-12 15:10:03 +02:00
|
|
|
}
|