Re: [rules-users] String comparison question

2009-06-02 Thread Nagaraju runkana
Try like this..it's working fine.

$c :CashMemoDtl(articleCode:articleCode)
eval($c.getArticleCode().equals( Laptop)$c.getArticleCode().equals(
Mouse)  )

Thanks,
-Manya

2009/6/1 Armaghan Mahmud mahmud.armag...@gmail.com

 Hey guys,

 I read in a previous post that == in Drools 4.0.7 maps to .equals()
 automatically. My situation required me to put a String object into the
 working memory and do a comparison on it to see if a particular word is in
 the passed String sentence. Could anybody please guide me as to how to
 approach this problem? Thanks in advance. Here's my original code:


 rule Find Alpha in a sentence
 *

 salience
 * 100

 wrap: WrapperClass(Sentence == Alpha)

 then

 System.out.*println*(Aha found ya!);

 end





 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] ClassCastException and other problems

2008-06-10 Thread Nagaraju runkana
Hi Edson,

i have some problem...
*core_preference_text* this my table name.Row like VARIABLE_CODE
VARCHAR2(60 BYTE)

i need write dsl,dslr files related data validation to the table.
1. variable_code should be unieque per enterprise_id
2. variable_code can not be updated


give me some suggestion ..how to write dsl,dslr file related two
conditions.ASAP..

=
Chanti


On Fri, Jun 6, 2008 at 8:19 PM, Edson Tirelli [EMAIL PROTECTED] wrote:



   Drools 5 implements a completely new propagation algorithm that
 allowed us to get rid of shadow proxies from the core engine. So, you will
 not have the problem.

   But for 4.0.x, if you are a community user, best you can do is open a
 JIRA with a test case to reproduce your problem. If we release a 4.0.8
 version, we can fix your issue there, but at this moment we don't know if
 there will be a 4.0.8 release or if the next release will be 5.0.
   If you are a Drools subscriber at Red Hat, then you can simply open a
 support case there and they will fix and provide a patch for you.


   []s
   Edson



 2008/6/6 Sibylle Duerr [EMAIL PROTECTED]:

 Thanks Edson,

 but the collections do return an empty collection. hm, I just tested this
 ones again and it worked fine. no exception when the set was empty. I will
 keep an eye on this and test some more but seems to work now for me.

 and for the other problem I then hope for 5.0 :).

 and what about the last problem I described before?

 best regards
 Sibylle



 Edson Tirelli wrote:



   Sibylle,

   Unfortunately, this is the way it was implemented to be, under a
 kind-of fail-fast philosophy we were following. I do think there is value
 in changing things in 5.0 so that, for instance:

 ProcessModel($activities : activities) from $models

   Simply does not match, instead of raises a CCE, in case the model is a
 TypeModel.
   But for 4.0.x, that is how things work.

The only suggestion I can give you is, in your second problem, to not
 return null on your collections. Simply return empty collections:

 class Project {
   ...
   public List getModels() {
if( this.models == null ) {
return Collections.emptyList();
}
return this.models;
   }
   ...
 }
 This is usually a good thing, unless you have a specific semantics
 for null collections in your domain model.

[]s
Edson

 2008/6/6 Sibylle Duerr [EMAIL PROTECTED]:

Hi there,

I have three issues, where I'm not sure if these are bugs in
drools, or if this is just the way it has to be.

the used classes in this case are:

Project
Model
ProcessModel extends Model

only the Project is in the working memory, because I didn't want
to load all elements due to performance issues (there can be
thousends of elements to load at startup).

if I have the following rule:

Project($models : models)
ProcessModel($activities : activities) from $models

there happen to be two problems. if the project does not only
contain ProcessModels but also TypeModels or others (all extend
Model), this leads to a ClassCastException.
I can solve this by writing the rule as follows:

Project($models : models)
$m : Model(eval($m instanceof ProcessModel)) from $models
ProcessModel($activities : activities) from $m

