[rules-users] drools syntax highlighting editor

2010-09-18 Thread Matt Young
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

is there a drools syntax highlighting widget along the lines of
tinymce for regular html pages.  I'm certain there is a seam or JSF
component but my application is a JSP based springmvc application and
I would like to not have to migrate to something else, just to
provided a good rules editor in my application.

- -- 
Cheers,
Matt Young
so...@youngdev.net
http://youngdev.net

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMlSqqAAoJEO5jycTTPEzcm4gQAJzG22gY+KRj+D6EdJzH4PfH
/WARpfHy+wtyy2N6WGmvpOnmUXsa4f4OTyIdU/DPf+4Sg+qSrDzZ3FzcTB3clQwD
vRVxfcF3ggGzEgZxUYVsaJdAtuhOn/rTwlybZZJYhHVnSorglMWn/eGbzrTtFpMs
CWTl4oewkamKHfGcBOymhEs5CwCuCG18HEwggYAirnO278T3zm4N1b+eTyp2vpyQ
EP+KwIUbjCHyve3u2J2qOLw5ajlUe8rM2z8bRSXgRZUUwtcWl9I66l08oS21/4ZF
Yfnqz1SoEgcKW2Cd8KjQ7ELihP9PGFfwCAvLZv+A1fIGIgqNRY/bKVIo+cB0s8Pb
OWKgYIbGTKD34xon858J/yxkeh4NQS24RJXj/1WoKsqvbmB3OmBDdK4MkAaF1rtg
iTGGp56AaXSI+FMRUF6tTESQCai+g6noKQqyjooWcmO8fETFBsKs/k2voATziJ9z
OgVjwfQ3akO0SpFNggnG3YEFqWqaHlkeBw8cFt7LtVQf+S2YBEvkAqA7digb+czK
d/MdnhmGvshBXquJDUwwPcS6/+Q3c5PbBIoKxUTPmcKOL5JS29NfQOjsuJtMX1uS
xZ4HPlCkIncJLyYNuuwSja5qMgtxX0FYRCk7VZERevr0gUETtUWmigENJEAVHL1a
CbVl9QDLfAChJ5crxwDd
=VjEx
-END PGP SIGNATURE-

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


Re: [rules-users] drools quirks

2010-09-18 Thread Matt Young
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks Wolfgang,
  The no-loop attribute fixed my crazy looping problem and your answer
on knowing EVERYTHING the rule might ever have to do is a good
answer.  I guess there will be a certain amount of trust I have to
place in the users.  In the meantime, are there any books on drools
you reccomend (other than the manual)?

