Graphit allows you to define input parameters whereby the generated documents are executed using various settings like LUIs, LU table columns and other specific parameters that require processing.
Parameters can be set when:
Click on the icon at the top Graphit Editor toolbar.
The URL Parameters & Properties right side panel opens and its top section is called Input Parameter & Path. In the beginning, no parameters are defined.
To add a new parameter, click on the plus (+) sign at the top of the Parameters sub section.
A New Parameter pane opens, where you can define for a new parameter: name, type, description and whether it is mandatory.
You can then add more parameters as needed. You can expand and collapse each of parameter pane, where in a collapsed mode only the name appears, as well as the debug value for testing.
Note: The debug value is not saved with the Graphit file and it is used only in the Graphit Editor, for testing the web service.
To use the input parameters in the Graphit file logic, you shall refer to them by using the ${} bracket.
For example, to use it in the GET command - which requires the iid - when inputting parameter, use 'Customer_ID' and LU is 'Customer':
get Customer.${Customer_ID}
.
In this example you can also have the LU name to be a parameter, like this: get ${LU}.${Customer_ID}
.
Parameters that can be used are not only input parameters but also those that are set in Graphit logic or retrieved from SQL queries:
var LU = 'Customer'
at a function node, the LU
variable can be used on later nodes, like get ${LU}.${Customer_ID}
. When using the parameters in function nodes, you shall use them as variables. For example, assuming that input1
and input2
are defined as input parameters, then in a function node you can do input1 + input2
to get their sum.
To test & debug a Graphit file:
To learn how to send input parameters when the Graphit is exposed as a web service - read here.
A Graphit file can be invoked internally, from other Fabric Implementation Components. Each component provides methods to transfer the Graphit input parameters.
When calling Graphit from a Java function, the input parameters shall be populated by either a parameter name or by a map object.
Example 1: sending parameters as a map:
Map<String, Object> graphitParams = new HashMap<>();
graphitParams.put("input1",1000);
graphitParams.put("input2",2463);
return graphit("gr1.graphit", graphitParams);
This code calls the following Graphit file, which uses ${input1} and ${input2} as parameters.
Example 2: sending parameters as parameter list, as parameter name followed by the parameter value, similar to the below example:
return graphit("gr2.graphit", "input1", 1000, "input2", 2463);
Note: You can send "format" as one of the parameters, when you wish to get the result document in a specific format, other than the default format, which is JSON.
When calling Graphit from Broadway, using the Graphit Actor, you can use one of the following two methods to transfer parameters to the Graphit: the 'params' input object or the auto-added input arguments. The input arguments are automatically added to the actor according to the Graphit definitions, that is - Broadway looks at the Graphit structure and generates them.
When running it, the actor first looks at the auto-added input arguments and if not found, it looks at the 'params' input argument.
In the below example, Broadway Graphit Actor calls to a Graphit file, which gets 2 input parameters, named 'input1' and 'input2' and sums them. The 2 parameters transfer methods are demonstrated below (the first image shows the auto-adding method and the second image the 'params' input object method):
Graphit allows you to define input parameters whereby the generated documents are executed using various settings like LUIs, LU table columns and other specific parameters that require processing.
Parameters can be set when:
Click on the icon at the top Graphit Editor toolbar.
The URL Parameters & Properties right side panel opens and its top section is called Input Parameter & Path. In the beginning, no parameters are defined.
To add a new parameter, click on the plus (+) sign at the top of the Parameters sub section.
A New Parameter pane opens, where you can define for a new parameter: name, type, description and whether it is mandatory.
You can then add more parameters as needed. You can expand and collapse each of parameter pane, where in a collapsed mode only the name appears, as well as the debug value for testing.
Note: The debug value is not saved with the Graphit file and it is used only in the Graphit Editor, for testing the web service.
To use the input parameters in the Graphit file logic, you shall refer to them by using the ${} bracket.
For example, to use it in the GET command - which requires the iid - when inputting parameter, use 'Customer_ID' and LU is 'Customer':
get Customer.${Customer_ID}
.
In this example you can also have the LU name to be a parameter, like this: get ${LU}.${Customer_ID}
.
Parameters that can be used are not only input parameters but also those that are set in Graphit logic or retrieved from SQL queries:
var LU = 'Customer'
at a function node, the LU
variable can be used on later nodes, like get ${LU}.${Customer_ID}
. When using the parameters in function nodes, you shall use them as variables. For example, assuming that input1
and input2
are defined as input parameters, then in a function node you can do input1 + input2
to get their sum.
To test & debug a Graphit file:
To learn how to send input parameters when the Graphit is exposed as a web service - read here.
A Graphit file can be invoked internally, from other Fabric Implementation Components. Each component provides methods to transfer the Graphit input parameters.
When calling Graphit from a Java function, the input parameters shall be populated by either a parameter name or by a map object.
Example 1: sending parameters as a map:
Map<String, Object> graphitParams = new HashMap<>();
graphitParams.put("input1",1000);
graphitParams.put("input2",2463);
return graphit("gr1.graphit", graphitParams);
This code calls the following Graphit file, which uses ${input1} and ${input2} as parameters.
Example 2: sending parameters as parameter list, as parameter name followed by the parameter value, similar to the below example:
return graphit("gr2.graphit", "input1", 1000, "input2", 2463);
Note: You can send "format" as one of the parameters, when you wish to get the result document in a specific format, other than the default format, which is JSON.
When calling Graphit from Broadway, using the Graphit Actor, you can use one of the following two methods to transfer parameters to the Graphit: the 'params' input object or the auto-added input arguments. The input arguments are automatically added to the actor according to the Graphit definitions, that is - Broadway looks at the Graphit structure and generates them.
When running it, the actor first looks at the auto-added input arguments and if not found, it looks at the 'params' input argument.
In the below example, Broadway Graphit Actor calls to a Graphit file, which gets 2 input parameters, named 'input1' and 'input2' and sums them. The 2 parameters transfer methods are demonstrated below (the first image shows the auto-adding method and the second image the 'params' input object method):