Question

using a prefetch query to populate a list parameter

  • 6 November 2017
  • 4 replies
  • 4 views

Badge +4

Hi,

I don't think this is possible but would be glad to be proved wrong. Can anyone think of a way to populate a list parameter from the result of an oracle query. I have an oracle schema where users can add tables. At run time I want the user to be able to select two tables from a drop down list and use those. Each time the workspace is run these table names would be different.


4 replies

Userlevel 5

It's not something that's supported out of the box.

But if you're a bit crafty and know your way around Python, it's possible to use a PythonCaller or a PythonCreator to display a dynamic dialog with lists populated from e.g. Oracle (e.g. using the cx_oracle module) and use those values later on in your translation. The difference will be that it won't be based on Published Parameters, but rather on feature attributes that you're manually requesting from the user at runtime.

For the GUI, you can use the built-in modules tkinter or ctypes, or you could look into using third-party modules like wxPython or PyQt for more advanced capabilities.

Here's a very simple example using a PythonCaller and ctypes that displays a dialog and waits for the user to press a button before either continuing or cancelling the workspace:

import fmeobjectsimport ctypesdef WaitForOk(feature):    message = "Hello workspace user.
Do you want to continue?"    res = ctypes.windll.user32.MessageBoxA(0, message, "My dialog title", 1)    if res == 1:        feature.setAttribute("CONTINUE_WORKSPACE", 1)    else:        feature.setAttribute("CONTINUE_WORKSPACE", 0)

In this example, I use a Tester after the PythonCaller to check the value of attribute CONTINUE_WORKSPACE before continuing or aborting.

waitforok.fmwt

Badge +4

It's not something that's supported out of the box.

But if you're a bit crafty and know your way around Python, it's possible to use a PythonCaller or a PythonCreator to display a dynamic dialog with lists populated from e.g. Oracle (e.g. using the cx_oracle module) and use those values later on in your translation. The difference will be that it won't be based on Published Parameters, but rather on feature attributes that you're manually requesting from the user at runtime.

For the GUI, you can use the built-in modules tkinter or ctypes, or you could look into using third-party modules like wxPython or PyQt for more advanced capabilities.

Here's a very simple example using a PythonCaller and ctypes that displays a dialog and waits for the user to press a button before either continuing or cancelling the workspace:

import fmeobjectsimport ctypesdef WaitForOk(feature):    message = "Hello workspace user.
Do you want to continue?"    res = ctypes.windll.user32.MessageBoxA(0, message, "My dialog title", 1)    if res == 1:        feature.setAttribute("CONTINUE_WORKSPACE", 1)    else:        feature.setAttribute("CONTINUE_WORKSPACE", 0)

In this example, I use a Tester after the PythonCaller to check the value of attribute CONTINUE_WORKSPACE before continuing or aborting.

waitforok.fmwt

Thanks David that is a great help. Just looking into it now :)

 

 

Badge +4

It's not something that's supported out of the box.

But if you're a bit crafty and know your way around Python, it's possible to use a PythonCaller or a PythonCreator to display a dynamic dialog with lists populated from e.g. Oracle (e.g. using the cx_oracle module) and use those values later on in your translation. The difference will be that it won't be based on Published Parameters, but rather on feature attributes that you're manually requesting from the user at runtime.

For the GUI, you can use the built-in modules tkinter or ctypes, or you could look into using third-party modules like wxPython or PyQt for more advanced capabilities.

Here's a very simple example using a PythonCaller and ctypes that displays a dialog and waits for the user to press a button before either continuing or cancelling the workspace:

import fmeobjectsimport ctypesdef WaitForOk(feature):    message = "Hello workspace user.
Do you want to continue?"    res = ctypes.windll.user32.MessageBoxA(0, message, "My dialog title", 1)    if res == 1:        feature.setAttribute("CONTINUE_WORKSPACE", 1)    else:        feature.setAttribute("CONTINUE_WORKSPACE", 0)

In this example, I use a Tester after the PythonCaller to check the value of attribute CONTINUE_WORKSPACE before continuing or aborting.

waitforok.fmwt

Hi David,

 

 

Apologies i'm a newbie in this area...

 

 

I've been experimenting with Tkinter but when running this produces an error in the workspace: 

 

 

Python Exception <TclError>: Can't find a usable init.tcl in the following directories: 

 


    {C:/Program Files/FME2017/fmepython27/lib/tcl8.5} {C:/Program Files/lib/tcl8.5} C:/lib/tcl8.5 {C:/Program Files/library} C:/library C:/tcl8.5.15/library C:/tcl8.5.15/library

 




This probably means that Tcl wasn't installed properly.

Can Tkinter be run nativly in the workspace or does it need to be used in a wrapper?  

 

Do you have any examples of this?

 

 

Many Thanks

 

 

Alex

 

 

Userlevel 5

I suspect that Tkinter isn't included in the somewhat stripped version of Python that's installed with FME.

You'll probably have to download and install a full Python distribution from e.g. python.org and tell FME to use it. See here for more information: https://knowledge.safe.com/articles/814/choosing-a-different-python-interpreter-installati.html

Reply