I have a dataset containing highway defects that I want to fanout to separate layers for potholes, blocked drains, etc. However there is no attribute which can immediately be used for fanout. The information required for fanout is part of the value of one of the attributes, but the whole value is not always the same e.g. "aaaa Pothole xyz", "bbbb Pothole abc", etc.
I have used a TestFilter to create output ports for different defect types e.g. If "@value(fieldname) CONTAINS Pothole" then output through "Pothole" port,
If "@value(fieldname) CONTAINS Blocked Drain" then output through "Blocked Drain" port. I then realised what I wanted to do was pick up the output port name somehow and use that to fanout out the data (e.g. in the writer set the table name to something like "highway_defects_@value(output_port_name)".
I could have a separate writer for each defect type, but the solution I'm going with at the moment is creating a DefectType attribute before the TestFilter, then having an AttributeCreator attached to each output port from the TestFilter and setting the DefectType value accordingly. Then everything goes to one writer which sets the table name to highway_defects_@value(DefectType).
If anyone has any better ideas, I'd be interested to hear them. Maybe TestFilter is the wrong starting point?