On 09/18/2010 01:24 PM, Wolfgang Laun wrote:
>
> On 18 September 2010 17:19, Matt Young  <mailto:so...@youngdev.net>> wrote:
>
> ksession.execute(document);
>
>
> I suppose this inserts a single EventRulesDocument object.
>
>
> Here is the rule:
>
> package sample1
>
> import sample1.bean.EventRulesDocument; import
> sample1.bean.Transaction; import java.util.Date;
>
> rule "Standard processing rule"
>
> when $doc : EventRulesDocument( ruleRun == false &&  # <<<
> Wolfgang event != null && event.eventType.eventCode == "testevent"
> ) then
>
> Transaction t = new Transaction(); t.setEvent($doc.getEvent());
> t.setCategory($doc.getEvent().getEventType().getEventCode());
> t.setTransactionAmount($doc.getEvent().getEventAmount());
> t.setCreateTs(new Date());
> t.setUsername($doc.getEvent().getCreateUsername());
>
> modify( $doc ) {setRuleRun(true)};   # Wolfgang <<<<<< modify( $doc
> ) {addSaveTransaction(t)} ;
>
>
> Here it is: You modify the EventRulesDocument, which causes
> another activation of the same rule. One way of avoiding this is to
> add the rule attribute no-loop true; another one is what you've
> done.
>
> This isn't going to be your only rule?? This one alone is scant
> reason to use an RBS.
>
> fireAllRules( 1 ) isn't a good remedy, because (normally) a
> Production System relies on repeated firings, depending on rules
> and facts.
>
>
> end
>
>
> Additionally If any code in the world can be executed in the RHS,
> then why shouldn't I just use groovy as my rule language?  At
> least then, I can write math like such: def num1=95; def num2=90;
> def num3=num2/num1;
>
> and all of the math is done with big decimal objects.  IF there is
> no restriction on what can be done in the RHS what is the advantage
> to using a rules engine over a general purpose scripting language?
>
>
> There is a good section in the Drools Expert manual: "Why use a
> rule engine?". Don't do it just to be trendy ;-)
>
>
> The whole purpose for me choosing drools over Groovy eval() was
> that I didn't want to give my users the ability to spawn threads,
> allocate massive amounts of memory etc.
>
>
> Seriously now, a Domain Specifiy Language is the maximum corset you
> can force upon your users. But you'll have to know /all/ they /may
> /do, and all the conditions.
>
> -W
>
>
>
> On 09/18/2010 10:59 AM, Wolfgang Laun wrote:
>> On 18 September 2010 16:15, Matt Young  <mailto:so...@youngdev.net>
>> <mailto:so...@youngdev.net <mailto:so...@youngdev.net>>> wrote:
>>
>> I just started using drools and this is my first time
>> implementing a rules engine.  Everything has been pretty smooth
>> but I have some quirks that I am not sure I can live with. 1) for
>> some
> reason,
>> if I execute the Knowlege session against an object, the
>> knowlege session never returns.
>>
>>
>>> I don't understand the term "execute...against an object". Do
>>> you mean that you have just one fact inserted befor you call
>>> fireAllRules()?
>>
>>> But anyway, this call not returning is almost certainly due to
>>> a loop in your rules, or have you made sure that they don't?
>>
>>
>> The only way I can get the ksession to return is to make IF
> (obj ==
>> null) part of the LHS and make
>> modify($input){setObj("complete")} part of the RHS This seems
>> like a deficiency since I have users writing their own rules, I
>> can see them forgetting this requirement.
>>
>>
>>> Writing rules is programming, no holds barred :-)
>>
>>> Look into Domain Specific Languages (DSL) as a cushion for the
>>> unwary.
>>
>>
>>
>> IS their a way to get the ksession to firerules only once?  If
>> so what does that look like?
>>
>>
>>> kSession.fireUntilHalt( 1 );
>>
>>
>> 2) It seems that any code I want can be executed in the RHS.  I
>> could literally execute something like the following in the RHS.
>>
>> byte[] b= new byte[10]; // Really big memory waste
>>
>> I also could just start a bunch

Re: [rules-users] drools quirks

2010-09-18 Thread Matt Young
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

OK I looked closer at what Wolfgang said.  By calling fireAllRules(int
limit) instead of execute(object), my rules now fire and return
immidiately without having to set a false condition for the lhs in the RHS

That still does not give me the ability to properly restrict what
objects the rules can create etc.

On 09/18/2010 10:59 AM, Wolfgang Laun wrote:
> On 18 September 2010 16:15, Matt Young  <mailto:so...@youngdev.net>> wrote:
>
> I just started using drools and this is my first time implementing
> a rules engine.  Everything has been pretty smooth but I have
> some quirks that I am not sure I can live with. 1) for some reason,
> if I execute the Knowlege session against an object, the knowlege
> session never returns.
>
>
>> I don't understand the term "execute...against an object". Do you
>> mean that you have just one fact inserted befor you call
>> fireAllRules()?
>
>> But anyway, this call not returning is almost certainly due to a
>> loop in your rules, or have you made sure that they don't?
>
>
> The only way I can get the ksession to return is to make IF (obj ==
> null) part of the LHS and make modify($input){setObj("complete")}
> part of the RHS This seems like a deficiency since I have users
> writing their own rules, I can see them forgetting this
> requirement.
>
>
>> Writing rules is programming, no holds barred :-)
>
>> Look into Domain Specific Languages (DSL) as a cushion for the
>> unwary.
>
>
>
> IS their a way to get the ksession to firerules only once?  If so
> what does that look like?
>
>
>> kSession.fireUntilHalt( 1 );
>
>
> 2) It seems that any code I want can be executed in the RHS.  I
> could literally execute something like the following in the RHS.
>
> byte[] b= new byte[10]; // Really big memory waste
>
> I also could just start a bunch of threads.
>
> The point is that I am intending to let the users write their own
> rules but I can't do that if there are no restrictions on how/what
> can be done inside the rules.  Any suggestions?  Are there
> sandboxes or filters I can activate to restrict the RHS?
>
>
>> Again: DSL.
>
>> Also, Rule Templates might be the starting point; it'd depend on
>> what the may be allowed to do.
>
>> And what about good old-fashioned training?!
>
>> -W
>
>

