[resolved] REST web service question (run if and main data flow)

Highlighted
One Star

[resolved] REST web service question (run if and main data flow)

I am creating a job that will create a RESTful web service:
tRESTRequest ----- business logic ----- tRESTResponse
This will be a POST operation with a Document.
As part of the business logic, I need to consume two other REST services - one of which will validate the information in the Document and the other which will post the information in the Document only IF the validate step passes.
So, my flow (with validation) will look something like:
tRESTRequest ---- tXMLMAP ----- tRESTClient (validate web service) ---- txmlMap (response) ---- tRESTResponse
Based on the information in the response from my validate web service, I may need to then consume a post web service.  My issue is that the original document is not the main data flow now.  The data flow is the response message from the validate web service.
How can I make a decision as to whether to proceed with consuming the post web service after the validate web service and have the document that came in through the original tRESTRequest?
I've used Run IF before but my understanding is that using this would disrupt the main flow?

Accepted Solutions
Community Manager

Re: [resolved] REST web service question (run if and main data flow)

Hi
You can cache the input request in memory for used later, and use runIf to trigger different business logic depends on the your validation result. for example:
tRESTRequest ---- main--tHashOutput--oncomponentok--tHashInput--main--tXMLMAP ----- tRESTClient (validate web service) ---- txmlMap (response) -main..tJavaRow --runIf1--tHashInput--main--tXMLMap---- tRESTResponse
                                                       --runIf2---tFixedFlowInput--main--tXMLMap--tRestResponse
tHashInput: read the original document from memory
on tJavaRow: parse the validation result, and put the result to a global variable for used as the condition of runIf link. eg:
if(input_row.columnName.equals("OK")){
globalMap.put("isValid",true);
}else{
globalMap.put("isValid", false);
}
set the condition of runIf1 as:
(Boolean)globalMap.get("isValid")
set the condition of runIf2 as:
!(Boolean)globalMap.get("isValid")
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] REST web service question (run if and main data flow)

Hi
You can cache the input request in memory for used later, and use runIf to trigger different business logic depends on the your validation result. for example:
tRESTRequest ---- main--tHashOutput--oncomponentok--tHashInput--main--tXMLMAP ----- tRESTClient (validate web service) ---- txmlMap (response) -main..tJavaRow --runIf1--tHashInput--main--tXMLMap---- tRESTResponse
                                                       --runIf2---tFixedFlowInput--main--tXMLMap--tRestResponse
tHashInput: read the original document from memory
on tJavaRow: parse the validation result, and put the result to a global variable for used as the condition of runIf link. eg:
if(input_row.columnName.equals("OK")){
globalMap.put("isValid",true);
}else{
globalMap.put("isValid", false);
}
set the condition of runIf1 as:
(Boolean)globalMap.get("isValid")
set the condition of runIf2 as:
!(Boolean)globalMap.get("isValid")
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] REST web service question (run if and main data flow)

Thanks so much, Shong.  I will definitely try this.
I was also playing with tReplicate yesterday and had some success with that.
Thanks again!

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read