2014-09-25

How to Specify List Name through Custom Transformer Parameter

In many existing transformers, users can specify name of list attribute that will be created by the transformer. e.g. ListBuilder, AttributeSplitter, StringSearcher etc.
As far as I know, the ListRenamer is the only way to add an interface to a custom transformer, so that users can specify list name, like the existing transformers.

Custom transformer implementation:
1) Create a published user parameter to receive list name specified by the user.
2) Add a ListRenamer to rename a target list to the parameter value.













Then, users can specify the list name through the parameter.
FME 2014 SP3 build 14391








=====
2014-09-30: This is a workspace that contains a custom transformer example which renames attribute/list based on parameter values specified by the user. FME 2014 SP3+
MyRenamer_FME2014.fmw
=====

In FME 2015 beta build 15179, such a custom transformer created with FME 2014 works fine to rename list, but the default name ("_list" in this example) is always visible in the Main Canvas.
FME 2015 Beta build 15179









Result of the translation is fine, but the GUI is not fun...

And also, I found that much enhancements have been done for the ListRenamer itself in FME 2015 beta. All the enhancements are great, but a user parameter cannot be used as new list name, at least in build 15179.
I hope one more enhancement for that, if possible.

=====
2014-11-13: I found another trick by chance in the implementation of the StringMultiSearcher (FME Store transformer). This screenshot illustrates the essence of the trick.













Transformers in the Bookmark expose list names specified by Published Parameters named "listName1" and "listName2" (default values are "_list1" and "_list2"). ​They do nothing other than the exposing; actual list attributes will be created by the PythonCaller.
The upper stream in the Bookmark exposes a structured list name:
$(listName1){}.sub1
$(listName1){}.sub2
The lower stream exposes a simple list name:
$(listName2){}
There are no inputs for the streams, it looks too strange but worked fine as expected in both FME 2014 SP4 build 14433 and FME 2015 Beta build 15210.

In addition, I tried using ListBuilders instead of the Aggregators so that the AttributeRemover_2 can be removed.
FME 2014: It worked fine with no problems.
FME 2015: It also worked fine but the default list names have appeared again in the interface of the custom transformer...orz
I'm not sure what has caused the difference.
Stop the investigation here in order not to fall into the FME darkness.

2 comments:

  1. Thanks for sharing this- nice stuff! Keep up the Excellent work, we look forward to reading more from you in the future! Custom Transformer | Current Transformer

    ReplyDelete
    Replies
    1. Thanks for your visiting. Yes, I'll keep up this blog!

      Delete