___
rules-users mailing list
rules-users@lists.jboss.org <mailto: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

- -- 
Cheers,
Matt Young
so...@youngdev.net
http://youngdev.net

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMlNuqAAoJEO5jycTTPEzcQ/wQAICJezwHIqTEm4P01vAzvnD+
Mjfgnaea3q8p7d/Vkapej4lOxOJ1tDHl/msa/JgHraTKttgcn8oHzWkavgx9L2+4
VKZBPyU4YUYdfHkE2TVRs0D0Lr/hJwzqP+uA4ryFB+pwGAbf8hpKLZ+8kmWXQfEe
9Towivs+d01BOXK0ob3+2D7ywWeW9nadx1SqBqu3z0tY8pOiN+4R4ucu9VrYpfzF
/uv72pBa5S96suQZTkLO2W7/R79PjSZCzjl+OHIEMyQR4nR0jUpwr6yjp/7o64u4
O6Byo9gcZo1Nqh+q2WAH2LPHAJ48/Btmpl2sp6JRmkUD7ccbvIcj11KGt/VelFMs
Dn7VtzbkcCLGDiU+pRQKytkMyXS0kiWSBsf1u9nD8gMaXXYEChDNO3Su/c6HydmG
lhrKVRk+Jo7UWvjBGB/Mnn3QWpZPHiq8CtcQOcMI8xbeV+vnXrm3fXayaN7qjJ4C
MB1plfW6EIFkbRz6KnCoYalz0/Brb+tLM0Gxn17mL949okVS5K2qC36LOJDWq1qG
DBZTmFiaWgP8fuuN12MI5ZmdTmIDAaRAMKmFAUAI5GB6ajzD7wjKr9Up3OGRWfS3
MIL7fWca61S1Kp4tmQe/SAJJQgSD6vd/nDnpG/LE9B/bUm/mOYpAart4QtAWxnlq
2ow3pOr5GmRc7DOb4DTh
=Gq8a
-END PGP SIGNATURE-

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


Re: [rules-users] drools quirks

2010-09-18 Thread Matt Young
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

maybe now would be a good time for some code.  Here is how I am
executing the rules against the object:
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();


KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
   
kbuilder.add(ResourceFactory.newByteArrayResource(ruledata),ResourceType.DRL
);
if ( kbuilder.hasErrors() ) {
System.err.println( kbuilder.getErrors().toString() );
}
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatelessKnowledgeSession ksession =
kbase.newStatelessKnowledgeSession();
ksession.execute(document);

Here is the rule:

package sample1

import sample1.bean.EventRulesDocument;
import sample1.bean.Transaction;
import java.util.Date;

rule "Standard processing rule"

when
  $doc : EventRulesDocument(
ruleRun == false &&  # <<< Wolfgang
event != null && event.eventType.eventCode == "testevent" )
then
   
   Transaction t = new Transaction();
t.setEvent($doc.getEvent());
t.setCategory($doc.getEvent().getEventType().getEventCode());
t.setTransactionAmount($doc.getEvent().getEventAmount());
 t.setCreateTs(new Date());
 t.setUsername($doc.getEvent().getCreateUsername());

modify( $doc ) {setRuleRun(true)};   # Wolfgang <<<<<<
modify( $doc ) {addSaveTransaction(t)} ;

   
end

If I take out the 2 lines marked "Wolfgang", the ksession never
returns from the execute() method.

Additionally If any code in the world can be executed in the RHS, then
why shouldn't I just use groovy as my rule language?  At least then, I
can write math like such:
def num1=95;
def num2=90;
def num3=num2/num1;

and all of the math is done with big decimal objects.  IF there is no
restriction on what can be done in the RHS what is the advantage to
using a rules engine over a general purpose scripting language?  The
whole purpose for me choosing drools over Groovy eval() was that I
didn't want to give my users the ability to spawn threads, allocate
massive amounts of memory etc.  

