How to add java logics in the LHS of a rule ?
by carnelk
Hi,
I have to rule below.
This rule finds the minimal date of a 'B object' that is still AFTER the
startDate of $aObject.
I would like it to find the minimal date of B that is at least 7 days after
the startDate of $aObject
(and perhaps no more then 14 days after).
For that I would need to add some java logics instead of line <9> to
manipulate the date with java,
wouldn't I?
Does anyone have any creative solution for that ???
1 rule "first measurement < 7 days> after the treatment"
2 salience 9
3 when
4 $aObject : A ( )
5 $minDate : Number()
6 from accumulate ( B (
7 # I would like to change the following line to
manipulate $aObject.startDate
8 # to be '$aObject.startDate + 7 days'
9 date > $aObject.startDate,
10 $bpDate : date),
11 min($bpDate.getTime()) )
12
13 then
14 # do something ....
15 end
Much thanks,
Carmel.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-add-java-logics-in-the-LHS-of-a-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 12 months
Drools rules
by annukaila
Hi
iam new to drools rules my problem is
iam receiving message in xml format so using drools have to route it my
drools rules work when the xml message is the format as below
<?xml version="1.0" encoding="UTF-8"?>
<IATA>
<messageaudit senderId="125" receiverId="FFCategory"
dateTimeOfMessage="19:00"
messageVersion="FSU/13/RCS" airwaybill="125-1234565" />
<fsurcs AwbNumber="125-1234565" origin="HYD" destination="KUL"
totalPieces="T40" totalWeight="K200"
statusCodeConsignmentRecieveDFromShipperOrAgent="RCS"
dayAndMonthOfReceipt="02June" actualTimeOfGivenStatusEvent="19:00"
airportCodeOfReceipt="HYD"
totalOrPartNumberOfPices="T40" weightOfTotalOrPartOfPieces="K200"
nameOfAgentOfShipper="Shipper" osi="RcsMessage"/>
</IATA>
but if the xml is the format as below
<?xml version="1.0" encoding="UTF-8"?>
<IATA>
<messageaudit>
<senderId>125</senderId>
<receiverId>FFCategory</receiverId>
<dateTimeOfMessage>19:00</dateTimeOfMessage>
<messageVersion>FSU/13/RCS</messageVersion>
<airwaybill>125-1234565</airwaybill>
</messageaudit>
<fsurcs>
<AwbNumber>125-1234565</AwbNumber>
<origin>HYD</origin>
<destination>KUL</destination>
<totalPieces>T40</totalPieces>
<totalWeight>K200</totalWeight>
<statusCodeConsignmentRecieveDFromShipperOrAgent>RCS</statusCodeConsignmentRecieveDFromShipperOrAgent>
<dayAndMonthOfReceipt>02June</dayAndMonthOfReceipt>
<actualTimeOfGivenStatusEvent>19:00</actualTimeOfGivenStatusEvent>
<airportCodeOfReceipt>HYD</airportCodeOfReceipt>
<totalOrPartNumberOfPices>T40</totalOrPartNumberOfPices>
<weightOfTotalOrPartOfPieces>K200</weightOfTotalOrPartOfPieces>
<nameOfAgentOfShipper>Shipper</nameOfAgentOfShipper>
<osi>RcsMessage</osi>
</fsurcs>
</IATA>
it is not routing the message means not recognizing the drools and my drools
file is as follows
package com.jboss.soa.esb.routing.cbr
#list any import classes here.
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageType;
expander XPathLanguage.dsl
#declare any global variables here
global java.util.List destinations;
rule "Blue Routing Rule using XPATH"
when
xpathEquals "/IATA/messageaudit/@messageVersion" "FSU/13/RCS"
then
Log : "Blue Team";
Destination : "blue";
end
rule "Red Routing Rule using XPATH"
when
xpathEquals "/IATA/messageaudit/@messageVersion" "FSU/13/MAN"
then
Log : "Red Team";
Destination : "red";
end
rule "Green Routing Rule using XPATH"
when
xpathEquals "/IATA/messageaudit/@messageVersion" "FSU/13/DEP"
then
Log : "Green Team";
Destination : "green";
end
please help me hoe to rectify this its very urgent for me and please dnt
mind if i did any mistakes
thanku
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-rules-tp2854688p2854688.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 12 months
Drools Rule verifier background
by Steffen Heublein
Hello,
I am currently using the Rule Verifier and am quite happy so far. Yet I
am interested in its (scientific) background background, but I am unsure
where to start. Are there any papers on the topic or anything else I
could relate to? There certainly is, but I don't really know what topic
I should look for to find what I want. My special interest so far is the
solving of the rule conditions and how the system finds out how e.g. two
rule conditions are equivalent.
Cheers, and thanks so far,
Steffen
14 years, 12 months
Need JSON request for Drools Server
by fulton
I have deployed Drools Server 5.1.1 on Tomcat and have successfully tested it
with the sample Test.jsp and with a raw XML <batch-execution> request via
TCPMON. However, I need to support JSON-based requests to the server, and I
have been unable to find any documentation or examples on how to specify a
valid JSON request to the server. Would someone please translate the sample
XML request to a JSON request that actually WORKS on the Drools Server.
<batch-execution lookup="ksession1">
<insert out-identifier="message">
<org.test.Message>
<text>Hello World</text>
</org.test.Message>
</insert>
</batch-execution>
BTW, I am behind a corporate proxy, so I cannot access certain web sites
(including plugtree.com!), but go ahead and point me to the "proper"
documentation for this, if any.
Thanks so much! Fulton
--
View this message in context: http://drools.46999.n3.nabble.com/Need-JSON-request-for-Drools-Server-tp2...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 12 months
Problem in compiling each rule separately
by saurabh maheshwari
Hi sir ,
I have 10 rules . rules are created dynamically .Now if any of them is
causing problem so none of them runs
so I want to compile each rule separately , so that i can create knowledge
base with rules which have no errors
but can i do this ?
I am not finding the way how i can do it . is it possible ?
thanks ,
Saurabh Maheshwari
14 years, 12 months
[guvnor] How to use a rule in a java application
by Mario Viertel
Hi all,
I am new in Guvnor and have a lot of questions.
I have created a decision table with the Guvnor web app. I have also
created some test. All seems to be fine.
Now I want to use the rules in a web application. Unfortunately Guvnor
doesn't provide a web service interface so I must develop an own web
service to deal with the rules. But thats not so easy ...
In the Guvnor documentation I can see how to create KnowledgeBases and
builders and how to fire rules. But I cannot see how to receive rule
results.
Example:
The decision table looks similar like this:
rule 1 "under age"
if person.age < 18 then "under age"
rule 2 "pensioner female"
if person.age > 64 and person.gender == "female" then "pensioner"
rule 3 "pensioner male"
if person.age > 67 and person.gender == "male" then "pensioner"
rule 4 "full age"
* then "full age"
In my java application I create a person object:
Person p = new Person();
p.setBirthday(...);
p.setGender(...);
Now I miss a method in the Guvnor api to exectute the rules and receive
the result like this:
Person result = (Person) rules.execute(p);
Can somebody explain how to execute a rule and receive the result.
Thanks in Advance
Mario Viertel
Germany
14 years, 12 months
And Or Problem
by saurabh maheshwari
Hi sir ,
I am facing one issue regarding and( , ) and OR( || ) condition
i have one rule like that
dialect "java"
rule "mytest1"
when
test ( ( i==1,j==2) || (i == 2 ,j==3) )
then
System.out.println("Found");
end
it gives excpetion [ERR 102] Line 24:22 mismatched input ',' expecting
'then' in rule "mytest1"
can we not do such type of combination ?
dialect "java"
rule "mytest1"
when
test (( i==1 || j==2) ,(i == 2 || j==3))
then
System.out.println("Found");
end
this gives no excpetion and works as expected .
Regards ,
Saurabh Maheshwari
14 years, 12 months
Re: [rules-users] unable to create field extractor for tickerId
by FrankVhh
"Unable to create FIeld extractor", mostly that is because you did not
declare getters and in your java class.
Drools uses the getters to extract the needed values.
Make sure you use the correct naming conventions as well. I.e. public int
getTicketId(){...}
Regards,
frank
sirinath wrote:
>
> declare ReqMktData
> @role( event )
> end
>
> declare TickPrice
> @role( event )
> @expires( 2m )
> end
>
> declare TickSize
> @role( event )
> @expires( 2m )
> end
>
>
> rule "Bids"
>
> when
> $req: ReqMktData($tickerId : tickerId) from entry-point "IB Events"
> $bidprice: TickPrice(field == 1, tickerId == $tickerId, this after $req)
> from entry-point "IB Events"
> $bidsize: TickSize(field == 0, tickerId == $tickerId, this after $req)
> from entry-point "IB Events"
> then
> Bid bid = new Bid($tickerId, $req.contract, size, price);
> insert(bid);
> end
>
>
>
>
>
>
> public class ReqMktData {
> public int tickerId;
> public Contract contract;
> public String genericTickList;
> public boolean snapshot;
> }
>
--
View this message in context: http://drools.46999.n3.nabble.com/unable-to-create-field-extractor-for-ti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 12 months
drools flow persistence doesn't work with spring jta - bug/TODO code in SingleSessionCommandService#initTransactionManager
by gs76pl
hi,
i've been trying to setup my drools flow persistence layer to use spring
transaction management (JTA) but it looks like some parts of the code are
missing in 5.1.1 rendering the whole idea impossible.
Whats happening is that when my transaction manager calls commit it gets
NullPointerException because jpm variable in SingleSessionCommandService has
never been set. It looks like it should be set in initTransactionManager
method in line 233 but all that this line is a comment that reads:
...else{
// configure spring for JPA and distributed transactions
}
So is there any way to have spring managing JTA transactions?
Sorry but it's been over a week for me trying to have drools persistence
working and after all the problems so far i'm considering jbpm5 as something
in a more "production ready state"
i've found similar thread here
http://drools.46999.n3.nabble.com/Drools-Spring-JPA-JTA-td2024942.html but
till now nobody replied to it with any explanation
below my spring config
<bean id="droolsFlowEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="droolsFlowDataSource"
p:persistenceUnitName="org.drools.persistence.jpa"
p:persistenceXmlLocation="classpath:/config/droolsflow/jpa/persistence.xml">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="true" p:generateDdl="false" />
</property>
</bean>
<bean id="bitronixTransactionManagerConfig"
factory-method="getConfiguration"
class="bitronix.tm.TransactionManagerServices">
<property name="serverId" value="spring-btm" />
<property name="warnAboutZeroResourceTransaction" value="true"></property>
</bean>
<bean id="bitronixTransactionManager" factory-method="getTransactionManager"
class="bitronix.tm.TransactionManagerServices"
depends-on="bitronixTransactionManagerConfig" destroy-method="shutdown" />
<bean id="droolsFlowTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="bitronixTransactionManager" />
<property name="userTransaction" ref="bitronixTransactionManager" />
</bean>
--
View this message in context: http://drools.46999.n3.nabble.com/drools-flow-persistence-doesn-t-work-wi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
Strange intermittent problem with Drools Flow
by Dan Nathanson
Hi,
I'm seeing some odd behavior in some of my test cases. And it only
seems to happen to one guy. And he's done fresh checkouts of the code,
blown away his local M2 repository and verified installed software
like OS and Java is same as everyone else's.
I have some test cases that build up some simple flows programatically
using fluent API. Very simple (start --> work item --> work item -->
state --> end). I am using Drools Flow 5.1.1 with JPA (in-memory H2
DB for unit tests). Intermittently, after completing a work item, the
flow doesn't continue. Logging in a process event listener shows that
the the work item node is never left, although I can see in the logs
that the work item is deleted from DB.
There are no errors, warning or info level messages coming out of
Drools or Hibernate prior to the failure.
It only happens to one guy, but he can reproduce the problem
regularly, although it moves around in different test cases and
different points in the flows.
Anyone ever seen this behavior before? Any possible explanations?
I'd attach the log file, but it is huge since I've got hibernate
logging set very verbose.
Regards,
Dan Nathanson
15 years