dynamic dmn execution with json payload

183 views
Skip to first unread message

Ravi Mangalagiri

unread,
Sep 29, 2021, 7:37:27 PM9/29/21
to Kogito development mailing list
I have a simple dmn which I am trying to execute dynamically. and here is the payload - {loan: {"baseLoanAmount":450000,"transaction":{"insuranceAmount":52000}}}

Is there any api similar to this which takes context as string or JSONObject?

DMNContext dmnContext = new DynamicDMNContextBuilder(dmnRuntime.newContext(), dmnModel).populateContextWith(context);

I tried the following and had no luck.
Map<String, Object> context = new HashMap<>();
context.put("loan", new JSONObject().put("baseLoanAmount", new BigDecimal("450000")).put("transaction", new JSONObject().put("insuranceAmount", new BigDecimal("52000"))));

--
Ravi Mangalagiri
703-505-4240 (c)

Matteo Mortari

unread,
Sep 30, 2021, 3:26:49 AM9/30/21
to Kogito development mailing list
Hi Ravi,
I'm not sure if I'm fully understanding your use-case this time, so I will advance some pointers:

A.
If you are looking to invoke DMN engine programmatically while being on the Kogito platform, you can use the Kogito API Incubation

B.
If you are looking for a way to manually handle the context from string unmarshalling to the DMN context,
you can use directly the Jackson unmarshaller, this will return a (jdk) Map of entry value pairs of the most common types, and not JSONObject
then you can wire the generic Map unmarshalled by Jackson (which will contain "baseLoanAmount"-450000, "transaction"-a Map of "insuranceAmount"-52000, etc)
and then you can use the internal DynamicDMNContextBuilder to build a DMNContext.
Alternatively, you can rely on the Kogito API Incubation mentioned above.

Hope these are helpful pointers, and don't hesitate to let us know more details if something is still unclear?
MM

--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CALg%3DC8PFNQkoxPjYxOR6KpxZd_dTAwPzchYgdUi0QD%2Brpkshjw%40mail.gmail.com.


--

Ravi Mangalagiri

unread,
Sep 30, 2021, 7:33:55 AM9/30/21
to Kogito development mailing list
Thanks Matteo.
I will go with option A.

One of the requirements : A springboot batch application be able to run dmn programmatically based on the payload (stored in a database)

Reply all
Reply to author
Forward
0 new messages