[rules-users] unmarshal global variable

Ormond, Alex C. (GDLP) ACOrmond at GreatDaneTrailers.com
Mon Jan 7 11:41:13 EST 2013


Thanks for the response.  The first rule table in the spreadsheet
(kinda) looks like this:
				
RuleTable Constants					
NAME	CONDITION	ACTION	ACTION		
					
	eval(! productPricer.isConstantsSet($1) )
productPricer.setConstant($1, $2);
productPricer.setConstantsSet($1);		
Rule Name	Set?				
ProductName	TRUE	"NAME", "Champion CL"			
DefaultCost	TRUE	"COST", "80000"			
DefaultPrice	TRUE	"PRICE", "100000"			
DefaultLength	TRUE	"LENGTH", "53"			
Done	TRUE		TRUE		
					

The first rule generated looks like this:

rule "ProductName"
	when
		eval(! productPricer.isConstantsSet() )
	then
		productPricer.setConstant("NAME", "Champion CL");
end


Alex


-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Monday, January 07, 2013 11:22 AM
To: Rules Users List
Subject: Re: [rules-users] unmarshal global variable

The crucial info is: what is in the first table, how do you insert this
data?
Is it a DRL global? A fact? How does the (generated) rule look like?
-W

On 07/01/2013, acormond <acormond at greatdanetrailers.com> wrote:
> Gentlepeople,
>
> I am fairly new to Drools and have what I hope is a simple question.
I am
> attempting to marshal (serialize) a Drools knowledge session and then
> unmarshall it.  The marshalling works but the unmarshalling fails with
a
> null pointer exception.  The error is apparently with unmarshalling a
> global
> variable in the session.
>
> The session is created from a spreadsheet (decision table).  This
> spreadsheet
> has two RuleTables.  The first of these exists solely so that I can
enter
> some
> constants into the session, specifically the name and price of the
product
> the
> spreadsheet is dealing with.  The second ruletable is where the rules
are
> specified.  The exception occurs when unmarshalling the first rule in
the
> first
> rule table.  If, as a test, I eliminate the first rule table, then I
can
> successfully marshal and unmarshall the session.
>
> The marshalling is done using the following, simplified, code:
>
>   Marshaller marshaller = MarshallerFactory.newMarshaller(kbase);
>   File droolsSessionFile = new File(MARSHAL_FILE);
>   foStream = new FileOutputStream(droolsSessionFile);
>   baos = new ByteArrayOutputStream();
>   marshaller.marshall(baos, ksession);
>   baos.writeTo(foStream);
>
> and the unmarshalling is done like this:
>
>   Marshaller marshaller =
> MarshallerFactory.newMarshaller(pricingProcessor.getKnowledgeBase());
>   FileInputStream fis = new FileInputStream(MARSHAL_FILE);
>   StatefulKnowledgeSession ksession = marshaller.unmarshall(fis);
>
>
> So, where did I go wrong?  Perhaps I need to deal with the global
variable
> differently, perhaps by putting it in the knowledgeBase before I
unmarshall
> the session?
>
> Thank you for any help.
>
> Alex Ormond
>
>
>
>
> --
> View this message in context:
>
http://drools.46999.n3.nabble.com/unmarshal-global-variable-tp4021375.ht
ml
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





More information about the rules-users mailing list