Mashaller code Generates JSON with no agenda filter

237 views
Skip to first unread message

Kripal S

unread,
Jul 20, 2016, 10:59:44 AM7/20/16
to Drools Usage

I have following code generate the JSON /XML. But in the process it loses agenda filter in fire-all-rules object. I tried to post Json with "agendaFilter":{"name":"SetAdUserLastName","accept":true} but it did not fire the matched rule. Does the Kie server support agenda filter posted from JSON/XML


user usr = new user("PreHire","111","Y","Y","");
aduser adu =
new aduser("", "");
InsertObjectCommand insertUsr =
new InsertObjectCommand(usr);
InsertObjectCommand insertAD =
new InsertObjectCommand(adu);
FireAllRulesCommand fireAllRulesCommand =
new FireAllRulesCommand();
fireAllRulesCommand.setMax(
1);
fireAllRulesCommand.setOutIdentifier(
"firedActivations");
fireAllRulesCommand.setAgendaFilter(
new RuleNameEndsWithAgendaFilter("faculty"));

List<GenericCommand<?>> commands =
new ArrayList<GenericCommand<?>>();
commands.add(insertUsr);
commands.add(insertAD);
commands.add(fireAllRulesCommand);
BatchExecutionCommand command = (BatchExecutionCommand)
new BatchExecutionCommandImpl(commands);

String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML(command);
//
String json = BatchExecutionHelper.newJSonMarshaller().toXML(command);
System.
out.println(xStreamXml);
System.
out.println(json);

 

{

         "batch-execution": {

                 "commands": [{

                          "insert": {

                                   "entry-point": "DEFAULT",

                                   "object": {

                                            "eventhandlers.affiliationshandler.user": {

                                                    "id": 111,

                                                    "affiliateStatus": "PreHire",

                                                    "howAffiliated": "",

                                                    "deceased": "Y",

                                                    "emeritus": "Y"

                                            }

                                   }

                          }

                 }, {

                          "insert": {

                                   "entry-point": "DEFAULT",

                                   "object": {

                                            "eventhandlers.affiliationshandler.aduser": {

                                                    "firstName": "",

                                                    "lastName": ""

                                            }

                                   }

                          }

                 }, {

                          "fire-all-rules": {

                                   "max": 1,

                                   "out-identifier": "firedActivations"

                          }

                 }]

         }

}

Maciej Swiderski

unread,
Jul 21, 2016, 5:43:47 AM7/21/16
to drools...@googlegroups.com
Don’t use manual marshalling of commands, simply pass them them to RuleServicesClient executeCommands method [1]

if you need to get the content then use MarshallerFactory.getMarshaller and then use it to produce the payload instead of legacy (in context of kie server) BatchExecutionHelper

Maciej

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/1d030d90-d6e3-497c-89e1-73482ed3d6d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kripal S

unread,
Jul 21, 2016, 11:22:40 AM7/21/16
to Drools Usage
I am trying to run Rules Agenda filter through web services not with java code.Like this curl command with marshalled JSON in a JSON file .

curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @droolsaff3.json http://localhost:8080
/kie-server/services/rest/server/containers/instances/handler2

ravi pillala

unread,
Feb 1, 2017, 1:24:00 AM2/1/17
to Drools Usage
Hi Maciej,

I have a json string. how do i add to commandFactory? I don't have respective unmarshalled class object.

Ravi

Maciej Swiderski

unread,
Feb 1, 2017, 1:30:43 AM2/1/17
to Drools Usage
you need to elaborate a bit more as not really sure what is the question...

Maciej

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages