Skip to main content

Hello, 

I am currently using a feature type reader with the Merge Feature Type filter * - wilcard to load a reader from command line, ex:

 

 

--folder all --data fullcoverage (the path formed with publish params: C:\\all\\fullcoverage\\area.shp

What I would like to do, is to allow a user to choose between a default reader (let's say, the YES choice, which would be the above example) or to allow him to insert a completely new path (the NO option). So, if the choice is YES, it will take him on a branch, if the choice is NO, on a different branch.

It should work somehow like this:

"--choice yes" -> would load the default reader C:\\all\\fullcoverage\\area.shp

"--choice no" (should require the "--path" param where the user could indicate the path for a completely different shapefile) which should create a reader like C:\\cities\\test\\dummy.shp if the command is:

"--choice no --path C:\\cities\\test\\dummy.shp"

I hope I stated the problem clearly enough. The above examples are just to state the issue, so any other path could work as well.

Hi Robert,

 

 

you might want to consider replacing your regular readers with a Creator that does that path processing (business logic) and routes the trigger feature to one or several FeatureReaders to do the actual reading later on.

 

 

Another option would be to create a wrapper workspace and use a WorkspaceRunner. It could pass on the necessary parameters based on the tests done in the wrapper workspace.

 

 

David
Hi,

 

 

back to the first David's suggestion to your previous question, using a scripted private parameter also could be an alternative solution. For example: 1) Define published parameters - 'choice' (yes / no) and 'path'. 2) Define a scripted (Python) private parameter e.g. 'src_path', specify the Value like: ----- src = 'C:\\\\all\\\\fullcoverage\\\\area.shp' if FME_MacroValuesu'choice'] == 'no':     src = FME_MacroValuesa'path'] return src ----- 3) Set the 'Merged Feature Type' option of the SHP reader on, and link the 'Source Esri Shape File(s)' parameter of the reader to 'src_path'.

 

  Scripted (Tcl) Parameter also would be available, but I'm not familiar with the TCL language, so I cannot provide any example.

 

 

Takashi

Hello all, 

I will try out both as I want to learn FME as best as I can. 

Thank you Takashi for the code sample. It is very useful as I am new to Python.

Is it possible to modify the variable in the background based on user Input? If the user's input is ---city 06 I would like the $city variable to take the value 06_Fresno. I have an excel table with the corresponding values for each number. I managed to import the file but that's as far as I got.


Hi Robert,

 

 

it is not possible to change the value of user parameters while the workspace is running.

 

 

David

I managed to solve the choise thing but a problem appeared. Now, it does not read the path correctly where I have "\\county\\town| I get "\\county  own"

It reads \\t as a special character I guess. 

I used the python code provided below. I tried to escape the \\t but It did not work.

'C:\\$(state)\\$(county)\\town_$(state)$(ctcounty).shp'

i get:

'C:\\ny\\schenectady  own_nyschenectady.shp'

 


Solved!

Thanks guys!


Hi Robert,

 

 

> Is it possible to modify the variable in the background based on user Input?   It's impossible but the similar work could be possible through creating another workspace, in which you can create preferable parameter values based on user input and the Excel table, and pass those to the main workspace through a WorkspaceRunner.

 

 

Takashi

Hello Takashi,

Ok, will do. The workspace is up and running, I am quite satisfied with the outcome.

The only thing I do not like is that I have many variables and one of them could be deduced from the other.

I think I am going to look over the workspace runner advice you gave me to further enhance the .fmw file.


Reply