|
|
@ -36,7 +36,6 @@ use App\Services\Shared\Import\Status\SubmissionStatusManager; |
|
|
|
use App\Services\Spectre\Conversion\RoutineManager as SpectreRoutineManager; |
|
|
|
use Illuminate\Contracts\Filesystem\FileNotFoundException; |
|
|
|
use JsonException; |
|
|
|
use Log; |
|
|
|
use Storage; |
|
|
|
|
|
|
|
/** |
|
|
@ -204,7 +203,7 @@ trait AutoImports |
|
|
|
$this->conversionWarnings = []; |
|
|
|
$this->conversionErrors = []; |
|
|
|
|
|
|
|
Log::debug(sprintf('Now in %s', __METHOD__)); |
|
|
|
app('log')->debug(sprintf('Now in %s', __METHOD__)); |
|
|
|
|
|
|
|
switch ($configuration->getFlow()) { |
|
|
|
default: |
|
|
@ -235,14 +234,14 @@ trait AutoImports |
|
|
|
try { |
|
|
|
$transactions = $manager->start(); |
|
|
|
} catch (ImporterErrorException $e) { |
|
|
|
Log::error($e->getMessage()); |
|
|
|
app('log')->error($e->getMessage()); |
|
|
|
RoutineStatusManager::setConversionStatus(ConversionStatus::CONVERSION_ERRORED, $this->identifier); |
|
|
|
$this->conversionMessages = $manager->getAllMessages(); |
|
|
|
$this->conversionWarnings = $manager->getAllWarnings(); |
|
|
|
$this->conversionErrors = $manager->getAllErrors(); |
|
|
|
} |
|
|
|
if (0 === count($transactions)) { |
|
|
|
Log::error('Zero transactions!'); |
|
|
|
app('log')->error('Zero transactions!'); |
|
|
|
RoutineStatusManager::setConversionStatus(ConversionStatus::CONVERSION_ERRORED, $this->identifier); |
|
|
|
$this->conversionMessages = $manager->getAllMessages(); |
|
|
|
$this->conversionWarnings = $manager->getAllWarnings(); |
|
|
@ -254,7 +253,7 @@ trait AutoImports |
|
|
|
try { |
|
|
|
$disk->put(sprintf('%s.json', $this->identifier), json_encode($transactions, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); |
|
|
|
} catch (JsonException $e) { |
|
|
|
Log::error(sprintf('JSON exception: %s', $e->getMessage())); |
|
|
|
app('log')->error(sprintf('JSON exception: %s', $e->getMessage())); |
|
|
|
RoutineStatusManager::setConversionStatus(ConversionStatus::CONVERSION_ERRORED, $this->identifier); |
|
|
|
$this->conversionMessages = $manager->getAllMessages(); |
|
|
|
$this->conversionWarnings = $manager->getAllWarnings(); |
|
|
@ -302,7 +301,7 @@ trait AutoImports |
|
|
|
*/ |
|
|
|
private function startImport(Configuration $configuration): void |
|
|
|
{ |
|
|
|
Log::debug(sprintf('Now at %s', __METHOD__)); |
|
|
|
app('log')->debug(sprintf('Now at %s', __METHOD__)); |
|
|
|
$routine = new RoutineManager($this->identifier); |
|
|
|
SubmissionStatusManager::startOrFindSubmission($this->identifier); |
|
|
|
$disk = Storage::disk('jobs'); |
|
|
@ -324,7 +323,7 @@ trait AutoImports |
|
|
|
try { |
|
|
|
$json = $disk->get($fileName); |
|
|
|
$transactions = json_decode($json, true, 512, JSON_THROW_ON_ERROR); |
|
|
|
Log::debug(sprintf('Found %d transactions on the drive.', count($transactions))); |
|
|
|
app('log')->debug(sprintf('Found %d transactions on the drive.', count($transactions))); |
|
|
|
} catch (FileNotFoundException | JsonException $e) { |
|
|
|
SubmissionStatusManager::setSubmissionStatus(SubmissionStatus::SUBMISSION_ERRORED, $this->identifier); |
|
|
|
$message = sprintf('File "%s" could not be decoded, cannot continue..', $fileName); |
|
|
@ -345,7 +344,7 @@ trait AutoImports |
|
|
|
try { |
|
|
|
$routine->start(); |
|
|
|
} catch (ImporterErrorException $e) { |
|
|
|
Log::error($e->getMessage()); |
|
|
|
app('log')->error($e->getMessage()); |
|
|
|
SubmissionStatusManager::setSubmissionStatus(SubmissionStatus::SUBMISSION_ERRORED, $this->identifier); |
|
|
|
SubmissionStatusManager::addError($this->identifier, 0, $e->getMessage()); |
|
|
|
$this->importMessages = $routine->getAllMessages(); |
|
|
|