but this is not really nice and I hope there is a better solution
for this, is there?

the second problem this rule gives me, is when the set 'models' is
empty. that will also throw an exception. to solve this I write:

$p : Project(eval($p.hasModels()), $models : models)
$m : Model(eval($m instanceof ProcessModel)) from $models
ProcessModel($activities : activities) from $m

and I need to use this in each case where I have possible empty sets.


the last problem I encountered when I tried to load all elements
to the working memory and then redefine some rules. used classes:

Aggregation extends DomainElement

rule:

Aggregation(owner.owner != type.owner)

causes some exception. the root exception is a ClassCastException:
ProxyShadowProxy cannot be cast to Aggregation.
when I rewrite the rule as:

$element : DomainElement(eval($element instanceof Aggregation))
Aggregation(owner.owner != type.owner) from $element

everything works fine. but that again is not a nice solution.

any help?

best regards
sibylle
___
rules-users mailing list
rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




 --
 Edson Tirelli
 JBoss Drools Core Development
 Office: +55 11 3529-6000
 Mobile: +55 11 9287-5646
 JBoss, a division of Red Hat @ www.jboss.com http://www.jboss.com
 

 ___
 rules-users mailing list
 

[rules-users] How to write related table dsl,dslr files

2008-06-10 Thread Nagaraju runkana
Hi ,

i have some problem...
core_preference_text this my table name.Row like VARIABLE_CODE VARCHAR2(60
BYTE)

i need write dsl,dslr files related data validation to the table.

1. variable_code should be unieque per enterprise_id
2. variable_code can not be updated


give me some suggestion ..how to write dsl,dslr file related two
conditions.ASAP..

=
Chanti
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] phone number validation using drools

2008-06-02 Thread Nagaraju runkana
 Hi ,
i am trying validate complex expression for phone numberl?

rule test2
 when
  $m : Message(email:email,phone:phone)
 Message(phone matches
^(([\\+]?\\d{1,3}(-|\\.)?\\(?\\w\\)?(-|\\.)?\\d{1,3})|(
\\(?\\d{2,3}\\)?))(-|\\.)?(\\d{3,4})(-|\\.)?(\\d{4file://(/?\\d{2,3}\\)?))(-|\\.)?(\\d{3,4})(-|\\.)?(\\d{4})((
x| ext)\\d{1,5}){0,1}$
then
   System.out.println(Invalid phone number:  + phone );
end 


in this case  some error should be comming.pls find out whethere the
expression is correct or not.

java.util.regex.PatternSyntaxException: Unknown inline modifier near index
21
^(([+]?d{1,3}(-|.)?(?w)?(-|.)?d{1,3})|((?d{2,3})?))(-|.)?(d{3,4})(-|.)?(d{4})((
x| ext)d{1,5}){0,1}$
 ^
 at java.util.regex.Pattern.error(Pattern.java:1713)
 at java.util.regex.Pattern.group0(Pattern.java:2519)
 at java.util.regex.Pattern.sequence(Pattern.java:1806)
 at java.util.regex.Pattern.expr(Pattern.java:1752)
 at java.util.regex.Pattern.group0(Pattern.java:2530)
 at java.util.regex.Pattern.sequence(Pattern.java:1806)
 at java.util.regex.Pattern.expr(Pattern.java:1752)
 at java.util.regex.Pattern.group0(Pattern.java:2530)
 at java.util.regex.Pattern.sequence(Pattern.java:1806)
 at java.util.regex.Pattern.expr(Pattern.java:1752)
 at java.util.regex.Pattern.compile(Pattern.java:1460)
 at java.util.regex.Pattern.init(Pattern.java:1133)
 at java.util.regex.Pattern.compile(Pattern.java:823)
 at java.util.regex.Pattern.matches(Pattern.java:928)
 at java.lang.String.matches(String.java:2091)
 at
org.drools.base.evaluators.StringFactory$StringMatchesEvaluator.evaluate(StringFactory.java:211)
 at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:61)
 at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:82)
 at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)
 at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
 at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
 at org.drools.reteoo.Rete.assertObject(Rete.java:175)
 at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
 at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:909)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:881)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:682)
 at com.sample.DroolsTest.main(DroolsTest.java:40)