On 09/18/2010 10:59 AM, Wolfgang Laun wrote:
> On 18 September 2010 16:15, Matt Young  <mailto:so...@youngdev.net>> wrote:
>
> I just started using drools and this is my first time implementing
> a rules engine.  Everything has been pretty smooth but I have
> some quirks that I am not sure I can live with. 1) for some reason,
> if I execute the Knowlege session against an object, the knowlege
> session never returns.
>
>
>> I don't understand the term "execute...against an object". Do you
>> mean that you have just one fact inserted befor you call
>> fireAllRules()?
>
>> But anyway, this call not returning is almost certainly due to a
>> loop in your rules, or have you made sure that they don't?
>
>
> The only way I can get the ksession to return is to make IF (obj ==
> null) part of the LHS and make modify($input){setObj("complete")}
> part of the RHS This seems like a deficiency since I have users
> writing their own rules, I can see them forgetting this
> requirement.
>
>
>> Writing rules is programming, no holds barred :-)
>
>> Look into Domain Specific Languages (DSL) as a cushion for the
>> unwary.
>
>
>
> IS their a way to get the ksession to firerules only once?  If so
> what does that look like?
>
>
>> kSession.fireUntilHalt( 1 );
>
>
> 2) It seems that any code I want can be executed in the RHS.  I
> could literally execute something like the following in the RHS.
>
> byte[] b= new byte[10]; // Really big memory waste
>
> I also could just start a bunch of threads.
>
> The point is that I am intending to let the users write their own
> rules but I can't do that if there are no restrictions on how/what
> can be done inside the rules.  Any suggestions?  Are there
> sandboxes or filters I can activate to restrict the RHS?
>
>
>> Again: DSL.
>
>> Also, Rule Templates might be the starting point; it'd depend on
>> what the may be allowed to do.
>
>> And what about good old-fashioned training?!
>
>> -W
>
>

___
rules-users mailing list
rules-users@lists.jboss.org <mailto: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

- -- 
Cheers,
Matt Young
so...@youngdev.net
http://youngdev.net

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Commen

[rules-users] drools quirks

2010-09-18 Thread Matt Young
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I just started using drools and this is my first time implementing a
rules engine.  Everything has been pretty smooth but I have  some
quirks that I am not sure I can live with.
1) for some reason, if I execute the Knowlege session against an
object, the knowlege session never returns.  The only way I can get
the ksession to return is to make IF (obj == null) part of the LHS and
make modify($input){setObj("complete")} part of the RHS
This seems like a deficiency since I have users writing their own
rules, I can see them forgetting this requirement.  IS their a way to
get the ksession to firerules only once?  If so what does that look like?
2) It seems that any code I want can be executed in the RHS.  I could
literally execute something like the following in the RHS.

byte[] b= new byte[10]; // Really big memory waste

I also could just start a bunch of threads.

The point is that I am intending to let the users write their own
rules but I can't do that if there are no restrictions on how/what can
be done inside the rules.  Any suggestions?  Are there sandboxes or
filters I can activate to restrict the RHS?

- -- 
Cheers,
Matt Young
so...@youngdev.net
http://youngdev.net

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMlMmHAAoJEO5jycTTPEzclUwQAJdLYF183A5fSo9cN0a1gkkR
bRyIEgUBUZGQVZi+W7vezQMVqLtV1/+HkfDj5EdylD9fGS6/OsBzOKMCKb4IIuOe
j8xgp4Z85G5JmowhWDh9AYfHMwcOJ/QSjrPm4ABs3ZQilBEeSKcYBNZ/YNX9WhVN
ZMeLwx9+VJqK1Wj4Aue6zdG4XiSA+CTNL309xLgyGkoiWtnp3+wY4Q3q1WGArWti
uIq0tN1xGk9mRkSGepdAjycv5mc+9BCjh6/5UqSIMsWSTqKzm6ce96YQIMgMV77m
J6/ya91eTGiqXXpXsrSKJSHUFe7ExAJjjVZFzXT55FSNRBzrInCXDIyMfH6hX00E
KFQyQWHi3lLRPSKnBpkBGQj1ZPB3WMBvq8Kfjjszzoa3MjmsfNy21YdrSdLUnJPC
NNdBCwYmNbntRu+6fhk8D5OxlLXqAY+OcuVLjySKdBq6eA+Q20XN8+GLWwAjSD8K
vc0/6HAICKzOXhpSiPEFsPSOxT/FSVBXPOmoO0fMoxjOLpEHU2G5CB6lIn8zZngQ
GodDE6s9uOWLsEyxsBCp7Nb9uLNEFXVW91SsYcGQuzCrVgwPR4Dc/KUzOdYUPIaM
RC1laZbdEfrhisZrHAkZDaMSzaYZO48Vb4ZpCJTqCVESdwjRbBLtTG7YNAFBKQQw
BN9Qjq6IJUUJDzfawsrr
=1xoA
-END PGP SIGNATURE-

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