Somewhat strange question: Rules without a RHS
by Joe Ammann
Hi all
I have an ongoing discussion with my users: They have been using several
home-grown rule oriented applications for years. Almost all of these
"rule engines" were built for one very specific reason, and the users
have come accustomed to just specify a LHS of a rule. They never needed
to specify a RHS, because the action of the rule was pre-determined by
the application. So when the rule fired, it was clear what needed to be
done in the application.
Now want to merge all these "rule engines" onto Drools (5.4.0), and use
the Guvnor BRL editor and DSLs to actually formulate them. Of course now
Drools can not "know" what the RHS is supposed to be, since we have
"merged" several applications. The users now need to select one of
several predefined DSL statements as the RHS, but unfortunately they
consistenly keep forgetting to put an RHS at all. Guvnor validates this
successfully but of course the rules then fail to work.
I have been thinking if there is any way in Guvnor or via some kind of
Drools expert mechanism to say something like "if a rule is in packaga
a.b.c, it's RHS should always be 'foo' unless specified otherwise". To
be honest, I could not come up with a way to achieve this and think just
need to educate my users better. But before doing that, I thought I'd
use the wisdom of this group :-)
--
CU, Joe
13 years, 10 months
Challenge! Using javassist and drools presents an issue with drl
by markricard
In order to make writing drl files easy and not requiring writers to be
developers, I have written some JavaAssist code that dynamically creates a
subclass and new methods in memory.
If for example there is a REAL java class called 'com.foo.Instance'. Via
javasssist, I create a new in-memory subclass called 'com.foo.InstanceEx'.
The new class dynamically creates a new getter called getFoo(). The drl
writer would like to directly reference 'foo' in the drl file like so:
when
i : Instance(foo == 'fee')
The problem is, in order to reference foo, I would need the drl file to do
this:
import com.rrd.xspace.drools.InstanceEx;
But I cannot do that because InstanceEx does not exist at runtime. The
error I get, which is an obvious one, is "Unable to create Field Extractor
for 'foo' of '[ClassObjectType class=com.foo.Instance]' in rule 'Test' :
[Rule name='Test']"
Is there a way to include a dynamic import of a JavaAssist class while I am
constructing the KnowledgeBase instances to run the rules so that I can
reference that new method?
I would hope to have something similar to:
KnowledgeBuilder kbuilder = ....
kbuilder.addImport("com.foo.InstanceEx")
or
kbuilder.addClass(Class.forName("com.foo.InstanceEx"))
Any help GREATLY appreciated.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Challenge-Using-javas...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
How to get objects inserted in the rule trhough Rest
by Antonio Anderson Souza
Dear All,
I'm using Drools integrated to Camel trough Rest, but I'm unable to receive
objects inserted in the session by the rules, I'm inserting the fact
acordos.Acordo and in the "then" section of the rule I create new facts to
be returned to my app in this case is the fact acordos.Retorno, but I'm
unable to access this facts in the Rest response
Does anybody have some clue how to get these objects inserted?
Follow bellow what I'm sending, receiving and my rule:
Rule Definition:
package acordos
declare Acordo
dataReserva: java.util.Date
dataEmbarque: java.util.Date
gds: String
ciaAerea: String
tipoAcordo: String
conexao: String
origem: String
destino: String
empresa: String
unidade: String
cliente: String
end
declare Retorno
codAcordo: String
end
#generated from Decision Table
import teste.*;
import java.util.Date;
# rule values at C18, header at C13
rule "tabelaTeste(Acordo acordo)_18"
salience 65518
when
Acordo(getDataReserva().after(new Date("22-Oct-2009")),
getDataReserva().before(new Date("31-Dec-2015")),
getDataEmbarque().after(new Date("1-Jan-2012")),
getDataEmbarque().before(new Date("31-Dec-2012")), gds == "1", ciaAerea ==
"AA", tipoAcordo == "1", getOrigem() in ("Brasil"), getDestino()
in("América do Norte","Brasil","Estados Unidos","Canadá","Ásia","América
Central","América do Sul","Mexico","Europa","Caribe"))
then
System.out.println("teteteetetet");
Retorno _retorno = new Retorno();
_retorno.setCodAcordo("PEB06");
insert(_retorno);
end
Rest request:
curl -v -H "Content-Type: text/plain" --data "
<batch-execution lookup=\"ksession1\">
<insert out-identifier=\"message\">
<acordos.Acordo>
<dataReserva>2012-01-30 08:00:00.000 -0300</dataReserva>
<dataEmbarque>2012-01-30 08:00:00.000 -0300</dataEmbarque>
<gds>1</gds>
<ciaAerea>AA</ciaAerea>
<conexao></conexao>
<origem>Brasil</origem>
<destino>Brasil</destino>
<tipoAcordo>1</tipoAcordo>
</acordos.Acordo>
<acordos.Retorno>
<codAcordo></codAcordo>
</acordos.Retorno>
</insert>
<fire-all-rules out-identifier=\"firedActivations\" />
</batch-execution>"
http://localhost:8080/drools-camel-server-5.4.0.Final/kservice/rest/execute
Rest Response:
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Date: Tue, 15 May 2012 22:20:00 GMT
< Content-Type: text/plain
< Content-Length: 528
<
* Connection #0 to host localhost left intact
* Closing connection #0
<?xml version='1.0' encoding='UTF-8'?><execution-results><result
identifier="message"><acordos.Acordo><dataReserva>2012-01-30 11:00:00.0
UTC</dataReserva><dataEmbarque>2012-01-30 11:00:00.0
UTC</dataEmbarque><gds>1</gds><ciaAerea>AA</ciaAerea><tipoAcordo>1</tipoAcordo><conexao></conexao><origem>Brasil</origem><destino>Brasil</destino></acordos.Acordo></result><result
identifier="firedActivations"><int>1</int></result><fact-handle
identifier="message"
external-form="0:2:1717445911:1717445911:2:DEFAULT"/></execution-results>
Best Regards,
Antonio Anderson Souza
<http://174.129.217.139:8080/makecallclient/callme?p=YXNvdXphQHZvaWNlLmJyY...>
Blog <http://www.antonioams.com> - Twitter <http://twitter.com/antonioams>-
LinkedIn <http://br.linkedin.com/in/antonioams> -
Facebook<http://www.facebook.com/antonioams>
13 years, 10 months
Issue while comparing BigDecimal and Long(only while using references)
by sumatheja
Hi,
I cam to know that we can compare BigDecimal, Long, Integer
interchangeably in the LHS of rule like
*when
Message(Decimalstatus == Longstatus)*
I found that this rule will fire as long as both Decimalstatus and
Longstatus Values are same. But when I try to use this feature in the below
mentioned way
*when
Message($dec:Decimalstatus)
Message(longstatus == $dec)*
This rule doesn't fire even though I have two Message object which satisfy
the condition.However, when I try
*
when
Message($dec:Decimalstatus)
Message(longstatus == $dec.longValue())*
It fires properly. Is this an issue or am I missing anything? Any
suggestions for better approach are welcome.Thanks in advance.
--
cheers
Sumatheja Dasararaju
13 years, 10 months
[rules-users] The Temporal Operators in Guvnor
by Carolina Pellecchia
Hi all
I have a new question. How can I define a Temporal Operators in GUVNOR?
I need to do something like this:
DoorOpeningEvent( this meets[25s] $obs )
thank you and kindly regards!
Carolina Pellecchia
13 years, 10 months