regards,
Chanti
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] how to write regular expressions in drools..

2008-05-30 Thread Nagaraju runkana
HI Guys,

present i am using drools 4.0 in this case.now, i am writting some rules
validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
this..

validation.dslr

rule email.mandatory:[insert][update][ui]
 when
  There is an Order
  Order email address checking for first letter
then
 Reject with response : email address must not start with @ 
end
rule phone.mandatory:[insert][update][ui]
when
 There is an Order
 Order phone number format should checking
 then
 Reject with response : The phone number you entered is not valid.Please
enter a phone number with the format xxx-xxx-.\
end
---
validation.dsl

[*][]Order email address checking for first letter= OrderBean(email matches
@[A-Za-z0-9]*)
[*][]Order phone number format should checking=OrderBean( phone not matches
(/\d{3}\-\d{3}\-\d{4}/)==-1))
this rules are not working ...any one can help me.ASAP

thanks,
chanti
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how to write regular expressions in drools..

2008-05-30 Thread Nagaraju runkana
Thanks for replay Chri.

in present product is writting rules validating fields related to table.In
this case i writting diff rules.like this is length rule it's working ...

rule name.lengthRule:[insert][update][ui]
 when
  There is an Category
  Category name length is greater than 8
  //CategoryBean($catid:catid,$name:name,$descn:descn)
  //CategoryBean(name != null, eval(name.length()  8) )
  then
  Reject with response : name length must be less than 8
//ruleViolationMap.put(drools.getRule().getName(),name length must be less
than 80); if(!isSuppressMode){ drools.halt(); }
end

  now i am trying write diff rules like email,zipcode,credit card
  i am trying to use regular expressions.In this case negativeTestCases also
Build Success.like this...suppose i am set in to the value like ..
bean.setEmail(@chnati);
in this cases actuly Build failure in our testcases.But,this time also Build
Success.

[*][]Order email address checking for first letter= OrderBean(email matches
@[A-Za-z0-9]*)

If any possiable give me the related code email,zipcode,phone number.ASAP...

On Fri, May 30, 2008 at 2:15 PM, Christine [EMAIL PROTECTED] wrote:

 Chanti,
 what exactly is your question?
 I think that checking zipcode and credit card formats is easier to do in
 java than with rules. Rules are more efficient in more complex situations,
 like when you have multiple objects that need to meet various conditions.

 Christine


 On Fri, May 30, 2008 09:24, Nagaraju runkana wrote:
  HI Guys,
 
  present i am using drools 4.0 in this case.now, i am writting some rules
  validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
  this..
  
  validation.dslr
  
  rule email.mandatory:[insert][update][ui]
   when
There is an Order
Order email address checking for first letter
  then
   Reject with response : email address must not start with @ 
  end
  rule phone.mandatory:[insert][update][ui]
  when
   There is an Order
   Order phone number format should checking
   then
   Reject with response : The phone number you entered is not valid.Please
  enter a phone number with the format xxx-xxx-.\
  end
  ---
  validation.dsl
  
  [*][]Order email address checking for first letter= OrderBean(email
  matches
  @[A-Za-z0-9]*)
  [*][]Order phone number format should checking=OrderBean( phone not
  matches
  (/\d{3}\-\d{3}\-\d{4}/)==-1))
  this rules are not working ...any one can help me.ASAP
 
  thanks,
  chanti
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 


 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how to write regular expressions in drools..

2008-05-30 Thread Nagaraju runkana
HI Jar,
 Thanks for replay,
 i am try to like this also: email matches @\[A-Za-z0-9\]*
in this case also nagetive test cases Build Success.

Chanti

On Fri, May 30, 2008 at 2:49 PM, Jaroslaw Kijanowski 
[EMAIL PROTECTED] wrote:

 Hi,
  you have to escape characters with regexp meaning (see docs for details).
 Try this:
 email matches @\[A-Za-z0-9\]*
 phone not matches d{3}-d{3}-d{4}

 Moreover I guess your rule is anyway broken, you will get a cross product
 of Orders, so I would remove There is an Order from both rules.

 Cheers,
  Jarek

 Nagaraju runkana wrote:

  HI Guys,

 present i am using drools 4.0 in this case.now, i am writting some rules
 validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
 this..
 
 validation.dslr
 
 rule email.mandatory:[insert][update][ui]
  when
  There is an Order
  Order email address checking for first letter
 then
  Reject with response : email address must not start with @ 
 end
 rule phone.mandatory:[insert][update][ui]
 when
  There is an Order
  Order phone number format should checking
  then
  Reject with response : The phone number you entered is not valid.Please
 enter a phone number with the format xxx-xxx-.\
 end
 ---
 validation.dsl
 
 [*][]Order email address checking for first letter= OrderBean(email
 matches
 @[A-Za-z0-9]*)
 [*][]Order phone number format should checking=OrderBean( phone not
 matches
 (/\d{3}\-\d{3}\-\d{4}/)==-1))
 this rules are not working ...any one can help me.ASAP

 thanks,
 chanti



 

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how to write regular expressions in drools..

2008-05-30 Thread Nagaraju runkana
i am trying to another way like this ..

rule email.firstletter:[insert][update][ui]
when
 There is an Order
 Order email address statr with @
 // OrderBean(eval(email.indexOf('@',0) == 0))
then
 Reject with response : email address must not start with @
end

this time also same problem.any another to slove this problem.


On Fri, May 30, 2008 at 3:32 PM, Jaroslaw Kijanowski [EMAIL PROTECTED]
wrote:

 Yeah, but that's not a drools issue any more. I guess your regexp is not
 sufficient to catch an email address.
 The rule will fire when you provide @aa but it will not fire if you use @
 aa.com, right? google for Validate an Email Address and you will find
 regexps which will handle the dot and other chars.


 Cheers,
  Jarek

 Nagaraju runkana wrote:

 HI Jar,
  Thanks for replay,
  i am try to like this also: email matches @\[A-Za-z0-9\]*
 in this case also nagetive test cases Build Success.

 Chanti

 On Fri, May 30, 2008 at 2:49 PM, Jaroslaw Kijanowski 
 [EMAIL PROTECTED] wrote:

 Hi,
  you have to escape characters with regexp meaning (see docs for
 details).
 Try this:
 email matches @\[A-Za-z0-9\]*
 phone not matches d{3}-d{3}-d{4}

 Moreover I guess your rule is anyway broken, you will get a cross product
 of Orders, so I would remove There is an Order from both rules.

 Cheers,
  Jarek

 Nagaraju runkana wrote:

  HI Guys,

 present i am using drools 4.0 in this case.now, i am writting some rules
 validation using regular expression ZIPCODE,EMAIL,CREDIT CARD
 number.like
 this..
 
 validation.dslr
 
 rule email.mandatory:[insert][update][ui]
  when
  There is an Order
  Order email address checking for first letter
 then
  Reject with response : email address must not start with @ 
 end
 rule phone.mandatory:[insert][update][ui]
 when
  There is an Order
  Order phone number format should checking
  then
  Reject with response : The phone number you entered is not
 valid.Please
 enter a phone number with the format xxx-xxx-.\
 end
 ---
 validation.dsl
 
 [*][]Order email address checking for first letter= OrderBean(email
 matches
 @[A-Za-z0-9]*)
 [*][]Order phone number format should checking=OrderBean( phone not
 matches
 (/\d{3}\-\d{3}\-\d{4}/)==-1))
 this rules are not working ...any one can help me.ASAP

 thanks,
 chanti



 

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users