Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Mapping/Joining of data from main to with a web service/rest/tjavaflex

I have a use case that I cannot figure out how to resolve.  
You have a main flow of data, coming from a RestRequest component.  This has data that needs to decorated with data from a RestClient call, with the results merged together so the main flow will now have the results for the RestRequest and RestClient together.  I know how to do this with SQL tables and flatfiles, but this case is more dynamic.
tRestRequest  (main flow, schema id=1, value="blah") -> call rest service and join results to flow (main flow, schema id=1, value="blah", restcallResults = "foobar") -> continue on so that I now have access to all these values in the schema.
I tried using a tMap component, using a RestClient as a lookup flow, but couldn't get this to work.  Not sure how to achieve this.
I also tried using a tJavaFlex component, but I cannot figure out how I can get the lookup column value from the main flow so that I can "force" a match.  
For example if the main flow is row1 and it has an id field which is used for lookup.  The tJavaFlex lookup is row2.  If I hard code this in the tJavaFlex I get a match:
row2.id = "1";  //row1.id is "1"
But I don't know how to dynamically get the value of row1 (its not available in the JavaFlex component).  Is there a way to get the look value here?
Labels (4)
5 Replies
vapukov
Master II
Master II

Hi Scott,

if You need help or suggestions - could You make description little more strait? (extremely hard to understand - what is the goal and what is the problem)

also great idea - attach picture of You current Job (with errors it not a problem) and it will be more easy - go thru the picture and found solution
Anonymous
Not applicable
Author

Simple scenario just to test the concept:  join data from a javaflex component to the main flow using Map:



FixFlow has 1 row with schema of one field "id".  It has a value of "1".




Now, I want to "lookup" data from a JavaFlex component and join it with the main flow.  So that the output from the map has the "id=1" and "value=foo" (where "value" comes from the JavaFlex component):



I need to use the = the "row1.id" in the JavaFlex component to get a match so that the values are joined in the Map component, but row1 is not available in the JavaFlex component:
0683p000009MG0I.png 0683p000009MG0N.png
0683p000009MG0S.png 0683p000009MG0X.png

Is there a way to get the value that is being uses as the lookup key in the JavaFlex component?

We are evaluating your product for use at my job, but if we cannot join data to main flow from JavaFlex or RestClient then it is a no go
vapukov
Master II
Master II

[font=Verdana, Helvetica, Arial, sans-serif] Hi Scott[/font]

We are evaluating your product for use at my job, but if we cannot join data to main flow from JavaFlex or RestClient then it is a no go


if exclude Sabrina and Shong - all other there already users, so for us ... it not so very important did You go or not 0683p000009MA9p.png
But we are ready to help and happy to make community bigger

short answer (for wrong question) - not, You can not use row1 in component, especial compare output (feature column) with outside column - this is never possible
but it not mean You are can not achieve Your real goals:
As You can know - any task could have a lot of solutions, 
for this reason better to understand what You are try to create? from where You plan take data in tJavaFlex? it will generate them? How?

[list=1]
  • did You try filters in tMap? 

  • did You try JOIN in tMap with real data flow?


  • 0683p000009MG0c.png
    If I will need I can add filter for reject empty rows and etc

    0683p000009MG0h.png
    0683p000009MG0m.png

    and how it look in real work, this is answer for second part - yes, You can send data from tRESTClient and tJavaFlex to tMap:
    0683p000009MFrN.png    0683p000009MFrO.png
    Anonymous
    Not applicable
    Author

    The real goal is to:
    1.  Expose a Rest service that accepts JSON data where that JSON data contains an id field.
    2.  Make a Rest client call, using the id as a parameter and get JSON back.
    3.  Merge data (map) from the original JSON data with the response from the Rest client call
    4.  Continue on with processing...

    I seem to have found an answer, at least for the simple example with tJavaFlex as input.
    In the map, if I set create a "globalMap Key" as:  Expr. row1.id    GlobalKey "myKey"
    I can then access the value "myKey" from the globalMap and get my match:


    0683p000009MFwW.png

    Then in the tJavaFlex:

    Main Code:

    String s = (String)globalMap.get("myKey");
    row2.id = s;
     
    vapukov
    Master II
    Master II

    I think all mores simple - like exactly as You explain

    tRESTClient -> JSON -> tJSONExtractField -> tFlowToIterate - > tRESTClient2 -> tMap with second flow from already received JSON

    add about Your idea, need of course test, but not forget about BEFORE and AFTER


    (String)globalMap.get("myKey");

    will be in globalMap - AFTER row come to tMap
    but You are try to use this value BEFORE send lookup row

    or use one more component BEFORE lookup (between tFixedFlowInput and tMap), for example tJAVFlex with 

    (String)globalMap.put("myKey");

    Than You will can use this key in next tJAVAFlex AFTER define this key