From 328fa444ad2e5245b4da8a7a225a53f5526f7637 Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Mon, 21 May 2018 12:20:01 +0100 Subject: [PATCH 1/7] Commit initial composer.json --- .gitignore | 4 ++++ composer.json | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8c49de --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor/ +/composer.lock +/.idea/ +/.php-version \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..43590d4 --- /dev/null +++ b/composer.json @@ -0,0 +1,38 @@ +{ + "name": "snowio/akeneo-bundle", + "license": "MIT", + "authors": [ + { + "name": "Cristian Quiroz", + "email": "cq@amp.co" + }, { + "name": "Nei Santos", + "email": "ns@amp.co" + } + ], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/akeneo/pim-community-dev.git", + "branch": "master" + } + ], + "require": { + "akeneo/pim-community-dev": "^2.2.*", + "guzzlehttp/guzzle": "^6.1", + "symfony/config": "^2.7.2", + "symfony/dependency-injection": "^2.7.2", + "symfony/http-kernel": "^2.7.2", + "phpspec/phpspec": "^3.2" + }, + "scripts": { + "test": "php vendor/bin/phpspec run --format=dot -c phpspec.yml", + "cs": "phpcs --standard=PSR2 -n ./ --ignore=vendor --report=summary" + }, + "autoload": { + "psr-4": { + "Snowio\\Bundle\\CsvConnectorBundle\\": "" + } + }, + "minimum-stability": "dev" +} \ No newline at end of file From e029e265c9f6c19bc8dd958ae529f3be6a26302a Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Mon, 21 May 2018 12:24:14 +0100 Subject: [PATCH 2/7] Amend composer.json --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 43590d4..4b6d5a3 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "snowio/akeneo-bundle", + "name": "snowio/akeneo2-snow-bundle", "license": "MIT", "authors": [ { @@ -8,6 +8,9 @@ }, { "name": "Nei Santos", "email": "ns@amp.co" + }, { + "name": "Liam Toohey", + "email": "lt@amp.co" } ], "repositories": [ From 5d398fe872d5bed47db8d245df339c9b65619505 Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Mon, 21 May 2018 12:26:27 +0100 Subject: [PATCH 3/7] Ensure all akeneo 2 versions are compatible in composer requirements --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4b6d5a3..0e22cd4 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } ], "require": { - "akeneo/pim-community-dev": "^2.2.*", + "akeneo/pim-community-dev": "2.*.*", "guzzlehttp/guzzle": "^6.1", "symfony/config": "^2.7.2", "symfony/dependency-injection": "^2.7.2", From 16696a267c645c9cbb8fd6516f4990f5caf6db82 Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Mon, 21 May 2018 12:38:14 +0100 Subject: [PATCH 4/7] Require new versions of symfony for Akeneo 2 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0e22cd4..2eae2af 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "require": { "akeneo/pim-community-dev": "2.*.*", "guzzlehttp/guzzle": "^6.1", - "symfony/config": "^2.7.2", - "symfony/dependency-injection": "^2.7.2", - "symfony/http-kernel": "^2.7.2", + "symfony/config": "^3.4.0", + "symfony/dependency-injection": "^3.4.0", + "symfony/http-kernel": "^3.4.0", "phpspec/phpspec": "^3.2" }, "scripts": { From b705c47faa0e7f047f5fb9027a1b95dd8975d274 Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Mon, 21 May 2018 14:43:34 +0100 Subject: [PATCH 5/7] Port over 1.* module files --- .../SnowioCsvConnectorExtension.php | 22 ++ Handler/ArchiveHandler.php | 65 ++++ Handler/MetadataHandler.php | 55 +++ Handler/PostHandler.php | 200 +++++++++++ .../ConstraintTrait.php | 49 +++ .../ProductConstraint.php | 17 + .../SimpleConstraint.php | 17 + .../DefaultValuesTrait.php | 30 ++ .../ProductDefaultValues.php | 17 + .../SimpleDefaultValues.php | 17 + MediaExport/ExportLocation.php | 68 ++++ MediaExport/Logger.php | 51 +++ .../snowio_product_export_edit.yml | 338 ++++++++++++++++++ .../snowio_product_export_show.yml | 311 ++++++++++++++++ .../snowio_simple_export_edit.yml | 237 ++++++++++++ .../snowio_simple_export_show.yml | 216 +++++++++++ Resources/config/form_parameters.yml | 9 + Resources/config/job_constraints.yml | 20 ++ Resources/config/job_defaults.yml | 21 ++ Resources/config/jobs.yml | 46 +++ Resources/config/steps.yml | 128 +++++++ Resources/config/writers.yml | 33 ++ Resources/translations/jsmessages.en.yml | 34 ++ Resources/translations/messages.en.yml | 37 ++ SnowioCsvConnectorBundle.php | 22 ++ Step/ArchiveStep.php | 81 +++++ Step/CheckThresholdsStep.php | 95 +++++ Step/MediaExportStep.php | 152 ++++++++ Step/MetadataStep.php | 70 ++++ Step/PostStep.php | 81 +++++ Writer/File/Csv/ProductModelWriter.php | 10 + Writer/File/Csv/ProductWriter.php | 10 + Writer/File/Csv/SimpleWriter.php | 10 + Writer/File/Csv/WriterOverriderTrait.php | 57 +++ phpspec.yml | 5 + .../ProductConstraintSpec.php | 54 +++ .../ProductDefaultValuesSpec.php | 67 ++++ spec/Step/ArchiveStepSpec.php | 119 ++++++ spec/Step/MetadataStepSpec.php | 89 +++++ spec/Step/PostStepSpec.php | 100 ++++++ 40 files changed, 3060 insertions(+) create mode 100644 DependencyInjection/SnowioCsvConnectorExtension.php create mode 100644 Handler/ArchiveHandler.php create mode 100644 Handler/MetadataHandler.php create mode 100644 Handler/PostHandler.php create mode 100644 Job/JobParameters/ConstraintCollectionProvider/ConstraintTrait.php create mode 100644 Job/JobParameters/ConstraintCollectionProvider/ProductConstraint.php create mode 100644 Job/JobParameters/ConstraintCollectionProvider/SimpleConstraint.php create mode 100644 Job/JobParameters/DefaultValuesProvider/DefaultValuesTrait.php create mode 100644 Job/JobParameters/DefaultValuesProvider/ProductDefaultValues.php create mode 100644 Job/JobParameters/DefaultValuesProvider/SimpleDefaultValues.php create mode 100644 MediaExport/ExportLocation.php create mode 100644 MediaExport/Logger.php create mode 100644 Resources/config/form_extensions/snowio_product_export_edit.yml create mode 100644 Resources/config/form_extensions/snowio_product_export_show.yml create mode 100644 Resources/config/form_extensions/snowio_simple_export_edit.yml create mode 100644 Resources/config/form_extensions/snowio_simple_export_show.yml create mode 100644 Resources/config/form_parameters.yml create mode 100644 Resources/config/job_constraints.yml create mode 100644 Resources/config/job_defaults.yml create mode 100644 Resources/config/jobs.yml create mode 100644 Resources/config/steps.yml create mode 100644 Resources/config/writers.yml create mode 100644 Resources/translations/jsmessages.en.yml create mode 100644 Resources/translations/messages.en.yml create mode 100644 SnowioCsvConnectorBundle.php create mode 100644 Step/ArchiveStep.php create mode 100644 Step/CheckThresholdsStep.php create mode 100644 Step/MediaExportStep.php create mode 100644 Step/MetadataStep.php create mode 100644 Step/PostStep.php create mode 100644 Writer/File/Csv/ProductModelWriter.php create mode 100644 Writer/File/Csv/ProductWriter.php create mode 100644 Writer/File/Csv/SimpleWriter.php create mode 100644 Writer/File/Csv/WriterOverriderTrait.php create mode 100644 phpspec.yml create mode 100644 spec/Job/JobParameters/ConstraintCollectionProvider/ProductConstraintSpec.php create mode 100644 spec/Job/JobParameters/DefaultValuesProvider/ProductDefaultValuesSpec.php create mode 100644 spec/Step/ArchiveStepSpec.php create mode 100644 spec/Step/MetadataStepSpec.php create mode 100644 spec/Step/PostStepSpec.php diff --git a/DependencyInjection/SnowioCsvConnectorExtension.php b/DependencyInjection/SnowioCsvConnectorExtension.php new file mode 100644 index 0000000..02c0877 --- /dev/null +++ b/DependencyInjection/SnowioCsvConnectorExtension.php @@ -0,0 +1,22 @@ +load('steps.yml'); + $loader->load('writers.yml'); + $loader->load('jobs.yml'); + $loader->load('form_parameters.yml'); + $loader->load('job_defaults.yml'); + $loader->load('job_constraints.yml'); + } +} diff --git a/Handler/ArchiveHandler.php b/Handler/ArchiveHandler.php new file mode 100644 index 0000000..b598322 --- /dev/null +++ b/Handler/ArchiveHandler.php @@ -0,0 +1,65 @@ +exportDir, '/') . DIRECTORY_SEPARATOR . self::ZIP_FILE_NAME; + $opened = $zip->open($location, \ZipArchive::CREATE); + if ($opened !== true) { + $this->stepExecution->addFailureException(new \RuntimeException('Failed to open zip, reason code:' . $opened)); + } else { + $success = $zip->addPattern( + '/(?:\w+\.csv|metadata.json)/', + $this->exportDir, + ['add_path' => '/', 'remove_all_path' => true] + ); + if (!$success) { + $this->stepExecution->addFailureException(new \RuntimeException('Failed to add files to zip.')); + } + $zip->close(); + $this->stepExecution->addSummaryInfo('zip_location', $location); + } + } + + public function getConfigurationFields() + { + return [ + 'exportDir' => [ + 'options' => [ + 'label' => 'snowio_connector.form.exportDir.label', + 'help' => 'snowio_connector.form.exportDir.help' + ] + ] + ]; + } + + public function setStepExecution(StepExecution $stepExecution) + { + $this->stepExecution = $stepExecution; + } + + public function getExportDir() + { + return $this->exportDir; + } + + public function setExportDir($exportDir) + { + $this->exportDir = $exportDir; + } +} diff --git a/Handler/MetadataHandler.php b/Handler/MetadataHandler.php new file mode 100644 index 0000000..f1d777f --- /dev/null +++ b/Handler/MetadataHandler.php @@ -0,0 +1,55 @@ +configs['exportDir'], '/') . DIRECTORY_SEPARATOR . 'metadata.json'; + file_put_contents( + $location, + json_encode([ + 'bundleVersion' => SnowioCsvConnectorBundle::VERSION, + 'jobCode' => $this->stepExecution->getJobExecution()->getJobInstance()->getAlias(), + 'date' => gmdate('Y-m-d_H:i:s'), + 'channel' => $this->configs['channel'], + 'delimiter' => $this->configs['delimiter'], + 'enclosure' => $this->configs['enclosure'], + 'withHeader' => $this->configs['withHeader'], + 'decimalSeparator' => $this->configs['decimalSeparator'], + 'dateFormat' => $this->configs['dateFormat'], + ]) + ); + + $this->stepExecution->addSummaryInfo('metadata_location', $location); + } + + public function getConfigurationFields() + { + return []; + } + + public function setConfiguration(array $config) + { + parent::setConfiguration($config); + $this->configs = $config; + + } + + public function setStepExecution(StepExecution $stepExecution) + { + $this->stepExecution = $stepExecution; + } + +} diff --git a/Handler/PostHandler.php b/Handler/PostHandler.php new file mode 100644 index 0000000..fa7b582 --- /dev/null +++ b/Handler/PostHandler.php @@ -0,0 +1,200 @@ + + */ + public function __construct(ClientInterface $client) + { + $this->client = $client; + } + + /** + * @throws \Exception + * @author Cristian Quiroz + */ + public function execute() + { + $url = $this->getUrl() . $this->getApplicationId(); + $this->stepExecution->addSummaryInfo('url', $url); + + $resource = fopen(rtrim($this->exportDir, '/') . DIRECTORY_SEPARATOR . ArchiveHandler::ZIP_FILE_NAME, 'r'); + + if (false === $resource) { + $this->stepExecution->addFailureException(new \RuntimeException('Failed to open file to send to snow.io')); + return; + } + + $response = $this->client->request( + 'POST', + $url, + [ + 'body' => $resource, + 'headers' => [ + 'Content-Type' => 'application/zip', + 'Authorization' => $this->getSecretKey(), + ], + ] + ); + + $this->stepExecution->addSummaryInfo('response_code', $response->getStatusCode()); + $this->stepExecution->addSummaryInfo('response_body', $response->getBody()); + + if ($response->getStatusCode() !== 204) { +// Unexpected response, handle + $this->stepExecution->addFailureException(new \Exception('Failed to POST csv data: ' . $response->getBody())); + } + + } + + /** + * @param \Akeneo\Component\Batch\Model\StepExecution $stepExecution + * @author Cristian Quiroz + */ + public function setStepExecution(StepExecution $stepExecution) + { + $this->stepExecution = $stepExecution; + } + + /** + * @param string $exportDir + * @return $this + * @author Cristian Quiroz + */ + public function setExportDir($exportDir) + { + $this->exportDir = $exportDir; + + return $this; + } + + /** + * @return string + * @author Cristian Quiroz + */ + public function getExportDir() + { + return $this->exportDir; + } + + /** + * @return string + */ + public function getApplicationId() + { + return $this->applicationId; + } + + /** + * @param string $applicationId + * @return $this + */ + public function setApplicationId($applicationId) + { + $this->applicationId = $applicationId; + + return $this; + } + + /** + * @return string + */ + public function getSecretKey() + { + return $this->secretKey; + } + + /** + * @param string $secretKey + * @return $this + */ + public function setSecretKey($secretKey) + { + $this->secretKey = $secretKey; + + return $this; + } + + /** + * @param $url + * @return $this + * @author Cristian Quiroz + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return string + * @author Cristian Quiroz + */ + public function getUrl() + { + return rtrim($this->url, '/') . '/'; + } + + /** + * Here, we define the form fields to use + * @return array + * @author Cristian Quiroz + */ + public function getConfigurationFields() + { + return [ + 'exportDir' => [ + 'options' => [ + 'label' => 'snowio_connector.form.exportDir.label', + 'help' => 'snowio_connector.form.exportDir.help' + ] + ], + 'url' => [ + 'type' => 'text', + 'required' => true, + 'options' => [ + 'label' => 'snowio_connector.form.url.label', + 'help' => 'snowio_connector.form.url.help' + ], + ], + 'applicationId' => [ + 'type' => 'text', + 'required' => true, + 'options' => [ + 'label' => 'snowio_connector.form.applicationId.label', + ], + ], + 'secretKey' => [ + 'type' => 'password', + 'required' => true, + 'options' => [ + 'label' => 'snowio_connector.form.secretKey.label', + ], + ], + ]; + } +} diff --git a/Job/JobParameters/ConstraintCollectionProvider/ConstraintTrait.php b/Job/JobParameters/ConstraintCollectionProvider/ConstraintTrait.php new file mode 100644 index 0000000..ff2d26e --- /dev/null +++ b/Job/JobParameters/ConstraintCollectionProvider/ConstraintTrait.php @@ -0,0 +1,49 @@ + + * @return Collection + */ + public function getConstraintCollection() + { + $constraintFields = parent::getConstraintCollection(); + $simpleFields = $constraintFields->fields; + + unset($simpleFields['filePath']); + + return new Collection(['fields' => array_merge([ + 'endpoint' => [ + new NotBlank(['groups' => ['Default', 'FileConfiguration']]), + new Regex([ + 'pattern' => '/^http(.*)\/$/', + 'message' => 'The endpoint should be an http url ending with slash. (http://localhost/)' + ]) + ], + 'applicationId' => [ + new Uuid(['groups' => ['Default', 'FileConfiguration']]), + new NotBlank(['groups' => ['Default', 'FileConfiguration']]) + ], + 'secretKey' => new NotBlank(['groups' => ['Default', 'FileConfiguration']]), + 'exportDir' => [ + new NotBlank(['groups' => ['Default', 'Execution', 'FileConfiguration']]), + new WritableDirectory(['groups' => ['Execution', 'FileConfiguration']]), + ], + 'rsyncDirectory' => [], + 'rsyncUser' => [], + 'rsyncHost' => [], + 'rsyncOptions' => [], + ], $simpleFields)]); + } +} diff --git a/Job/JobParameters/ConstraintCollectionProvider/ProductConstraint.php b/Job/JobParameters/ConstraintCollectionProvider/ProductConstraint.php new file mode 100644 index 0000000..22639f7 --- /dev/null +++ b/Job/JobParameters/ConstraintCollectionProvider/ProductConstraint.php @@ -0,0 +1,17 @@ +getName(), $this->supportedJobNames); + } +} diff --git a/Job/JobParameters/ConstraintCollectionProvider/SimpleConstraint.php b/Job/JobParameters/ConstraintCollectionProvider/SimpleConstraint.php new file mode 100644 index 0000000..6321f20 --- /dev/null +++ b/Job/JobParameters/ConstraintCollectionProvider/SimpleConstraint.php @@ -0,0 +1,17 @@ +getName(), $this->supportedJobNames); + } +} diff --git a/Job/JobParameters/DefaultValuesProvider/DefaultValuesTrait.php b/Job/JobParameters/DefaultValuesProvider/DefaultValuesTrait.php new file mode 100644 index 0000000..2e0448a --- /dev/null +++ b/Job/JobParameters/DefaultValuesProvider/DefaultValuesTrait.php @@ -0,0 +1,30 @@ + + * @return Collection + */ + public function getDefaultValues() + { + $simpleDefaults = parent::getDefaultValues(); + + unset($simpleDefaults['filePath']); + + return array_merge([ + 'endpoint' => '', + 'applicationId' => '', + 'secretKey' => '', + 'exportDir' => '', + 'rsyncDirectory'=> '', + 'rsyncUser' => '', + 'rsyncHost' => '', + 'rsyncOptions' => [], + ], $simpleDefaults); + } +} diff --git a/Job/JobParameters/DefaultValuesProvider/ProductDefaultValues.php b/Job/JobParameters/DefaultValuesProvider/ProductDefaultValues.php new file mode 100644 index 0000000..761e118 --- /dev/null +++ b/Job/JobParameters/DefaultValuesProvider/ProductDefaultValues.php @@ -0,0 +1,17 @@ +getName(), $this->supportedJobNames); + } +} diff --git a/Job/JobParameters/DefaultValuesProvider/SimpleDefaultValues.php b/Job/JobParameters/DefaultValuesProvider/SimpleDefaultValues.php new file mode 100644 index 0000000..2f134d2 --- /dev/null +++ b/Job/JobParameters/DefaultValuesProvider/SimpleDefaultValues.php @@ -0,0 +1,17 @@ +getName(), $this->supportedJobNames); + } +} diff --git a/MediaExport/ExportLocation.php b/MediaExport/ExportLocation.php new file mode 100644 index 0000000..47ac0cd --- /dev/null +++ b/MediaExport/ExportLocation.php @@ -0,0 +1,68 @@ +directory = $directory; + $this->host = $host; + $this->user = $user; + } + + /** + * @return string + */ + public function toString() + { + if ($this->user && $this->host) { + return sprintf( + '%s@%s:%s', + $this->user, + $this->host, + $this->directory + ); + } + + if (!$this->user && $this->host) { + return sprintf( + '%s:%s', + $this->host, + $this->directory + ); + } + + return $this->directory; + } + + public function setUser($user) + { + if (is_string($user) && !empty($user)) { + $this->user = $user; + } + } + + public function setDirectory($directory) + { + if (is_string($directory) && !empty($directory)) { + $this->directory = $directory; + } + } + + public function setHost($host) + { + if (is_string($host) && !empty($host)) { + $this->host = $host; + } + } +} diff --git a/MediaExport/Logger.php b/MediaExport/Logger.php new file mode 100644 index 0000000..7103011 --- /dev/null +++ b/MediaExport/Logger.php @@ -0,0 +1,51 @@ +logDirectory = $logDirectory; + } + + /** + * @param array $content + * @param $jobId + */ + public function writeLog(array $content, $jobId) + { + $logFile = $this->getLogFileNameForJob($jobId); + + if (!is_dir(dirname($logFile))) { + mkdir(dirname($logFile), 0755, true); + } + + $handle = fopen($logFile, 'a+'); + if ($handle === false) { + throw new FileNotFoundException( + sprintf('Error - log file (%s) could not be opened during media export.', $logFile) + ); + } + + fputcsv($handle, $content, PHP_EOL); + fclose($handle); + } + + /** + * @param $jobId + * @return string + */ + public function getLogFileNameForJob($jobId) + { + return rtrim($this->logDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $jobId . '.log'; + } +} diff --git a/Resources/config/form_extensions/snowio_product_export_edit.yml b/Resources/config/form_extensions/snowio_product_export_edit.yml new file mode 100644 index 0000000..918eeeb --- /dev/null +++ b/Resources/config/form_extensions/snowio_product_export_edit.yml @@ -0,0 +1,338 @@ +extensions: + snowio-csv-product-export-edit: + module: pim/form/common/edit-form + + snowio-csv-product-export-edit-cache-invalidator: + module: pim/cache-invalidator + parent: snowio-csv-product-export-edit + position: 1000 + + snowio-csv-product-export-edit-tabs: + module: pim/form/common/form-tabs + parent: snowio-csv-product-export-edit + targetZone: content + position: 100 + + snowio-csv-product-export-edit-properties: + module: pim/job/common/edit/properties + parent: snowio-csv-product-export-edit-tabs + aclResourceId: pim_importexport_export_profile_property_edit + targetZone: container + position: 100 + config: + tabTitle: pim_enrich.form.job_instance.tab.properties.title + tabCode: pim-job-instance-properties + + snowio-csv-product-export-edit-content: + module: pim/job/product/edit/content + parent: snowio-csv-product-export-edit-tabs + aclResourceId: pim_importexport_export_profile_content_edit + targetZone: container + position: 110 + config: + tabTitle: pim_enrich.form.job_instance.tab.content.title + tabCode: pim-job-instance-content + + snowio-csv-product-export-edit-content-structure: + module: pim/job/product/edit/content/structure + parent: snowio-csv-product-export-edit-content + targetZone: structure-filters + position: 100 + + snowio-csv-product-export-edit-history: + module: pim/common/tab/history + parent: snowio-csv-product-export-edit-tabs + targetZone: container + aclResourceId: pim_importexport_export_profile_history + position: 120 + config: + class: Akeneo\Component\Batch\Model\JobInstance + title: pim_enrich.form.job_instance.tab.history.title + tabCode: pim-job-instance-history + + snowio-csv-product-export-edit-properties-code: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 100 + targetZone: properties + config: + fieldCode: code + label: pim_enrich.form.job_instance.tab.properties.code.title + readOnly: true + + snowio-csv-product-export-edit-properties-label: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 110 + targetZone: properties + config: + fieldCode: label + label: pim_enrich.form.job_instance.tab.properties.label.title + readOnly: false + + snowio-csv-product-export-edit-properties-decimal-separator: + module: pim/job/common/edit/field/decimal-separator + parent: snowio-csv-product-export-edit-properties + position: 120 + targetZone: global-settings + config: + fieldCode: configuration.decimalSeparator + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.decimal_separator.title + tooltip: pim_enrich.form.job_instance.tab.properties.decimal_separator.help + + snowio-csv-product-export-edit-properties-date-format: + module: pim/job/product/edit/field/date-format + parent: snowio-csv-product-export-edit-properties + position: 130 + targetZone: global-settings + config: + fieldCode: configuration.dateFormat + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.date_format.title + tooltip: pim_enrich.form.job_instance.tab.properties.date_format.help + + snowio-csv-product-export-edit-properties-delimiter: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 140 + targetZone: global-settings + config: + fieldCode: configuration.delimiter + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.delimiter.title + tooltip: pim_enrich.form.job_instance.tab.properties.delimiter.help + + snowio-csv-product-export-edit-properties-enclosure: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 150 + targetZone: global-settings + config: + fieldCode: configuration.enclosure + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.enclosure.title + tooltip: pim_enrich.form.job_instance.tab.properties.enclosure.help + + snowio-csv-product-export-edit-properties-with-header: + module: pim/job/common/edit/field/switch + parent: snowio-csv-product-export-edit-properties + position: 160 + targetZone: global-settings + config: + fieldCode: configuration.withHeader + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.with_header.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_header.help + + snowio-csv-product-export-edit-properties-with-media: + module: pim/job/common/edit/field/switch + parent: snowio-csv-product-export-edit-properties + position: 170 + targetZone: global-settings + config: + fieldCode: configuration.with_media + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.with_media.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_media.help + + snowio-csv-product-export-edit-properties-endpoint: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 180 + targetZone: global-settings + config: + fieldCode: configuration.endpoint + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.endpoint.title + tooltip: snowio_connector.form.job_instance.tab.properties.endpoint.help + + snowio-csv-product-export-edit-properties-application-id: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 190 + targetZone: global-settings + config: + fieldCode: configuration.applicationId + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.application_id.title + tooltip: snowio_connector.form.job_instance.tab.properties.application_id.help + + snowio-csv-product-export-edit-properties-secret-key: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.secretKey + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.secret_key.title + tooltip: snowio_connector.form.job_instance.tab.properties.secret_key.help + + snowio-csv-product-export-edit-properties-export-dir: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 210 + targetZone: global-settings + config: + fieldCode: configuration.exportDir + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.export_dir.title + tooltip: snowio_connector.form.job_instance.tab.properties.export_dir.help + + snowio-csv-product-export-edit-properties-rsync-directory: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 220 + targetZone: global-settings + config: + fieldCode: configuration.rsyncDirectory + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_directory.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_directory.help + + snowio-csv-product-export-edit-properties-rsync-user: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 230 + targetZone: global-settings + config: + fieldCode: configuration.rsyncUser + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_user.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_user.help + + snowio-csv-product-export-edit-properties-rsync-host: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 240 + targetZone: global-settings + config: + fieldCode: configuration.rsyncHost + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_host.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_host.help + + snowio-csv-product-export-edit-properties-rsync-options: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-edit-properties + position: 240 + targetZone: global-settings + config: + fieldCode: configuration.rsyncOptions + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_options.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_options.help + + snowio-csv-product-export-edit-label: + module: pim/job/common/edit/label + parent: snowio-csv-product-export-edit + targetZone: title + position: 100 + + snowio-csv-product-export-edit-meta: + module: pim/job/common/edit/meta + parent: snowio-csv-product-export-edit + targetZone: meta + position: 100 + + snowio-csv-product-export-edit-back-to-grid: + module: pim/form/common/back-to-grid + parent: snowio-csv-product-export-edit + targetZone: back + aclResourceId: pim_importexport_export_profile_index + position: 80 + config: + backUrl: pim_importexport_export_profile_index + + snowio-csv-product-export-edit-delete: + module: pim/job/export/edit/delete + parent: snowio-csv-product-export-edit + targetZone: buttons + aclResourceId: pim_importexport_export_profile_remove + position: 100 + config: + trans: + title: confirmation.remove.job_instance + content: pim_enrich.confirmation.delete_item + success: flash.job_instance.removed + failed: error.removing.job_instance + redirect: pim_importexport_export_profile_index + + snowio-csv-product-export-edit-save-buttons: + module: pim/form/common/save-buttons + parent: snowio-csv-product-export-edit + targetZone: buttons + position: 120 + + snowio-csv-product-export-edit-save: + module: pim/job-instance-export-edit-form/save + parent: snowio-csv-product-export-edit + targetZone: buttons + position: 0 + config: + redirectPath: pim_importexport_export_profile_show + + snowio-csv-product-export-edit-state: + module: pim/form/common/state + parent: snowio-csv-product-export-edit + targetZone: state + position: 900 + config: + entity: pim_enrich.entity.job_instance.title + + snowio-csv-product-export-edit-content-structure-scope: + module: pim/job/product/edit/content/structure/scope + parent: snowio-csv-product-export-edit-content-structure + targetZone: filters + position: 90 + + snowio-csv-product-export-edit-content-structure-locales: + module: pim/job/product/edit/content/structure/locales + parent: snowio-csv-product-export-edit-content-structure + targetZone: filters + position: 100 + + snowio-csv-product-export-edit-content-structure-attributes: + module: pim/job/product/edit/content/structure/attributes + parent: snowio-csv-product-export-edit-content-structure + targetZone: filters + position: 110 + + snowio-csv-product-export-edit-content-data: + module: pim/job/product/edit/content/data + parent: snowio-csv-product-export-edit-content + targetZone: data-filters + config: + filters: + - + field: family + view: akeneo-product-family-filter + - + field: enabled + view: akeneo-product-enabled-filter + - + field: completeness + view: akeneo-product-completeness-filter + - + field: updated + view: akeneo-product-updated-filter + - + field: categories + view: akeneo-product-category-filter + + snowio-csv-product-export-edit-content-default-attribute-filters: + module: pim/job/product/edit/content/data/default-attribute-filters + parent: snowio-csv-product-export-edit-content-data + config: + types: [pim_catalog_identifier] + + snowio-csv-product-export-edit-validation: + module: pim/job/common/edit/validation + parent: snowio-csv-product-export-edit + + snowio-csv-product-export-edit-content-data-add-filter: + module: pim/job/product/edit/content/data/add-select/attribute + parent: snowio-csv-product-export-edit-content-data + targetZone: headings + position: 90 \ No newline at end of file diff --git a/Resources/config/form_extensions/snowio_product_export_show.yml b/Resources/config/form_extensions/snowio_product_export_show.yml new file mode 100644 index 0000000..5d20c7c --- /dev/null +++ b/Resources/config/form_extensions/snowio_product_export_show.yml @@ -0,0 +1,311 @@ +extensions: + snowio-csv-product-export-show: + module: pim/form/common/edit-form + + snowio-csv-product-export-show-tabs: + module: pim/form/common/form-tabs + parent: snowio-csv-product-export-show + targetZone: content + position: 100 + + snowio-csv-product-export-show-properties: + module: pim/job/common/edit/properties + parent: snowio-csv-product-export-show-tabs + aclResourceId: pim_importexport_export_profile_property_show + targetZone: container + position: 100 + config: + tabTitle: pim_enrich.form.job_instance.tab.properties.title + tabCode: pim-properties + + snowio-csv-product-export-show-content: + module: pim/job/product/edit/content + parent: snowio-csv-product-export-show-tabs + aclResourceId: pim_importexport_export_profile_content_show + targetZone: container + position: 110 + config: + tabTitle: pim_enrich.form.job_instance.tab.content.title + tabCode: pim-job-instance-content + + snowio-csv-product-export-show-history: + module: pim/common/tab/history + parent: snowio-csv-product-export-show-tabs + targetZone: container + aclResourceId: pim_importexport_export_profile_history + position: 120 + config: + class: Akeneo\Component\Batch\Model\JobInstance + title: pim_enrich.form.job_instance.tab.history.title + tabCode: pim-history + + snowio-csv-product-export-show-properties-code: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 100 + targetZone: properties + config: + fieldCode: code + label: pim_enrich.form.job_instance.tab.properties.code.title + readOnly: true + + snowio-csv-product-export-show-properties-label: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 110 + targetZone: properties + config: + fieldCode: label + label: pim_enrich.form.job_instance.tab.properties.label.title + readOnly: true + + snowio-csv-product-export-show-properties-decimal-separator: + module: pim/job/common/edit/field/decimal-separator + parent: snowio-csv-product-export-show-properties + position: 130 + targetZone: global-settings + config: + fieldCode: configuration.decimalSeparator + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.decimal_separator.title + tooltip: pim_enrich.form.job_instance.tab.properties.decimal_separator.help + + snowio-csv-product-export-show-properties-date-format: + module: pim/job/product/edit/field/date-format + parent: snowio-csv-product-export-show-properties + position: 140 + targetZone: global-settings + config: + fieldCode: configuration.dateFormat + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.date_format.title + tooltip: pim_enrich.form.job_instance.tab.properties.date_format.help + + snowio-csv-product-export-show-properties-delimiter: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 150 + targetZone: global-settings + config: + fieldCode: configuration.delimiter + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.delimiter.title + tooltip: pim_enrich.form.job_instance.tab.properties.delimiter.help + + snowio-csv-product-export-show-properties-enclosure: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 160 + targetZone: global-settings + config: + fieldCode: configuration.enclosure + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.enclosure.title + tooltip: pim_enrich.form.job_instance.tab.properties.enclosure.help + + snowio-csv-product-export-show-properties-with-header: + module: pim/job/common/edit/field/switch + parent: snowio-csv-product-export-show-properties + position: 170 + targetZone: global-settings + config: + fieldCode: configuration.withHeader + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.with_header.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_header.help + + snowio-csv-product-export-show-properties-with-media: + module: pim/job/common/edit/field/switch + parent: snowio-csv-product-export-show-properties + position: 180 + targetZone: global-settings + config: + fieldCode: configuration.with_media + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.with_media.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_media.help + + snowio-csv-product-export-show-properties-endpoint: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 190 + targetZone: global-settings + config: + fieldCode: configuration.endpoint + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.endpoint.title + tooltip: snowio_connector.form.job_instance.tab.properties.endpoint.help + + snowio-csv-product-export-show-properties-secret-key: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.secretKey + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.secret_key.title + tooltip: snowio_connector.form.job_instance.tab.properties.secret_key.help + + snowio-csv-product-export-show-properties-application-id: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 210 + targetZone: global-settings + config: + fieldCode: configuration.applicationId + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.application_id.title + tooltip: snowio_connector.form.job_instance.tab.properties.application_id.help + + snowio-csv-product-export-show-properties-export-dir: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 220 + targetZone: global-settings + config: + fieldCode: configuration.exportDir + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.export_dir.title + tooltip: snowio_connector.form.job_instance.tab.properties.export_dir.help + + snowio-csv-product-export-show-properties-rsync-directory: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 230 + targetZone: global-settings + config: + fieldCode: configuration.rsyncDirectory + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_directory.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_directory.help + + snowio-csv-product-export-show-properties-rsync-user: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 240 + targetZone: global-settings + config: + fieldCode: configuration.rsyncUser + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_user.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_user.help + + snowio-csv-product-export-show-properties-rsync-host: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 250 + targetZone: global-settings + config: + fieldCode: configuration.rsyncHost + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_host.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_host.help + + snowio-csv-product-export-show-properties-rsync-options: + module: pim/job/common/edit/field/text + parent: snowio-csv-product-export-show-properties + position: 240 + targetZone: global-settings + config: + fieldCode: configuration.rsyncOptions + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_options.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_options.help + + snowio-csv-product-export-show-content-structure: + module: pim/job/product/edit/content/structure + parent: snowio-csv-product-export-show-content + targetZone: structure-filters + position: 100 + + snowio-csv-product-export-show-label: + module: pim/job/common/edit/label + parent: snowio-csv-product-export-show + targetZone: title + position: 100 + + snowio-csv-product-export-show-meta: + module: pim/job/common/edit/meta + parent: snowio-csv-product-export-show + targetZone: meta + position: 100 + + snowio-csv-product-export-show-back-to-grid: + module: pim/form/common/back-to-grid + parent: snowio-csv-product-export-show + targetZone: back + aclResourceId: pim_importexport_export_profile_index + position: 80 + config: + backUrl: pim_importexport_export_profile_index + + snowio-csv-product-export-show-content-structure-scope: + module: pim/job/product/edit/content/structure/scope + parent: snowio-csv-product-export-show-content-structure + targetZone: filters + position: 90 + config: + readOnly: true + + snowio-csv-product-export-show-content-structure-locales: + module: pim/job/product/edit/content/structure/locales + parent: snowio-csv-product-export-show-content-structure + targetZone: filters + position: 100 + config: + readOnly: true + + snowio-csv-product-export-show-content-structure-attributes: + module: pim/job/product/edit/content/structure/attributes + parent: snowio-csv-product-export-show-content-structure + targetZone: filters + position: 110 + config: + readOnly: true + + snowio-csv-product-export-show-content-data: + module: pim/job/product/edit/content/data + parent: snowio-csv-product-export-show-content + targetZone: data-filters + config: + filters: + - + field: family + view: akeneo-product-family-filter + - + field: enabled + view: akeneo-product-enabled-filter + - + field: completeness + view: akeneo-product-completeness-filter + - + field: updated + view: akeneo-product-updated-filter + - + field: categories + view: akeneo-product-category-filter + + snowio-csv-product-export-show-edit: + module: pim/common/redirect + parent: snowio-csv-product-export-show + targetZone: buttons + position: 100 + config: + label: pim_enrich.form.job_instance.button.edit.title + route: pim_importexport_export_profile_edit + identifier: + path: code + name: code + + snowio-csv-product-export-show-launch: + module: pim/job/common/edit/launch + parent: snowio-csv-product-export-show + targetZone: buttons + position: 110 + config: + label: pim_enrich.form.job_instance.button.export.title + route: pim_enrich_job_instance_rest_export_launch + identifier: + path: code + name: code diff --git a/Resources/config/form_extensions/snowio_simple_export_edit.yml b/Resources/config/form_extensions/snowio_simple_export_edit.yml new file mode 100644 index 0000000..f1edbd6 --- /dev/null +++ b/Resources/config/form_extensions/snowio_simple_export_edit.yml @@ -0,0 +1,237 @@ +extensions: + snowio-csv-export-edit: + module: pim/form/common/edit-form + + snowio-csv-export-edit-cache-invalidator: + module: pim/cache-invalidator + parent: snowio-csv-export-edit + position: 1000 + + snowio-csv-export-edit-tabs: + module: pim/form/common/form-tabs + parent: snowio-csv-export-edit + targetZone: content + position: 100 + + snowio-csv-export-edit-properties: + module: pim/job/common/edit/properties + parent: snowio-csv-export-edit-tabs + aclResourceId: pim_importexport_export_profile_property_edit + targetZone: container + position: 100 + config: + tabTitle: pim_enrich.form.job_instance.tab.properties.title + tabCode: pim-job-instance-properties + + snowio-csv-export-edit-history: + module: pim/common/tab/history + parent: snowio-csv-export-edit-tabs + targetZone: container + aclResourceId: pim_importexport_export_profile_history + position: 120 + config: + class: Akeneo\Component\Batch\Model\JobInstance + title: pim_enrich.form.job_instance.tab.history.title + tabCode: pim-job-instance-history + + snowio-csv-export-edit-properties-code: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 100 + targetZone: properties + config: + fieldCode: code + label: pim_enrich.form.job_instance.tab.properties.code.title + readOnly: true + + snowio-csv-export-edit-properties-label: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 110 + targetZone: properties + config: + fieldCode: label + label: pim_enrich.form.job_instance.tab.properties.label.title + readOnly: false + + snowio-csv-export-edit-properties-delimiter: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 120 + targetZone: global-settings + config: + fieldCode: configuration.delimiter + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.delimiter.title + tooltip: pim_enrich.form.job_instance.tab.properties.delimiter.help + + snowio-csv-export-edit-properties-enclosure: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 130 + targetZone: global-settings + config: + fieldCode: configuration.enclosure + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.enclosure.title + tooltip: pim_enrich.form.job_instance.tab.properties.enclosure.help + + snowio-csv-export-edit-properties-with-header: + module: pim/job/common/edit/field/switch + parent: snowio-csv-export-edit-properties + position: 140 + targetZone: global-settings + config: + fieldCode: configuration.withHeader + readOnly: false + label: pim_enrich.form.job_instance.tab.properties.with_header.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_header.help + + snowio-csv-export-edit-properties-endpoint: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 150 + targetZone: global-settings + config: + fieldCode: configuration.endpoint + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.endpoint.title + tooltip: snowio_connector.form.job_instance.tab.properties.endpoint.help + + snowio-csv-export-edit-properties-application-id: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 160 + targetZone: global-settings + config: + fieldCode: configuration.applicationId + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.application_id.title + tooltip: snowio_connector.form.job_instance.tab.properties.application_id.help + + snowio-csv-export-edit-properties-secret-key: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 170 + targetZone: global-settings + config: + fieldCode: configuration.secretKey + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.secret_key.title + tooltip: snowio_connector.form.job_instance.tab.properties.secret_key.help + + snowio-csv-export-edit-properties-export-dir: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 180 + targetZone: global-settings + config: + fieldCode: configuration.exportDir + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.export_dir.title + tooltip: snowio_connector.form.job_instance.tab.properties.export_dir.help + + snowio-csv-export-edit-properties-rsync-directory: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 190 + targetZone: global-settings + config: + fieldCode: configuration.rsyncDirectory + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_directory.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_directory.help + + snowio-csv-export-edit-properties-rsync-user: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.rsyncUser + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_user.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_user.help + + snowio-csv-export-edit-properties-rsync-host: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 210 + targetZone: global-settings + config: + fieldCode: configuration.rsyncHost + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_host.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_host.help + + snowio-csv-export-edit-properties-rsync-options: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-edit-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.rsyncOptions + readOnly: false + label: snowio_connector.form.job_instance.tab.properties.rsync_options.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_options.help + + snowio-csv-export-edit-label: + module: pim/job/common/edit/label + parent: snowio-csv-export-edit + targetZone: title + position: 100 + + snowio-csv-export-edit-meta: + module: pim/job/common/edit/meta + parent: snowio-csv-export-edit + targetZone: meta + position: 100 + + snowio-csv-export-edit-back-to-grid: + module: pim/form/common/back-to-grid + parent: snowio-csv-export-edit + targetZone: back + aclResourceId: pim_importexport_export_profile_index + position: 80 + config: + backUrl: pim_importexport_export_profile_index + + snowio-csv-export-edit-delete: + module: pim/job/export/edit/delete + parent: snowio-csv-export-edit + targetZone: buttons + aclResourceId: pim_importexport_export_profile_remove + position: 100 + config: + trans: + title: confirmation.remove.job_instance + content: pim_enrich.confirmation.delete_item + success: flash.job_instance.removed + failed: error.removing.job_instance + redirect: pim_importexport_export_profile_index + + snowio-csv-export-edit-save-buttons: + module: pim/form/common/save-buttons + parent: snowio-csv-export-edit + targetZone: buttons + position: 120 + + snowio-csv-export-edit-save: + module: pim/job-instance-export-edit-form/save + parent: snowio-csv-export-edit + targetZone: buttons + position: 0 + config: + redirectPath: pim_importexport_export_profile_show + + snowio-csv-export-edit-state: + module: pim/form/common/state + parent: snowio-csv-export-edit + targetZone: state + position: 900 + config: + entity: pim_enrich.entity.job_instance.title + + snowio-csv-export-edit-validation: + module: pim/job/common/edit/validation + parent: snowio-csv-export-edit diff --git a/Resources/config/form_extensions/snowio_simple_export_show.yml b/Resources/config/form_extensions/snowio_simple_export_show.yml new file mode 100644 index 0000000..c6b9868 --- /dev/null +++ b/Resources/config/form_extensions/snowio_simple_export_show.yml @@ -0,0 +1,216 @@ +extensions: + snowio-csv-export-show: + module: pim/form/common/edit-form + + snowio-csv-export-show-tabs: + module: pim/form/common/form-tabs + parent: snowio-csv-export-show + targetZone: content + position: 100 + + snowio-csv-export-show-properties: + module: pim/job/common/edit/properties + parent: snowio-csv-export-show-tabs + aclResourceId: pim_importexport_export_profile_property_edit + targetZone: container + position: 100 + config: + tabTitle: pim_enrich.form.job_instance.tab.properties.title + tabCode: pim-job-instance-properties + + snowio-csv-export-show-history: + module: pim/common/tab/history + parent: snowio-csv-export-show-tabs + targetZone: container + aclResourceId: pim_importexport_export_profile_history + position: 120 + config: + class: Akeneo\Component\Batch\Model\JobInstance + title: pim_enrich.form.job_instance.tab.history.title + tabCode: pim-job-instance-history + + snowio-csv-export-show-properties-code: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 100 + targetZone: properties + config: + fieldCode: code + label: pim_enrich.form.job_instance.tab.properties.code.title + readOnly: true + + snowio-csv-export-show-properties-label: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 110 + targetZone: properties + config: + fieldCode: label + label: pim_enrich.form.job_instance.tab.properties.label.title + readOnly: true + + snowio-csv-export-show-properties-delimiter: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 120 + targetZone: global-settings + config: + fieldCode: configuration.delimiter + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.delimiter.title + tooltip: pim_enrich.form.job_instance.tab.properties.delimiter.help + + snowio-csv-export-show-properties-enclosure: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 130 + targetZone: global-settings + config: + fieldCode: configuration.enclosure + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.enclosure.title + tooltip: pim_enrich.form.job_instance.tab.properties.enclosure.help + + snowio-csv-export-show-properties-with-header: + module: pim/job/common/edit/field/switch + parent: snowio-csv-export-show-properties + position: 140 + targetZone: global-settings + config: + fieldCode: configuration.withHeader + readOnly: true + label: pim_enrich.form.job_instance.tab.properties.with_header.title + tooltip: pim_enrich.form.job_instance.tab.properties.with_header.help + + snowio-csv-export-show-properties-endpoint: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 150 + targetZone: global-settings + config: + fieldCode: configuration.endpoint + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.endpoint.title + tooltip: snowio_connector.form.job_instance.tab.properties.endpoint.help + + snowio-csv-export-show-properties-application-id: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 160 + targetZone: global-settings + config: + fieldCode: configuration.applicationId + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.application_id.title + tooltip: snowio_connector.form.job_instance.tab.properties.application_id.help + + snowio-csv-export-show-properties-secret-key: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 170 + targetZone: global-settings + config: + fieldCode: configuration.secretKey + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.secret_key.title + tooltip: snowio_connector.form.job_instance.tab.properties.secret_key.help + + snowio-csv-export-show-properties-export-dir: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 180 + targetZone: global-settings + config: + fieldCode: configuration.exportDir + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.export_dir.title + tooltip: snowio_connector.form.job_instance.tab.properties.export_dir.help + + snowio-csv-export-show-properties-rsync-directory: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 190 + targetZone: global-settings + config: + fieldCode: configuration.rsyncDirectory + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_directory.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_directory.help + + snowio-csv-export-show-properties-rsync-user: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.rsyncUser + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_user.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_user.help + + snowio-csv-export-show-properties-rsync-host: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 210 + targetZone: global-settings + config: + fieldCode: configuration.rsyncHost + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_host.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_host.help + + snowio-csv-export-show-properties-rsync-options: + module: pim/job/common/edit/field/text + parent: snowio-csv-export-show-properties + position: 200 + targetZone: global-settings + config: + fieldCode: configuration.rsyncOptions + readOnly: true + label: snowio_connector.form.job_instance.tab.properties.rsync_options.title + tooltip: snowio_connector.form.job_instance.tab.properties.rsync_options.help + + snowio-csv-export-show-label: + module: pim/job/common/edit/label + parent: snowio-csv-export-show + targetZone: title + position: 100 + + snowio-csv-export-show-meta: + module: pim/job/common/edit/meta + parent: snowio-csv-export-show + targetZone: meta + position: 100 + + snowio-csv-export-show-back-to-grid: + module: pim/form/common/back-to-grid + parent: snowio-csv-export-show + targetZone: back + aclResourceId: pim_importexport_export_profile_index + position: 80 + config: + backUrl: pim_importexport_export_profile_index + + snowio-csv-export-show-edit: + module: pim/common/redirect + parent: snowio-csv-export-show + targetZone: buttons + position: 100 + config: + label: pim_enrich.form.job_instance.button.edit.title + route: pim_importexport_export_profile_edit + identifier: + path: code + name: code + + snowio-csv-export-show-launch: + module: pim/job/common/edit/launch + parent: snowio-csv-export-show + targetZone: buttons + position: 110 + config: + label: pim_enrich.form.job_instance.button.export.title + route: pim_enrich_job_instance_rest_export_launch + identifier: + path: code + name: code diff --git a/Resources/config/form_parameters.yml b/Resources/config/form_parameters.yml new file mode 100644 index 0000000..c3c1af0 --- /dev/null +++ b/Resources/config/form_parameters.yml @@ -0,0 +1,9 @@ +services: + snowio_connector.provider.form.job_instance: + class: '%pim_enrich.provider.form.job_instance.class%' + arguments: + - + full_export: snowio-csv-product-export + partial_export: snowio-csv-export + tags: + - { name: pim_enrich.provider.form, priority: 100 } diff --git a/Resources/config/job_constraints.yml b/Resources/config/job_constraints.yml new file mode 100644 index 0000000..52d1327 --- /dev/null +++ b/Resources/config/job_constraints.yml @@ -0,0 +1,20 @@ +parameters: + snowio_connector.job.job_parameters.constraint_collection_provider.product.class: Snowio\Bundle\CsvConnectorBundle\Job\JobParameters\ConstraintCollectionProvider\ProductConstraint + snowio_connector.job.job_parameters.constraint_collection_provider.simple.class: Snowio\Bundle\CsvConnectorBundle\Job\JobParameters\ConstraintCollectionProvider\SimpleConstraint + +services: + # Validation constraints for our JobParameters + snowio_connector.job.job_parameters.constraint_collection_provider.full_export: + class: '%snowio_connector.job.job_parameters.constraint_collection_provider.product.class%' + arguments: + - '@pim_connector.job.job_parameters.constraint_collection_provider.simple_csv_export' + - ['full_export'] + tags: + - { name: akeneo_batch.job.job_parameters.constraint_collection_provider } + + snowio_connector.job.job_parameters.constraint_collection_provider.partial_export: + class: '%snowio_connector.job.job_parameters.constraint_collection_provider.simple.class%' + arguments: + - ['partial_export'] + tags: + - { name: akeneo_batch.job.job_parameters.constraint_collection_provider } diff --git a/Resources/config/job_defaults.yml b/Resources/config/job_defaults.yml new file mode 100644 index 0000000..73b86b0 --- /dev/null +++ b/Resources/config/job_defaults.yml @@ -0,0 +1,21 @@ +parameters: + snowio_connector.job.job_parameters.default_values_provider.product.class: Snowio\Bundle\CsvConnectorBundle\Job\JobParameters\DefaultValuesProvider\ProductDefaultValues + snowio_connector.job.job_parameters.default_values_provider.simple.class: Snowio\Bundle\CsvConnectorBundle\Job\JobParameters\DefaultValuesProvider\SimpleDefaultValues + +services: + snowio_connector.job.job_parameters.default_values_provider.full_export: + class: '%snowio_connector.job.job_parameters.default_values_provider.product.class%' + arguments: + - '@pim_connector.job.job_parameters.default_values_provider.simple_csv_export' + - '@pim_catalog.repository.channel' + - '@pim_catalog.repository.locale' + - ['full_export'] + tags: + - { name: akeneo_batch.job.job_parameters.default_values_provider } + + snowio_connector.job.job_parameters.default_values_provider.partial_export: + class: '%snowio_connector.job.job_parameters.default_values_provider.simple.class%' + arguments: + - ['partial_export'] + tags: + - { name: akeneo_batch.job.job_parameters.default_values_provider } diff --git a/Resources/config/jobs.yml b/Resources/config/jobs.yml new file mode 100644 index 0000000..238641a --- /dev/null +++ b/Resources/config/jobs.yml @@ -0,0 +1,46 @@ +parameters: + snowio_connector.connector_name.csv: 'Snowio Connector' + snowio_connector.job_name.full_export: 'full_export' + snowio_connector.job_name.partial_export: 'partial_export' + +services: + snowio_connector.job.full_export: + class: '%pim_connector.job.simple_job.class%' + arguments: + - '%snowio_connector.job_name.full_export%' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - + - '@snowio_connector.step.csv_product.export' + - '@snowio_connector.step.check_threshold.products' + - '@snowio_connector.step.csv_product_model.export' + - '@snowio_connector.step.csv_category.export' + - '@snowio_connector.step.csv_attribute.export' + - '@snowio_connector.step.check_threshold.attributes' + - '@snowio_connector.step.csv_attribute_option.export' + - '@snowio_connector.step.csv_family.export' + - '@snowio_connector.step.csv_attribute_group.export' + - '@snowio_connector.step.metadata' + - '@snowio_connector.step.media_export' + - '@snowio_connector.step.archive' + - '@snowio_connector.step.post' + tags: + - { name: akeneo_batch.job, connector: '%snowio_connector.connector_name.csv%', type: '%pim_connector.job.export_type%' } + + snowio_connector.job.partial_export: + class: '%pim_connector.job.simple_job.class%' + arguments: + - '%snowio_connector.job_name.partial_export%' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - + - '@snowio_connector.step.csv_category.export' + - '@snowio_connector.step.csv_attribute.export' + - '@snowio_connector.step.csv_attribute_option.export' + - '@snowio_connector.step.csv_family.export' + - '@snowio_connector.step.csv_attribute_group.export' + - '@snowio_connector.step.metadata' + - '@snowio_connector.step.archive' + - '@snowio_connector.step.post' + tags: + - { name: akeneo_batch.job, connector: '%snowio_connector.connector_name.csv%', type: '%pim_connector.job.export_type%' } diff --git a/Resources/config/steps.yml b/Resources/config/steps.yml new file mode 100644 index 0000000..1881185 --- /dev/null +++ b/Resources/config/steps.yml @@ -0,0 +1,128 @@ +parameters: + snowio_connector.step.post.class: Snowio\Bundle\CsvConnectorBundle\Step\PostStep + snowio_connector.step.archive.class: Snowio\Bundle\CsvConnectorBundle\Step\ArchiveStep + snowio_connector.step.metadata.class: Snowio\Bundle\CsvConnectorBundle\Step\MetadataStep + guzzlehttp.client.class: GuzzleHttp\Client + snowio_connector.step.archive.zip.class: ZipArchive + snowio_connector.step.media_export.class: Snowio\Bundle\CsvConnectorBundle\Step\MediaExportStep + snowio_connector.step.check_thresholds.class: Snowio\Bundle\CsvConnectorBundle\Step\CheckThresholdsStep + snowio_connector.media_export.export_location.class: Snowio\Bundle\CsvConnectorBundle\MediaExport\ExportLocation + snowio_connector.media_export.logger.class: Snowio\Bundle\CsvConnectorBundle\MediaExport\Logger + +services: + guzzlehttp.client: + class: '%guzzlehttp.client.class%' + + snowio_connector.step.archive.zip: + class: '%snowio_connector.step.archive.zip.class%' + + snowio_connector.step.archive: + class: '%snowio_connector.step.archive.class%' + arguments: + - 'archive' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - '@snowio_connector.step.archive.zip' + - '@snowio_connector.media_export.logger' + + snowio_connector.media_export.export_location: + class: '%snowio_connector.media_export.export_location.class%' + arguments: + - '%media_export_directory%' + - '%media_export_host%' + - '%media_export_user%' + + snowio_connector.media_export.logger: + class: '%snowio_connector.media_export.logger.class%' + arguments: + - '%kernel.root_dir%/logs/media_export' + + snowio_connector.step.media_export: + class: '%snowio_connector.step.media_export.class%' + arguments: + - 'media_export' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - '@snowio_connector.media_export.export_location' + - '@snowio_connector.media_export.logger' + + snowio_connector.step.post: + class: '%snowio_connector.step.post.class%' + arguments: + - 'post' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - '@guzzlehttp.client' + + snowio_connector.step.metadata: + class: '%snowio_connector.step.metadata.class%' + arguments: + - 'metadata' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + + snowio_connector.step.check_threshold.products: + class: '%snowio_connector.step.check_thresholds.class%' + arguments: + - 'check_thresholds' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - '%minimum_products_export%' + + snowio_connector.step.check_threshold.attributes: + class: '%snowio_connector.step.check_thresholds.class%' + arguments: + - 'check_thresholds' + - '@event_dispatcher' + - '@akeneo_batch.job_repository' + - '%minimum_attributes_export%' + + # Overwrite service definition to set step name (arg 0) and writer + snowio_connector.step.csv_product.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_product.export' + arguments: + index_0: 'product' + index_5: '@snowio_connector.writer.file.csv_product' + + snowio_connector.step.csv_product_model.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_product_model.export' + arguments: + index_0: 'variant_group' + index_5: '@snowio_connector.writer.file.csv_product_model' + + snowio_connector.step.csv_category.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_category.export' + arguments: + index_0: 'category' + index_5: '@snowio_connector.writer.file.csv_category' + + snowio_connector.step.csv_attribute.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_attribute.export' + arguments: + index_0: 'attribute' + index_5: '@snowio_connector.writer.file.csv_attribute' + + snowio_connector.step.csv_attribute_option.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_attribute_option.export' + arguments: + index_0: 'attribute_option' + index_5: '@snowio_connector.writer.file.csv_attribute_option' + + snowio_connector.step.csv_family.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_family.export' + arguments: + index_0: 'family' + index_5: '@snowio_connector.writer.file.csv_family' + + snowio_connector.step.csv_attribute_group.export: + class: '%pim_connector.step.item_step.class%' + parent: 'pim_connector.step.csv_attribute_group_export.export' + arguments: + index_0: 'attribute_group' + index_5: '@snowio_connector.writer.file.csv_attribute_group' diff --git a/Resources/config/writers.yml b/Resources/config/writers.yml new file mode 100644 index 0000000..508237f --- /dev/null +++ b/Resources/config/writers.yml @@ -0,0 +1,33 @@ +parameters: + snowio_connector.writer.file.csv_product.class: Snowio\Bundle\CsvConnectorBundle\Writer\File\Csv\ProductWriter + snowio_connector.writer.file.csv_product_model.class: Snowio\Bundle\CsvConnectorBundle\Writer\File\Csv\ProductModelWriter + snowio_connector.writer.file.csv_simple.class: Snowio\Bundle\CsvConnectorBundle\Writer\File\Csv\SimpleWriter + +services: + snowio_connector.writer.file.csv_product: + class: %snowio_connector.writer.file.csv_product.class% + parent: pim_connector.writer.file.csv_product + + snowio_connector.writer.file.csv_product_model: + class: %snowio_connector.writer.file.csv_product_model.class% + parent: pim_connector.writer.file.csv_product_model + + snowio_connector.writer.file.csv_category: + class: %snowio_connector.writer.file.csv_simple.class% + parent: pim_connector.writer.file.csv_category + + snowio_connector.writer.file.csv_attribute: + class: %snowio_connector.writer.file.csv_simple.class% + parent: pim_connector.writer.file.csv_attribute + + snowio_connector.writer.file.csv_attribute_option: + class: %snowio_connector.writer.file.csv_simple.class% + parent: pim_connector.writer.file.csv_attribute_option + + snowio_connector.writer.file.csv_family: + class: %snowio_connector.writer.file.csv_simple.class% + parent: pim_connector.writer.file.csv_family + + snowio_connector.writer.file.csv_attribute_group: + class: %snowio_connector.writer.file.csv_simple.class% + parent: pim_connector.writer.file.csv_attribute_group diff --git a/Resources/translations/jsmessages.en.yml b/Resources/translations/jsmessages.en.yml new file mode 100644 index 0000000..fcf2557 --- /dev/null +++ b/Resources/translations/jsmessages.en.yml @@ -0,0 +1,34 @@ +job_execution: + summary: + zip_location: Zip File Location + url: Send Zip to Endpoint + metadata_location: Metadata file + response_code: Response Code + response_body: Response Body + +snowio_connector.form.job_instance.tab.properties: + endpoint: + title: Endpoint Url + help: The URL where to make the request after file generation. + application_id: + title: Application Id + help: The Application ID provided by Snow.io + secret_key: + title: Secret Key + help: The Secret Key provided by Snow.io + export_dir: + title: Export Directory + help: The directory to store CSV and ZIP files. + rsync_directory: + title: Rsync Directory + help: The directory to rsync images to + rsync_user: + title: Rsync User + help: The user for the media rsync step. + rsync_host: + title: Rsync Host + help: The host for the media rsync step. + rsync_options: + title: Rsync Options + help: Any other rsync options required + diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml new file mode 100644 index 0000000..aa546a3 --- /dev/null +++ b/Resources/translations/messages.en.yml @@ -0,0 +1,37 @@ +batch_jobs: + partial_export: + label: "Partial Export (categories, attributes, attribute options, families and attribute groups)" + category.label: "Category Export Step" + attribute.label: "Attribute Export Step" + attribute_option.label: "Attribute Option Export Step" + family.label: "Family Export Step" + attribute_group.label: "Attribute Group Export Step" + archive.label: "Archive Step" + metadata.label: "Metadata Step" + post.label: "Post Step" + media_export.label: "Media Export Step" + full_export: + label: "Full Export (products, variant groups, categories, attributes, attribute options, families and attribute groups)" + product.label: "Product Export Step" + variant_group.label: "Variant Group Export Step" + category.label: "Category Export Step" + attribute.label: "Attribute Export Step" + attribute_option.label: "Attribute Option Export Step" + family.label: "Family Export Step" + attribute_group.label: "Attribute Group Export Step" + archive.label: "Archive Step" + metadata.label: "Metadata Step" + post.label: "Post Step" + media_export.label: "Media Export Step" + check_thresholds.label: "Check Thresholds Step" + +job_execution: + summary: + endpoint: Endpoint + response_code: Response code + response_body: Body + zip_location: Zip file + metadata_location: Metadata file + export_location: Export location + log_file: Log file + minimum_threshold: Minimum threshold diff --git a/SnowioCsvConnectorBundle.php b/SnowioCsvConnectorBundle.php new file mode 100644 index 0000000..bb9a510 --- /dev/null +++ b/SnowioCsvConnectorBundle.php @@ -0,0 +1,22 @@ + + * + * This Bundle is used to create new csv export jobs that: + * 1) Generate CSV files, using Akeneo's Csv Connector functionality + * 2) Posts product data to a Snow.io using Guzzle + */ +class SnowioCsvConnectorBundle extends Bundle +{ + /** Increment the version number if exported data has BC break changes. */ + const VERSION = 2; +} diff --git a/Step/ArchiveStep.php b/Step/ArchiveStep.php new file mode 100644 index 0000000..98e95ab --- /dev/null +++ b/Step/ArchiveStep.php @@ -0,0 +1,81 @@ +name = $name; + $this->jobRepository = $jobRepository; + $this->eventDispatcher = $eventDispatcher; + $this->zip = $zip; + $this->mediaExportLogger = $mediaExportLogger; + } + + /** + * Archive will Zip the csv files on the specified directory + * and the metada.json file. + * + * @param StepExecution $stepExecution + */ + protected function doExecute(StepExecution $stepExecution) + { + $jobParameters = $stepExecution->getJobParameters(); + + $location = rtrim($jobParameters->get('exportDir'), '/') . DIRECTORY_SEPARATOR . self::ZIP_FILE_NAME; + + $opened = $this->zip->open($location, ZipArchive::CREATE); + + if ($opened !== true) { + $stepExecution->addFailureException(new \RuntimeException('Failed to open zip, reason code:' . $opened)); + } else { + $this->zip->addFile( + $this->mediaExportLogger->getLogFileNameForJob($stepExecution->getJobExecution()->getId()), + '/media_export.log' + ); + + $success = $this->zip->addPattern( + '/(?:\w+\.csv|metadata.json)/', + $jobParameters->get('exportDir'), + ['add_path' => '/', 'remove_all_path' => true] + ); + + if (!$success) { + $stepExecution->addFailureException(new \RuntimeException('Failed to add files to zip.')); + return; + } + + $this->zip->close(); + + $stepExecution->addSummaryInfo('zip_location', $location); + } + } +} diff --git a/Step/CheckThresholdsStep.php b/Step/CheckThresholdsStep.php new file mode 100644 index 0000000..c896e09 --- /dev/null +++ b/Step/CheckThresholdsStep.php @@ -0,0 +1,95 @@ +minimumExportThreshold = (int)$minimumExportThreshold; + } + + /** + * Extension point for subclasses to execute business logic. Subclasses should set the {@link ExitStatus} on the + * {@link StepExecution} before returning. + * + * Do not catch exception here. It will be correctly handled by the execute() method. + * + * @param StepExecution $stepExecution the current step context + * + * @throws \Exception + */ + protected function doExecute(StepExecution $stepExecution) + { + $previousStepExecution = $this->getPreviousStepExecution($stepExecution); + + $stepExecution->addSummaryInfo( + 'minimum_threshold', + sprintf('%s (%s)', $this->minimumExportThreshold, $previousStepExecution->getStepName()) + ); + + if ($this->minimumExportThreshold > 0 && !$this->doesExportCountMeetThreshold($previousStepExecution)) { + throw new \Exception( + sprintf( + 'Error - attempted to export less than the minimum threshold (step: %s/threshold: %s).', + $previousStepExecution->getStepName(), + $this->minimumExportThreshold + ) + ); + } + } + + /** + * @param StepExecution $stepExecution + * @return bool + * @author James Pollard + */ + private function doesExportCountMeetThreshold(StepExecution $stepExecution) + { + return $stepExecution->getSummaryInfo('read') >= $this->minimumExportThreshold; + } + + /** + * @param StepExecution $stepExecution + * @return StepExecution + * @throws \Exception + * @author James Pollard + */ + private function getPreviousStepExecution(StepExecution $stepExecution) + { + $stepExecutions = $stepExecution->getJobExecution()->getStepExecutions()->toArray(); + // set array pointer to last element i.e. the current execution + end($stepExecutions); + $previousStepExecution = prev($stepExecutions); + + if (!($previousStepExecution instanceof StepExecution)) { + throw new \Exception('Error during threshold check step - previous execution step was not found.'); + } + + return $previousStepExecution; + } +} diff --git a/Step/MediaExportStep.php b/Step/MediaExportStep.php new file mode 100644 index 0000000..0b9124a --- /dev/null +++ b/Step/MediaExportStep.php @@ -0,0 +1,152 @@ +exportLocation = $exportLocation; + $this->logger = $logger; + } + + /** + * Extension point for subclasses to execute business logic. Subclasses should set the {@link ExitStatus} on the + * {@link StepExecution} before returning. + * + * Do not catch exception here. It will be correctly handled by the execute() method. + * + * @param StepExecution $stepExecution the current step context + * + * @throws \Exception + */ + protected function doExecute(StepExecution $stepExecution) + { + try { + $currentExportDir = rtrim($stepExecution->getJobParameters()->get('exportDir'), '/'); + + $this->exportLocation->setUser($stepExecution->getJobParameters()->get('rsyncUser')); + $this->exportLocation->setHost($stepExecution->getJobParameters()->get('rsyncHost')); + $this->exportLocation->setDirectory($stepExecution->getJobParameters()->get('rsyncDirectory')); + + $newExportDir = rtrim($this->exportLocation->toString(), '/'); + + $stepExecution->addSummaryInfo('export_location', $newExportDir); + + $stepExecution->addSummaryInfo( + 'log_file', + $this->logger->getLogFileNameForJob($stepExecution->getJobExecution()->getId()) + ); + + $output = $this->syncMedia($currentExportDir, $newExportDir, $stepExecution->getJobParameters()->get('rsyncOptions')); + + $this->writeLog( + $this->getModifiedOutputForLog($output, $stepExecution), + $stepExecution->getJobExecution() + ); + + } catch (FileTransferException $e) { + $this->writeLog( + ['Error - something went wrong during rsync.', $e->getMessage()], + $stepExecution->getJobExecution() + ); + + //Do not rethrow the exception we want execution to proceed + } catch(\Exception $e) { + $this->writeLog( + ['Error - something went wrong during media export.', $e->getMessage()], + $stepExecution->getJobExecution() + ); + throw $e; + } + } + + /** + * @param $currentExportDir + * @param $newExportDir + * @param $options + * @return array + * @throws FileTransferException + * @author James Pollard + */ + protected function syncMedia($currentExportDir, $newExportDir, $options = '') + { + /** + * append files to the current export dir so that we do not unnecessarily + * copy over the export csv files + */ + exec("rsync -aK $options $currentExportDir/files/ $newExportDir/", $output, $status); + + if ($status !== 0) { + throw new FileTransferException('Error - rsync failure during media export.' . implode(" : ", $output)); + } + + return $output; + } + + /** + * @param array $content + * @author James Pollard + */ + protected function writeLog(array $content, JobExecution $job) + { + $this->logger->writeLog($content, $job->getId()); + } + + /** + * @param array $output + * @param StepExecution $stepExecution + * @return array + * @author James Pollard + */ + protected function getModifiedOutputForLog(array $output, StepExecution $stepExecution) + { + $jobParameters = $stepExecution->getJobParameters(); + $jobExecution = $stepExecution->getJobExecution(); + + array_unshift( + $output, + '------------------------------', + sprintf('Export Profile: %s (%s)', $jobExecution->getLabel(), $jobParameters->get('applicationId')), + sprintf('Execution ID: %s', $jobExecution->getId()), + date('d/m/Y H:i:s') + ); + + return $output; + } +} diff --git a/Step/MetadataStep.php b/Step/MetadataStep.php new file mode 100644 index 0000000..69ea8ca --- /dev/null +++ b/Step/MetadataStep.php @@ -0,0 +1,70 @@ +getJobParameters(); + + $location = rtrim($jobParameters->get('exportDir'), '/') . DIRECTORY_SEPARATOR . 'metadata.json'; + + $content = $this->generateContent($stepExecution, $jobParameters); + + if (false === file_put_contents($location, $content)) { + $stepExecution->addFailureException( + new \RuntimeException('Cannot create metadata file.') + ); + } + + $stepExecution->addSummaryInfo('metadata_location', $location); + } + + /** + * Create json file with metadata + * + * @param StepExecution $stepExecution + * @param JobParameters $jobParameters + * + * @return String Json + */ + protected function generateContent($stepExecution, $jobParameters) + { + $content = [ + 'bundleVersion' => SnowioCsvConnectorBundle::VERSION, + 'jobCode' => $stepExecution->getJobExecution()->getJobInstance()->getJobName(), + 'date' => gmdate('Y-m-d H:i:s'), + 'delimiter' => $jobParameters->get('delimiter'), + 'enclosure' => $jobParameters->get('enclosure'), + 'withHeader' => $jobParameters->get('withHeader') + ]; + + if ($jobParameters->has('filters')) { + $content['filters'] = $jobParameters->get('filters'); + } + + if ($jobParameters->has('decimalSeparator')) { + $content['decimalSeparator'] = $jobParameters->get('decimalSeparator'); + } + + if ($jobParameters->has('dateFormat')) { + $content['dateFormat'] = $jobParameters->get('dateFormat'); + } + + if ($jobParameters->has('with_media')) { + $content['with_media'] = $jobParameters->get('with_media'); + } + + return json_encode($content); + } +} diff --git a/Step/PostStep.php b/Step/PostStep.php new file mode 100644 index 0000000..95e3074 --- /dev/null +++ b/Step/PostStep.php @@ -0,0 +1,81 @@ +name = $name; + $this->jobRepository = $jobRepository; + $this->eventDispatcher = $eventDispatcher; + $this->guzzle = $guzzle; + } + + /** + * Post Step will send the zip file generated on preview step + * to Snow.io + * + * @author Nei Rauni + * @param StepExecution $stepExecution + */ + protected function doExecute(StepExecution $stepExecution) + { + $jobParameters = $stepExecution->getJobParameters(); + $endpoint = $jobParameters->get('endpoint') . $jobParameters->get('applicationId'); + + $stepExecution->addSummaryInfo('endpoint', $endpoint); + + $zipFile = rtrim($jobParameters->get('exportDir'), '/') . DIRECTORY_SEPARATOR . ArchiveStep::ZIP_FILE_NAME; + + if (!file_exists($zipFile)) { + $stepExecution->addFailureException( + new \RuntimeException('Failed to open file '.$zipFile.' to send to snow.io') + ); + } + + if (($resource = fopen($zipFile, 'r')) === false) { + $stepExecution->addFailureException( + new \RuntimeException('Failed to open file '.$zipFile.' to send to snow.io') + ); + } + + $response = $this->guzzle->request( + 'POST', + $endpoint, + [ + 'body' => $resource, + 'headers' => [ + 'Content-Type' => 'application/zip', + 'Authorization' => $jobParameters->get('secretKey'), + ], + ] + ); + + if ($response->getStatusCode() !== 204) { + $stepExecution->addFailureException(new \Exception('Failed to POST CSV file: ' . $response->getBody())); + } + + $stepExecution->addSummaryInfo('response_code', $response->getStatusCode()); + $stepExecution->addSummaryInfo('response_body', $response->getBody()->getContents()); + } +} diff --git a/Writer/File/Csv/ProductModelWriter.php b/Writer/File/Csv/ProductModelWriter.php new file mode 100644 index 0000000..d52b0d8 --- /dev/null +++ b/Writer/File/Csv/ProductModelWriter.php @@ -0,0 +1,10 @@ + + * @return string + */ + public function getPath(array $placeholders = []) + { + $parameters = $this->stepExecution->getJobParameters(); + + $filePath = implode( + '', + [ + rtrim($parameters->get('exportDir'), '/'), + DIRECTORY_SEPARATOR, + $this->sanitize($this->stepExecution->getStepName()), + ".csv" + ] + ); + + return $filePath; + } + + /** + * Export medias from the working directory to the output expected directory. + * + * Basically, we first remove the content of /path/where/my/user/expects/the/export/files/. + * (This path can exist of an export was launched previously) + * + * Then we copy /path/of/the/working/directory/files/ to /path/where/my/user/expects/the/export/files/. + */ + protected function exportMedias() + { + $outputDirectory = dirname($this->getPath()); + $workingDirectory = $this->stepExecution->getJobExecution()->getExecutionContext() + ->get(JobInterface::WORKING_DIRECTORY_PARAMETER); + + $outputFilesDirectory = $outputDirectory . DIRECTORY_SEPARATOR . 'files'; + $workingFilesDirectory = $workingDirectory . 'files'; + + /* + if ($this->localFs->exists($outputFilesDirectory)) { + $this->localFs->remove($outputFilesDirectory); + }*/ + + if ($this->localFs->exists($workingFilesDirectory)) { + $this->localFs->mirror($workingFilesDirectory, $outputFilesDirectory); + } + } +} diff --git a/phpspec.yml b/phpspec.yml new file mode 100644 index 0000000..2b0b223 --- /dev/null +++ b/phpspec.yml @@ -0,0 +1,5 @@ +suites: + SnowioCsvConnectorBundle: + namespace: Snowio\Bundle\CsvConnectorBundle + psr4_prefix: Snowio\Bundle\CsvConnectorBundle + src_path: . diff --git a/spec/Job/JobParameters/ConstraintCollectionProvider/ProductConstraintSpec.php b/spec/Job/JobParameters/ConstraintCollectionProvider/ProductConstraintSpec.php new file mode 100644 index 0000000..1ae3ddf --- /dev/null +++ b/spec/Job/JobParameters/ConstraintCollectionProvider/ProductConstraintSpec.php @@ -0,0 +1,54 @@ +beConstructedWith( + $provider, + ['test11','test22'] + ); + } + + // @codingStandardsIgnoreLine + public function it_is_a_default_values() + { + $this->shouldImplement('Akeneo\Component\Batch\Job\JobParameters\ConstraintCollectionProviderInterface'); + } + + // @codingStandardsIgnoreLine + public function it_supports_a_job(JobInterface $job) + { + $job->getName()->willReturn('test11'); + $this->supports($job)->shouldReturn(true); + } + + // @codingStandardsIgnoreLine + public function it_provides_constraints_collection( + $provider, + Collection $decoratedCollection + ) { + $provider->getConstraintCollection()->willReturn($decoratedCollection); + $collection = $this->getConstraintCollection(); + $collection->shouldReturnAnInstanceOf('Symfony\Component\Validator\Constraints\Collection'); + $fields = $collection->fields; + + $fields->shouldHaveCount(8); + $fields->shouldHaveKey('decimalSeparator'); + $fields->shouldHaveKey('dateFormat'); + $fields->shouldHaveKey('with_media'); + $fields->shouldHaveKey('endpoint'); + $fields->shouldHaveKey('applicationId'); + $fields->shouldHaveKey('secretKey'); + $fields->shouldHaveKey('exportDir'); + } +} diff --git a/spec/Job/JobParameters/DefaultValuesProvider/ProductDefaultValuesSpec.php b/spec/Job/JobParameters/DefaultValuesProvider/ProductDefaultValuesSpec.php new file mode 100644 index 0000000..99808dd --- /dev/null +++ b/spec/Job/JobParameters/DefaultValuesProvider/ProductDefaultValuesSpec.php @@ -0,0 +1,67 @@ +beConstructedWith($decoratedProvider, $channelRepository, $localeRepository, ['my_supported_job_name']); + } + + // @codingStandardsIgnoreLine + function it_is_a_default_values() + { + $this->shouldImplement('Akeneo\Component\Batch\Job\JobParameters\DefaultValuesProviderInterface'); + } + + // @codingStandardsIgnoreLine + function it_supports_a_job(JobInterface $job) + { + $job->getName()->willReturn('my_supported_job_name'); + $this->supports($job)->shouldReturn(true); + } + + // @codingStandardsIgnoreLine + function it_provides_default_values( + $decoratedProvider, + ChannelRepositoryInterface $channelRepository, + LocaleRepositoryInterface $localeRepository, + LocaleInterface $locale, + ChannelInterface $channel + ) { + $channel->getCode()->willReturn('channel_code'); + $channelRepository->getFullChannels()->willReturn([$channel]); + + $locale->getCode()->willReturn('locale_code'); + $localeRepository->getActivatedLocaleCodes()->willReturn([$locale]); + + $decoratedProvider->getDefaultValues()->willReturn(['decoratedParam' => true]); + $this->getDefaultValues()->shouldReturnWellFormedDefaultValues(); + } + + public function getMatchers() + { + return [ + 'returnWellFormedDefaultValues' => function ($parameters) { + return true === $parameters['decoratedParam'] && + '.' === $parameters['decimalSeparator'] && + '' === $parameters['endpoint'] && + '' === $parameters['secretKey'] && + '' === $parameters['applicationId'] && + '' === $parameters['exportDir']; + } + ]; + } +} diff --git a/spec/Step/ArchiveStepSpec.php b/spec/Step/ArchiveStepSpec.php new file mode 100644 index 0000000..950ecc6 --- /dev/null +++ b/spec/Step/ArchiveStepSpec.php @@ -0,0 +1,119 @@ +directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR; + + $this->beConstructedWith(['job_test_name'], $dispatcher, $respository, $zip); + } + + // @codingStandardsIgnoreLine + public function it_executes_with_success( + StepExecution $execution, + $dispatcher, + $respository, + JobParameters $jobParameters, + BatchStatus $status, + ExitStatus $exitStatus, + $zip + ) { + $jobParameters->get('exportDir')->willReturn($this->directory); + $execution->getJobParameters()->willReturn($jobParameters); + $execution->getJobExecution()->willReturn($execution); + + # before + $execution->getStatus()->willReturn($status); + $status->getValue()->willReturn(BatchStatus::STARTING); + $dispatcher->dispatch(EventInterface::BEFORE_STEP_EXECUTION, Argument::any())->shouldBeCalled(); + $execution->setStartTime(Argument::any())->shouldBeCalled(); + $execution->setStatus(Argument::any())->shouldBeCalled(); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + + $zip->open(Argument::any(), Argument::any())->willReturn(true); + $zip->addPattern(Argument::any(), Argument::any(), Argument::any())->willReturn(array( + '/tmp/metadata.json', + '/tmp/anotherfile.csv' + )); + $zip->close()->shouldBeCalled(); + + $execution->addSummaryInfo('zip_location', $this->directory.'export.zip')->shouldBeCalled(); + + # after + $execution->getExitStatus()->willReturn($exitStatus); + $exitStatus->getExitCode()->willReturn(ExitStatus::COMPLETED); + $execution->isTerminateOnly()->willReturn(false); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_SUCCEEDED, Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_COMPLETED, Argument::any())->shouldBeCalled(); + $execution->setEndTime(Argument::any())->shouldBeCalled(); + $execution->setExitStatus(Argument::any())->shouldBeCalled(); + + $this->execute($execution); + } + + // @codingStandardsIgnoreLine + public function it_throws_add_failure_exception_when_there_is_none_mathed_files( + StepExecution $execution, + $dispatcher, + $respository, + JobParameters $jobParameters, + BatchStatus $status, + ExitStatus $exitStatus, + $zip + ) { + + $jobParameters->get('exportDir')->willReturn($this->directory); + $execution->getJobParameters()->willReturn($jobParameters); + $execution->getJobExecution()->willReturn($execution); + + # before + $execution->getStatus()->willReturn($status); + $status->getValue()->willReturn(BatchStatus::STARTING); + $dispatcher->dispatch(EventInterface::BEFORE_STEP_EXECUTION, Argument::any())->shouldBeCalled(); + $execution->setStartTime(Argument::any())->shouldBeCalled(); + $execution->setStatus(Argument::any())->shouldBeCalled(); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + + $zip->open(Argument::any(), Argument::any())->willReturn(true); + + // return empty array + $zip->addPattern(Argument::any(), Argument::any(), Argument::any())->willReturn(array()); + + $execution->addFailureException(Argument::any())->shouldBeCalled(); + + # after + $execution->getExitStatus()->willReturn($exitStatus); + $exitStatus->getExitCode()->willReturn(ExitStatus::COMPLETED); + $execution->isTerminateOnly()->willReturn(false); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_SUCCEEDED, Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_COMPLETED, Argument::any())->shouldBeCalled(); + $execution->setEndTime(Argument::any())->shouldBeCalled(); + $execution->setExitStatus(Argument::any())->shouldBeCalled(); + + $this->execute($execution); + } +} diff --git a/spec/Step/MetadataStepSpec.php b/spec/Step/MetadataStepSpec.php new file mode 100644 index 0000000..c2546be --- /dev/null +++ b/spec/Step/MetadataStepSpec.php @@ -0,0 +1,89 @@ +directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR; + $this->filesystem = new Filesystem(); + $this->filesystem->mkdir($this->directory); + + $this->beConstructedWith(['job_test_name'], $dispatcher, $respository); + } + + // @codingStandardsIgnoreLine + function it_executes_with_success( + StepExecution $execution, + $dispatcher, + JobParameters $jobParameters, + BatchStatus $status, + ExitStatus $exitStatus, + JobInstance $jobInstance, + JobExecution $jobExecution + ) { + $jobParameters->get('exportDir')->willReturn($this->directory); + $jobParameters->get('delimiter')->willReturn('abc'); + $jobParameters->get('filters')->willReturn('abc'); + $jobParameters->has('filters')->willReturn(true); + $jobParameters->get('enclosure')->willReturn('abc'); + $jobParameters->get('withHeader')->willReturn('abc'); + $jobParameters->get('decimalSeparator')->willReturn('abc'); + $jobParameters->has('decimalSeparator')->willReturn(true); + $jobParameters->get('dateFormat')->willReturn('abc'); + $jobParameters->has('dateFormat')->willReturn(true); + $jobParameters->get('with_media')->willReturn('abc'); + $jobParameters->has('with_media')->willReturn(true); + + $execution->getJobParameters()->willReturn($jobParameters); + + $jobInstance->getJobName()->willReturn('Jobtest'); + $jobExecution->getJobInstance()->willReturn($jobInstance); + $execution->getJobExecution()->willReturn($jobExecution); + + # before + $execution->getStatus()->willReturn($status); + $status->getValue()->willReturn(BatchStatus::STARTING); + $dispatcher->dispatch(EventInterface::BEFORE_STEP_EXECUTION, Argument::any())->shouldBeCalled(); + $execution->setStartTime(Argument::any())->shouldBeCalled(); + $execution->setStatus(Argument::any())->shouldBeCalled(); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + + # my step logic assertions + $execution->addSummaryInfo('metadata_location', $this->directory.'metadata.json')->shouldBeCalled(); + + # after + $execution->getExitStatus()->willReturn($exitStatus); + $exitStatus->getExitCode()->willReturn(ExitStatus::COMPLETED); + $execution->isTerminateOnly()->willReturn(false); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_SUCCEEDED, Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_COMPLETED, Argument::any())->shouldBeCalled(); + $execution->setEndTime(Argument::any())->shouldBeCalled(); + $execution->setExitStatus(Argument::any())->shouldBeCalled(); + + $this->execute($execution); + } +} diff --git a/spec/Step/PostStepSpec.php b/spec/Step/PostStepSpec.php new file mode 100644 index 0000000..9b506de --- /dev/null +++ b/spec/Step/PostStepSpec.php @@ -0,0 +1,100 @@ +directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR; + $this->filesystem = new Filesystem(); + + $this->beConstructedWith(['job_test_name'], $dispatcher, $respository, $guzzle); + } + + public function letGo() + { + $this->filesystem->remove($this->directory); + } + + // @codingStandardsIgnoreLine + function it_executes_with_success( + StepExecution $execution, + $dispatcher, + $respository, + JobParameters $jobParameters, + BatchStatus $status, + ExitStatus $exitStatus, + Client $guzzle, + Response $response, + StreamInterface $body + ) { + $jobParameters->get('endpoint')->willReturn('myendpointfortest'); + $jobParameters->get('exportDir')->willReturn($this->directory); + $jobParameters->get('secretKey')->willReturn('abc'); + $jobParameters->get('applicationId')->willReturn('999'); + + $file = $this->directory.'export.zip'; + $resource = fopen($file, 'w+'); + + $execution->getJobParameters()->willReturn($jobParameters); + $execution->getJobExecution()->willReturn($execution); + + # before + $execution->getStatus()->willReturn($status); + $status->getValue()->willReturn(BatchStatus::STARTING); + $dispatcher->dispatch(EventInterface::BEFORE_STEP_EXECUTION, Argument::any())->shouldBeCalled(); + $execution->setStartTime(Argument::any())->shouldBeCalled(); + $execution->setStatus(Argument::any())->shouldBeCalled(); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + + # my step logic assertions + $execution->addSummaryInfo('endpoint', 'myendpointfortest999')->shouldBeCalled(); + $execution->addSummaryInfo('response_code', '204')->shouldBeCalled(); + $execution->addSummaryInfo('response_body', 'data received')->shouldBeCalled(); + + $response->getStatusCode()->willReturn(204); + + $body->getContents()->willReturn('data received'); + $response->getBody()->willReturn($body); + $guzzle->request('POST', 'myendpointfortest999', Argument::any())->willReturn($response); + + # after + $execution->getExitStatus()->willReturn($exitStatus); + $exitStatus->getExitCode()->willReturn(ExitStatus::COMPLETED); + $execution->isTerminateOnly()->willReturn(false); + $execution->upgradeStatus(Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_SUCCEEDED, Argument::any())->shouldBeCalled(); + $dispatcher->dispatch(EventInterface::STEP_EXECUTION_COMPLETED, Argument::any())->shouldBeCalled(); + $execution->setEndTime(Argument::any())->shouldBeCalled(); + $execution->setExitStatus(Argument::any())->shouldBeCalled(); + + $this->execute($execution); + + //remove file after test + unlink($file); + } +} From 718a999960bafca414f9c5e9a9224074ea88ba80 Mon Sep 17 00:00:00 2001 From: Liam Toohey Date: Tue, 22 May 2018 14:52:55 +0100 Subject: [PATCH 6/7] Amend bundle to ensure product_model uses no filters and fix FE --- .../SnowioCsvConnectorExtension.php | 1 + README.md | 1 - Reader/Database/ProductModelReader.php | 13 +++++++ .../snowio_product_export_edit.yml | 37 +++++++------------ .../snowio_product_export_show.yml | 37 +++++++------------ .../snowio_simple_export_edit.yml | 31 ++++++---------- .../snowio_simple_export_show.yml | 33 ++++++----------- Resources/config/readers.yml | 7 ++++ Resources/config/steps.yml | 3 +- Resources/translations/messages.en.yml | 4 +- Writer/File/Csv/ProductModelWriter.php | 4 +- phpspec.yml | 5 --- 12 files changed, 78 insertions(+), 98 deletions(-) delete mode 100644 README.md create mode 100644 Reader/Database/ProductModelReader.php create mode 100644 Resources/config/readers.yml delete mode 100644 phpspec.yml diff --git a/DependencyInjection/SnowioCsvConnectorExtension.php b/DependencyInjection/SnowioCsvConnectorExtension.php index 02c0877..61d098d 100644 --- a/DependencyInjection/SnowioCsvConnectorExtension.php +++ b/DependencyInjection/SnowioCsvConnectorExtension.php @@ -13,6 +13,7 @@ public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('steps.yml'); + $loader->load('readers.yml'); $loader->load('writers.yml'); $loader->load('jobs.yml'); $loader->load('form_parameters.yml'); diff --git a/README.md b/README.md deleted file mode 100644 index e0d7032..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# akeneo2-snow-bundle diff --git a/Reader/Database/ProductModelReader.php b/Reader/Database/ProductModelReader.php new file mode 100644 index 0000000..19e0953 --- /dev/null +++ b/Reader/Database/ProductModelReader.php @@ -0,0 +1,13 @@ + Date: Wed, 23 May 2018 09:50:09 +0100 Subject: [PATCH 7/7] Amend FE for partial export --- Resources/config/form_extensions/snowio_simple_export_show.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/form_extensions/snowio_simple_export_show.yml b/Resources/config/form_extensions/snowio_simple_export_show.yml index 6c32cd2..fcfb43f 100644 --- a/Resources/config/form_extensions/snowio_simple_export_show.yml +++ b/Resources/config/form_extensions/snowio_simple_export_show.yml @@ -185,7 +185,7 @@ extensions: snowio-csv-export-show-edit: module: pim/common/redirect parent: snowio-csv-export-show - targetZone: buttonssnowio-csv-product-export-show-properties-decimal-separator + targetZone: buttons position: 100 config: label: pim_enrich.form.job_instance.button.edit.title