This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 3a7e07ce56 issue #3232 : Set Variables - add support for parents
(#7377)
3a7e07ce56 is described below
commit 3a7e07ce56c55623f8b9c8b65496bc053c30b565
Author: Matt Casters <[email protected]>
AuthorDate: Wed Jul 1 15:35:55 2026 +0200
issue #3232 : Set Variables - add support for parents (#7377)
* issue #3232 : Set Variables - add support for parents
* issue #3232 : Set Variables - add support for parents (doc update)
---
.../pages/pipeline/transforms/setvariable.adoc | 11 +-
.../ROOT/pages/workflow/actions/setvariables.adoc | 9 +-
.../actions/0018-set-variables-nested-workflow.hwf | 83 +++++++++
.../actions/0018-set-variables-pipeline.hpl | 107 ++++++++++++
.../actions/0018-set-variables-verify.hpl | 191 +++++++++++++++++++++
.../main-0018-set-variables.hwf} | 23 ++-
.../0064-set-variables-child-pipeline.hpl | 111 ++++++++++++
...s.hwf => 0064-set-variables-child-workflow.hwf} | 46 +----
.../0064-set-variables-parent-pipeline.hpl | 107 ++++++++++++
.../0064-set-variables-verify-nested.hpl | 191 +++++++++++++++++++++
.../transforms/main-0064-set-variables.hwf | 70 ++++++++
.../actions/setvariables/ActionSetVariables.java | 48 ++++--
.../messages/messages_en_US.properties | 4 +-
.../pipeline/transforms/mapping/SimpleMapping.java | 5 +-
.../pipelineexecutor/PipelineExecutor.java | 5 +-
.../transforms/setvariable/SetVariable.java | 74 ++++----
.../setvariable/messages/messages_en_US.properties | 6 +-
.../workflowexecutor/WorkflowExecutor.java | 4 +-
18 files changed, 982 insertions(+), 113 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/setvariable.adoc
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/setvariable.adoc
index e3f7cf7caa..18256d9104 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/setvariable.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/setvariable.adoc
@@ -65,9 +65,14 @@ Otherwise no formatting is done.
|Variable scope type a|Define the scope of the variable, possible options are:
* Valid in the Java Virtual Machine: the complete virtual machine will know
about this variable.
-* Valid in the parent workflow: the variable is only valid in the parent
workflow.
-* Valid in the grand-parent workflow: the variable is valid in the
grand-parent workflow and all the child workflows and pipelines.
-* Valid in the root workflow: the variable is valid in the root workflow and
all the child workflows and pipelines.
+* Valid in the parent: the variable is valid in the parent workflow or
pipeline.
+* Valid in the grand-parent: the variable is valid in the grand-parent
workflow or pipeline and all child workflows and pipelines.
+* Valid in the root: the variable is valid in the root workflow or pipeline
and all child workflows and pipelines.
|Default value|Value that will be set for empty rows
|===
+
+[NOTE]
+====
+Variables set using the "Set Variables" transform are automatically propagated
across nested/mixed execution hierarchies (e.g., Workflow -> Pipeline ->
Workflow) by dynamically crawling the parent execution engines.
+====
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/setvariables.adoc
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/setvariables.adoc
index c86942a8b6..d47930ac83 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/setvariables.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/setvariables.adoc
@@ -37,13 +37,18 @@ The `Set variables` action sets variables at various scopes.
|Variable scope a|
* Valid in the Java Virtual machine
* Valid in the current workflow
-* Valid in the parent workflow
-* Valid in the root workflow
+* Valid in the parent
+* Valid in the root
2+|Settings
|Variable substitution|Whether or not to substitute variables. Leave unchecked
only if you actually want to set a literal value like
`{openvar}MyVariable{closevar}` in the Value column.
|Variables|A list of variables to set to a certain value at a certain scope.
|===
+[NOTE]
+====
+Variables set using the "Set variables" action are automatically propagated
across nested/mixed execution hierarchies (e.g., Workflow -> Pipeline ->
Workflow) by dynamically crawling the parent execution engines.
+====
+
== Working with Properties Files
Properties files are simple text files used to store key-value pairs. They are
commonly used to manage configuration settings and variables outside of the
codebase. In Apache Hop, a properties file can be used to set multiple
variables at once in a workflow.
diff --git a/integration-tests/actions/0018-set-variables-nested-workflow.hwf
b/integration-tests/actions/0018-set-variables-nested-workflow.hwf
new file mode 100644
index 0000000000..431f41738b
--- /dev/null
+++ b/integration-tests/actions/0018-set-variables-nested-workflow.hwf
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>0018-set-variables-nested-workflow</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:50:35.688</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:50:35.688</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <DayOfMonth>1</DayOfMonth>
+ <hour>12</hour>
+ <intervalMinutes>60</intervalMinutes>
+ <intervalSeconds>0</intervalSeconds>
+ <minutes>0</minutes>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <weekDay>1</weekDay>
+ <parallel>N</parallel>
+ <xloc>192</xloc>
+ <yloc>192</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Set action_var_nested</name>
+ <description/>
+ <type>SET_VARIABLES</type>
+ <attributes/>
+ <replacevars>Y</replacevars>
+ <filename/>
+ <file_variable_type>JVM</file_variable_type>
+ <fields>
+ <field>
+ <variable_name>action_var_nested</variable_name>
+ <variable_value>NestedWorkflowValue</variable_value>
+ <variable_type>ROOT_WORKFLOW</variable_type>
+ </field>
+ </fields>
+ <parallel>N</parallel>
+ <xloc>352</xloc>
+ <yloc>192</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>Set action_var_nested</to>
+ <enabled>Y</enabled>
+ <unconditional>Y</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git a/integration-tests/actions/0018-set-variables-pipeline.hpl
b/integration-tests/actions/0018-set-variables-pipeline.hpl
new file mode 100644
index 0000000000..dbac54314d
--- /dev/null
+++ b/integration-tests/actions/0018-set-variables-pipeline.hpl
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0018-set-variables-pipeline</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:52:39.898</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:52:39.898</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Data grid</from>
+ <to>Workflow Executor</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Data grid</name>
+ <type>DataGrid</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <data>
+ <line>
+ <item>dummy</item>
+ </line>
+ </data>
+ <fields>
+ <field>
+ <length>-1</length>
+ <precision>-1</precision>
+ <currency/>
+ <set_empty_string>N</set_empty_string>
+ <name>dummy</name>
+ <format/>
+ <group/>
+ <decimal/>
+ <type>String</type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>192</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Workflow Executor</name>
+ <type>WorkflowExecutor</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/0018-set-variables-nested-workflow.hwf</filename>
+ <group_size>1</group_size>
+ <group_field/>
+ <group_time/>
+ <parameters>
+ <inherit_all_vars>Y</inherit_all_vars>
+ </parameters>
+ <attributes/>
+ <GUI>
+ <xloc>384</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+</pipeline>
diff --git a/integration-tests/actions/0018-set-variables-verify.hpl
b/integration-tests/actions/0018-set-variables-verify.hpl
new file mode 100644
index 0000000000..c15217a113
--- /dev/null
+++ b/integration-tests/actions/0018-set-variables-verify.hpl
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0018-set-variables-verify</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:52:39.898</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:52:39.898</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>1 row</from>
+ <to>Get variables</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Get variables</from>
+ <to>Filter rows</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Filter rows</from>
+ <to>OK</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Filter rows</from>
+ <to>Abort</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>1 row</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ </fields>
+ <limit>1</limit>
+ <attributes/>
+ <GUI>
+ <xloc>240</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Filter rows</name>
+ <type>FilterRows</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <compare>
+ <condition>
+ <conditions>
+ </conditions>
+ <function>=</function>
+ <leftvalue>nested_val</leftvalue>
+ <negated>N</negated>
+ <operator>-</operator>
+ <value>
+ <isnull>N</isnull>
+ <length>-1</length>
+ <name>constant</name>
+ <precision>-1</precision>
+ <type>String</type>
+ <text>NestedWorkflowValue</text>
+ </value>
+ </condition>
+ </compare>
+ <send_true_to>OK</send_true_to>
+ <send_false_to>Abort</send_false_to>
+ <attributes/>
+ <GUI>
+ <xloc>560</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Get variables</name>
+ <type>GetVariable</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>nested_val</name>
+ <variable>${action_var_nested}</variable>
+ <type>String</type>
+ <format/>
+ <currency/>
+ <decimal/>
+ <group/>
+ <length>-1</length>
+ <precision>-1</precision>
+ <trim_type>none</trim_type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>400</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>OK</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>720</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Abort</name>
+ <type>Abort</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <row_threshold>0</row_threshold>
+ <message>action_var_nested was not set correctly!</message>
+ <always_log_rows>Y</always_log_rows>
+ <abort_option>ABORT_WITH_ERROR</abort_option>
+ <attributes/>
+ <GUI>
+ <xloc>560</xloc>
+ <yloc>288</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/transforms/main-0064-set-variables.hwf
b/integration-tests/actions/main-0018-set-variables.hwf
similarity index 87%
copy from integration-tests/transforms/main-0064-set-variables.hwf
copy to integration-tests/actions/main-0018-set-variables.hwf
index 25fe7b3c7e..0e7b234a7f 100644
--- a/integration-tests/transforms/main-0064-set-variables.hwf
+++ b/integration-tests/actions/main-0018-set-variables.hwf
@@ -18,7 +18,7 @@ limitations under the License.
-->
<workflow>
- <name>main-0064-set-variables</name>
+ <name>main-0018-set-variables</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
@@ -28,7 +28,7 @@ limitations under the License.
<modified_user>-</modified_user>
<modified_date>2022/12/29 16:50:35.688</modified_date>
<parameters>
- </parameters>
+ </parameters>
<actions>
<action>
<name>Start</name>
@@ -49,11 +49,11 @@ limitations under the License.
<attributes_hac/>
</action>
<action>
- <name>0064-set-variables-init</name>
+ <name>Run Parent Pipeline</name>
<description/>
<type>PIPELINE</type>
<attributes/>
- <filename>${PROJECT_HOME}/0064-set-variables-init.hpl</filename>
+ <filename>${PROJECT_HOME}/0018-set-variables-pipeline.hpl</filename>
<params_from_previous>N</params_from_previous>
<exec_per_row>N</exec_per_row>
<clear_rows>N</clear_rows>
@@ -72,16 +72,16 @@ limitations under the License.
<pass_all_parameters>Y</pass_all_parameters>
</parameters>
<parallel>N</parallel>
- <xloc>368</xloc>
+ <xloc>384</xloc>
<yloc>192</yloc>
<attributes_hac/>
</action>
<action>
- <name>0064-set-variables-get-values</name>
+ <name>Verify Variable</name>
<description/>
<type>PIPELINE</type>
<attributes/>
- <filename>${PROJECT_HOME}/0064-set-variables-get-values.hpl</filename>
+ <filename>${PROJECT_HOME}/0018-set-variables-verify.hpl</filename>
<params_from_previous>N</params_from_previous>
<exec_per_row>N</exec_per_row>
<clear_rows>N</clear_rows>
@@ -100,7 +100,7 @@ limitations under the License.
<pass_all_parameters>Y</pass_all_parameters>
</parameters>
<parallel>N</parallel>
- <xloc>560</xloc>
+ <xloc>576</xloc>
<yloc>192</yloc>
<attributes_hac/>
</action>
@@ -108,14 +108,13 @@ limitations under the License.
<hops>
<hop>
<from>Start</from>
- <to>0064-set-variables-init</to>
+ <to>Run Parent Pipeline</to>
<enabled>Y</enabled>
- <evaluation>Y</evaluation>
<unconditional>Y</unconditional>
</hop>
<hop>
- <from>0064-set-variables-init</from>
- <to>0064-set-variables-get-values</to>
+ <from>Run Parent Pipeline</from>
+ <to>Verify Variable</to>
<enabled>Y</enabled>
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
diff --git a/integration-tests/transforms/0064-set-variables-child-pipeline.hpl
b/integration-tests/transforms/0064-set-variables-child-pipeline.hpl
new file mode 100644
index 0000000000..9d9abbf879
--- /dev/null
+++ b/integration-tests/transforms/0064-set-variables-child-pipeline.hpl
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0064-set-variables-child-pipeline</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:52:39.898</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:52:39.898</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Data grid</from>
+ <to>Set variables</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Data grid</name>
+ <type>DataGrid</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <data>
+ <line>
+ <item>XYZ</item>
+ </line>
+ </data>
+ <fields>
+ <field>
+ <length>-1</length>
+ <precision>-1</precision>
+ <currency/>
+ <set_empty_string>N</set_empty_string>
+ <name>nested_val</name>
+ <format/>
+ <group/>
+ <decimal/>
+ <type>String</type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>304</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Set variables</name>
+ <type>SetVariable</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <field_name>nested_val</field_name>
+ <variable_name>var_nested</variable_name>
+ <variable_type>ROOT_WORKFLOW</variable_type>
+ <default_value/>
+ </field>
+ </fields>
+ <use_formatting>Y</use_formatting>
+ <attributes/>
+ <GUI>
+ <xloc>480</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/transforms/main-0064-set-variables.hwf
b/integration-tests/transforms/0064-set-variables-child-workflow.hwf
similarity index 65%
copy from integration-tests/transforms/main-0064-set-variables.hwf
copy to integration-tests/transforms/0064-set-variables-child-workflow.hwf
index 25fe7b3c7e..1b67c7eda6 100644
--- a/integration-tests/transforms/main-0064-set-variables.hwf
+++ b/integration-tests/transforms/0064-set-variables-child-workflow.hwf
@@ -18,7 +18,7 @@ limitations under the License.
-->
<workflow>
- <name>main-0064-set-variables</name>
+ <name>0064-set-variables-child-workflow</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
@@ -28,7 +28,7 @@ limitations under the License.
<modified_user>-</modified_user>
<modified_date>2022/12/29 16:50:35.688</modified_date>
<parameters>
- </parameters>
+ </parameters>
<actions>
<action>
<name>Start</name>
@@ -49,11 +49,11 @@ limitations under the License.
<attributes_hac/>
</action>
<action>
- <name>0064-set-variables-init</name>
+ <name>Run Child Pipeline</name>
<description/>
<type>PIPELINE</type>
<attributes/>
- <filename>${PROJECT_HOME}/0064-set-variables-init.hpl</filename>
+
<filename>${PROJECT_HOME}/0064-set-variables-child-pipeline.hpl</filename>
<params_from_previous>N</params_from_previous>
<exec_per_row>N</exec_per_row>
<clear_rows>N</clear_rows>
@@ -76,50 +76,14 @@ limitations under the License.
<yloc>192</yloc>
<attributes_hac/>
</action>
- <action>
- <name>0064-set-variables-get-values</name>
- <description/>
- <type>PIPELINE</type>
- <attributes/>
- <filename>${PROJECT_HOME}/0064-set-variables-get-values.hpl</filename>
- <params_from_previous>N</params_from_previous>
- <exec_per_row>N</exec_per_row>
- <clear_rows>N</clear_rows>
- <clear_files>N</clear_files>
- <set_logfile>N</set_logfile>
- <logfile/>
- <logext/>
- <add_date>N</add_date>
- <add_time>N</add_time>
- <loglevel>Basic</loglevel>
- <set_append_logfile>N</set_append_logfile>
- <wait_until_finished>Y</wait_until_finished>
- <create_parent_folder>N</create_parent_folder>
- <run_configuration>local</run_configuration>
- <parameters>
- <pass_all_parameters>Y</pass_all_parameters>
- </parameters>
- <parallel>N</parallel>
- <xloc>560</xloc>
- <yloc>192</yloc>
- <attributes_hac/>
- </action>
</actions>
<hops>
<hop>
<from>Start</from>
- <to>0064-set-variables-init</to>
+ <to>Run Child Pipeline</to>
<enabled>Y</enabled>
- <evaluation>Y</evaluation>
<unconditional>Y</unconditional>
</hop>
- <hop>
- <from>0064-set-variables-init</from>
- <to>0064-set-variables-get-values</to>
- <enabled>Y</enabled>
- <evaluation>Y</evaluation>
- <unconditional>N</unconditional>
- </hop>
</hops>
<notepads>
</notepads>
diff --git
a/integration-tests/transforms/0064-set-variables-parent-pipeline.hpl
b/integration-tests/transforms/0064-set-variables-parent-pipeline.hpl
new file mode 100644
index 0000000000..80d163ffd2
--- /dev/null
+++ b/integration-tests/transforms/0064-set-variables-parent-pipeline.hpl
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0064-set-variables-parent-pipeline</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:52:39.898</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:52:39.898</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>Data grid</from>
+ <to>Workflow Executor</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>Data grid</name>
+ <type>DataGrid</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <data>
+ <line>
+ <item>dummy</item>
+ </line>
+ </data>
+ <fields>
+ <field>
+ <length>-1</length>
+ <precision>-1</precision>
+ <currency/>
+ <set_empty_string>N</set_empty_string>
+ <name>dummy</name>
+ <format/>
+ <group/>
+ <decimal/>
+ <type>String</type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>192</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Workflow Executor</name>
+ <type>WorkflowExecutor</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <run_configuration>local</run_configuration>
+ <filename>${PROJECT_HOME}/0064-set-variables-child-workflow.hwf</filename>
+ <group_size>1</group_size>
+ <group_field/>
+ <group_time/>
+ <parameters>
+ <inherit_all_vars>Y</inherit_all_vars>
+ </parameters>
+ <attributes/>
+ <GUI>
+ <xloc>384</xloc>
+ <yloc>192</yloc>
+ </GUI>
+ </transform>
+</pipeline>
diff --git a/integration-tests/transforms/0064-set-variables-verify-nested.hpl
b/integration-tests/transforms/0064-set-variables-verify-nested.hpl
new file mode 100644
index 0000000000..99a801865f
--- /dev/null
+++ b/integration-tests/transforms/0064-set-variables-verify-nested.hpl
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+ <info>
+ <name>0064-set-variables-verify-nested</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <pipeline_version/>
+ <pipeline_type>Normal</pipeline_type>
+ <parameters>
+ </parameters>
+ <capture_transform_performance>N</capture_transform_performance>
+
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+ <created_user>-</created_user>
+ <created_date>2022/12/29 16:52:39.898</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2022/12/29 16:52:39.898</modified_date>
+ </info>
+ <notepads>
+ </notepads>
+ <order>
+ <hop>
+ <from>1 row</from>
+ <to>Get variables</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Get variables</from>
+ <to>Filter rows</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Filter rows</from>
+ <to>OK</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>Filter rows</from>
+ <to>Abort</to>
+ <enabled>Y</enabled>
+ </hop>
+ </order>
+ <transform>
+ <name>1 row</name>
+ <type>RowGenerator</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ </fields>
+ <limit>1</limit>
+ <attributes/>
+ <GUI>
+ <xloc>240</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Filter rows</name>
+ <type>FilterRows</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <compare>
+ <condition>
+ <conditions>
+ </conditions>
+ <function>=</function>
+ <leftvalue>nested_val</leftvalue>
+ <negated>N</negated>
+ <operator>-</operator>
+ <value>
+ <isnull>N</isnull>
+ <length>-1</length>
+ <name>constant</name>
+ <precision>-1</precision>
+ <type>String</type>
+ <text>XYZ</text>
+ </value>
+ </condition>
+ </compare>
+ <send_true_to>OK</send_true_to>
+ <send_false_to>Abort</send_false_to>
+ <attributes/>
+ <GUI>
+ <xloc>560</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Get variables</name>
+ <type>GetVariable</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <fields>
+ <field>
+ <name>nested_val</name>
+ <variable>${var_nested}</variable>
+ <type>String</type>
+ <format/>
+ <currency/>
+ <decimal/>
+ <group/>
+ <length>-1</length>
+ <precision>-1</precision>
+ <trim_type>none</trim_type>
+ </field>
+ </fields>
+ <attributes/>
+ <GUI>
+ <xloc>400</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>OK</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <attributes/>
+ <GUI>
+ <xloc>720</xloc>
+ <yloc>160</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>Abort</name>
+ <type>Abort</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <row_threshold>0</row_threshold>
+ <message>var_nested was not set correctly!</message>
+ <always_log_rows>Y</always_log_rows>
+ <abort_option>ABORT_WITH_ERROR</abort_option>
+ <attributes/>
+ <GUI>
+ <xloc>560</xloc>
+ <yloc>288</yloc>
+ </GUI>
+ </transform>
+ <transform_error_handling>
+ </transform_error_handling>
+ <attributes/>
+</pipeline>
diff --git a/integration-tests/transforms/main-0064-set-variables.hwf
b/integration-tests/transforms/main-0064-set-variables.hwf
index 25fe7b3c7e..967155d9a2 100644
--- a/integration-tests/transforms/main-0064-set-variables.hwf
+++ b/integration-tests/transforms/main-0064-set-variables.hwf
@@ -104,6 +104,62 @@ limitations under the License.
<yloc>192</yloc>
<attributes_hac/>
</action>
+ <action>
+ <name>0064-set-variables-parent-pipeline</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+
<filename>${PROJECT_HOME}/0064-set-variables-parent-pipeline.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>752</xloc>
+ <yloc>192</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0064-set-variables-verify-nested</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0064-set-variables-verify-nested.hpl</filename>
+ <params_from_previous>N</params_from_previous>
+ <exec_per_row>N</exec_per_row>
+ <clear_rows>N</clear_rows>
+ <clear_files>N</clear_files>
+ <set_logfile>N</set_logfile>
+ <logfile/>
+ <logext/>
+ <add_date>N</add_date>
+ <add_time>N</add_time>
+ <loglevel>Basic</loglevel>
+ <set_append_logfile>N</set_append_logfile>
+ <wait_until_finished>Y</wait_until_finished>
+ <create_parent_folder>N</create_parent_folder>
+ <run_configuration>local</run_configuration>
+ <parameters>
+ <pass_all_parameters>Y</pass_all_parameters>
+ </parameters>
+ <parallel>N</parallel>
+ <xloc>960</xloc>
+ <yloc>192</yloc>
+ <attributes_hac/>
+ </action>
</actions>
<hops>
<hop>
@@ -120,6 +176,20 @@ limitations under the License.
<evaluation>Y</evaluation>
<unconditional>N</unconditional>
</hop>
+ <hop>
+ <from>0064-set-variables-get-values</from>
+ <to>0064-set-variables-parent-pipeline</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0064-set-variables-parent-pipeline</from>
+ <to>0064-set-variables-verify-nested</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
</hops>
<notepads>
</notepads>
diff --git
a/plugins/actions/setvariables/src/main/java/org/apache/hop/workflow/actions/setvariables/ActionSetVariables.java
b/plugins/actions/setvariables/src/main/java/org/apache/hop/workflow/actions/setvariables/ActionSetVariables.java
index 5c26d9e54c..7f375f23ec 100644
---
a/plugins/actions/setvariables/src/main/java/org/apache/hop/workflow/actions/setvariables/ActionSetVariables.java
+++
b/plugins/actions/setvariables/src/main/java/org/apache/hop/workflow/actions/setvariables/ActionSetVariables.java
@@ -37,6 +37,7 @@ import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.IEnumHasCode;
import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
import org.apache.hop.metadata.api.IHopMetadataProvider;
+import org.apache.hop.pipeline.engine.IPipelineEngine;
import org.apache.hop.resource.ResourceEntry;
import org.apache.hop.resource.ResourceEntry.ResourceType;
import org.apache.hop.resource.ResourceReference;
@@ -237,6 +238,13 @@ public class ActionSetVariables extends ActionBase
implements Cloneable, IAction
value = resolve(value);
}
+ java.util.List<IVariables> parents = new java.util.ArrayList<>();
+ IVariables parentEngine = getParentEngine(parentWorkflow);
+ while (parentEngine != null) {
+ parents.add(parentEngine);
+ parentEngine = getParentEngine(parentEngine);
+ }
+
// OK, where do we set this value...
switch (definition.getType()) {
case JVM:
@@ -246,20 +254,22 @@ public class ActionSetVariables extends ActionBase
implements Cloneable, IAction
System.clearProperty(name);
}
setVariable(name, value);
- IWorkflowEngine<WorkflowMeta> parentWorkflowTraverse =
parentWorkflow;
- while (parentWorkflowTraverse != null) {
- parentWorkflowTraverse.setVariable(name, value);
- parentWorkflowTraverse =
parentWorkflowTraverse.getParentWorkflow();
+ if (parentWorkflow != null) {
+ parentWorkflow.setVariable(name, value);
+ for (IVariables p : parents) {
+ p.setVariable(name, value);
+ }
}
break;
case ROOT_WORKFLOW:
// set variable in this action
setVariable(name, value);
- IWorkflowEngine<WorkflowMeta> rootWorkflow = parentWorkflow;
- while (rootWorkflow != null) {
- rootWorkflow.setVariable(name, value);
- rootWorkflow = rootWorkflow.getParentWorkflow();
+ if (parentWorkflow != null) {
+ parentWorkflow.setVariable(name, value);
+ for (IVariables p : parents) {
+ p.setVariable(name, value);
+ }
}
break;
@@ -294,9 +304,8 @@ public class ActionSetVariables extends ActionBase
implements Cloneable, IAction
if (parentWorkflow != null) {
parentWorkflow.setVariable(name, value);
- IWorkflowEngine<WorkflowMeta> gpWorkflow =
parentWorkflow.getParentWorkflow();
- if (gpWorkflow != null) {
- gpWorkflow.setVariable(name, value);
+ if (!parents.isEmpty()) {
+ parents.get(0).setVariable(name, value);
} else {
throw new HopWorkflowException(
BaseMessages.getString(
@@ -418,4 +427,21 @@ public class ActionSetVariables extends ActionBase
implements Cloneable, IAction
public void setFileVariableType(VariableType scope) {
this.fileVariableType = scope;
}
+
+ private IVariables getParentEngine(IVariables engine) {
+ if (engine instanceof IPipelineEngine) {
+ IPipelineEngine<?> pe = (IPipelineEngine<?>) engine;
+ if (pe.getParentPipeline() != null) {
+ return pe.getParentPipeline();
+ }
+ return pe.getParentWorkflow();
+ } else if (engine instanceof IWorkflowEngine) {
+ IWorkflowEngine<?> we = (IWorkflowEngine<?>) engine;
+ if (we.getParentPipeline() != null) {
+ return we.getParentPipeline();
+ }
+ return we.getParentWorkflow();
+ }
+ return null;
+ }
}
diff --git
a/plugins/actions/setvariables/src/main/resources/org/apache/hop/workflow/actions/setvariables/messages/messages_en_US.properties
b/plugins/actions/setvariables/src/main/resources/org/apache/hop/workflow/actions/setvariables/messages/messages_en_US.properties
index 14f3d5d8aa..8cc26b1f04 100644
---
a/plugins/actions/setvariables/src/main/resources/org/apache/hop/workflow/actions/setvariables/messages/messages_en_US.properties
+++
b/plugins/actions/setvariables/src/main/resources/org/apache/hop/workflow/actions/setvariables/messages/messages_en_US.properties
@@ -38,7 +38,7 @@ ActionSetVariables.UnExcpectedError=Unexpected error\! {0}
ActionSetVariables.Variables.Label=Variables \:
ActionSetVariables.VariableType.CurrentWorkflow=Valid in the current workflow
ActionSetVariables.VariableType.JVM=Valid in the Java Virtual Machine
-ActionSetVariables.VariableType.ParentWorkflow=Valid in the parent workflow
-ActionSetVariables.VariableType.RootWorkflow=Valid in the root workflow
+ActionSetVariables.VariableType.ParentWorkflow=Valid in the parent
+ActionSetVariables.VariableType.RootWorkflow=Valid in the root
ActionSetVariables.VarsReplace.Label=Variable substitution
ActionSetVariables.VarsReplace.Tooltip=Check this option if you want to do a
variable\nsubstitution (in name and value) before setting variables.
diff --git
a/plugins/transforms/mapping/src/main/java/org/apache/hop/pipeline/transforms/mapping/SimpleMapping.java
b/plugins/transforms/mapping/src/main/java/org/apache/hop/pipeline/transforms/mapping/SimpleMapping.java
index 16270c61ec..06052bdd35 100644
---
a/plugins/transforms/mapping/src/main/java/org/apache/hop/pipeline/transforms/mapping/SimpleMapping.java
+++
b/plugins/transforms/mapping/src/main/java/org/apache/hop/pipeline/transforms/mapping/SimpleMapping.java
@@ -158,7 +158,10 @@ public class SimpleMapping extends
BaseTransform<SimpleMappingMeta, SimpleMappin
simpleMappingData.mappingPipeline =
(LocalPipelineEngine)
PipelineEngineFactory.createPipelineEngine(
- this, runConfigName, metadataProvider,
simpleMappingData.mappingPipelineMeta);
+ getPipeline(),
+ runConfigName,
+ metadataProvider,
+ simpleMappingData.mappingPipelineMeta);
}
// Copy the parameters over...
diff --git
a/plugins/transforms/pipelineexecutor/src/main/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutor.java
b/plugins/transforms/pipelineexecutor/src/main/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutor.java
index 42d9c61e22..6689a647ee 100644
---
a/plugins/transforms/pipelineexecutor/src/main/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutor.java
+++
b/plugins/transforms/pipelineexecutor/src/main/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutor.java
@@ -295,7 +295,10 @@ public class PipelineExecutor extends
BaseTransform<PipelineExecutorMeta, Pipeli
String runConfigurationName = resolve(meta.getRunConfigurationName());
IPipelineEngine<PipelineMeta> executorPipeline =
PipelineEngineFactory.createPipelineEngine(
- this, runConfigurationName, metadataProvider,
getData().getExecutorPipelineMeta());
+ getPipeline(),
+ runConfigurationName,
+ metadataProvider,
+ getData().getExecutorPipelineMeta());
executorPipeline.setParentPipeline(getPipeline());
executorPipeline.setParent(this);
executorPipeline.setLogLevel(getLogLevel());
diff --git
a/plugins/transforms/setvariable/src/main/java/org/apache/hop/pipeline/transforms/setvariable/SetVariable.java
b/plugins/transforms/setvariable/src/main/java/org/apache/hop/pipeline/transforms/setvariable/SetVariable.java
index ef2b59fc9a..634cea9d72 100644
---
a/plugins/transforms/setvariable/src/main/java/org/apache/hop/pipeline/transforms/setvariable/SetVariable.java
+++
b/plugins/transforms/setvariable/src/main/java/org/apache/hop/pipeline/transforms/setvariable/SetVariable.java
@@ -29,7 +29,6 @@ import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.engine.IPipelineEngine;
import org.apache.hop.pipeline.transform.BaseTransform;
import org.apache.hop.pipeline.transform.TransformMeta;
-import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.engine.IWorkflowEngine;
/** Convert Values in a certain fields to other values */
@@ -137,8 +136,6 @@ public class SetVariable extends
BaseTransform<SetVariableMeta, SetVariableData>
}
}
- IWorkflowEngine<WorkflowMeta> parentWorkflow;
-
// We always set the variable in this transform and in the parent
pipeline...
//
setVariable(varname, value);
@@ -155,71 +152,61 @@ public class SetVariable extends
BaseTransform<SetVariableMeta, SetVariableData>
pipeline.setVariable(varname, value);
}
- // The pipeline object we have now is the pipeline being executed by a
workflow.
- // It has one or more parent workflows.
- // Below we see where we need to this value as well...
+ // Now construct the list of parent engines starting from this top-level
pipeline
//
+ java.util.List<IVariables> parents = new java.util.ArrayList<>();
+ IVariables parent = getParentEngine(pipeline);
+ while (parent != null) {
+ parents.add(parent);
+ parent = getParentEngine(parent);
+ }
+
switch (vars.get(i).getVariableType()) {
case VariableItem.VARIABLE_TYPE_JVM:
System.setProperty(varname, value);
-
- parentWorkflow = pipeline.getParentWorkflow();
- while (parentWorkflow != null) {
- parentWorkflow.setVariable(varname, value);
- parentWorkflow = parentWorkflow.getParentWorkflow();
+ for (IVariables p : parents) {
+ p.setVariable(varname, value);
}
-
break;
+
case VariableItem.VARIABLE_TYPE_ROOT_WORKFLOW:
- parentWorkflow = pipeline.getParentWorkflow();
- while (parentWorkflow != null) {
- parentWorkflow.setVariable(varname, value);
- parentWorkflow = parentWorkflow.getParentWorkflow();
+ for (IVariables p : parents) {
+ p.setVariable(varname, value);
}
break;
case VariableItem.VARIABLE_TYPE_GRAND_PARENT_WORKFLOW:
- // Set the variable in the parent workflow
- //
- parentWorkflow = pipeline.getParentWorkflow();
- if (parentWorkflow != null) {
- parentWorkflow.setVariable(varname, value);
+ if (!parents.isEmpty()) {
+ parents.get(0).setVariable(varname, value);
} else {
if (isBasic()) {
logBasic(
CONST_WARNING_CAN_T_SET_VARIABLE
+ varname
- + "] on parent workflow: the parent workflow is not
available");
+ + "] on parent: the parent is not available");
}
}
-
- // Set the variable on the grand-parent workflow
- //
- IVariables gpJob = pipeline.getParentWorkflow().getParentWorkflow();
- if (gpJob != null) {
- gpJob.setVariable(varname, value);
+ if (parents.size() > 1) {
+ parents.get(1).setVariable(varname, value);
} else {
if (isBasic()) {
logBasic(
CONST_WARNING_CAN_T_SET_VARIABLE
+ varname
- + "] on grand parent workflow: the grand parent workflow
is not available");
+ + "] on grand parent: the grand parent is not available");
}
}
break;
case VariableItem.VARIABLE_TYPE_PARENT_WORKFLOW:
- // Set the variable in the parent workflow
- //
- parentWorkflow = pipeline.getParentWorkflow();
- if (parentWorkflow != null) {
- parentWorkflow.setVariable(varname, value);
+ if (!parents.isEmpty()) {
+ parents.get(0).setVariable(varname, value);
} else {
if (isBasic()) {
logBasic(
CONST_WARNING_CAN_T_SET_VARIABLE
+ varname
- + "] on parent workflow: the parent workflow is not
available");
+ + "] on parent: the parent is not available");
}
}
break;
@@ -234,4 +221,21 @@ public class SetVariable extends
BaseTransform<SetVariableMeta, SetVariableData>
PKG, "SetVariable.Log.SetVariableToValue",
vars.get(i).getVariableName(), value));
}
}
+
+ private IVariables getParentEngine(IVariables engine) {
+ if (engine instanceof IPipelineEngine) {
+ IPipelineEngine<?> pe = (IPipelineEngine<?>) engine;
+ if (pe.getParentPipeline() != null) {
+ return pe.getParentPipeline();
+ }
+ return pe.getParentWorkflow();
+ } else if (engine instanceof IWorkflowEngine) {
+ IWorkflowEngine<?> we = (IWorkflowEngine<?>) engine;
+ if (we.getParentPipeline() != null) {
+ return we.getParentPipeline();
+ }
+ return we.getParentWorkflow();
+ }
+ return null;
+ }
}
diff --git
a/plugins/transforms/setvariable/src/main/resources/org/apache/hop/pipeline/transforms/setvariable/messages/messages_en_US.properties
b/plugins/transforms/setvariable/src/main/resources/org/apache/hop/pipeline/transforms/setvariable/messages/messages_en_US.properties
index b1d698feab..52ae3907f6 100644
---
a/plugins/transforms/setvariable/src/main/resources/org/apache/hop/pipeline/transforms/setvariable/messages/messages_en_US.properties
+++
b/plugins/transforms/setvariable/src/main/resources/org/apache/hop/pipeline/transforms/setvariable/messages/messages_en_US.properties
@@ -22,10 +22,10 @@ SetVariable.Log.SettingVar=Setting project variables...
SetVariable.Log.SetVariableToValue=Set variable {0} to value [{1}]
SetVariable.Name=Set variables
SetVariable.RuntimeError.MoreThanOneRowReceived.SETVARIABLE0007=Only 1 input
row was expected to set the variables and at least 2 were received.
-SetVariable.Validity.GParent=Valid in the grand-parent workflow
+SetVariable.Validity.GParent=Valid in the grand-parent
SetVariable.Validity.Jvm=Valid in the Java Virtual Machine
-SetVariable.Validity.Parent=Valid in the parent workflow
-SetVariable.Validity.RootWf=Valid in the root workflow
+SetVariable.Validity.Parent=Valid in the parent
+SetVariable.Validity.RootWf=Valid in the root
SetVariableDialog.DialogTitle=Set variables
SetVariableDialog.FailedToGetFields.DialogTitle=Error getting fields
SetVariableDialog.Fields.Column.DefaultValue=Default value
diff --git
a/plugins/transforms/workflowexecutor/src/main/java/org/apache/hop/pipeline/transforms/workflowexecutor/WorkflowExecutor.java
b/plugins/transforms/workflowexecutor/src/main/java/org/apache/hop/pipeline/transforms/workflowexecutor/WorkflowExecutor.java
index dfa49d74a8..826e0100bf 100644
---
a/plugins/transforms/workflowexecutor/src/main/java/org/apache/hop/pipeline/transforms/workflowexecutor/WorkflowExecutor.java
+++
b/plugins/transforms/workflowexecutor/src/main/java/org/apache/hop/pipeline/transforms/workflowexecutor/WorkflowExecutor.java
@@ -197,7 +197,7 @@ public class WorkflowExecutor extends
BaseTransform<WorkflowExecutorMeta, Workfl
data.executorWorkflow = createWorkflow(data.executorWorkflowMeta, this);
- data.executorWorkflow.initializeFrom(this);
+ data.executorWorkflow.initializeFrom(getPipeline());
data.executorWorkflow.setParentPipeline(getPipeline());
data.executorWorkflow.setLogLevel(getLogLevel());
data.executorWorkflow.setInternalHopVariables();
@@ -353,7 +353,7 @@ public class WorkflowExecutor extends
BaseTransform<WorkflowExecutorMeta, Workfl
WorkflowMeta workflowMeta, ILoggingObject parentLogging) throws
HopException {
return WorkflowEngineFactory.createWorkflowEngine(
- this,
+ getPipeline(),
resolve(meta.getRunConfigurationName()),
metadataProvider,
workflowMeta,