Drools: Executing multiple rules simultaneously via REST - rest

I am new to drools. I want to fire multiple rules simultaneously depending on the condition.
I am using batch-execution command as follows, but it gives me error : "Bad request, no commands to be executed - either wrong format or no data"
{
"batch-execution":{
"lookup":"defaultKieSession",
"commands":[
{
"insert":{
"out-identifier":"TestAdvance",
"object":{
"LoanAdvance":{
"tenure":4,
"isBlacklisted":false
}
}
}
},
{
"insert":{
"out-identifier":"TestAdvance",
"object":{
"LoanAdvance":{
"tenure":3,
"isBlacklisted":false
}
}
}
},
{
"fire-all-rules":{
}
}
]
}
}
My rule in guided decision table looks like this:
I want to make a REST request to the rule engine and get the result set as a list.
Please confirm if my JSON request is correct. Or is there any better way to achieve the same?
Any help would be appreciated.
Thanks & Regards

you are using incorrect json request format. With JSON request payload no need to use ''batch-execution", remove that. And correct JSON request will look like as:
{
"commands":[
{
"insert":{
"out-identifier":"obj",
"object":{
"example.project4_91839699.Person":{
"firstName":"abc",
"lastName":"abc",
"hourlyRate":22,
"wage":100
}
}
}
},{
"insert":{
"out-identifier":"obj2",
"object":{
"example.project4_91839699.Person":{
"firstName":"xyz",
"lastName":"xyz",
"hourlyRate":24,
"wage":100
}
}
}
}
{
"fire-all-rules":""
}
]
}

Related

Not giving same results with dimensions and metrics from front end to API

I was able to do the following request: { "dimensions":[ { "name":"date" } { "name":"deviceCategory" } { "name":"eventName" } { "name":"customEvent:from_marketplace" } ] "metrics":[ { "name":"eventCount" } { "name":"eventCountPerUser" } ] "dateRanges":[ { "startDate":"2022-11-01" "endDate":"2022-12-12" } ] "dimensionFilter":{ "filter":{ "stringFilter":{ "matchType":"EXACT" "value":"send_offer" } "fieldName":"eventName" } } "offset":"0" "keepEmptyRows":true } when pulling data for dates before Nov 1, i get data for the event, but after Nov1, I dont get any data. If i remove the customEvent:from_marketplace and then i get data.
I usually minimized the # of dimensions in a call, but don't understand why the front end with the same dimensions and metrics provide data.

GitHub Projects Beta - How to get the data from a view in the API

My company is using the new GitHub projects beta and we're really enjoying the experience, but we're facing a problem and it is how to export the data from a specific view (or even all the data) with all the custom columns that we have.
The ideal solution for us is to get this same data as JSON using the API.
Using https://api.github.com/orgs/.../issues does not work because the issues does not have the custom columns that we create inside the project, and https://api.github.com/orgs/.../projects does not have the data of the issues.
Any idea or work-around to get this data easily using APIs?
After reading the feedback post on GitHub, it's not possible to do it with API, just GraphQL, at least for now.
So my problem was solved with this useful code.
To get the first 100 project from your organization and their ID:
query{
organization(login: "MY_ORG") {
projectsNext(first: 20) {
nodes {
id
title
}
}
}
}
To get the first 100 issues and drafts from a specific project:
{
node(id: "My_Project_ID") {
... on ProjectNext {
items(first: 100, after: null) {
edges {
cursor
}
nodes {
content {
... on Issue {
title
assignees(first: 1) {
nodes {
login
}
}
milestone {
title
}
labels(first: 5) {
nodes {
name
}
}
repository{
name
}
}
}
fieldValues(first: 15) {
nodes {
value
projectField {
name
settings
}
}
}
}
}
}
}
}
Those codes can be easily tested in THIS LINK

How to externalise repeated SOAP response attributes in mule dataweave?

