Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Selector for JSON Payload #437

Open
wants to merge 6 commits into
base: 1.x
Choose a base branch
from

Conversation

cancan101
Copy link
Contributor

@cancan101 cancan101 commented Nov 22, 2024

@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen the name "path" and "expression" used. do we have a preference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or name it what it is .. the jmesPath?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "JMESPath"? That is what is shown here: https://jmespath.org/tutorial.html

xtype: 'textfield',
fieldLabel: t('plugin_pimcore_datahub_data_importer_configpanel_json_path'),
name: this.dataNamePrefix + 'path',
value: this.data.path || '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I need anything else here, such as:

allowBlank: true,
msgTarget: 'under'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think so, should be fine.

@@ -32,13 +35,17 @@ class JsonFileInterpreter extends AbstractInterpreter

protected function loadData(string $path): array
{
if ($this->cachedFilePath === $path && !empty($this->cachedContent)) {
if ($this->cachedFilePath !== $path || empty($this->cachedContent)) {
Copy link
Contributor Author

@cancan101 cancan101 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe this logic was wrong before. See fix for Xml: #438

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering for what we need that caching at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept the logic as is (or how it was supposed to be). if the caching does not make sense, can that be removed in a subsequent PR?

Copy link

@@ -52,7 +63,7 @@ protected function doInterpretFileAndCallProcessRow(string $path): void

public function setSettings(array $settings): void
{
//nothing to do
$this->path = $settings['path'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to do any validation here that the path passed in is a valid JmesPath?

@@ -32,13 +35,17 @@ class JsonFileInterpreter extends AbstractInterpreter

protected function loadData(string $path): array
{
if ($this->cachedFilePath === $path && !empty($this->cachedContent)) {
if ($this->cachedFilePath !== $path || empty($this->cachedContent)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering for what we need that caching at all?

@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for path?

xtype: 'textfield',
fieldLabel: t('plugin_pimcore_datahub_data_importer_configpanel_json_path'),
name: this.dataNamePrefix + 'path',
value: this.data.path || '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think so, should be fine.

@@ -45,6 +45,7 @@ plugin_pimcore_datahub_data_importer_configpanel_csv_escape: Escape
plugin_pimcore_datahub_data_importer_configpanel_xlsx_sheet: Sheet
plugin_pimcore_datahub_data_importer_configpanel_xml_xpath: XPath
plugin_pimcore_datahub_data_importer_configpanel_xml_schema: Schema
plugin_pimcore_datahub_data_importer_configpanel_json_path: Path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or name it what it is .. the jmesPath?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants