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 995b370602 vCard output keeps only the last card and reopens its file
for every … (#9438)
995b370602 is described below
commit 995b370602cab6df060d876764926cc1293e1601
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Nov 13 16:27:04 2026 +0100
vCard output keeps only the last card and reopens its file for every …
(#9438)
* vCard output keeps only the last card and reopens its file for every row,
fixes #9437
* fix remarks
---
...l => 0104-vcard-output-categories-generate.hpl} | 53 ++++---
...hpl => 0104-vcard-output-categories-verify.hpl} | 125 +++++-----------
...04-vcard-output-date-time-in-name-generate.hpl} | 58 +++-----
...0104-vcard-output-date-time-in-name-verify.hpl} | 120 +++++-----------
...0104-vcard-output-file-name-field-generate.hpl} | 63 ++++----
...> 0104-vcard-output-file-name-field-verify.hpl} | 148 +++++++++----------
.../transforms/0104-vcard-output-generate.hpl | 12 ++
...-generate.hpl => 0104-vcard-output-no-rows.hpl} | 50 ++-----
.../datasets/golden-vcard-output-categories.csv | 4 +
.../golden-vcard-output-date-time-in-name.csv | 4 +
.../golden-vcard-output-file-name-field.csv | 5 +
.../transforms/datasets/golden-vcard-output.csv | 2 +
.../main-0104-vcard-output-categories.hwf | 114 +++++++++++++++
.../main-0104-vcard-output-date-time-in-name.hwf | 139 ++++++++++++++++++
.../main-0104-vcard-output-file-name-field.hwf | 139 ++++++++++++++++++
.../transforms/main-0104-vcard-output-no-rows.hwf | 135 +++++++++++++++++
.../dataset/golden-vcard-output-categories.json | 32 +++++
.../golden-vcard-output-date-time-in-name.json | 24 ++++
.../golden-vcard-output-file-name-field.json | 32 +++++
.../0104-vcard-output-categories-verify UNIT.json | 36 +++++
...vcard-output-date-time-in-name-verify UNIT.json | 32 +++++
...4-vcard-output-file-name-field-verify UNIT.json | 37 +++++
.../hop/pipeline/transforms/vcard/VCardMapper.java | 48 ++++++-
.../transforms/vcardoutput/VCardFileSettings.java | 56 ++++----
.../transforms/vcardoutput/VCardOutput.java | 119 ++++++++++++---
.../transforms/vcardoutput/VCardOutputData.java | 21 +++
.../pipeline/transforms/vcard/VCardMapperTest.java | 63 ++++++--
.../vcardoutput/VCardFileSettingsTest.java | 36 ++++-
.../transforms/vcardoutput/VCardOutputTest.java | 159 +++++++++++++++++++++
29 files changed, 1409 insertions(+), 457 deletions(-)
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-categories-generate.hpl
similarity index 79%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to integration-tests/transforms/0104-vcard-output-categories-generate.hpl
index b298b87658..22deb75688 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++ b/integration-tests/transforms/0104-vcard-output-categories-generate.hpl
@@ -19,9 +19,9 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-categories-generate</name>
<name_sync_with_filename>Y</name_sync_with_filename>
- <description/>
+ <description>A categories mapping on a new card, and a card without
categories.</description>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
@@ -31,21 +31,21 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
+ <from>cards with and without categories</from>
<to>VCard output</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
+ <name>cards with and without categories</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
@@ -57,10 +57,19 @@ limitations under the License.
</partitioning>
<data>
<line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
+ <item>Hal Grouped</item>
+ <item>categories-1</item>
+ <item>friends,work</item>
+ </line>
+ <line>
+ <item>Ida Plain</item>
+ <item>categories-2</item>
+ <item/>
+ </line>
+ <line>
+ <item>Jon Grouped</item>
+ <item>categories-3</item>
+ <item>family</item>
</line>
</data>
<fields>
@@ -82,14 +91,7 @@ limitations under the License.
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
+ <name>categories</name>
<type>String</type>
</field>
</fields>
@@ -120,7 +122,7 @@ limitations under the License.
<file_name_field>vcard_filename</file_name_field>
<encoding>UTF-8</encoding>
<file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
+ <name>${java.io.tmpdir}/vcard-output-0104-categories</name>
<extension>vcf</extension>
<create_parent_folder>Y</create_parent_folder>
<append>N</append>
@@ -139,16 +141,11 @@ limitations under the License.
<parameter_types/>
</field>
<field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
+ <hop_field>categories</hop_field>
+ <property>categories</property>
+ <parameter_types/>
</field>
- <add_to_result_filenames>Y</add_to_result_filenames>
+ <add_to_result_filenames>N</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-categories-verify.hpl
similarity index 51%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to integration-tests/transforms/0104-vcard-output-categories-verify.hpl
index b298b87658..516465e356 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++ b/integration-tests/transforms/0104-vcard-output-categories-verify.hpl
@@ -19,7 +19,7 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-categories-verify</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
@@ -31,23 +31,23 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
- <to>VCard output</to>
+ <from>vcard-output-0104-categories.vcf</from>
+ <to>validate</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
- <type>DataGrid</type>
- <description/>
+ <name>vcard-output-0104-categories.vcf</name>
+ <type>VCardInput</type>
+ <description>Reads categories also from the card that has
none.</description>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
@@ -55,44 +55,34 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <data>
- <line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
- </line>
- </data>
- <fields>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>fn</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>uid</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
- <type>String</type>
- </field>
- </fields>
+ <include_filename>N</include_filename>
+ <filename_field>vcard_filename</filename_field>
+ <ignore_empty_file>Y</ignore_empty_file>
+ <do_not_fail_if_no_file>N</do_not_fail_if_no_file>
+ <encoding>UTF-8</encoding>
+ <files>
+ <file>
+ <name>${java.io.tmpdir}/vcard-output-0104-categories.vcf</name>
+ <filemask/>
+ <file_required>Y</file_required>
+ <include_subfolders>N</include_subfolders>
+ </file>
+ </files>
+ <field>
+ <hop_field>fn</hop_field>
+ <property>fn</property>
+ <parameter_types/>
+ </field>
+ <field>
+ <hop_field>uid</hop_field>
+ <property>uid</property>
+ <parameter_types/>
+ </field>
+ <field>
+ <hop_field>categories</hop_field>
+ <property>categories</property>
+ <parameter_types/>
+ </field>
<attributes/>
<GUI>
<xloc>80</xloc>
@@ -100,8 +90,8 @@ limitations under the License.
</GUI>
</transform>
<transform>
- <name>VCard output</name>
- <type>VCardOutput</type>
+ <name>validate</name>
+ <type>Dummy</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
@@ -110,45 +100,6 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <operation_type>writetofile</operation_type>
- <vcard_version>3.0</vcard_version>
- <output_field>vcard_text</output_field>
- <pass_input_fields>N</pass_input_fields>
- <add_prodid>N</add_prodid>
- <add_revision>N</add_revision>
- <file_name_in_field>N</file_name_in_field>
- <file_name_field>vcard_filename</file_name_field>
- <encoding>UTF-8</encoding>
- <file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
- <extension>vcf</extension>
- <create_parent_folder>Y</create_parent_folder>
- <append>N</append>
- <add_date>N</add_date>
- <add_time>N</add_time>
- <doNotOpenNewFileInit>Y</doNotOpenNewFileInit>
- </file>
- <field>
- <hop_field>fn</hop_field>
- <property>fn</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>uid</hop_field>
- <property>uid</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-date-time-in-name-generate.hpl
similarity index 73%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to
integration-tests/transforms/0104-vcard-output-date-time-in-name-generate.hpl
index b298b87658..5ac279a07a 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++
b/integration-tests/transforms/0104-vcard-output-date-time-in-name-generate.hpl
@@ -19,9 +19,9 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-date-time-in-name-generate</name>
<name_sync_with_filename>Y</name_sync_with_filename>
- <description/>
+ <description>The file name gets the date and the time of the run:
contacts_yyyyMMdd_HHmmss.vcf.</description>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
@@ -31,21 +31,21 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
+ <from>three cards</from>
<to>VCard output</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
+ <name>three cards</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
@@ -57,10 +57,16 @@ limitations under the License.
</partitioning>
<data>
<line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
+ <item>Eve Dated</item>
+ <item>dated-1</item>
+ </line>
+ <line>
+ <item>Fay Dated</item>
+ <item>dated-2</item>
+ </line>
+ <line>
+ <item>Gus Dated</item>
+ <item>dated-3</item>
</line>
</data>
<fields>
@@ -78,20 +84,6 @@ limitations under the License.
<name>uid</name>
<type>String</type>
</field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
- <type>String</type>
- </field>
</fields>
<attributes/>
<GUI>
@@ -120,12 +112,12 @@ limitations under the License.
<file_name_field>vcard_filename</file_name_field>
<encoding>UTF-8</encoding>
<file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
+ <name>${java.io.tmpdir}/vcard-output-0104-dated/contacts</name>
<extension>vcf</extension>
<create_parent_folder>Y</create_parent_folder>
<append>N</append>
- <add_date>N</add_date>
- <add_time>N</add_time>
+ <add_date>Y</add_date>
+ <add_time>Y</add_time>
<doNotOpenNewFileInit>Y</doNotOpenNewFileInit>
</file>
<field>
@@ -138,17 +130,7 @@ limitations under the License.
<property>uid</property>
<parameter_types/>
</field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
+ <add_to_result_filenames>N</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-date-time-in-name-verify.hpl
similarity index 50%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to
integration-tests/transforms/0104-vcard-output-date-time-in-name-verify.hpl
index b298b87658..cc611df58f 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++
b/integration-tests/transforms/0104-vcard-output-date-time-in-name-verify.hpl
@@ -19,7 +19,7 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-date-time-in-name-verify</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
@@ -31,23 +31,23 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
- <to>VCard output</to>
+ <from>contacts_yyyyMMdd_HHmmss.vcf</from>
+ <to>validate</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
- <type>DataGrid</type>
- <description/>
+ <name>contacts_yyyyMMdd_HHmmss.vcf</name>
+ <type>VCardInput</type>
+ <description>Only a name with a real date and time matches, not a
placeholder like <yyyyMMdd>.</description>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
@@ -55,44 +55,29 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <data>
- <line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
- </line>
- </data>
- <fields>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>fn</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>uid</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
- <type>String</type>
- </field>
- </fields>
+ <include_filename>N</include_filename>
+ <filename_field>vcard_filename</filename_field>
+ <ignore_empty_file>Y</ignore_empty_file>
+ <do_not_fail_if_no_file>N</do_not_fail_if_no_file>
+ <encoding>UTF-8</encoding>
+ <files>
+ <file>
+ <name>${java.io.tmpdir}/vcard-output-0104-dated</name>
+ <filemask>contacts_[0-9]{8}_[0-9]{6}\.vcf</filemask>
+ <file_required>Y</file_required>
+ <include_subfolders>N</include_subfolders>
+ </file>
+ </files>
+ <field>
+ <hop_field>fn</hop_field>
+ <property>fn</property>
+ <parameter_types/>
+ </field>
+ <field>
+ <hop_field>uid</hop_field>
+ <property>uid</property>
+ <parameter_types/>
+ </field>
<attributes/>
<GUI>
<xloc>80</xloc>
@@ -100,8 +85,8 @@ limitations under the License.
</GUI>
</transform>
<transform>
- <name>VCard output</name>
- <type>VCardOutput</type>
+ <name>validate</name>
+ <type>Dummy</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
@@ -110,45 +95,6 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <operation_type>writetofile</operation_type>
- <vcard_version>3.0</vcard_version>
- <output_field>vcard_text</output_field>
- <pass_input_fields>N</pass_input_fields>
- <add_prodid>N</add_prodid>
- <add_revision>N</add_revision>
- <file_name_in_field>N</file_name_in_field>
- <file_name_field>vcard_filename</file_name_field>
- <encoding>UTF-8</encoding>
- <file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
- <extension>vcf</extension>
- <create_parent_folder>Y</create_parent_folder>
- <append>N</append>
- <add_date>N</add_date>
- <add_time>N</add_time>
- <doNotOpenNewFileInit>Y</doNotOpenNewFileInit>
- </file>
- <field>
- <hop_field>fn</hop_field>
- <property>fn</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>uid</hop_field>
- <property>uid</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-file-name-field-generate.hpl
similarity index 73%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to
integration-tests/transforms/0104-vcard-output-file-name-field-generate.hpl
index b298b87658..71d3b1f99a 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++
b/integration-tests/transforms/0104-vcard-output-file-name-field-generate.hpl
@@ -19,9 +19,9 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-file-name-field-generate</name>
<name_sync_with_filename>Y</name_sync_with_filename>
- <description/>
+ <description>Each file keeps all of its cards, also when another file was
written to in between.</description>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
@@ -31,23 +31,23 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
+ <from>cards for two files</from>
<to>VCard output</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
+ <name>cards for two files</name>
<type>DataGrid</type>
- <description/>
+ <description>Rows alternate between a.vcf and b.vcf: both files are
written to twice.</description>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
@@ -57,10 +57,24 @@ limitations under the License.
</partitioning>
<data>
<line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
+ <item>Ann Alpha</item>
+ <item>field-a-1</item>
+ <item>${java.io.tmpdir}/vcard-output-0104-field/a.vcf</item>
+ </line>
+ <line>
+ <item>Bob Beta</item>
+ <item>field-b-1</item>
+ <item>${java.io.tmpdir}/vcard-output-0104-field/b.vcf</item>
+ </line>
+ <line>
+ <item>Cid Alpha</item>
+ <item>field-a-2</item>
+ <item>${java.io.tmpdir}/vcard-output-0104-field/a.vcf</item>
+ </line>
+ <line>
+ <item>Dee Beta</item>
+ <item>field-b-2</item>
+ <item>${java.io.tmpdir}/vcard-output-0104-field/b.vcf</item>
</line>
</data>
<fields>
@@ -82,14 +96,7 @@ limitations under the License.
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
+ <name>target</name>
<type>String</type>
</field>
</fields>
@@ -116,11 +123,11 @@ limitations under the License.
<pass_input_fields>N</pass_input_fields>
<add_prodid>N</add_prodid>
<add_revision>N</add_revision>
- <file_name_in_field>N</file_name_in_field>
- <file_name_field>vcard_filename</file_name_field>
+ <file_name_in_field>Y</file_name_in_field>
+ <file_name_field>target</file_name_field>
<encoding>UTF-8</encoding>
<file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
+ <name/>
<extension>vcf</extension>
<create_parent_folder>Y</create_parent_folder>
<append>N</append>
@@ -138,17 +145,7 @@ limitations under the License.
<property>uid</property>
<parameter_types/>
</field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
+ <add_to_result_filenames>N</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-file-name-field-verify.hpl
similarity index 53%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to
integration-tests/transforms/0104-vcard-output-file-name-field-verify.hpl
index b298b87658..1afa506de4 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++ b/integration-tests/transforms/0104-vcard-output-file-name-field-verify.hpl
@@ -19,7 +19,7 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-file-name-field-verify</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
@@ -31,22 +31,27 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
- <to>VCard output</to>
+ <from>vcard-output-0104-field</from>
+ <to>file name only</to>
+ <enabled>Y</enabled>
+ </hop>
+ <hop>
+ <from>file name only</from>
+ <to>validate</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
- <type>DataGrid</type>
+ <name>vcard-output-0104-field</name>
+ <type>VCardInput</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
@@ -55,53 +60,69 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <data>
- <line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
- </line>
- </data>
+ <include_filename>Y</include_filename>
+ <filename_field>vcard_filename</filename_field>
+ <ignore_empty_file>Y</ignore_empty_file>
+ <do_not_fail_if_no_file>N</do_not_fail_if_no_file>
+ <encoding>UTF-8</encoding>
+ <files>
+ <file>
+ <name>${java.io.tmpdir}/vcard-output-0104-field</name>
+ <filemask>.*\.vcf</filemask>
+ <file_required>Y</file_required>
+ <include_subfolders>N</include_subfolders>
+ </file>
+ </files>
+ <field>
+ <hop_field>fn</hop_field>
+ <property>fn</property>
+ <parameter_types/>
+ </field>
+ <field>
+ <hop_field>uid</hop_field>
+ <property>uid</property>
+ <parameter_types/>
+ </field>
+ <attributes/>
+ <GUI>
+ <xloc>80</xloc>
+ <yloc>64</yloc>
+ </GUI>
+ </transform>
+ <transform>
+ <name>file name only</name>
+ <type>ReplaceString</type>
+ <description>Keeps only the name of the file: the folder differs from one
machine to the next.</description>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
<fields>
<field>
- <length>-1</length>
- <precision>-1</precision>
+ <in_stream_name>vcard_filename</in_stream_name>
+ <out_stream_name/>
+ <use_regex>Y</use_regex>
+ <replace_string>^.*[/\\]</replace_string>
+ <replace_by_string/>
<set_empty_string>N</set_empty_string>
- <name>fn</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>uid</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
- <type>String</type>
+ <replace_field_by_string/>
+ <whole_word>N</whole_word>
+ <case_sensitive>N</case_sensitive>
+ <is_unicode>N</is_unicode>
</field>
</fields>
<attributes/>
<GUI>
- <xloc>80</xloc>
+ <xloc>288</xloc>
<yloc>64</yloc>
</GUI>
</transform>
<transform>
- <name>VCard output</name>
- <type>VCardOutput</type>
+ <name>validate</name>
+ <type>Dummy</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
@@ -110,48 +131,9 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
- <operation_type>writetofile</operation_type>
- <vcard_version>3.0</vcard_version>
- <output_field>vcard_text</output_field>
- <pass_input_fields>N</pass_input_fields>
- <add_prodid>N</add_prodid>
- <add_revision>N</add_revision>
- <file_name_in_field>N</file_name_in_field>
- <file_name_field>vcard_filename</file_name_field>
- <encoding>UTF-8</encoding>
- <file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
- <extension>vcf</extension>
- <create_parent_folder>Y</create_parent_folder>
- <append>N</append>
- <add_date>N</add_date>
- <add_time>N</add_time>
- <doNotOpenNewFileInit>Y</doNotOpenNewFileInit>
- </file>
- <field>
- <hop_field>fn</hop_field>
- <property>fn</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>uid</hop_field>
- <property>uid</property>
- <parameter_types/>
- </field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
<attributes/>
<GUI>
- <xloc>288</xloc>
+ <xloc>496</xloc>
<yloc>64</yloc>
</GUI>
</transform>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-generate.hpl
index b298b87658..3b6f8702ba 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++ b/integration-tests/transforms/0104-vcard-output-generate.hpl
@@ -62,6 +62,18 @@ limitations under the License.
<item>[email protected]</item>
<item>INTERNET,WORK</item>
</line>
+ <line>
+ <item>Second Card</item>
+ <item>hop-test-002</item>
+ <item>[email protected]</item>
+ <item>INTERNET,WORK</item>
+ </line>
+ <line>
+ <item>Third Card</item>
+ <item>hop-test-003</item>
+ <item>[email protected]</item>
+ <item>INTERNET,WORK</item>
+ </line>
</data>
<fields>
<field>
diff --git a/integration-tests/transforms/0104-vcard-output-generate.hpl
b/integration-tests/transforms/0104-vcard-output-no-rows.hpl
similarity index 72%
copy from integration-tests/transforms/0104-vcard-output-generate.hpl
copy to integration-tests/transforms/0104-vcard-output-no-rows.hpl
index b298b87658..4d39abdd87 100644
--- a/integration-tests/transforms/0104-vcard-output-generate.hpl
+++ b/integration-tests/transforms/0104-vcard-output-no-rows.hpl
@@ -19,9 +19,9 @@ limitations under the License.
-->
<pipeline>
<info>
- <name>0104-vcard-output-generate</name>
+ <name>0104-vcard-output-no-rows</name>
<name_sync_with_filename>Y</name_sync_with_filename>
- <description/>
+ <description>'Do not create file at start' is off: the file exists even
without rows.</description>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
@@ -31,23 +31,23 @@ limitations under the License.
<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>2026/06/12 12:00:00.000</created_date>
+ <created_date>2026/11/13 12:00:00.000</created_date>
<modified_user>-</modified_user>
- <modified_date>2026/06/12 12:00:00.000</modified_date>
+ <modified_date>2026/11/13 12:00:00.000</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
- <from>Data grid</from>
+ <from>no cards</from>
<to>VCard output</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
- <name>Data grid</name>
+ <name>no cards</name>
<type>DataGrid</type>
- <description/>
+ <description>No data: no row reaches the vCard output.</description>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
@@ -56,12 +56,6 @@ limitations under the License.
<schema_name/>
</partitioning>
<data>
- <line>
- <item>Hop Test</item>
- <item>hop-test-001</item>
- <item>[email protected]</item>
- <item>INTERNET,WORK</item>
- </line>
</data>
<fields>
<field>
@@ -78,20 +72,6 @@ limitations under the License.
<name>uid</name>
<type>String</type>
</field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email</name>
- <type>String</type>
- </field>
- <field>
- <length>-1</length>
- <precision>-1</precision>
- <set_empty_string>N</set_empty_string>
- <name>email_type</name>
- <type>String</type>
- </field>
</fields>
<attributes/>
<GUI>
@@ -120,13 +100,13 @@ limitations under the License.
<file_name_field>vcard_filename</file_name_field>
<encoding>UTF-8</encoding>
<file>
- <name>${java.io.tmpdir}/vcard-output-0104</name>
+ <name>${java.io.tmpdir}/vcard-output-0104-no-rows/contacts</name>
<extension>vcf</extension>
<create_parent_folder>Y</create_parent_folder>
<append>N</append>
<add_date>N</add_date>
<add_time>N</add_time>
- <doNotOpenNewFileInit>Y</doNotOpenNewFileInit>
+ <doNotOpenNewFileInit>N</doNotOpenNewFileInit>
</file>
<field>
<hop_field>fn</hop_field>
@@ -138,17 +118,7 @@ limitations under the License.
<property>uid</property>
<parameter_types/>
</field>
- <field>
- <hop_field>email</hop_field>
- <property>email</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <field>
- <hop_field>email_type</hop_field>
- <property>email_type</property>
- <parameter_types>INTERNET,WORK</parameter_types>
- </field>
- <add_to_result_filenames>Y</add_to_result_filenames>
+ <add_to_result_filenames>N</add_to_result_filenames>
<attributes/>
<GUI>
<xloc>288</xloc>
diff --git
a/integration-tests/transforms/datasets/golden-vcard-output-categories.csv
b/integration-tests/transforms/datasets/golden-vcard-output-categories.csv
new file mode 100644
index 0000000000..e7a602fa5e
--- /dev/null
+++ b/integration-tests/transforms/datasets/golden-vcard-output-categories.csv
@@ -0,0 +1,4 @@
+fn,uid,categories
+Hal Grouped,categories-1,"friends, work"
+Ida Plain,categories-2,
+Jon Grouped,categories-3,family
diff --git
a/integration-tests/transforms/datasets/golden-vcard-output-date-time-in-name.csv
b/integration-tests/transforms/datasets/golden-vcard-output-date-time-in-name.csv
new file mode 100644
index 0000000000..f473804866
--- /dev/null
+++
b/integration-tests/transforms/datasets/golden-vcard-output-date-time-in-name.csv
@@ -0,0 +1,4 @@
+fn,uid
+Eve Dated,dated-1
+Fay Dated,dated-2
+Gus Dated,dated-3
diff --git
a/integration-tests/transforms/datasets/golden-vcard-output-file-name-field.csv
b/integration-tests/transforms/datasets/golden-vcard-output-file-name-field.csv
new file mode 100644
index 0000000000..fdd694cd4f
--- /dev/null
+++
b/integration-tests/transforms/datasets/golden-vcard-output-file-name-field.csv
@@ -0,0 +1,5 @@
+fn,uid,vcard_filename
+Ann Alpha,field-a-1,a.vcf
+Cid Alpha,field-a-2,a.vcf
+Bob Beta,field-b-1,b.vcf
+Dee Beta,field-b-2,b.vcf
diff --git a/integration-tests/transforms/datasets/golden-vcard-output.csv
b/integration-tests/transforms/datasets/golden-vcard-output.csv
index 5ae2f61d59..c2ea50f020 100644
--- a/integration-tests/transforms/datasets/golden-vcard-output.csv
+++ b/integration-tests/transforms/datasets/golden-vcard-output.csv
@@ -1,2 +1,4 @@
fn,uid,email,email_type
Hop Test,hop-test-001,[email protected],"INTERNET,WORK"
+Second Card,hop-test-002,[email protected],"INTERNET,WORK"
+Third Card,hop-test-003,[email protected],"INTERNET,WORK"
diff --git a/integration-tests/transforms/main-0104-vcard-output-categories.hwf
b/integration-tests/transforms/main-0104-vcard-output-categories.hwf
new file mode 100644
index 0000000000..678e13840f
--- /dev/null
+++ b/integration-tests/transforms/main-0104-vcard-output-categories.hwf
@@ -0,0 +1,114 @@
+<?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>main-0104-vcard-output-categories</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/11/13 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/13 12:00:00.000</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>112</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-categories-generate</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+
<filename>${PROJECT_HOME}/0104-vcard-output-categories-generate.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>336</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-categories-verify UNIT</name>
+ <description/>
+ <type>RunPipelineTests</type>
+ <attributes/>
+ <test_names>
+ <test_name>
+ <name>0104-vcard-output-categories-verify UNIT</name>
+ </test_name>
+ </test_names>
+ <parallel>N</parallel>
+ <xloc>624</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>0104-vcard-output-categories-generate</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>0104-vcard-output-categories-generate</from>
+ <to>0104-vcard-output-categories-verify UNIT</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/transforms/main-0104-vcard-output-date-time-in-name.hwf
b/integration-tests/transforms/main-0104-vcard-output-date-time-in-name.hwf
new file mode 100644
index 0000000000..57f39d71fa
--- /dev/null
+++ b/integration-tests/transforms/main-0104-vcard-output-date-time-in-name.hwf
@@ -0,0 +1,139 @@
+<?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>main-0104-vcard-output-date-time-in-name</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/11/13 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/13 12:00:00.000</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>112</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>remove earlier output</name>
+ <description/>
+ <type>DELETE_FOLDERS</type>
+ <attributes/>
+ <arg_from_previous>N</arg_from_previous>
+ <fields>
+ <field>
+ <name>${java.io.tmpdir}/vcard-output-0104-dated</name>
+ </field>
+ </fields>
+ <limit_folders>10</limit_folders>
+ <success_condition>success_if_no_errors</success_condition>
+ <parallel>N</parallel>
+ <xloc>288</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-date-time-in-name-generate</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+
<filename>${PROJECT_HOME}/0104-vcard-output-date-time-in-name-generate.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>496</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-date-time-in-name-verify UNIT</name>
+ <description/>
+ <type>RunPipelineTests</type>
+ <attributes/>
+ <test_names>
+ <test_name>
+ <name>0104-vcard-output-date-time-in-name-verify UNIT</name>
+ </test_name>
+ </test_names>
+ <parallel>N</parallel>
+ <xloc>752</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>remove earlier output</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>remove earlier output</from>
+ <to>0104-vcard-output-date-time-in-name-generate</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0104-vcard-output-date-time-in-name-generate</from>
+ <to>0104-vcard-output-date-time-in-name-verify UNIT</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/transforms/main-0104-vcard-output-file-name-field.hwf
b/integration-tests/transforms/main-0104-vcard-output-file-name-field.hwf
new file mode 100644
index 0000000000..1afbad4dbe
--- /dev/null
+++ b/integration-tests/transforms/main-0104-vcard-output-file-name-field.hwf
@@ -0,0 +1,139 @@
+<?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>main-0104-vcard-output-file-name-field</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/11/13 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/13 12:00:00.000</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>112</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>remove earlier output</name>
+ <description/>
+ <type>DELETE_FOLDERS</type>
+ <attributes/>
+ <arg_from_previous>N</arg_from_previous>
+ <fields>
+ <field>
+ <name>${java.io.tmpdir}/vcard-output-0104-field</name>
+ </field>
+ </fields>
+ <limit_folders>10</limit_folders>
+ <success_condition>success_if_no_errors</success_condition>
+ <parallel>N</parallel>
+ <xloc>288</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-file-name-field-generate</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+
<filename>${PROJECT_HOME}/0104-vcard-output-file-name-field-generate.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>496</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-file-name-field-verify UNIT</name>
+ <description/>
+ <type>RunPipelineTests</type>
+ <attributes/>
+ <test_names>
+ <test_name>
+ <name>0104-vcard-output-file-name-field-verify UNIT</name>
+ </test_name>
+ </test_names>
+ <parallel>N</parallel>
+ <xloc>752</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>remove earlier output</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>remove earlier output</from>
+ <to>0104-vcard-output-file-name-field-generate</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0104-vcard-output-file-name-field-generate</from>
+ <to>0104-vcard-output-file-name-field-verify UNIT</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git a/integration-tests/transforms/main-0104-vcard-output-no-rows.hwf
b/integration-tests/transforms/main-0104-vcard-output-no-rows.hwf
new file mode 100644
index 0000000000..d34ed83a35
--- /dev/null
+++ b/integration-tests/transforms/main-0104-vcard-output-no-rows.hwf
@@ -0,0 +1,135 @@
+<?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>main-0104-vcard-output-no-rows</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/11/13 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/13 12:00:00.000</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>112</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>remove earlier output</name>
+ <description/>
+ <type>DELETE_FOLDERS</type>
+ <attributes/>
+ <arg_from_previous>N</arg_from_previous>
+ <fields>
+ <field>
+ <name>${java.io.tmpdir}/vcard-output-0104-no-rows</name>
+ </field>
+ </fields>
+ <limit_folders>10</limit_folders>
+ <success_condition>success_if_no_errors</success_condition>
+ <parallel>N</parallel>
+ <xloc>288</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>0104-vcard-output-no-rows</name>
+ <description/>
+ <type>PIPELINE</type>
+ <attributes/>
+ <filename>${PROJECT_HOME}/0104-vcard-output-no-rows.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>496</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>the file was created</name>
+ <description/>
+ <type>FILE_EXISTS</type>
+ <attributes/>
+
<filename>${java.io.tmpdir}/vcard-output-0104-no-rows/contacts.vcf</filename>
+ <parallel>N</parallel>
+ <xloc>720</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>remove earlier output</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>remove earlier output</from>
+ <to>0104-vcard-output-no-rows</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>0104-vcard-output-no-rows</from>
+ <to>the file was created</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/integration-tests/transforms/metadata/dataset/golden-vcard-output-categories.json
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-categories.json
new file mode 100644
index 0000000000..1137ed95ad
--- /dev/null
+++
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-categories.json
@@ -0,0 +1,32 @@
+{
+ "base_filename": "golden-vcard-output-categories.csv",
+ "name": "golden-vcard-output-categories",
+ "description": "",
+ "dataset_fields": [
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "fn",
+ "field_format": ""
+ },
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "uid",
+ "field_format": ""
+ },
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "categories",
+ "field_format": ""
+ }
+ ],
+ "folder_name": ""
+}
diff --git
a/integration-tests/transforms/metadata/dataset/golden-vcard-output-date-time-in-name.json
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-date-time-in-name.json
new file mode 100644
index 0000000000..d0bbf262e9
--- /dev/null
+++
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-date-time-in-name.json
@@ -0,0 +1,24 @@
+{
+ "base_filename": "golden-vcard-output-date-time-in-name.csv",
+ "name": "golden-vcard-output-date-time-in-name",
+ "description": "",
+ "dataset_fields": [
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "fn",
+ "field_format": ""
+ },
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "uid",
+ "field_format": ""
+ }
+ ],
+ "folder_name": ""
+}
diff --git
a/integration-tests/transforms/metadata/dataset/golden-vcard-output-file-name-field.json
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-file-name-field.json
new file mode 100644
index 0000000000..2d28f3745e
--- /dev/null
+++
b/integration-tests/transforms/metadata/dataset/golden-vcard-output-file-name-field.json
@@ -0,0 +1,32 @@
+{
+ "base_filename": "golden-vcard-output-file-name-field.csv",
+ "name": "golden-vcard-output-file-name-field",
+ "description": "",
+ "dataset_fields": [
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "fn",
+ "field_format": ""
+ },
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "uid",
+ "field_format": ""
+ },
+ {
+ "field_comment": "",
+ "field_length": -1,
+ "field_type": 2,
+ "field_precision": -1,
+ "field_name": "vcard_filename",
+ "field_format": ""
+ }
+ ],
+ "folder_name": ""
+}
diff --git
a/integration-tests/transforms/metadata/unit-test/0104-vcard-output-categories-verify
UNIT.json
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-categories-verify
UNIT.json
new file mode 100644
index 0000000000..7fb044f69f
--- /dev/null
+++
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-categories-verify
UNIT.json
@@ -0,0 +1,36 @@
+{
+ "database_replacements": [],
+ "autoOpening": true,
+ "description": "",
+ "persist_filename": "",
+ "test_type": "UNIT_TEST",
+ "variableValues": [],
+ "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+ "golden_data_sets": [
+ {
+ "field_mappings": [
+ {
+ "transform_field": "fn",
+ "data_set_field": "fn"
+ },
+ {
+ "transform_field": "uid",
+ "data_set_field": "uid"
+ },
+ {
+ "transform_field": "categories",
+ "data_set_field": "categories"
+ }
+ ],
+ "field_order": [
+ "uid"
+ ],
+ "data_set_name": "golden-vcard-output-categories",
+ "transform_name": "validate"
+ }
+ ],
+ "input_data_sets": [],
+ "name": "0104-vcard-output-categories-verify UNIT",
+ "trans_test_tweaks": [],
+ "pipeline_filename": "./0104-vcard-output-categories-verify.hpl"
+}
diff --git
a/integration-tests/transforms/metadata/unit-test/0104-vcard-output-date-time-in-name-verify
UNIT.json
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-date-time-in-name-verify
UNIT.json
new file mode 100644
index 0000000000..0d504776d5
--- /dev/null
+++
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-date-time-in-name-verify
UNIT.json
@@ -0,0 +1,32 @@
+{
+ "database_replacements": [],
+ "autoOpening": true,
+ "description": "",
+ "persist_filename": "",
+ "test_type": "UNIT_TEST",
+ "variableValues": [],
+ "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+ "golden_data_sets": [
+ {
+ "field_mappings": [
+ {
+ "transform_field": "fn",
+ "data_set_field": "fn"
+ },
+ {
+ "transform_field": "uid",
+ "data_set_field": "uid"
+ }
+ ],
+ "field_order": [
+ "uid"
+ ],
+ "data_set_name": "golden-vcard-output-date-time-in-name",
+ "transform_name": "validate"
+ }
+ ],
+ "input_data_sets": [],
+ "name": "0104-vcard-output-date-time-in-name-verify UNIT",
+ "trans_test_tweaks": [],
+ "pipeline_filename": "./0104-vcard-output-date-time-in-name-verify.hpl"
+}
diff --git
a/integration-tests/transforms/metadata/unit-test/0104-vcard-output-file-name-field-verify
UNIT.json
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-file-name-field-verify
UNIT.json
new file mode 100644
index 0000000000..86a251ded9
--- /dev/null
+++
b/integration-tests/transforms/metadata/unit-test/0104-vcard-output-file-name-field-verify
UNIT.json
@@ -0,0 +1,37 @@
+{
+ "database_replacements": [],
+ "autoOpening": true,
+ "description": "",
+ "persist_filename": "",
+ "test_type": "UNIT_TEST",
+ "variableValues": [],
+ "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+ "golden_data_sets": [
+ {
+ "field_mappings": [
+ {
+ "transform_field": "fn",
+ "data_set_field": "fn"
+ },
+ {
+ "transform_field": "uid",
+ "data_set_field": "uid"
+ },
+ {
+ "transform_field": "vcard_filename",
+ "data_set_field": "vcard_filename"
+ }
+ ],
+ "field_order": [
+ "vcard_filename",
+ "uid"
+ ],
+ "data_set_name": "golden-vcard-output-file-name-field",
+ "transform_name": "validate"
+ }
+ ],
+ "input_data_sets": [],
+ "name": "0104-vcard-output-file-name-field-verify UNIT",
+ "trans_test_tweaks": [],
+ "pipeline_filename": "./0104-vcard-output-file-name-field-verify.hpl"
+}
diff --git
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcard/VCardMapper.java
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcard/VCardMapper.java
index ea6a39314a..33f858fdf8 100644
---
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcard/VCardMapper.java
+++
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcard/VCardMapper.java
@@ -21,6 +21,7 @@ import ezvcard.VCard;
import ezvcard.VCardVersion;
import ezvcard.parameter.EmailType;
import ezvcard.parameter.TelephoneType;
+import ezvcard.property.Categories;
import ezvcard.property.Email;
import ezvcard.property.FormattedName;
import ezvcard.property.Nickname;
@@ -40,10 +41,13 @@ import java.time.Instant;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.hop.core.exception.HopException;
@@ -54,6 +58,11 @@ import org.apache.hop.core.util.Utils;
/** Converts between Hop rows and ez-vcard {@link VCard} objects. */
public final class VCardMapper {
+ /** Parsed TYPE tokens per mapping text, see {@link #typeTokens(String)}. */
+ private static final Map<String, Set<String>> TYPE_TOKENS = new
ConcurrentHashMap<>();
+
+ private static final int MAX_CACHED_TYPE_TOKENS = 1000;
+
private VCardMapper() {}
public static List<VCard> parseAll(String vcardText) throws IOException {
@@ -86,7 +95,7 @@ public final class VCardMapper {
case TITLE -> firstTitle(card);
case NOTE -> firstNote(card);
case URL -> firstUrl(card);
- case CATEGORIES -> joinList(card.getCategories().getValues());
+ case CATEGORIES -> categories(card);
case EMAIL -> emailValue(card, mapping.getParameterTypes());
case EMAIL_TYPE -> emailTypeValue(card, mapping.getParameterTypes());
case TEL -> telephoneValue(card, mapping.getParameterTypes());
@@ -168,7 +177,15 @@ public final class VCardMapper {
case TITLE -> card.addTitle(new Title(value));
case NOTE -> card.addNote(new Note(value));
case URL -> card.addUrl(new Url(value));
- case CATEGORIES ->
card.getCategories().getValues().addAll(splitList(value));
+ case CATEGORIES -> {
+ // a card has no categories property until one is set
+ Categories categories = card.getCategories();
+ if (categories == null) {
+ categories = new Categories();
+ card.setCategories(categories);
+ }
+ categories.getValues().addAll(splitList(value));
+ }
case EMAIL -> {
Email email = new Email(value);
String typeValue =
@@ -237,6 +254,11 @@ public final class VCardMapper {
return org.getValues().get(0);
}
+ private static String categories(VCard card) {
+ Categories categories = card.getCategories();
+ return categories == null ? null : joinList(categories.getValues());
+ }
+
private static String firstNote(VCard card) {
return card.getNotes().isEmpty() ? null :
card.getNotes().get(0).getValue();
}
@@ -394,10 +416,26 @@ public final class VCardMapper {
.collect(Collectors.joining(", "));
}
+ /**
+ * The upper-cased TYPE tokens of a mapping. The text comes from the
transform's mappings and is
+ * asked for with every card, so each distinct text is parsed once and the
set is kept.
+ */
private static Set<String> typeTokens(String parameterTypes) {
- return splitList(parameterTypes).stream()
- .map(s -> s.toUpperCase(Locale.ROOT))
- .collect(Collectors.toCollection(LinkedHashSet::new));
+ if (Utils.isEmpty(parameterTypes)) {
+ return Set.of();
+ }
+ Set<String> tokens = TYPE_TOKENS.get(parameterTypes);
+ if (tokens == null) {
+ tokens =
+ Collections.unmodifiableSet(
+ splitList(parameterTypes).stream()
+ .map(s -> s.toUpperCase(Locale.ROOT))
+ .collect(Collectors.toCollection(LinkedHashSet::new)));
+ if (TYPE_TOKENS.size() < MAX_CACHED_TYPE_TOKENS) {
+ TYPE_TOKENS.put(parameterTypes, tokens);
+ }
+ }
+ return tokens;
}
private static List<String> splitList(String value) {
diff --git
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettings.java
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettings.java
index aacae2d053..1fcf03b0ec 100644
---
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettings.java
+++
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettings.java
@@ -66,37 +66,41 @@ public class VCardFileSettings {
this.doNotOpenNewFileInit = other.doNotOpenNewFileInit;
}
+ /**
+ * The file name as the dialog shows it.
+ *
+ * @param showSamples true for a sample with the current date and time,
false for the name with
+ * {@code <yyyyMMdd>} and {@code <HHmmss>} where the date and time will
go
+ */
public String buildFilename(IVariables variables, boolean showSamples) {
- String realFileName = variables.resolve(fileName);
+ if (showSamples) {
+ return buildFilename(variables, new Date());
+ }
+ return buildFilename(variables, "<yyyyMMdd>", "<HHmmss>");
+ }
+
+ /**
+ * The name of the file to write.
+ *
+ * @param date the moment that goes into the name when the date or the time
is included
+ */
+ public String buildFilename(IVariables variables, Date date) {
+ return buildFilename(
+ variables,
+ new SimpleDateFormat("yyyyMMdd").format(date),
+ new SimpleDateFormat("HHmmss").format(date));
+ }
+
+ private String buildFilename(IVariables variables, String datePart, String
timePart) {
+ String filename = variables.resolve(fileName);
String realExtension = variables.resolve(extension);
- SimpleDateFormat dateFormat = new SimpleDateFormat();
- String filename = realFileName;
- Date now = new Date();
if (dateInFileName) {
- if (showSamples) {
- dateFormat.applyPattern("yyyMMdd");
- filename += "_" + dateFormat.format(now);
- } else {
- filename += "_<yyyMMdd>";
- }
- if (timeInFileName) {
- if (showSamples) {
- dateFormat.applyPattern("HHmmss");
- filename += "_" + dateFormat.format(now);
- } else {
- filename += "_<HHmmss>";
- }
- }
- } else if (timeInFileName) {
- if (showSamples) {
- dateFormat.applyPattern("HHmmss");
- filename += "_" + dateFormat.format(now);
- } else {
- filename += "_<HHmmss>";
- }
+ filename += "_" + datePart;
+ }
+ if (timeInFileName) {
+ filename += "_" + timePart;
}
-
if (!Utils.isEmpty(realExtension)) {
filename += "." + realExtension;
}
diff --git
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutput.java
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutput.java
index 3539bd83c7..82892562e1 100644
---
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutput.java
+++
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutput.java
@@ -17,10 +17,11 @@
package org.apache.hop.pipeline.transforms.vcardoutput;
import ezvcard.VCard;
+import java.io.BufferedOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.util.Date;
import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.ResultFile;
import org.apache.hop.core.exception.HopException;
@@ -39,6 +40,8 @@ public class VCardOutput extends
BaseTransform<VCardOutputMeta, VCardOutputData>
private static final Class<?> PKG = VCardOutput.class;
+ private static final int BUFFER_SIZE = 64 * 1024;
+
public VCardOutput(
TransformMeta transformMeta,
VCardOutputMeta meta,
@@ -49,10 +52,50 @@ public class VCardOutput extends
BaseTransform<VCardOutputMeta, VCardOutputData>
super(transformMeta, meta, data, copyNr, pipelineMeta, pipeline);
}
+ @Override
+ public boolean init() {
+ if (!super.init()) {
+ return false;
+ }
+ try {
+ data.charset = outputCharset();
+ if (meta.writesToFile() && !meta.isFileNameInField()) {
+ // One name for the whole run: the date and time in it are those of
the start
+ data.staticFileName =
resolve(meta.getFileSettings().buildFilename(this, new Date()));
+ if (!meta.getFileSettings().isDoNotOpenNewFileInit()
+ && !Utils.isEmpty(data.staticFileName)) {
+ // The file has to exist even when no row arrives
+ openFile(data.staticFileName);
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ logError(BaseMessages.getString(PKG,
"VCardOutput.Exception.WriteFailed", e.getMessage()), e);
+ return false;
+ }
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ closeFile();
+ } catch (Exception e) {
+ logError(BaseMessages.getString(PKG,
"VCardOutput.Exception.WriteFailed", e.getMessage()), e);
+ }
+ super.dispose();
+ }
+
@Override
public boolean processRow() throws HopException {
Object[] row = getRow();
if (row == null) {
+ // Complete the file before the next transforms are told that this one
is done
+ try {
+ closeFile();
+ } catch (IOException e) {
+ throw new HopTransformException(
+ BaseMessages.getString(PKG, "VCardOutput.Exception.WriteFailed",
e.getMessage()), e);
+ }
setOutputDone();
return false;
}
@@ -69,6 +112,9 @@ public class VCardOutput extends
BaseTransform<VCardOutputMeta, VCardOutputData>
PKG, "VCardOutput.Exception.FileNameFieldNotFound",
meta.getFileNameField()));
}
}
+ if (meta.outputsValue()) {
+ data.outputFieldIndex =
data.outputRowMeta.indexOfValue(meta.getOutputField());
+ }
}
VCard card = new VCard();
@@ -97,9 +143,8 @@ public class VCardOutput extends
BaseTransform<VCardOutputMeta, VCardOutputData>
} else {
outputRow = RowDataUtil.allocateRowData(data.outputRowMeta.size());
}
- int outputIndex = data.outputRowMeta.indexOfValue(meta.getOutputField());
- if (outputIndex >= 0) {
- outputRow[outputIndex] = vcardText;
+ if (data.outputFieldIndex >= 0) {
+ outputRow[data.outputFieldIndex] = vcardText;
}
putRow(data.outputRowMeta, outputRow);
} else if (meta.isPassInputFields() || meta.writesToFile()) {
@@ -113,37 +158,69 @@ public class VCardOutput extends
BaseTransform<VCardOutputMeta, VCardOutputData>
private void writeToFile(Object[] row, String vcardText) throws
HopTransformException {
try {
- String filename = resolveFileName(row);
- createParentFolder(filename);
- try (OutputStream out = HopVfs.getOutputStream(filename,
meta.getFileSettings().isAppend())) {
- out.write(vcardText.getBytes(outputCharset()));
- }
- if (meta.isAddingToResult()) {
- ResultFile resultFile =
- new ResultFile(
- ResultFile.FILE_TYPE_GENERAL,
- HopVfs.getFileObject(filename, this),
- getPipelineMeta().getName(),
- getTransformName());
- addResultFile(resultFile);
- }
+ openFile(resolveFileName(row));
+ data.outputStream.write(vcardText.getBytes(data.charset));
} catch (Exception e) {
throw new HopTransformException(
BaseMessages.getString(PKG, "VCardOutput.Exception.WriteFailed",
e.getMessage()), e);
}
}
+ /**
+ * Makes the given file the open one. The file stays open from row to row;
it is only closed when
+ * another file name comes along or when the transform ends.
+ *
+ * <p>The first time a run writes to a file it is created, or emptied unless
"Append" is on. A
+ * file the run wrote to before is added to, so every card of the run ends
up in it.
+ */
+ private void openFile(String filename) throws Exception {
+ if (filename.equals(data.currentFileName)) {
+ return;
+ }
+ closeFile();
+
+ boolean firstTime = data.writtenFiles.add(filename);
+ if (firstTime) {
+ createParentFolder(filename);
+ }
+ boolean append = meta.getFileSettings().isAppend() || !firstTime;
+ data.outputStream =
+ new BufferedOutputStream(HopVfs.getOutputStream(filename, append),
BUFFER_SIZE);
+ data.currentFileName = filename;
+
+ if (firstTime && meta.isAddingToResult()) {
+ ResultFile resultFile =
+ new ResultFile(
+ ResultFile.FILE_TYPE_GENERAL,
+ HopVfs.getFileObject(filename, this),
+ getPipelineMeta().getName(),
+ getTransformName());
+ addResultFile(resultFile);
+ }
+ }
+
+ private void closeFile() throws IOException {
+ if (data.outputStream != null) {
+ try {
+ data.outputStream.close();
+ } finally {
+ data.outputStream = null;
+ data.currentFileName = null;
+ }
+ }
+ }
+
private String resolveFileName(Object[] row) throws HopException {
String filename;
if (meta.isFileNameInField()) {
- filename = getInputRowMeta().getString(row, data.fileNameFieldIndex);
+ filename = resolve(getInputRowMeta().getString(row,
data.fileNameFieldIndex));
} else {
- filename = meta.getFileSettings().buildFilename(this, false);
+ filename = data.staticFileName;
}
if (Utils.isEmpty(filename)) {
throw new HopException(BaseMessages.getString(PKG,
"VCardOutput.Exception.FileNameMissing"));
}
- return resolve(filename);
+ return filename;
}
private Charset outputCharset() {
diff --git
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputData.java
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputData.java
index eaf1cea36a..f81d52db95 100644
---
a/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputData.java
+++
b/plugins/transforms/vcard/src/main/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputData.java
@@ -16,6 +16,10 @@
*/
package org.apache.hop.pipeline.transforms.vcardoutput;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.pipeline.transform.BaseTransformData;
import org.apache.hop.pipeline.transform.ITransformData;
@@ -23,4 +27,21 @@ import org.apache.hop.pipeline.transform.ITransformData;
public class VCardOutputData extends BaseTransformData implements
ITransformData {
public int fileNameFieldIndex;
public IRowMeta outputRowMeta;
+
+ /** Position of the vCard text in the output row, -1 when it is not written
to a field. */
+ public int outputFieldIndex = -1;
+
+ /** The character set of the files, resolved once. */
+ public Charset charset;
+
+ /** The file name when it does not come from a field, resolved once per run.
*/
+ public String staticFileName;
+
+ /** The file that is open now and its name. One file is open at a time. */
+ public OutputStream outputStream;
+
+ public String currentFileName;
+
+ /** Every file this run has written to: a file that comes back is added to,
not emptied. */
+ public final Set<String> writtenFiles = new HashSet<>();
}
diff --git
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcard/VCardMapperTest.java
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcard/VCardMapperTest.java
index 59a24cdc76..212781f835 100644
---
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcard/VCardMapperTest.java
+++
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcard/VCardMapperTest.java
@@ -17,12 +17,14 @@
package org.apache.hop.pipeline.transforms.vcard;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import ezvcard.VCard;
import ezvcard.VCardVersion;
import java.util.List;
import org.apache.hop.core.row.RowMeta;
+import org.apache.hop.core.row.value.ValueMetaString;
import org.junit.jupiter.api.Test;
class VCardMapperTest {
@@ -59,10 +61,10 @@ class VCardMapperTest {
@Test
void roundTripPreservesMappedFields() throws Exception {
RowMeta rowMeta = new RowMeta();
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("fn"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("uid"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("email"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("email_type"));
+ rowMeta.addValueMeta(new ValueMetaString("fn"));
+ rowMeta.addValueMeta(new ValueMetaString("uid"));
+ rowMeta.addValueMeta(new ValueMetaString("email"));
+ rowMeta.addValueMeta(new ValueMetaString("email_type"));
VCard card = new VCard();
Object[] row = {"Hop Test", "hop-test-001", "[email protected]",
"INTERNET,WORK"};
@@ -86,10 +88,10 @@ class VCardMapperTest {
@Test
void buildVCardFromRow() throws Exception {
RowMeta rowMeta = new RowMeta();
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("fn"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("uid"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("email"));
- rowMeta.addValueMeta(new
org.apache.hop.core.row.value.ValueMetaString("email_type"));
+ rowMeta.addValueMeta(new ValueMetaString("fn"));
+ rowMeta.addValueMeta(new ValueMetaString("uid"));
+ rowMeta.addValueMeta(new ValueMetaString("email"));
+ rowMeta.addValueMeta(new ValueMetaString("email_type"));
VCard card = new VCard();
Object[] row = {"Hop Test", "hop-test-001", "[email protected]",
"INTERNET,WORK"};
@@ -107,4 +109,49 @@ class VCardMapperTest {
assertTrue(text.contains("UID:hop-test-001"));
assertTrue(text.toUpperCase().contains("EMAIL;TYPE=INTERNET,WORK:[email protected]"));
}
+
+ /** Mapping a field to the categories used to fail: a new card has no
categories property. */
+ @Test
+ void categoriesAreWrittenAndReadBack() throws Exception {
+ RowMeta rowMeta = new RowMeta();
+ rowMeta.addValueMeta(new ValueMetaString("fn"));
+ rowMeta.addValueMeta(new ValueMetaString("tags"));
+ List<VCardFieldMapping> mappings =
+ List.of(
+ new VCardFieldMapping(VCardPropertyType.FN, "fn"),
+ new VCardFieldMapping(VCardPropertyType.CATEGORIES, "tags"));
+
+ VCard card = new VCard();
+ VCardMapper.applyMappings(
+ card, new Object[] {"Hop Test", "friends, work"}, rowMeta, mappings,
false, false);
+ String text = VCardMapper.write(card, VCardVersion.V3_0);
+ assertTrue(text.contains("CATEGORIES:friends,work"), text);
+
+ VCard parsed = VCardMapper.parseAll(text).get(0);
+ assertEquals("friends, work", VCardMapper.extractValue(parsed,
mappings.get(1)));
+ }
+
+ @Test
+ void aCardWithoutCategoriesGivesNoValue() throws Exception {
+ VCard card = VCardMapper.parseAll(SAMPLE).get(0);
+
+ assertNull(
+ VCardMapper.extractValue(
+ card, new VCardFieldMapping(VCardPropertyType.CATEGORIES,
"tags")));
+ }
+
+ /** The type tokens of a mapping are parsed once; the lookups keep giving
the same values. */
+ @Test
+ void typeLookupsAreStableOverManyCards() throws Exception {
+ VCard card = VCardMapper.parseAll(SAMPLE).get(0);
+ VCardFieldMapping tel = new VCardFieldMapping(VCardPropertyType.TEL,
"tel", "work, voice");
+ VCardFieldMapping fax = new VCardFieldMapping(VCardPropertyType.TEL,
"fax", "FAX");
+ VCardFieldMapping anyEmail = new
VCardFieldMapping(VCardPropertyType.EMAIL, "email");
+
+ for (int i = 0; i < 3; i++) {
+ assertEquals("+1-555-0100", VCardMapper.extractValue(card, tel));
+ assertNull(VCardMapper.extractValue(card, fax));
+ assertEquals("[email protected]", VCardMapper.extractValue(card,
anyEmail));
+ }
+ }
}
diff --git
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettingsTest.java
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettingsTest.java
index ca3afe3812..2067db2572 100644
---
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettingsTest.java
+++
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardFileSettingsTest.java
@@ -19,6 +19,9 @@ package org.apache.hop.pipeline.transforms.vcardoutput;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
import org.apache.hop.core.variables.Variables;
import org.junit.jupiter.api.Test;
@@ -33,7 +36,7 @@ class VCardFileSettingsTest {
settings.setTimeInFileName(true);
String filename = settings.buildFilename(new Variables(), false);
- assertTrue(filename.startsWith("/tmp/contact_<yyyMMdd>_<HHmmss>.vcf"));
+ assertEquals("/tmp/contact_<yyyyMMdd>_<HHmmss>.vcf", filename);
}
@Test
@@ -44,4 +47,35 @@ class VCardFileSettingsTest {
assertEquals(2, settings.getFiles(new Variables(), true).length);
}
+
+ /** The file that is written carries the date and time, not the
placeholders. */
+ @Test
+ void buildFilenameForADateUsesItsDateAndTime() {
+ VCardFileSettings settings = new VCardFileSettings();
+ settings.setFileName("/tmp/contact");
+ settings.setExtension("vcf");
+ settings.setDateInFileName(true);
+ settings.setTimeInFileName(true);
+ Date date = new GregorianCalendar(2026, Calendar.MARCH, 9, 14, 5,
7).getTime();
+
+ assertEquals("/tmp/contact_20260309_140507.vcf",
settings.buildFilename(new Variables(), date));
+
+ settings.setDateInFileName(false);
+ assertEquals("/tmp/contact_140507.vcf", settings.buildFilename(new
Variables(), date));
+
+ settings.setTimeInFileName(false);
+ settings.setExtension("");
+ assertEquals("/tmp/contact", settings.buildFilename(new Variables(),
date));
+ }
+
+ @Test
+ void theSampleNameHasNoPlaceholders() {
+ VCardFileSettings settings = new VCardFileSettings();
+ settings.setFileName("/tmp/contact");
+ settings.setDateInFileName(true);
+ settings.setTimeInFileName(true);
+
+ assertTrue(
+ settings.buildFilename(new Variables(),
true).matches("/tmp/contact_\\d{8}_\\d{6}\\.vcf"));
+ }
}
diff --git
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputTest.java
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputTest.java
index 1b01358060..81786779dd 100644
---
a/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputTest.java
+++
b/plugins/transforms/vcard/src/test/java/org/apache/hop/pipeline/transforms/vcardoutput/VCardOutputTest.java
@@ -24,6 +24,8 @@ import static org.mockito.Mockito.when;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.List;
+import java.util.stream.Stream;
import org.apache.hop.core.HopEnvironment;
import org.apache.hop.core.IRowSet;
import org.apache.hop.core.exception.HopException;
@@ -97,4 +99,161 @@ class VCardOutputTest {
assertTrue(Files.exists(outputFile));
assertTrue(Files.readString(outputFile).contains("FN:Hop Test"));
}
+
+ /** With "Append" off every row used to overwrite the file, leaving only the
last card. */
+ @Test
+ void everyCardOfARunEndsUpInTheFile(@TempDir Path tempDir) throws Exception {
+ Path outputBase = tempDir.resolve("contacts");
+ VCardOutputMeta meta = fileMeta(outputBase);
+ Path outputFile = Path.of(outputBase + ".vcf");
+ Files.writeString(outputFile, "left over from an earlier run");
+
+ run(meta, nameRows(), new Object[] {"Ann"}, new Object[] {"Bob"}, new
Object[] {"Cid"});
+
+ String content = Files.readString(outputFile);
+ assertEquals(3, count(content, "BEGIN:VCARD"));
+ assertTrue(content.contains("FN:Ann"));
+ assertTrue(content.contains("FN:Bob"));
+ assertTrue(content.contains("FN:Cid"));
+ // not appending: the earlier content is replaced
+ assertFalse(content.contains("left over"));
+ }
+
+ @Test
+ void appendKeepsWhatAnEarlierRunWrote(@TempDir Path tempDir) throws
Exception {
+ Path outputBase = tempDir.resolve("contacts");
+ VCardOutputMeta meta = fileMeta(outputBase);
+ meta.getFileSettings().setAppend(true);
+
+ run(meta, nameRows(), new Object[] {"Ann"});
+ run(meta, nameRows(), new Object[] {"Bob"}, new Object[] {"Cid"});
+
+ String content = Files.readString(Path.of(outputBase + ".vcf"));
+ assertEquals(3, count(content, "BEGIN:VCARD"));
+ assertTrue(content.indexOf("FN:Ann") < content.indexOf("FN:Bob"));
+ }
+
+ @Test
+ void aSecondRunWithoutAppendReplacesTheFile(@TempDir Path tempDir) throws
Exception {
+ Path outputBase = tempDir.resolve("contacts");
+ VCardOutputMeta meta = fileMeta(outputBase);
+
+ run(meta, nameRows(), new Object[] {"Ann"}, new Object[] {"Bob"});
+ run(meta, nameRows(), new Object[] {"Cid"});
+
+ String content = Files.readString(Path.of(outputBase + ".vcf"));
+ assertEquals(1, count(content, "BEGIN:VCARD"));
+ assertTrue(content.contains("FN:Cid"));
+ }
+
+ /** A file name that returns later in the run keeps the cards it already
has. */
+ @Test
+ void cardsFollowTheFileNameFromAField(@TempDir Path tempDir) throws
Exception {
+ String a = tempDir.resolve("a.vcf").toString();
+ String b = tempDir.resolve("b.vcf").toString();
+ VCardOutputMeta meta = fileMeta(tempDir.resolve("unused"));
+ meta.setFileNameInField(true);
+ meta.setFileNameField("file");
+
+ RowMeta rowMeta = nameRows();
+ rowMeta.addValueMeta(new ValueMetaString("file"));
+ VCardOutput transform =
+ run(
+ meta,
+ rowMeta,
+ new Object[] {"Ann", a},
+ new Object[] {"Bob", b},
+ new Object[] {"Cid", a},
+ new Object[] {"Dee", a});
+
+ String contentA = Files.readString(Path.of(a));
+ assertEquals(3, count(contentA, "BEGIN:VCARD"));
+ assertTrue(contentA.contains("FN:Ann"));
+ assertTrue(contentA.contains("FN:Cid"));
+ assertTrue(contentA.contains("FN:Dee"));
+ String contentB = Files.readString(Path.of(b));
+ assertEquals(1, count(contentB, "BEGIN:VCARD"));
+ assertTrue(contentB.contains("FN:Bob"));
+ // each file is in the result once, however many cards it got
+ assertEquals(2, transform.getResultFiles().size());
+ }
+
+ @Test
+ void theDateAndTimeInTheFileNameAreDigits(@TempDir Path tempDir) throws
Exception {
+ VCardOutputMeta meta = fileMeta(tempDir.resolve("contacts"));
+ meta.getFileSettings().setDateInFileName(true);
+ meta.getFileSettings().setTimeInFileName(true);
+
+ run(meta, nameRows(), new Object[] {"Ann"}, new Object[] {"Bob"});
+
+ try (Stream<Path> files = Files.list(tempDir)) {
+ List<String> names = files.map(p -> p.getFileName().toString()).toList();
+ assertEquals(1, names.size(), names.toString());
+ assertTrue(names.get(0).matches("contacts_\\d{8}_\\d{6}\\.vcf"),
names.toString());
+ }
+ }
+
+ @Test
+ void theFileIsCreatedAtStartOnlyWhenAskedFor(@TempDir Path tempDir) throws
Exception {
+ VCardOutputMeta notAtStart = fileMeta(tempDir.resolve("later"));
+ run(notAtStart, nameRows());
+ assertFalse(Files.exists(tempDir.resolve("later.vcf")));
+
+ VCardOutputMeta atStart = fileMeta(tempDir.resolve("empty"));
+ atStart.getFileSettings().setDoNotOpenNewFileInit(false);
+ run(atStart, nameRows());
+ assertTrue(Files.exists(tempDir.resolve("empty.vcf")));
+ assertEquals(0, Files.size(tempDir.resolve("empty.vcf")));
+ }
+
+ private static VCardOutputMeta fileMeta(Path outputBase) {
+ VCardOutputMeta meta = new VCardOutputMeta();
+ meta.setOperationType(VCardOutputMeta.OperationType.WRITE_TO_FILE);
+ meta.setPassInputFields(false);
+ meta.setAddProdId(false);
+ meta.setAddRevision(false);
+ meta.setFileNameInField(false);
+ meta.getFileSettings().setFileName(outputBase.toAbsolutePath().toString());
+ meta.getFieldMappings().add(new VCardFieldMapping(VCardPropertyType.FN,
"fn"));
+ return meta;
+ }
+
+ private static RowMeta nameRows() {
+ RowMeta rowMeta = new RowMeta();
+ rowMeta.addValueMeta(new ValueMetaString("fn"));
+ return rowMeta;
+ }
+
+ /** Runs the transform over the rows, from init to dispose. */
+ private VCardOutput run(VCardOutputMeta meta, RowMeta rowMeta, Object[]...
rows)
+ throws Exception {
+ IRowSet rowSet = mockHelper.getMockInputRowSet(rows);
+ when(rowSet.getRowMeta()).thenReturn(rowMeta);
+
+ VCardOutput transform =
+ new VCardOutput(
+ mockHelper.transformMeta,
+ meta,
+ new VCardOutputData(),
+ 0,
+ mockHelper.pipelineMeta,
+ mockHelper.pipeline);
+ transform.addRowSetToInputRowSets(rowSet);
+
+ assertTrue(transform.init());
+ for (int i = 0; i < rows.length; i++) {
+ assertTrue(transform.processRow());
+ }
+ assertFalse(transform.processRow());
+ transform.dispose();
+ return transform;
+ }
+
+ private static int count(String text, String part) {
+ int count = 0;
+ for (int at = text.indexOf(part); at >= 0; at = text.indexOf(part, at +
part.length())) {
+ count++;
+ }
+ return count;
+ }
}