[rules-users] Smooks and Drools Pipeline

Dave Macpherson dave at praxis-inc.com
Mon Mar 2 14:41:44 EST 2009


Hey guys (Drools newbie here) 

I'm *attempting* to use the Drools/Smooks pipeline functionality to insert
facts into my knowledgebase and I'm having a little trouble figuring out
exactly how to do this. I've read the API docs for the 5.0.0.M5 and looked
at the test cases but I guess I'm still not quite getting it, so I'm hoping
someone here can point me in the right direction.

I've got an XML file defined basically like this: 

<submission> 
   <facility> 
      <faccode>xxx</faccode> 
   </facility> 
   <lineitem> 
      <acctcode>xxxx</acctcode> 
      <amount>999</amount> 
   <lineitem> 
   <lineitem> 
      <acctcode>xxxx</acctcode> 
      <amount>999</amount> 
   <lineitem> 
<submission> 

Within the XML file, there is 1 and only 1 "facility" node and multiple
"lineitem" nodes. I'd like to use the DroolsSmooks pipleline functionality
to use Smooks to insert 1 "facility" fact and multiple "lineitem" facts into
my knowledgbase.

The code I've written to do this is similar to the following (taken from
sample test code I've seen in the Drools source):

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); 
Action executeResultHandler = PipelineFactory.newExecuteResultHandler(); 
KnowledgeRuntimeCommand insertStage =
PipelineFactory.newStatefulKnowledgeSessionInsert(); 
insertStage.setReceiver(executeResultHandler); 
Smooks smooks = new Smooks("smooks-config.xml"); 
Transformer transformer =
PipelineFactory.newSmooksFromSourceTransformer(smooks, "root"); 
transformer.setReceiver(insertStage); 
Pipeline pipeline =
PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession); 
pipeline.setReceiver(transformer); 
ResultHandlerImpl resultHandler = new ResultHandlerImpl(); 
pipeline.insert(ResourceFactory.newClassPathResource("submission.xml"),
resultHandler ); 

While stepping through the above code, the last line returns an NPE. I've
tried playing with the "Transformer transformer - PipeLineFactory." line,
substituting "root" for something else and it goes into an infinite loop.
What is the purpose of the "root" value being set in this line?

Can anyone tell me if I'm even on the right track here, or am I
misunderstanding what the Smooks data loader can do for me?

Regards, 

Dave

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090302/0f99bf39/attachment.html 


More information about the rules-users mailing list