I am constructing a SOAP response in Dataweave. Certain components (ESBHeader) of the response are repeated in multiple flows. I also need to set the Status code and message per request.
I need a generic/common way of loading these repeated lines into a common dwl file for code optimisation. How do I do it?
Example Response Message1 of flow1
{
ns1#ResponseMsg1: {
ns0#ESBHeader: {
ns0#InitialContext #(CreationTime: flowVars.req.ResponseMsg1.ESBHeader.InitialContext.#CreationTime, TrackingID: flowVars.req.ResponseMsg1.ESBHeader.InitialContext.#TrackingID): {
ns0#Actor #(Component: flowVars.req.ResponseMsg1.ESBHeader.InitialContext.Actor.#Component , Operation: flowVars.req.ResponseMsg1.ESBHeader.InitialContext.Actor.#Operation): null
},
ns0#MessageContext : {
ns0#Actor #(Component: flowVars.req.ResponseMsg1.ESBHeader.MessageContext.Actor.#Component , Operation: flowVars.req.ResponseMsg1.ESBHeader.MessageContext.Actor.#Operation): null
},
ns0#Status: {
ns0#Code: "Success",
ns0#Message: ""
}
},
ns1#var1: flowVars.var1
}
}
Example Response Message2 of flow2
{
ns1#ResponseMsg2: {
ns0#ESBHeader: {
ns0#InitialContext #(CreationTime: flowVars.req.ResponseMsg2.ESBHeader.InitialContext.#CreationTime, TrackingID: flowVars.req.ResponseMsg2.ESBHeader.InitialContext.#TrackingID): {
ns0#Actor #(Component: flowVars.req.ResponseMsg2.ESBHeader.InitialContext.Actor.#Component , Operation: flowVars.req.ResponseMsg2.ESBHeader.InitialContext.Actor.#Operation): null
},
ns0#MessageContext : {
ns0#Actor #(Component: flowVars.req.ResponseMsg2.ESBHeader.MessageContext.Actor.#Component , Operation: flowVars.req.ResponseMsg2.ESBHeader.MessageContext.Actor.#Operation): null
},
ns0#Status: {
ns0#Code: "Failure",
ns0#Message: ""
}
},
ns1#var1: flowVars.var1,
ns1#var2: flowVars.x.var2
}
}
Any pointers are greatly appreciated.
Thanks a lot.
If you are using Mule 4 it is easy to create and import a DataWeave module.
In Mule 3 there is a similar method but it is not really supported and you could run into some issues. From your script it looks like Mule 3. This blog post explains the method.

Elastic search - Unable to filter the JSON exact body using RestClient

Trying to query the exact JSON body by using Elastic search with RestClient API, but getting the whole body as response with hits,_source,etc.
So tried the filter_path [[filter_path=hits.hits._source]] approach in order to resolve this, but even that won't help to fetch exact body and coming with _source tag as mentioned below filter_path Response.
Can any one suggest please howt to get the exact json body as response like
{ "testAcct":"1234" }
Client.java:-
RestClient client = RestClient.builder(
new HttpHost(HOST, 9200, HTTP)).build();
Response response1 = client.performRequest("GET", SERVICE_URL + "_search",
Collections.<String, String>emptyMap(), new BasicHeader("testAcct", "1234"));
System.out.println(EntityUtils.toString(response1.getEntity()));
Response:-
{
"took":6,
"timed_out":false,
"_shards":{
"total":1,
"successful":1,
"failed":0
},
"hits":{
"total":21,
"max_score":1.0,
"hits":[
{
"_index":"testindex",
"_type":"testexternal",
"_id":"AVmHwA7Pkw5MudRUOp-q",
"_score":1.0,
"_source":{
"testAcct":"1234"
}
}
}
]
}
filter_path Response:-
{
"hits":{
"hits":[
{
"_source":{
"testAcct":"1234"
}
}
}
}

How to Map reskit with json

This is the type of JSON I am receiving, and I need to map with my model using restkit. What could be a possible solution? I have no idea about restkit.
{
-cal
{
-site{
id:""
name:""
}
-region{
id:""
name:""
}
-stats[
{
key:""
status:""
-product{
id:""
name:""
}
},{},{}
]
}
}