(no subject)
by fakhfakh ismail
hello,
first sorry for my bad english
when I execute the code
rule "sample1"
when
$P: User($name : name, email matches ".*(a)bull.net")
$role :Role
then
$role.addUser($P);
end
User and Role are JavaBean
error is affiched
Exception in thread "main" org.drools.rule.InvalidRulePackage: unknown:12:0 mismatched token: [@78,169:172='then',<33>,12:0]; expecting type '('
at org.drools.rule.Package.checkValidity(Unknown Source)
at org.drools.common.AbstractRuleBase.addPackage(Unknown Source)
at org.drools.jsr94.rules.admin.RuleExecutionSetImpl.<init>(Unknown Source)
at org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown Source)
at org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown Source)
at org.drools.jsr94.rules.admin.LocalRuleExecutionSetProviderImpl.createRuleExecutionSet(Unknown Source)
at com.sample.Rule.fireRules(Rule.java:41)
at com.sample.Rule.fireRules(Rule.java:70)
at com.sample.DroolsTest.main(DroolsTest.java:34)
Best regard
Ismail
---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
17 years, 8 months
Help : drools implementing
by vista2007
I want to call rules from session bean. I implement this by calling a utility
callss from the Session bean method.
That Utility class load the rule file as
"final Reader source = new
InputStreamReader(BaseRuleImpl.class.getResourceAsStream(rulefile));"
this gives the result as expected. But it throws an exception in the server
as follows,(Server log)
java.lang.Throwable
at
com.sun.enterprise.loader.EJBClassLoader$SentinelInputStream.<init>(EJBClassLoader.java:1123)
at
com.sun.enterprise.loader.EJBClassLoader$InternalJarURLConnection.getInputStream(EJBClassLoader.java:1216)
at java.net.URL.openStream(URL.java:1009)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1161)
at
com.sun.enterprise.loader.EJBClassLoader.getResourceAsStream(EJBClassLoader.java:782)
at java.lang.Class.getResourceAsStream(Class.java:2030)
at org.drools.semantics.java.RuleBuilder.<clinit>(Unknown Source)
at org.drools.compiler.PackageBuilder.addRule(Unknown Source)
at org.drools.compiler.PackageBuilder.addPackage(Unknown Source)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(Unknown
Source)
at
com.argosoftware.rules.impl.BaseRuleImpl.readRule(BaseRuleImpl.java:29)
at com.argosoftware.rules.impl.RuleImpl.fireRule(RuleImpl.java:54)
at
com.argosoftware.rules.ejb.session.LogicHandlerBean.ruleHandler(LogicHandlerBean.java:42)
I think this is because of the IO operation.
Can anybody kindly suggest a solution for this.?
--
View this message in context: http://www.nabble.com/Help-%3A-drools-implementing-tf3530032.html#a9851208
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months
RE: Need DRL authoring Help
by John.Tal@gxs.com
Ok, Thanks for the help on the drl syntax.
So this works.
rule "UCCnet_DVE_Depth_All"
when
catalogObject : CatalogObject( )
eval( catalogObject.getElementValue("depth") == null ||
catalogObject.getElementValue("depth") == "" )
then
logWriter.logDebug("Package Depth is Blank");
end
But how do I get the drl parser to accept something like this:
rule "UCCnet_DVE_Depth_All"
when
catalogObject : CatalogObject( )
String s = catalogObject.getElementValue("depth");
eval( s == null || s == "" )
then
logWriter.logDebug("Package Depth is Blank");
end
I am getting an Unexpected token 's' InvalidRulePackage
17 years, 8 months
Fwd: Please help me
by Sudipta deb
Note: forwarded message attached.
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers
17 years, 8 months
Fwd: Please help me
by Sudipta deb
Note: forwarded message attached.
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers
17 years, 8 months
Need DRL authoring Help
by John.Tal@gxs.com
Writing DRL is not easy for people new to drools. Can someone please
help me understand how to write this simple rule? You can see the
approaches I have taken.
In this case I do not have getters and setters for the attributes I am
checking. I need to pass parameters to the object for it to get the
data.
I can't get any of the code in the when block to be syntax proper.
Existing DRL doc is lacking in this area.
Thanks John
rule "UCCnet_DVE_Depth_All"
when
catalogObject : CatalogObject( getElementValue("depth") ==
null, getElementValue("depth") == "")
# String depth = CatalogObject.getElementValue("depth")
# depth == null
# depth == ""
# catalogObject : CatalogObject( depth == null)
# catalogObject : CatalogObject( depth == "")
then
logWriter : LogWriter();
logWriter.logDebug("Package Depth is Blank");
System.out.println( "Package Depth is Blank" );
end
17 years, 8 months
RE: Hi.
by Anstis, Michael (M.)
Hi Sanjay,
To firstly answer your questions (in my opinion):
1. You can't do nested whens in the LHS but you can do nested if / else
in the RHS (although you'd fore go the benefits of a RETE-based
inference engine; but possible if you've got very few rules and
facts...). I believe that there is work to have an "otherwise" statement
for rule syntax, how progressed this is and how it will work I don't
know - over to Mark and team?!?
2. Yes, take a look at the "from" statement (new for 3.1-M1, see
http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes)
3. Yes, take a look at rule-flow at
http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa
ult.blog.PrjBlogPortletWindowDefaultBlog&project=jbossrules&from=1&link=
RuleFlow_%28Kris_Verlaenen%29#RuleFlow_%28Kris_Verlaenen%29 (although I
don't know if this is complete if 3.1-M1 - I think it's not). Although I
don't think your rules really need rule-flow; you just need to identify
and isolate the patterns (IF's) that would cause each "Do Something" to
be ran and create a rule for each - this has the benefit of separating
each action into a separate rule making maintenance a whole bunch
easier).
Anyway, I'd try some rules like the following examples (the rest are
based upon these):-
Rule "Rule 1"
when
NewItem ( itemStatusCode == null)
then
//do something
end
Rule "Rule 2"
when
$u : User( )
$ni : NewItem ( $isc : itemStatusCode != null )
not Codes ( codes contains $isc ) from
valDao.getValidItemStatusCodesForUser($u)
then
//Do something
end
Rule "Rule 3"
when
$u : User( )
$ni : NewItem( itemStatusCode == ItemVO.DELETED )
Codes ( codes contains $isc ) from
valDao.getValidCrossReferencePrimeCodesForUser($u)
then
//Do something
end
I've posted to the news group so everyone can contribute - don't be shy
;-)
With kind regards,
Mike
________________________________
From: Sanjay Singh - s0singh [mailto:Sanjay.Singh@wal-mart.com]
Sent: 26 March 2007 14:24
To: Anstis, Michael (M.)
Subject: Hi.
Hey Mike ... I am sorry to bother you but you seemed to be
pretty good with rules and i just could not think of anyone else to ask
abt it ... I am sorry if i am taking much of your time .. Here is my
problem if you can have a quick look ..
Look at this code once .. its very easy but it involves tons of
if else blocks conditions ..
if( newItem.getItemStatusCode() == null){
//do something
}
else{
if(
!valDao.isValidItemStatus(newItem.getItemStatusCode(),user) ){
//do something
}
if(
newItem.getItemStatusCode().equals(ItemVo.DELETED)||getItemStatusCode().
equals(ItemVo.INACTIVE) ){
if(
valDao.isCrossReferencePrime(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.isFutrCrossReferencePrimeOrSecond(newItem.getItemNbr(),user) ){
//do something
}
else if(
valDao.isComponentLink(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.hasWhseOnHandsOrOnOrders(newItem.getItemNbr(),user)&&CountryCode(
).equals("CA") ){
//do something
}
}
else{
if(
valDao.isUnlikeAsstParentWithNonActiveChildren(newItemNbr,user) ){
//do something;
}else if
(isLikeAssortmentBaby(newItemNbr,user)&&!alDao.isLikeAsstParentActive(ne
wItemNbr, user)){
//do something
}else{
//do something
}
}
}
}
What i am trying to understand is the right way of putting it in
drl files ..
1.What are the options for putting if else conditions ? Will i
have to write all the rules anyway and they will be called as well all
the time depending on the criteria ... or is there a way where when my
first if check which was if item number is null failed i should not go
for any other rules .. Is there a way where we could have like "when"
inside "when" .. kinda looping of conditions so if one does not meet you
dont go to the next .. jsut like in above blocks ? Whats the good way of
doing it ?
2.Is it possible to make database calls like from my dao
instance in LHS (condition) .. i know we can do it in RHS and i have
tested that as well but can we do it in LHS as sometimes we need to do
that ..like with null checks for the item status code we also want to
check something from the database like a boolean value and if that meets
the criteria we will run the rules ..as u can see above we have basic
state check with nulls etc plus we have some dao calls as well in the
condition part and then we //do something
3.Can i call rules within other rules .. so something like in
rule1 i want to call rule2 .. is that possible ?
Can you suggest a decent way of doing these if else blocks ..
this is the core stuff which we do for our rules here .. if i can handle
this kind of conditions i guess i can handle anything out here ...
Thanks for all the help ..
Sanjay
________________________________
*******************************************************************
*** This email and any files transmitted with it are
confidential
and intended solely for the individual or entity to whom they
are
addressed. If you have received this email in error destroy it
immediately.
******************************************************
**************** Wal-Mart Confidential
****************************
******************************************
17 years, 8 months
RE: [rules-users]The Rule is not working with milestone
by Sikkandar Nawabjan
Hi,
The below rule for dublicate checking is working fine with 3.0.5 but not with milestone version? Is that a problem with milesone?
rule "rule01"
when
$provAddress:ProviderAddress( $addType : addressTypeCode, $pPI : primaryPracticeIndicator )
$provAdd:ProviderAddress( addressTypeCode == $addType, $pp:primaryPracticeIndicator == $pPI )
then
System.out.println("Hi"+$addType+" "+$pPI+"::"+$pp);
retract($provAddress);
end
Basha
17 years, 8 months
(no subject)
by fakhfakh ismail
hello,
private static final String PROVIDER_CLASSNAME =
"org.drools.jsr94.rules.RuleServiceProviderImpl";
private static final String DROOLS_URI = "http://drools.org/";
private static final String RULE_URI = "rules.xml";
public static void main(String[] args)
when I write this code an error is affiched:
RuleException(javax.rules.ConfigurationException: No RuleServiceProvider registered against URI: http://drools.org/), root cause(null)
please help me
thank you
---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
17 years, 8 months