forked from apache/hop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
286 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
integration-tests/transforms/0069-user-defined-java-class-basic.hpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<pipeline> | ||
<info> | ||
<name>0069-user-java-class-basic</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>2023/03/08 14:23:12.586</created_date> | ||
<modified_user>-</modified_user> | ||
<modified_date>2023/03/08 14:23:12.586</modified_date> | ||
</info> | ||
<notepads> | ||
</notepads> | ||
<order> | ||
<hop> | ||
<from>sample data</from> | ||
<to>User defined Java class</to> | ||
<enabled>Y</enabled> | ||
</hop> | ||
</order> | ||
<transform> | ||
<name>User defined Java class</name> | ||
<type>UserDefinedJavaClass</type> | ||
<description/> | ||
<distribute>Y</distribute> | ||
<custom_distribution/> | ||
<copies>1</copies> | ||
<partitioning> | ||
<method>none</method> | ||
<schema_name/> | ||
</partitioning> | ||
<definitions> | ||
<definition> | ||
<class_type>TRANSFORM_CLASS</class_type> | ||
<class_name>Processor</class_name> | ||
<class_source>import java.util.function.Function; | ||
|
||
public class UpperCase implements Function { | ||
public Object apply( Object obj ) { | ||
if ( obj==null ) return null; | ||
String upper = obj.toString().toUpperCase(); | ||
return upper; | ||
} | ||
} | ||
|
||
|
||
// Perform the equivalent of processing one row. | ||
public boolean processRow() throws HopException { | ||
|
||
Object[] row = getRow(); | ||
|
||
// Return false when finished processing input rows. | ||
if ( row == null ) { | ||
setOutputDone(); | ||
return false; | ||
} | ||
|
||
// Get the output row | ||
Object[] outputRowData = RowDataUtil.createResizedCopy( row, data.outputRowMeta.size() ); | ||
String string = get( Fields.In, "VALUE" ).getString( row ); | ||
|
||
UpperCase method = new UpperCase(); | ||
|
||
get(Fields.Out, "VALUE").setValue( row, method.apply(string)); | ||
|
||
putRow( data.outputRowMeta, row ); | ||
|
||
// Return true to represent we have not finsh processing all of the input rows | ||
return true; | ||
|
||
} | ||
|
||
</class_source> | ||
</definition> | ||
</definitions> | ||
<fields> | ||
</fields> | ||
<clear_result_fields>N</clear_result_fields> | ||
<info_transforms/> | ||
<target_transforms/> | ||
<usage_parameters/> | ||
<attributes/> | ||
<GUI> | ||
<xloc>320</xloc> | ||
<yloc>96</yloc> | ||
</GUI> | ||
</transform> | ||
<transform> | ||
<name>sample data</name> | ||
<type>DataGrid</type> | ||
<description/> | ||
<distribute>Y</distribute> | ||
<custom_distribution/> | ||
<copies>1</copies> | ||
<partitioning> | ||
<method>none</method> | ||
<schema_name/> | ||
</partitioning> | ||
<data> | ||
<line> | ||
<item>aaaaaa</item> | ||
</line> | ||
<line> | ||
<item>cc ddd</item> | ||
</line> | ||
<line> | ||
<item/> | ||
</line> | ||
<line> | ||
<item>This string is too long</item> | ||
</line> | ||
<line> | ||
<item>short</item> | ||
</line> | ||
<line> | ||
<item> not trimmed </item> | ||
</line> | ||
<line> | ||
<item>gggggg</item> | ||
</line> | ||
<line> | ||
<item>COM comment</item> | ||
</line> | ||
<line> | ||
<item>special end END</item> | ||
</line> | ||
<line> | ||
<item>non-alpha "</item> | ||
</line> | ||
<line> | ||
<item>zzzzzzz</item> | ||
</line> | ||
</data> | ||
<fields> | ||
<field> | ||
<length>-1</length> | ||
<precision>-1</precision> | ||
<set_empty_string>N</set_empty_string> | ||
<name>VALUE</name> | ||
<type>String</type> | ||
</field> | ||
</fields> | ||
<attributes/> | ||
<GUI> | ||
<xloc>128</xloc> | ||
<yloc>96</yloc> | ||
</GUI> | ||
</transform> | ||
<transform_error_handling> | ||
</transform_error_handling> | ||
<attributes/> | ||
</pipeline> |
125 changes: 125 additions & 0 deletions
125
integration-tests/transforms/main-0069-user-defined-java-class.hwf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?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-0069-user-defined-java-class</name> | ||
<name_sync_with_filename>Y</name_sync_with_filename> | ||
<description/> | ||
<extended_description/> | ||
<workflow_version/> | ||
<created_user>-</created_user> | ||
<created_date>2023/05/13 09:44:37.641</created_date> | ||
<modified_user>-</modified_user> | ||
<modified_date>2023/05/13 09:44:37.641</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>50</xloc> | ||
<yloc>50</yloc> | ||
<attributes_hac/> | ||
</action> | ||
<action> | ||
<name>0069-user-defined-java-class-basic.hpl</name> | ||
<description/> | ||
<type>PIPELINE</type> | ||
<attributes/> | ||
<add_date>N</add_date> | ||
<add_time>N</add_time> | ||
<clear_files>N</clear_files> | ||
<clear_rows>N</clear_rows> | ||
<create_parent_folder>N</create_parent_folder> | ||
<exec_per_row>N</exec_per_row> | ||
<filename>${PROJECT_HOME}/0069-user-defined-java-class-basic.hpl</filename> | ||
<loglevel>Basic</loglevel> | ||
<parameters> | ||
<pass_all_parameters>Y</pass_all_parameters> | ||
</parameters> | ||
<params_from_previous>N</params_from_previous> | ||
<run_configuration>local</run_configuration> | ||
<set_append_logfile>N</set_append_logfile> | ||
<set_logfile>N</set_logfile> | ||
<wait_until_finished>Y</wait_until_finished> | ||
<parallel>N</parallel> | ||
<xloc>336</xloc> | ||
<yloc>48</yloc> | ||
<attributes_hac/> | ||
</action> | ||
<action> | ||
<name>not ok</name> | ||
<description/> | ||
<type>ABORT</type> | ||
<attributes/> | ||
<always_log_rows>N</always_log_rows> | ||
<parallel>N</parallel> | ||
<xloc>336</xloc> | ||
<yloc>160</yloc> | ||
<attributes_hac/> | ||
</action> | ||
<action> | ||
<name>ok</name> | ||
<description/> | ||
<type>DUMMY</type> | ||
<attributes/> | ||
<parallel>N</parallel> | ||
<xloc>592</xloc> | ||
<yloc>48</yloc> | ||
<attributes_hac/> | ||
</action> | ||
</actions> | ||
<hops> | ||
<hop> | ||
<from>Start</from> | ||
<to>0069-user-defined-java-class-basic.hpl</to> | ||
<enabled>Y</enabled> | ||
<evaluation>Y</evaluation> | ||
<unconditional>Y</unconditional> | ||
</hop> | ||
<hop> | ||
<from>0069-user-defined-java-class-basic.hpl</from> | ||
<to>not ok</to> | ||
<enabled>Y</enabled> | ||
<evaluation>N</evaluation> | ||
<unconditional>N</unconditional> | ||
</hop> | ||
<hop> | ||
<from>0069-user-defined-java-class-basic.hpl</from> | ||
<to>ok</to> | ||
<enabled>Y</enabled> | ||
<evaluation>Y</evaluation> | ||
<unconditional>N</unconditional> | ||
</hop> | ||
</hops> | ||
<notepads> | ||
</notepads> | ||
<attributes/> | ||
</workflow> |