Solved

Receive Server Workspace parameters as json


Badge

I have to create a workspace that runs a not-predefined number of copy/conversion jobs and at the end send back a REST-call with a json body to signal success or failure.

The sending party wants to submit a json structure in the form

{
  portalid = 4711,
  source = 'config',
  target = 'qs',
  tables = [
    'gsm.viertel',
'rgu.abfallanlagen',
'plan.gruen_poly'
  ],
  raster = [
'flaechennutzungsplan.tif'
  ]
}

with variable numbers of tables and rasters, and my workspace has to

* receive,

* parse,

* run the tasks

and collect the information on the subprocesses.

While I know how to submit the single jobs through FMEServerJobSubmitter, I have no idea of how to realise especially the receiving part. 

When the json request body has arrived in the workspace, I guess the JSONFlattener will be the Transformer to use in order to get at the different parameter, and probably a list exploder to extract the list of tables.

Any support, especially a hint where this is described in the documentation, will be greatly appreciated.

icon

Best answer by takashi 10 May 2018, 00:28

View original

8 replies

Badge
OK - got one step further:

 

https://knowledge.safe.com/articles/1293/data-loading-with-fme-server.html

 

seems to cover at least a bigger part of what I need to know

 

 

 

Badge

Ok, some steps further I have this:

0684Q00000ArLjkQAF.png

Which gets submitted to the server and called through curl with the json data from the opening message. The logger writes those lines in the log:

Attribute(64 bit integer): `po_portalid' has value `4711'
Attribute(encoded: UTF-8)         : `po_raster{0}' has value `flaechennutzungsplan.tif'
Attribute(encoded: UTF-8)         : `po_source' has value `config'
Attribute(encoded: UTF-8)         : `po_tables{0}' has value `gsm.viertel'
Attribute(encoded: UTF-8)         : `po_tables{1}' has value `rgu.abfallanlagen'
Attribute(encoded: UTF-8)         : `po_tables{2}' has value `plan.gruen_poly'
Attribute(encoded: UTF-8)         : `po_target' has value `qs'
Attribute(string)                 : `text_line_data' has value 
`{"portalid":4711,"source":"config","target":"qs","tables":["gsm.viertel","rgu.abfallanlagen","plan.gruen_poly"],"raster":["flaechennutzungsplan.tif"]}'

This is correct - there are lists for tables and raster as it was submitted in the json-body of the request.

The point where I am struggling now is how to feed those list values into a  ServerJobSubmitter that will do the processing for each list entry?

Userlevel 2
Badge +17

Expose required attribute names including the list names ("po_raster{}" and "po_tables{}") via the Attributes to Expose parameter in the JSONFlattener. You can then assign desired attributes to published parameters of the workspace through the FMEServerJobSubmitter. A list element can be specified with an index - e.g. "po_tables{1}".

Badge

Ok, got it that far - your answers confirmed what I had assumed.

receivepost.fmw is the workspace.

The job log shows this:

i.e. the child workspace gets only called once, and unfortunately without set parameter.

I guess its the way I set the parameter in the JobSubmitter - the list doesn't get expanded.

What I need is that the job submitter gets called for every entry in the list. The number of entries can not be defined beforehand, but varies from call to call.

Userlevel 2
Badge +17

Ok, got it that far - your answers confirmed what I had assumed.

receivepost.fmw is the workspace.

The job log shows this:

i.e. the child workspace gets only called once, and unfortunately without set parameter.

I guess its the way I set the parameter in the JobSubmitter - the list doesn't get expanded.

What I need is that the job submitter gets called for every entry in the list. The number of entries can not be defined beforehand, but varies from call to call.

If you need to submit the job for each element of the "po_tables{}" list, consider using the ListExploder to explode the feature.

 

 

Badge
If you need to submit the job for each element of the "po_tables{}" list, consider using the ListExploder to explode the feature.

 

 

Yes, @takashi, but how?

 

 

The dropdown does not offer 'po_tables' and I did not find a way to enter that into the red text field

 

 

,
Userlevel 2
Badge +17
If you need to submit the job for each element of the "po_tables{}" list, consider using the ListExploder to explode the feature.

 

 

Please reread my first answer: "Expose required attribute names including the list names ("po_raster{}" and "po_tables{}") via the Attributes to Expose parameter in the JSONFlattener."

 

 

Badge
Please reread my first answer: "Expose required attribute names including the list names ("po_raster{}" and "po_tables{}") via the Attributes to Expose parameter in the JSONFlattener."

 

 

Thanks million, @takashi - I had overlooked those curly braces. Now it seems to work.

 

Reply