Skip to main content

I'm trying to create a re-usable template that uses a dynamic reader to allow it to read a table from a database, the 'connection', 'feature types to read' and 'where clause' attributes would be defined before the reader but this approach seems to be causing me problems.

 

The process so far looks like this...

Dynamic feature reader test 

The FeatureReader looks like this...

Dynamic feature reader testIf I define the connection, table and where parameters within the feature reader everything works fine, the reader recognises the schema and creates an appropriate output port. Using the above approach and defining the same parameters as attributes doesn't create a output port (which I understand as how can it create a port for a feature type it hasn't read yet), next stop was the generic port but I can't seem to get anything useable out of this.

 

I've read numerous articles on here about using a feature merger to merge the schema and the generic ports but this doesn't seem to give me anything useable either. I've also tried an attribute exploder on the generic port from which does expose the schema and data but not in the format I would have expected.

 

Does anybody know of a way to make the feature reader act in the same way as it does when the parameters are hardcoded, that is, I end up with the data (tabular and geographic) presented in an expected schema?

 

It looks like I've mostly solved this, maybe writing out this question focussed my mind a little more!

 

The trick seemed to be to include both the schema feature and the generic feature from the feature reader in the output, when properly configured in the feature writer it reads the schema feature and outputs it as expected with both geometry and attributes present.

 

This is the revised version...

dynamic schema test revised 

The feature writer is setup like this...

dynamic schema test feature writerThe only downsides I can see now are:

  • I'm unable to carry out any further transformations on the data between the feature reader and the writer, for example, use an attribute manager as the attributes with the schema don't seem to exist at this point?
  • The only way I could seem to get my configuration attributes through to the feature writer (to use for the dataset and table name parameters) was to set the accumulation mode in the feature reader to 'merge initiator and result', this has the unfortunate side effect of including all of the configuration attributes into the resulting data set

 

Looking at the bigger picture this is only part of what I'm trying to create which is a standardised method of accessing data that would also include additional steps for source validation, for example, check that the database and table actually exist, and custom logging, for example, if the table doesn't exist then write a custom log (in easy to understand language) that lets the user know.

 

It could be that I'm trying to create a monster that isn't actually worth the time but getting there is teaching me more about FME which can't be a bad thing 😀


Reply