Re: [rules-users] A relational SQL Database as RuleBase

2009-06-04 Thread Marcus Ilgner
On Wed, Jun 3, 2009 at 10:21 PM, r.r.neum...@freenet.de
 wrote:
>
> Hi guys,
>
> my question is listed in the topic. Is it possible? I read, that Drools 4
> provides such a feature but in this case, there is noch DSL available? Is
> this correct? What's about Drools 5, same thing?
>
> Thanks for an answer!
>
> Regards
> René
>

If you want to store the rules in a RDBMS in order to have them
accessible from many sources and/or outside your application, you may
want to consider using Guvnor to decouple the rule management from the
main application code.
Inside your app you can then download the rules which were created
within Guvnor from a URL on the application server.
Maybe that helps.

Best regards
Marcus

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


Re: [rules-users] The Eclipse JDT Core jar is not in the classpath error

2009-06-02 Thread Marcus Ilgner
2009/6/2 Chris Richmond :
> Hello,
>
>
>
> I am using netbeans and ivy with Drools 5.  I have successfully named,
> published the jars from drools to and could build my port of the stock
> ticker application in netbeans, but when I try to run it, I get the
> following error:
>
>
>
>
>
> java.lang.NoClassDefFoundError: org/antlr/runtime/tree/TreeNodeStream
>
>
>
> I have the antlr-runtime jar from the bin/lib on my classpath where I added
> all the others, but it always fails at this line
>
> In loadRuleBase() in Broker.java of the stock ticker sample
>
>
>
> builder.add( ResourceFactory.newInputStreamResource(
> Broker.class.getResourceAsStream( RULES_FILE ) ),
>
> ResourceType.DRL);.
>
>
>
>
>
> Does anyone have any ideas what jar I might be missing if it’s not the
> antlr-runtime?
>
>
>
> Thanks,
>
> Chris
>

Hi,

in one of my projects, I actually needed two different versions of
antlr in the classpath. Did you check if the class referenced in the
exception actually exists in the deployed antlr jar file?

Best regards
Marcus

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


Re: [rules-users] Does drools have any trigger?

2009-04-28 Thread Marcus Ilgner
2009/4/24 Lindy hagan :
> I was looking at  Blaze Advisor documentation it has  “when changed”
> operator that only fires when an attribute of an object changes. A business
> analyst might use it to watch for any important issue, such as a thermostat
> warning in a process plant or a particular stock reaching a certain price or
> volume.
>
> In similar way does Drools have this feature?
>
> Can any one correct if I am wrong: Rules can be updated by business users
> thru BRMS and Guvnor? (I did not get chance to go thru these)

Hi,

you can register your business objects (facts) as dynamic facts. They
will need to implement addPropertyChangeListener and related methods.
That way, as soon as a property that is used in a rule changes, the
rule will re-evaluate and fire if appropriate.
See section 2.5.4.7. of the docs for more information on this feature.

Best regards
Marcus

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


Re: [rules-users] Writing rules using java from template

2009-03-31 Thread Marcus Ilgner
2009/3/31 Meny Kobel :
> Hi,
> First - Thanks for your quick response.
> Second - As I wrote rules conditions are saved in DB.
>
> Conditions table example :
>
>
> TypeName    Operation       Value                Return Value
> Var1                 >=    5    “Segment
> 1”
> Var2 matches  “someString”    “Segment 1”
> Var3 <                  6    “Segment
> 1”
> Var4                  ==   1                        “Segment
> 2”
> Var5  ==                5   “Segment
> 2”
>
> The table above should trasform to the following DRL rule -
>
> rule "example 1"
>     when
>
>     Bean(var1 >= 5 ,var2 matches "someString",var3 < 6)
>
>     then
>         list.add("Segment 1");
> End
>
> rule "example 2"
>     when
>     Bean(var4 == 1 ,var5 == 5)
>     then
>         list.add("Segment 2");
> End
>
> The conditions are dynamically build on Site by customer and I don’t know
> the number of conditions And the conditions values(the values of columns
> TypeName,Operation, Value and Return Value ).
>
> On Tue, Mar 31, 2009 at 2:35 PM, Meny Kobel  wrote:
>>
>> Hi,
>> Any updates regarding this subject?
>> I have the same problem and can't find a solution.
>> Like newbie I need to read varying rules from DB and transform them to
>> drools language.
>>
>> Thanks,
>> Meny
>

Hi,

since you seem to have a concrete idea on how your rules should look,
you can simply render them into a String according to your
specification and then pass a StringReader to
PackageBuilder.addPackageFromDrl(). The resultig package can then be
added to your rulebase.
Of course you could also use rules to generate the rules from the
conditions in the DB, which would be more complex but more extensible,
too.

HTH
Marcus

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


[rules-users] Defining fallback rules

2008-09-17 Thread Marcus Ilgner
Hi all,

I'm currently puzzled on how to implement a sort of fallback rule. In
my scenario I have a couple of articles and payments related to those
articles. Now I need to distribute royalties to the authors of these
articles. There's a common business logic which says "distribute X
percent for articles of type T, Y percent for articles of type S and Z
percent for all other articles".
At first, my approach was to write the rules like this (omitting a
rule for type 'S' for the sake of brevity):

rule1
activation-group "article1"
salience 100
when
  $article : Article(type == 'T')
  $payment : Payment( article==$article )
then
  account(x%)
end

rule3
activation-group "article1"
salience 0
when
  $article : Article()
  $payment : Payment( article==$article )
then
  account(z%)
end

However, I quickly found out that the use of activation-group will
then only consider all articles of type T and ignore all other
fact-combinations. Retracting payments from the WM is also not
feasible since there may be other rules that should work on them.
I also cannot write the last rule as Article( type != 'T', type != 'S'
etc) since new article types may be added later on and it would not be
manageable to update all previously written rules (which may very well
number in thousands in the future).
Now I'm a bit stuck on this issue and would welcome any hints.

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


Re: [rules-users] Storing RuleDescr and/or PackageDescr in a database table

2008-09-17 Thread Marcus Ilgner
Hi,

On Mon, Sep 15, 2008 at 10:11 PM, imraan <[EMAIL PROTECTED]> wrote:
>
> Users in my system will be able to configure their own rules to an extent
> through a UI.  I will create these rules programmatically using the
> org.drools.lang.descr package.  Right now, I am trying to see if its
> possible to store the RuleDescr or PackageDescr object(s) in a database.  Is
> there another way to store these objects in a database besides storing the
> contents of a DRL dump?
>
> Thanks,
> Imraan

those objects implement java.io.Serializable, so you can directly
write them to and from a storage type of your liking.

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


Re: [rules-users] Request for assistance in removing eval from a rule

2008-09-17 Thread Marcus Ilgner
Hi,

On Wed, Sep 17, 2008 at 12:48 AM, Warren, David [USA]
<[EMAIL PROTECTED]> wrote:
> If it helps, RulesUtil.containsKeywordString()  checks to see if a string
> passed in is present in a list of keywords held in the class.
>

maybe it would work if you asserted your keywords as a List
global and then did something like

s1 : Sensor( source == "X", $rfp : RFP , $rfp memberOf keywordList , $tcn : TCN)

But I'm not sure if "memberOf" would work in this case since the
documentation states that it requires a variable.

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


Re: [rules-users] Handle activationCancelled Event

2008-07-25 Thread Marcus Ilgner
On Fri, Jul 25, 2008 at 3:15 PM, Ingomar Otter <[EMAIL PROTECTED]> wrote:
> Why don't you use facts for control?
> when mylamp=="on"
> then
> assert/update sth?
>
> That looks easier to me.
>
> --I

Indeed. If I understand your problem correctly, the corresponding rule
should rather look like
rule "Lamp is not on"
when
 $lamp : Lamp(state != "on")
then
// the lamp isn't on anymore - do something
end

Best regards
Marcus

> Am 25.07.2008 um 13:04 schrieb Claudio Rainoldi:
>
>> Hi everyone,
>> i'm developing a java application using drools 4 for domotic control;
>> i ve implemented a listener on my working memory with the method
>> afterActivationFired(...)
>> and activationCancelled(...) .
>> At startup of my app i've write the following lines:
>>
>> listener = *new* FiredRulesListener();
>> workingMemory.addEventListener(listener);
>>
>> Each time a rule is fired the method afterActivationFired(...) is called
>> and
>> it is ok; but when the rule stop to be true the method
>> activationCancelled  isn't
>> never called.
>> I try to be more clear:
>>
>> i 've the following rule:
>> when mylamp=="on"
>> then
>> System.out.println("light 1 on");
>>
>>
>> When i turn on the light 1 the method afterActivationFired(...)  is
>> called,
>> but when i turn off the light the method activationCancelled isn't called.
>> Can someboy help me??
>> Thanks in advance.
>>
>>
>> Cla
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Handle activationCancelled Event

2008-07-25 Thread Marcus Ilgner
On Fri, Jul 25, 2008 at 1:04 PM, Claudio Rainoldi
<[EMAIL PROTECTED]> wrote:
> Hi everyone,
> i'm developing a java application using drools 4 for domotic control;
> i ve implemented a listener on my working memory with the
> method afterActivationFired(...) and activationCancelled(...) .
> At startup of my app i've write the following lines:
>
> listener = new FiredRulesListener();
> workingMemory.addEventListener(listener);
>
> Each time a rule is fired the method afterActivationFired(...) is called and
> it is ok; but when the rule stop to be true the
> method activationCancelled  isn't never called.

Afaik, activationCancelled works like this:
The fact is added, a rule would match, the activation is scheduled.
However, another rule (probably with higher priority) matches, too,
and it modifies the fact in a way that would make the first rule not
match - thus, the activation is cancelled and the corresponding
listener method gets called.

Somebody correct me if I'm wrong, please ;)
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to avoid circular rule activation for non circular problems?

2008-07-24 Thread Marcus Ilgner
On Thu, Jul 24, 2008 at 3:28 PM, Ralph Ammon <[EMAIL PROTECTED]> wrote:
> I'd like to get some hints to improve the rules of my simple planning
> system.
>
>
>
> My simple planning system is derived from the HelloWorld Drools Project. The
> job of my planning system is to calculate startTime and endTime as function
> of duration and predecessors for each task. Each task has the fields
>
> long duration;
>
> Set predesessors;
>
> long startTime;
>
> long endTime;
>
> For each task the rule (endTime = startTime + duration) should hold. If a
> task has no predecessors, then its startTime should be 0. If a task has
> predecessors, then is should start at the latest endTime of all
> predecessors.
>

Maybe something like this would work?

rule "Calc EndTime"
no-loop true
when
$t : Task(endTime != (startTime+duration))
then
$t.setEndTime( $t.getStartTime() + $t.getDuration() );
System.out.println( "Drools: Set " + $t.getName() + ".EndTime to "
+ $t.getEndTime() );
update( $t );
end

Afaik, this will also enable Drools to only check this rule if one of
the attributes used in the LHS is changed. So if you change any other
field of your object at some point, this rule will not be evaluated
again.
Please note that I haven't checked the syntax but I think that it
should work like this.

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


Re: [rules-users] Using from

2008-07-17 Thread Marcus Ilgner
Hi Aziz,

On Thu, Jul 17, 2008 at 8:26 PM, Aziz Boxwala <[EMAIL PROTECTED]> wrote:
> I have the following class structure.
>
> Class GrandFather {
>   List fathers;
>   public List getFathers() {return fathers;}
> }
>
> Class Father {
>int age;
>   List sons;
>   public int getAge() {return age;}
>   public List getSons() {return sons;}
> }
>
> Class Son {
>  int age;
>   public int getAge() {return age;}
> }
>
> I'd like to write a rule that finds all the Fathers who have age > 45 and
> have Sons where the son's age is greater than 5. But I can't figure out how
> to use "from" to iterate over father first and then over son.
>
> Any help will be greatly appreciated.
>
> Thanks,
> --Aziz

Something like this?

rule "FatherAndSon
when
  $father : Father(age > 45)
  $son : Son(age > 5) from $father.sons
then
// do something
end

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


Re: [rules-users] Decision table

2008-07-11 Thread Marcus Ilgner
Hi Vanina,

On Thu, Jul 10, 2008 at 4:44 PM, Vanina Beraudo <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I need use a excel Decision table, in the CONDITION I invoque a
> method, not a getter, and this method have a parameter. I dont know
> how is the correct way to call a method with a parameter in CONDITION
> part.
>
> I do this,
>
> CONDITION
> i:Tax
> taxValue("$1") <  $2
>
> 10, 20
>
> Could somebody give some idea how can I call a method with parameters?
>
> Thanks,
>

Have a look at the eval expression documented in
http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.html#d0e3787
You'll probably end up with something similar to this:
$t : Tax()
eval($t.taxValue($param1) < $param2)

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


Re: [rules-users] insert a collection/ArrayList of facts

2008-07-03 Thread Marcus Ilgner
On Thu, Jul 3, 2008 at 2:55 PM, thomas kukofka <[EMAIL PROTECTED]> wrote:
> Hello,
>
> is it possible to insert an Arraylist of facts like this?:
>
> ArraList list;
> wm.insert (list);
>
> And if yes how can I iterate over the list in the when-part of the rule?
> The rule should be applied to all elements of the inserted list.
>
> A short drl-example would be perfect.
>
> Kind Regards
> Thomas
>

Hi Thomas,

I'm not sure if this is what you want but I think this should work:

rule "ItemsFromList"
when
  $list : List();
  $item : MyObject() from $list;
then
  // do something
end

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


Re: [rules-users] drools-eclipse sources?

2008-07-03 Thread Marcus Ilgner
On Thu, Jul 3, 2008 at 8:23 AM, Markus Helbig <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> where can i get the sources for drools-eclipse? I remember they were
> in svn but currently i can't find them there.
>
> Cheers
>
> Markus

Hi Markus,

have a look at 
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-eclipse/

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


Re: [rules-users] Beginner question about Dynamic Beans

2008-07-02 Thread Marcus Ilgner
Hi Francesco,

On Wed, Jul 2, 2008 at 10:28 AM, fmarchioni <[EMAIL PROTECTED]> wrote:
>
> Hi all drools users!
> I'm just learning Drools from the manual, I have a question about Dynamic
> Beans. I have added PropertyChangeSupport and listeners to my Beans: I can
> see that inside my rule, if I change
> one property the bean.
>
> rule "Check Age"
>
> salience 20
>
>  when
> b : Buyer (age <18)
>  then
>  bankApp.addMessage(Messages.AGE_UNDER_18);
>  b.setCash(4); // CHANGE OF PROPERTY
> end
>
> ..then all rules are fired back again. Is it the correct behaviour ? is
> there a way to re-evaluate only some of the Rules back again ?
> thanks a lot
> Francesco
> --

that's strange. From my experience, only those rules that depend on
the cash property should be fired if the new value triggers an
activation that wouldn't have been triggered for the old value. Could
you post the code of your PropertyChangeSupport implementation?

Here's some sample code from one of my projects:

public abstract class BindObject { /* simple proxy */
private PropertyChangeSupport propertyChangeSupport = new
PropertyChangeSupport(this);

public void addPropertyChangeListener(PropertyChangeListener _listener) {
propertyChangeSupport.addPropertyChangeListener(_listener);
}

public void addPropertyChangeListener(String _propertyName,
PropertyChangeListener _listener) {
propertyChangeSupport.addPropertyChangeListener(_propertyName,
_listener);
}

public void removePropertyChangeListener(PropertyChangeListener _listener) {
propertyChangeSupport.removePropertyChangeListener(_listener);
}

public void removePropertyChangeListener(String _propertyName,
PropertyChangeListener _listener) {
propertyChangeSupport.removePropertyChangeListener(_propertyName,
_listener);
}

protected void firePropertyChange(String _propertyName, Object
_oldValue, Object _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}

protected void firePropertyChange(String _propertyName, int
_oldValue, int _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}

protected void firePropertyChange(String _propertyName, boolean
_oldValue, boolean _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}
}

Now I simply inherit my classes from BindObject and write my setters like this:

public final static String PROPERTY_ARTICLE_NUMBER = "articleNumber";
public void setArticleNumber(String _articleNumber) {
String oldValue = _articleNumber;
articleNumber = _articleNumber;
firePropertyChange(PROPERTY_ARTICLE_NUMBER, oldValue, articleNumber);
}

This has been working great for me so far.

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


Re: [rules-users] Re: access to in working memory generated objects

2008-06-18 Thread Marcus Ilgner
Hi,

On Wed, Jun 18, 2008 at 1:17 PM, Alexander Claus <[EMAIL PROTECTED]> wrote:
>> I want to use rules which shall generate as a consequence a new java
>> object.
>> The GUI of my application shall display the new generated objekt.
>> but how can the GUI of my application get informed by the rule engine that
>> it has generated a new object (Warning)? And how the GUI or any other java
>> component can access this new generated object from outside?
>
> Have a look at org.drools.event.WorkingMemoryEventListener.
> I think you find yourself how to use it.
>
> Best regards.
> Alexander Claus

another approach would be to register some service as a global to your
working memory. Then, when creating the object in the RHS of your
rule, you call some method on it like this

rule "Value below threshold"
when
FactX ( property  < threshold)
then
Warning warning = new Warning( "Under threshold" );
service.addWarning(warning);
insert(warning);
end

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


Re: [rules-users] logging

2008-06-18 Thread Marcus Ilgner
On Wed, Jun 18, 2008 at 10:29 AM, Jaroslaw Kijanowski
<[EMAIL PROTECTED]> wrote:
> May be you could store the names of every fired rule in a global by putting
> drools.getRule().getName() into a list on the RHS.
> Then you could get all rules in your package ( pkg.getRules() ) into another
> list and "diff" both collections (another_list.removeAll(list) ).
>
>
> Thalupula Ravi wrote:
>>
>> Hi,
>> How can i log that where a rule is executed or not for supplied data? If
>> the
>> rule fires, in 'then' section i can have a log statement.
>> How can i log that the rule is not executed??
>>
>> I need to log in both scenarios.
>>
>> Thanks,
>> Ravi Thalupula
>

Hi Ravi,

have you looked at the logging facilities included in Drools,
especially AgendaEventListener? That way you wouldn't have to manually
log activations in the RHS of every rule. Diffing the the names of
available rules versus those collected by the logging seems to me the
most straightforward solution, too.

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


Re: [rules-users] precompile rules

2008-06-07 Thread Marcus Ilgner
Hi,

On Fri, Jun 6, 2008 at 10:02 PM, apor <[EMAIL PROTECTED]> wrote:
>
> hi, i am new with drools. one question , The rules can precompilar ?

yes, you can compile your rulebase and serialize then later
deserialize the compiled packages.
>From the documentation:
7.1.4.4. Serializing

Practically all of the rulebase related objects in Drools are
serializable. For a working memory to be serializable, all of your
objects must of course be serializable. So it is always possible to
deploy remotely, and "bind" rule assets to JNDI as a means of using
them in a container environment.

Please note that when using package builder, you may want to check the
hasError() flag before continuing deploying your rules (if there are
errors, you can get them from the package builder - rather then
letting it fail later on when you try to deploy).

Best regards
Marcus

> Thank you
> --
> View this message in context: 
> http://www.nabble.com/precompile-rules-tp17700145p17700145.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> ___
> 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] eval question

2008-06-04 Thread Marcus Ilgner
Hi Mike,

On Wed, Jun 4, 2008 at 3:53 PM, Mike D <[EMAIL PROTECTED]> wrote:
>
> I'm close, but no cigar...
>
> I have a header record amount and did an accumulate on a detail amount.  The
> sum of the detail can be within a percent of the total.
>
> The $valueUsAmt is the header, and the totValue is the sum of lines...
> What I need to do is to take the valueUsAmt * .0001 and if that is >= the
> abs value, all is good.
>
> eval($valueUsAmt.subtract($totValue).abs().compareTo(???) <= 0)
>
> It's the * .0001 that is giving me the problem.  Any help would be
> appreciated.
>
> Thanks!

Have you tried compareTo(new Float($valueUsAm*0.0001f)) ?
I'm not 100% percent sure if this is faster, but eventually you could even use
Number(intValue < 0) from
$valueUsAmt.subtract($totValue).abs().compareTo(new
Float($valueUsAm*0.0001f))

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


Re: [rules-users] eclipse-jdtcore.jar

2008-06-03 Thread Marcus Ilgner
Hi,

just as a side note: I had one project using Eclipse which already
used another version of the JDT core. Encountering the same problem, I
just put the core-3.2.3.v_686_R32x.jar from Drools in my project, too,
and it worked without problems.

Best regards
Marcus

On Tue, Jun 3, 2008 at 3:25 PM, Augusto Rodriguez
<[EMAIL PROTECTED]> wrote:
> Hi Corneil,
>
> Unluckily I've seen that error more often that I would like. It's not a bug
> in drools, but is related to the dependencies of the drools-compiler.
>
> There's a big chance that you have a different version of the JDT core jar
> in your classpath (drools depends on version 3.2.3 - the filename of that
> jar is core-3.2.3.v_686_R32x.jar). This jar is used by drools to compile the
> rules.
>
> I hope this helps you to solve this issue.
>
>
> Cheers,
> Augusto
>
> Corneil du Plessis wrote:
>>
>> I am experiencing a conflict with a deployment:
>>
>> We used WebSphere Application Server 6.0.2.x in our integration testing
>> environment and now the deployed application at a customer site is
>> reporting
>> the following exception:
>>
>>
>> java.lang.NoSuchMethodError:
>> org.eclipse.jdt.internal.compiler.CompilationResult: method
>> getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem; not found
>>at
>>
>> org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJ
>> avaCompiler.java(Compiled Code))
>>at
>>
>> org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.
>> java(Compiled Code))
>>at
>> org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java(Compiled
>> Code))
>>at
>>
>> org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaComp
>> iler.java(Compiled Code))
>>at
>>
>> org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCo
>> mpiler.java:51)
>>at
>>
>> org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java
>> :342)
>>
>> Has anyone else comes across this?
>>
>> I am not sure where the JAR comes from because has not version info.
>>
>> ___
>> 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 Configure Hibernate and use in Drools

2008-06-03 Thread Marcus Ilgner
Hi Sekhar,

On Mon, Jun 2, 2008 at 5:56 PM, RAJA SEKHAR REDDY MAYALURU
<[EMAIL PROTECTED]> wrote:
> hi ,
>
> i need to connect to data from a .drl file from a rule . i need to get the
> dynamic data from DB to frmae a rule .
>
> I have seen that Drools support  Hibernate .
>
> so how can i connect to DB from a drl to  DB using hibernate .
>
> i need to have dynamic (data ) rules in my drl file .
>
> we can configure hibernate on top of pojo , my main intrest is to know how
> to invoke hibernate from a drl file .
>
> how to execute named queries  in the rule project .
>
> please send me the steps to configure hibernate and use it in rules project
.
while you cannot directly access your ORM in Drools, it's nonetheless
quite simple: just write some DAO which provides methods to access
your objects - you could, for example, simply have a method which
takes the name of a NamedQuery and executes it - and register it as a
global. Then you can use the "from" syntax to retrieve the objects in
your rules.

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


Re: [rules-users] Advantages and Disadvantages of "from"

2008-05-30 Thread Marcus Ilgner
Hi,


On Fri, May 30, 2008 at 5:06 PM, Thalupula Ravi <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Can some one describe about advantages and disadvantages of below to
> approaches
>
> 1. Interacting Database for information in rule ( using "from" or something
> else)?
>
> or
>
> 2. Required information supplied to rules in the form facts at one shot by
> client instead of again hitting the database.
>
> Thanks for your help:handshake:

if you're going to use "from" in your rules, you should make sure that
you provide some extra methods in your DAOs instead of only some
generic "getAll()" method. This way, if there are some hundred
thousands records in your database, Drools will not have to
instantiate an object for each of them since the DAO/database can
filter out those objects that are not relevant to the use case.
If, for example, you write some rule that handles order processing,
you could write a DAO method "getUnprocessedOrders()" which will
ignore all orders that are already processed. AFAIK Drools does no
sharing/caching of objects retrieved via equivalent "from" calls in
different rules.
When planning my current project, I quickly found that manually
retrieving the objects and inserting them into the working memory gave
me somewhat more flexibility but that of course depends on the use
case at hand.

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


Re: [rules-users] Drools 4.0.7 supports Clustering and DB interaction ?

2008-05-30 Thread Marcus Ilgner
Hi,

On Fri, May 30, 2008 at 10:13 AM, Thalupula Ravi
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> Can some one answer my questions regarding drools support
>
> 1. is drools supports clustering?

I don't have that much experience on the topic, but I my guess would
be that if you write your code on top of some application server like
JBoss AS, clustering should be fairly transparent to your application.
You may want to have a look at
http://docs.jboss.com/jbossas/guides/clusteringguide/r2/en/html/ to
evaluate this approach with regard to your requirements.

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


Re: Re:[rules-users] JUnit testing

2008-05-22 Thread Marcus Ilgner
Glad that I could actually contribute something back to this great project.
I put together a patch for this issue in the JIRA at
http://jira.jboss.org/jira/browse/JBRULES-1618 as promised.

Best regards
Marcus

On Tue, May 20, 2008 at 2:34 AM, Mike Dean <[EMAIL PROTECTED]> wrote:
>
> Sorry to ask question and then figure it out!  I just substituted the actual
> name of my suite class instead of saying this.class and it works
> beautifully.  I am now testing Drools with JUnit 4 with no problems, after
> nearly six months!  THANK YOU.
>
> - Mike
>
> Mike Dean wrote:
>>
>> Thanks to both of you for pursuing this problem.  I have worked around it
>> by putting my business classes and rules in a separate Drools project,
>> testing everything there, and then copying them to my RCP.  I look forward
>> to a better solution!
>>
>> I must confess Java ignorance, but I use a test suite and try to
>> instantiate the engine once and then run a series of tests.  My crash
>> occurs before I get to the individual tests.  However, the setUp routine
>> is static, and your code work around cannot be executed in a static
>> context.  Where exactly to you put the test for a null classloader?
>>
>> Thanks again.  I thought this issue simply died.
>>
>>
>> Marcus Ilgner wrote:
>>>
>>> Hi Edson,
>>>
>>> thank you very much for testing this! Since I could not discern any
>>> differences between your approach and mine, I decided to resolve the
>>> issue manually by inserting a work-around in my test routine which
>>> sets the context class loader for the current thread before calling
>>> the method under test.
>>>
>>> if (Thread.currentThread().getContextClassLoader() == null) {
>>>
>>> Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
>>> }
>>>
>>> My guess is that the custom JUnit 4 class runner
>>> (SpringJUnit4ClassRunner) somehow is responsible for the faulty
>>> behaviour.
>>>
>>> Thanks again
>>> Marcus
>>>
>>>
>>> On Mon, May 19, 2008 at 3:09 PM, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>>>>
>>>>All,
>>>>
>>>>I see that the code in that spot is weak and could be improved.
>>>> Although,
>>>> using drools 4.0.7, I successfully created a junit 4 test that I paste
>>>> bellow. Also, the whole drools code is tested with junit 3 and we have
>>>> no
>>>> problems. For instance, look at our integration tests here:
>>>>
>>>> http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/
>>>>
>>>>The code I used to create the junit 4 test is based on the default
>>>> example create by the drools plugin + the snippet you showed bellow:
>>>>
>>>> @Test
>>>> public void testRuleBase() {
>>>> try {
>>>>
>>>> //load up the rulebase
>>>> RuleBase ruleBase = readRule();
>>>> StatefulSession workingMemory =
>>>> ruleBase.newStatefulSession();
>>>>
>>>> //go !
>>>> Message message = new Message();
>>>> message.setMessage(  "Hello World" );
>>>> message.setStatus( Message.HELLO );
>>>> workingMemory.insert( message );
>>>> workingMemory.fireAllRules();
>>>> workingMemory.dispose();
>>>>
>>>> } catch (Throwable t) {
>>>> t.printStackTrace();
>>>> Assert.fail("Something is wrong: "+t.getMessage());
>>>> }
>>>> }
>>>>
>>>> /**
>>>>  * Please note that this is the "low level" rule assembly API.
>>>>  */
>>>> private RuleBase readRule() throws Exception {
>>>> //read in the source
>>>> Reader source = new InputStreamReader(
>>>> DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
>>>>
>>>> PackageBuilderConfiguration conf = new
>>>> PackageBuilderConfiguration();
>>>> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
>>>> conf.getDialectConfiguration("java");
>>>> javaConf.setCompiler(JavaDialectConfigura

Re: Re:[rules-users] JUnit testing

2008-05-19 Thread Marcus Ilgner
On Mon, May 19, 2008 at 6:00 PM, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>
>Marcus, can you please open a JIRA for us, anyway, so that we can improve
> that code spot to check for nulls? This will avoid such problems in the
> future.
>
>If you want to contribute a patch, it is also welcome.
>
>Thanks.
>Edson
>

Of course I'll gladly write a patch for this issue. Although I'm head
over heels in my current project, there's a holiday coming up this
week, so you may expect the patch by the end of the week.

Cheers
Marcus

> 2008/5/19 Marcus Ilgner <[EMAIL PROTECTED]>:
>>
>> Hi Edson,
>>
>> thank you very much for testing this! Since I could not discern any
>> differences between your approach and mine, I decided to resolve the
>> issue manually by inserting a work-around in my test routine which
>> sets the context class loader for the current thread before calling
>> the method under test.
>>
>> if (Thread.currentThread().getContextClassLoader() == null) {
>>
>>  
>> Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
>> }
>>
>> My guess is that the custom JUnit 4 class runner
>> (SpringJUnit4ClassRunner) somehow is responsible for the faulty
>> behaviour.
>>
>> Thanks again
>> Marcus
>>
>>
>> On Mon, May 19, 2008 at 3:09 PM, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>> >
>> >All,
>> >
>> >I see that the code in that spot is weak and could be improved.
>> > Although,
>> > using drools 4.0.7, I successfully created a junit 4 test that I paste
>> > bellow. Also, the whole drools code is tested with junit 3 and we have
>> > no
>> > problems. For instance, look at our integration tests here:
>> >
>> >
>> > http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/
>> >
>> >The code I used to create the junit 4 test is based on the default
>> > example create by the drools plugin + the snippet you showed bellow:
>> >
>> > @Test
>> > public void testRuleBase() {
>> > try {
>> >
>> > //load up the rulebase
>> > RuleBase ruleBase = readRule();
>> > StatefulSession workingMemory =
>> > ruleBase.newStatefulSession();
>> >
>> > //go !
>> > Message message = new Message();
>> > message.setMessage(  "Hello World" );
>> > message.setStatus( Message.HELLO );
>> > workingMemory.insert( message );
>> > workingMemory.fireAllRules();
>> > workingMemory.dispose();
>> >
>> > } catch (Throwable t) {
>> > t.printStackTrace();
>> > Assert.fail("Something is wrong: "+t.getMessage());
>> > }
>> > }
>> >
>> > /**
>> >  * Please note that this is the "low level" rule assembly API.
>> >  */
>> > private RuleBase readRule() throws Exception {
>> > //read in the source
>> > Reader source = new InputStreamReader(
>> > DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
>> >
>> >     PackageBuilderConfiguration conf = new
>> > PackageBuilderConfiguration();
>> > JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
>> > conf.getDialectConfiguration("java");
>> > javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
>> > javaConf.setJavaLanguageLevel("1.5");
>> >
>> > PackageBuilder builder = new PackageBuilder( conf );
>> > builder.addPackageFromDrl( source );
>> >
>> > RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>> > ruleBase.addPackage( builder.getPackage() );
>> > return ruleBase;
>> > }
>> >
>> > Hope it helps,
>> >   Edson
>> >
>> >
>> > 2008/5/19 Marcus Ilgner <[EMAIL PROTECTED]>:
>> >>
>> >> Hi list,
>> >>
>> >> I'm reviving this thread because I happen to have the same problem.
>> >>
>> >> On Sun, Mar 23, 2008 at 7:34 PM, Mike Dean <[EMAIL PROTECTED]> wrote:
>> >> >
>> >> > Thanks (months later!).  I have cut down my code exam

Re: Re:[rules-users] JUnit testing

2008-05-19 Thread Marcus Ilgner
Hi Edson,

thank you very much for testing this! Since I could not discern any
differences between your approach and mine, I decided to resolve the
issue manually by inserting a work-around in my test routine which
sets the context class loader for the current thread before calling
the method under test.

if (Thread.currentThread().getContextClassLoader() == null) {

Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
}

My guess is that the custom JUnit 4 class runner
(SpringJUnit4ClassRunner) somehow is responsible for the faulty
behaviour.

Thanks again
Marcus


On Mon, May 19, 2008 at 3:09 PM, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>
>All,
>
>I see that the code in that spot is weak and could be improved. Although,
> using drools 4.0.7, I successfully created a junit 4 test that I paste
> bellow. Also, the whole drools code is tested with junit 3 and we have no
> problems. For instance, look at our integration tests here:
>
> http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/
>
>The code I used to create the junit 4 test is based on the default
> example create by the drools plugin + the snippet you showed bellow:
>
> @Test
> public void testRuleBase() {
> try {
>
> //load up the rulebase
> RuleBase ruleBase = readRule();
> StatefulSession workingMemory = ruleBase.newStatefulSession();
>
> //go !
> Message message = new Message();
> message.setMessage(  "Hello World" );
> message.setStatus( Message.HELLO );
> workingMemory.insert( message );
> workingMemory.fireAllRules();
> workingMemory.dispose();
>
> } catch (Throwable t) {
> t.printStackTrace();
> Assert.fail("Something is wrong: "+t.getMessage());
> }
> }
>
> /**
>  * Please note that this is the "low level" rule assembly API.
>  */
> private RuleBase readRule() throws Exception {
> //read in the source
> Reader source = new InputStreamReader(
> DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
>
> PackageBuilderConfiguration conf = new
> PackageBuilderConfiguration();
> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
> conf.getDialectConfiguration("java");
> javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
> javaConf.setJavaLanguageLevel("1.5");
>
> PackageBuilder builder = new PackageBuilder( conf );
> builder.addPackageFromDrl( source );
>
> RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> ruleBase.addPackage( builder.getPackage() );
> return ruleBase;
> }
>
> Hope it helps,
>   Edson
>
>
> 2008/5/19 Marcus Ilgner <[EMAIL PROTECTED]>:
>>
>> Hi list,
>>
>> I'm reviving this thread because I happen to have the same problem.
>>
>> On Sun, Mar 23, 2008 at 7:34 PM, Mike Dean <[EMAIL PROTECTED]> wrote:
>> >
>> > Thanks (months later!).  I have cut down my code example below to show
>> > this
>> > issue more clearly:
>> >
>> >
>> > John J. Franey wrote:
>> >>
>> >> NullPointerException on line 146 means classLoader is null.   That is
>> >> odd.
>> >> I have no idea why the code that gets classLoader won't work in
>> >> eclipse's
>> >> junit runtime, but does when run in your eclipse plugin.
>>
>>  It seems indeed like during JUnit tests, the context classloader of
>> the thread gets not set (null).
>>
>> The code leading up to the problem is as follows:
>> PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
>> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
>> conf.getDialectConfiguration("java");
>> javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
>> javaConf.setJavaLanguageLevel("1.5");
>> RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>>
>> The resulting stacktrace is:
>> java.lang.NullPointerException
>>at
>> org.drools.RuleBaseConfiguration.instantiateClass(RuleBaseConfiguration.java:569)
>>at
>> org.drools.RuleBaseConfiguration.determineConsequenceExceptionHandler(RuleBaseConfiguration.java:561)
>>at
>> org.drools.RuleBaseConfiguration.init(RuleBaseConfiguration.java:220)
>>at
>> org.drools.RuleBaseConfiguration.(RuleBaseConfiguration

Re: Re:[rules-users] JUnit testing

2008-05-19 Thread Marcus Ilgner
Hi list,

I'm reviving this thread because I happen to have the same problem.

On Sun, Mar 23, 2008 at 7:34 PM, Mike Dean <[EMAIL PROTECTED]> wrote:
>
> Thanks (months later!).  I have cut down my code example below to show this
> issue more clearly:
>
>
> John J. Franey wrote:
>>
>> NullPointerException on line 146 means classLoader is null.   That is odd.
>> I have no idea why the code that gets classLoader won't work in eclipse's
>> junit runtime, but does when run in your eclipse plugin.

 It seems indeed like during JUnit tests, the context classloader of
the thread gets not set (null).

The code leading up to the problem is as follows:
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
conf.getDialectConfiguration("java");
javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
javaConf.setJavaLanguageLevel("1.5");
RuleBase ruleBase = RuleBaseFactory.newRuleBase();

The resulting stacktrace is:
java.lang.NullPointerException
at 
org.drools.RuleBaseConfiguration.instantiateClass(RuleBaseConfiguration.java:569)
at 
org.drools.RuleBaseConfiguration.determineConsequenceExceptionHandler(RuleBaseConfiguration.java:561)
at org.drools.RuleBaseConfiguration.init(RuleBaseConfiguration.java:220)
at 
org.drools.RuleBaseConfiguration.(RuleBaseConfiguration.java:133)
at org.drools.common.AbstractRuleBase.(AbstractRuleBase.java:147)
at org.drools.reteoo.ReteooRuleBase.(ReteooRuleBase.java:124)
at org.drools.reteoo.ReteooRuleBase.(ReteooRuleBase.java:101)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:57)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:38)

Has anyone set up Drools and JUnit successfully? Maybe we forgot to
set up the environment properly?

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


Re: [rules-users] Drools as OSGI bundle

2008-05-14 Thread Marcus Ilgner
Hi,

On Wed, May 14, 2008 at 1:12 PM, ekke <[EMAIL PROTECTED]> wrote:
>
>  just seen that SpringSource published Drools as OSGI bundles
>  http://www.springsource.com/repository/app/search?query=drools
>  http://www.springsource.com/repository/app/search?query=drools
>  - I'll create a request to get 4.0.7 - they published 4.0.4
>  next two weeks I'll try the bundles
>  ekke
>  --

thanks for the hint! It's especially interesting that they apparently
managed to deploy core, compiler and JSR94 interface in separate
packages. Have you tried these packages already? I'd assume that one
has to specify "Eclipse-RegisterBuddy: com.springsource.org.drools" or
some equivalent so Drools can find the classes from the bundles that
are using it?
I tried to package Drools in OSGi bundles myself some weeks ago but
stumbled over some class loader issues after dividing the components
into their own bundles.
If SpringSource managed to build working manifest files, it would be
great if the Drools team would incorporate these into the
JAR-distribution.

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


Re: [rules-users] Globals asserted as facts... how to modify them...

2008-02-16 Thread Marcus Ilgner
Hi,

On Feb 16, 2008 1:00 PM, mmquelo massi <[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> I followed all the topics about globals and the fact that they are
> immutables.
>
> I also understood that once we decide to reason over globals, it's
> time we no more use them and we start to use simple WM facts.
>
> Now...
>
> I tell you my scenario.
>
> I have got two globals.
>
> A "request" global and a "reply" global. The first one is a "Request" java
> instance
> and the second one is a "Reply" java instance. They belong to the Object
> model
> I designed.
>
> My application makes a request to the rule engine passing it a "request" as
> global,
> and get back a reply from it receiving a modified "reply"  global.
>
> I use a ruleflow to execute the rules.
>
> I think everything would be perfect and smooth if I had not the need to
> reason
> over the reply during the rule session
>
> That's the point!
>
> I do not just need to modify the "reply" global in order to get the final
> value outside
> the rule engine, but I DO need to reason over it INSIDE the rule session.
>
> So what should I do in order to reason over the reply INSIDE AND OUTSIDE
> the Rule Session?
>
> Should I insert the "reply" global into the WM?
>
> Let assume I do that, what happen if I pass the "reply" global to
> a drools function which alters the "reply"?
>
> Imagine a rule as follows and imagine I previously inserted the "reply"
> global into the WM:
>
> 
> ...
> global my.object.model.Reply reply
> ...
> rule "addcriminal_2_reply"
>   when
> $p: Person(job=="criminal")
>   then
>  addCriminaltoReply(reply, $p );
> end
> 
>
> Will this alteration affect the corresponding Reply() fact in the WM as
> well?
>
>
> Now let see this other rule:
>
> (Same, let imagine i previously inserted: insert(reply); )
> 
> global my.object.model.Reply reply
>
>
> rule "FullFill_replyCode"
>   when
>  $r: Reply(code=="john.wayne") from reply
>   then
>  $r.code.name = john;
>  $r.code.lastname = wayne;
> end
> 
>
> If I execute this rule in a ruleflow, do i need to "update($r)"
> in order to get the modified $r value in the next ruleflow node?
>
> And what happens to the global??? Will it get modified as well?
>
> I am sure you can help me.
>
> Bye bye.
>
> Massi
>

have you thought about initializing and asserting the Reply instance
in a separate rule at the beginning of the ruleflow?
After the ruleflow has finished, you can look for instances of Reply
in the WorkingMemory and retrieve your Reply object.

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


[rules-users] Remotely debugging application server code

2007-11-15 Thread Marcus Ilgner
Hi list,

I'm experiencing problems when remotely debugging my JBoss-Rules-using
application running on an application server.
The application server is JBoss 4.2.1.GA and I connect to it via
Eclipse. My JBoss Rules version is 4.0.3.
As soon as I start inserting facts, the application seems to hang. The
debugger reports the status "Running" on all threads, however the
application does not seem to reach the next statement (which is a
logging statement).
When I disconnect the debugger, the execution resumes and everything works fine.
The displayed callstack when suspending the execution claims that the
execution has reached the next breakpoint, however I'm in doubt that
this is true and there's no way for me to resume the execution.

Maybe some of you have experienced something similar. I had no
problems at all debugging the code that does all the work before the
fact insertion. Only after starting to insert facts the debugging goes
awry.

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


Re: [rules-users] Can set field in LHS part?

2007-05-08 Thread Marcus Ilgner

On 5/8/07, Joj <[EMAIL PROTECTED]> wrote:


Hi,

I know tht v can set value of a field in the RHS part using setter method in
simple Java.
Similarly, can v assign a value to a field of an object in the LHS? Is it
feasible?
I think no. :)

Thanx
Jojan



Aside from the fact that this is not possible (though you could use
eval, maybe), it sounds like a really(!) bad thing to do.
Save yourself lots of trouble and don't do it.
Please. ;)

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


Re: [rules-users] Getting validation errors

2007-03-13 Thread Marcus Ilgner

Hi Mike,

On 3/13/07, Mike Dougherty <[EMAIL PROTECTED]> wrote:

Hello,

I am using JBoss Rules to validate entities before storing them in the
database. I therefore need a way to inform the calling code that the entity
which was asserted failed verification. The only way I have been able to
find that works is to assert an exception from within the rule file. For
example:

rule "user is 'miked'"
  when
identity : Identity( username == "miked" )
  then
assertLogical(new IllegalStateException("Entity failed verification."));
end

Then in the Java that fires the rule, I have:

workingMemory.fireAllRules();
for(Iterator i = workingMemory.getObjects(Exception.class).iterator();
i.hasNext(); ) {
System.out.println("Exception: "+i.next());
}

Which seems to be working OK. But I wanted to see if maybe there is a better
way to accomplish what I need.

Thanks for you help.
Mike



My approach would be to derive all objects that will be validated from
a superclass, e.g. ValidatedObject, which provides a boolean property
"validated".
Then you can set this property in your rules and later on display
warning/error messages for those objects that failed validation.

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


Re: [rules-users] Using rules with database scenario

2007-03-09 Thread Marcus Ilgner

On 3/9/07, Uday Kamath <[EMAIL PROTECTED]> wrote:







We had similar use case. What we do is we model the Schema elements,
generate Java Beans (pojo), and write rules using these Pojo. Now we have
written a Service on top which takes Hibernate QL and gets the database
records as the same Pojos that Rules are defined on and fire the Rules. Thus
the service is generic and can be changed to take any Query. The Rules can
me modified and changed anytime and redeployed but business objects in form
of Pojos remain the same. Hope this helps

-Uday

 


From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Joe Chuby
 Sent: Friday, March 09, 2007 3:53 AM
 To: rules-users@lists.jboss.org
 Subject: [rules-users] Using rules with database scenario




Hi all,

 First time trying to learn JBoss Rules here. We have a pretty large
database (DBMS), we want to build some rules and retrieve data based on the
rules.

 Could someone give a hint or an example of this usage scenario? I mean, how
can I use rules for database query, without writing my rules in SQL
directly? We are currently writing everything in HQL (Hibernate), but the
rules change every 3 months on average, so that's not a way to maintain the
system. Therefore, we want to extract that portion of the business logic out
of the code. The data structure does not change, but the rules keep on
changing.

 I'm reading the user's guide, running thru the examples, writing some of my
own, but still no clue how to make it work with database.

 If someone could give a sample, that would be greatly appreciated.

 Thanks a lot.



That's probably the best solution. Using the current version (3.1M1),
you can use the FROM keyword to reference facts from List object
returned from a method call on a service, for example.
Something like this works very good in my current testing project:

rule foobar
when
 MyObject( someValue = "foobar" ) from MyObjectDAO.loadAll()
then
...
end

The DAO then uses Hibernate to load some objects and returns a
List which can be used by Drools.
As Uday already wrote, you could also write a DAO which retrieves
arbitrary objects using a given HQL statement.

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


Re: [rules-users] column binding vs field binding - any performance implications?

2007-03-07 Thread Marcus Ilgner

Hi Vlad,

On 3/7/07, Olenin, Vladimir (MOH) <[EMAIL PROTECTED]> wrote:

Hi,



I wonder if there are any performance implications of choosing column
binding vs field binding (I'll be using bound variable in eval). Eg, in such
case:



Record($field : field)

eval ( $field.equals("xxx") )



vs



$r: Record()

eval ( $r.field.equals("xxx") )





Does it start to make difference only when some significant number of
variable get bound?



Thanks,



Vlad




If you're only comparing strings, you can write Record( field == "xxx"
) without any separate binding. I'm not sure about custom
implementations of Object::equals though. Maybe those have to be
called explicitly. That's an interesting question however. I'd be
great if someone could elaborate on that.
Additionally, using eval just executes the Java code in the expression
and hinders the engine to make a lot of optimizations. I'd imagine
that the difference in speed is not really measurable. The only
difference is one level less of indirection in the Java code in the
first approach. Not that much, really. If you're really in need of
that much optimization, you better try to eliminate the eval first and
then maybe take a look at other components of your application.

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


Re: [rules-users] Rules with Lookup Tables...

2007-03-02 Thread Marcus Ilgner

On 3/2/07, Francisco Brum <[EMAIL PROTECTED]> wrote:


I also need to make a rule with a lookup tables, and I have found that the new 
version of rules support 'from'.


Another solution could be the the use of globals:
http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.5/html_single/index.html#d0e719

You could insert a global "PartnerList" and a global
"PortLocationList" and evaluate on these.
It somewhat depends on your situation: using "FROM" is definitely more
powerful, globals are quicker to implement because you probably have
this List object laying around already.

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


Re: [rules-users] Using Java to write rules?

2007-03-02 Thread Marcus Ilgner

On 3/2/07, Aeinehchi Nader <[EMAIL PROTECTED]> wrote:


 I wonder if it is possible to write rules and make queries toward the
knowledge database of Jboss Rules using Java language itself.  What I need
is to to be able to access the rule engine's API.

I do not want to use Drools language or XML.



Although I guess that it would be possible to make all those calls manually,
I wonder what the advantage would be.
The RHS of a rule is already Java code and the LHS provides a lot of Java
functionality or can use eval() if neccessary.
Also you can embed the DRL in your source or dynamically create new rules
and add those using StringReader if need be: I'm currently working on a
business project where new rules are assembled by the application: POC works
like a charm.
If that is not feasible, I'd probably take a look at the
drools-decisiontables codebase which basically does a similar thing: replace
DRL/XML syntax with a new interface (decision tables).
Anyway, that's just my $0.02 ;)

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


[rules-users] Re: Using Enums in LHS

2007-02-26 Thread Marcus Ilgner

Hello again,

On 2/19/07, Marcus Ilgner <[EMAIL PROTECTED]> wrote:


Hi list,

I'm having problems using Enums in the LHS of my rules.
Running this rule

> rule "demo"
> when
> $t : Transition( from == PlayerCharacter.STATE_IDLE,
>  to == PlayerCharacter.STATE_GENERATING,
>  state != TransitionState.REQUESTED )
> then
> System.out.println("The state is: " + $t.getState());
> end


actually results in the output
> The state is: REQUESTED

Am I doing something wrong?
I'm currently using the experimental 3.1.0M1 release.



Since it seems that I'm the only one who experiences this odd behaviour, I
have put together a simple self-contained test case:
http://dude-development.de/enumtest.java
This example, running on Version 3.1.0-M1, always prints every value, even
those that are equal to VALUE1. If I change the comparator to equal, no
value gets printed.
Is it me who's doing something wrong or is it really a bug? Judging from
previous posts and what I read on the JIRA, Enums should work like that,
don't they?
I'd be grateful for any hints.

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


[rules-users] A question regarding licensing

2007-02-21 Thread Marcus Ilgner

Hello list,

I'm somewhat confused about how to license my software. I have made a couple
of searches on the net, but could not come up with any good solution. That's
the situation:
JBoss Rules is licensed under the Apache License. It does, however contain
Eclipse compiler components, which are licensed under the EPL. My project
also builds upon the Eclipse RCP, which is EPL, too.
Now I'm uncertain under which license I can or must release my software. Is
it Apache License (from what I understand after my research, it is the more
restrictive one of the two), or could I release under EPL, too?
It is especially unclear to me if I did create a derivative work of JBoss
Rules or even Eclipse, since I did not modify any of its code, I'm only
using the product in my project.
I'd be grateful for any enlightenment or weblinks to information on that
matter.

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


Re: [rules-users] Janino vs. Eclipse

2007-02-20 Thread Marcus Ilgner

On 2/20/07, Dirk Bergstrom <[EMAIL PROTECTED]> wrote:

I do not understand the difference between the Janino and Eclipse options for
rules compilation.  The documentation only says that there are two options, and
the javadocs don't really go any further.  Can someone provide more detail?

My questions include:

*) Why would I prefer one over the other?

*) What are the advantages and disadvantages of each?

*) In what situations is it necessary to use Janino?  Which ones require 
Eclipse?

*) Can I use the Eclipse compiler if I'm building rules outside of Eclipse (eg.
dynamically generated rules in a web application)?

*) I've read that the Eclipse compiler provides some sort of Java 1.5
compatibility/autoboxing/mumble-mumble.  What's that about?

I'll try to put the answers together into something that can be added to the
manual (as soon as the manual is again buildable, see
http://jira.jboss.com/jira/browse/JBRULES-672).

Thanks.

--
Dirk Bergstrom   [EMAIL PROTECTED]
_
Juniper Networks Inc.,  Computer Geek
Tel: 408.745.3182   Fax: 408.745.8905
___


The biggest difference would be that Janino does not support language
level 1.5. That's definetely a reason to use Eclipse, for me. Beyond
that, I really did not investigate, either.

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


Re: [rules-users] Need Help: Errors while running FibonacciExample

2007-02-19 Thread Marcus Ilgner

Hi Venkatesh,

On 2/19/07, venkatesh devalapura nagabhushana <[EMAIL PROTECTED]>
wrote:



Hi,

After successfully compiling the example code FibnacciExample.java, I
tried to run it, I get the following error, let me know how to solve it:

java FibonacciExample
Exception in thread "main" java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
   at org.drools.semantics.java.RuleBuilder.() (Unknown Source)
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
   at
org.drools.compiler.PackageBuilder.addRule(org.drools.lang.descr.RuleDescr)
(Unknown Source)
   at
org.drools.compiler.PackageBuilder.addPackage(
org.drools.lang.descr.PackageDescr) (Unknown Source)
   at
org.drools.compiler.PackageBuilder.addPackageFromDrl(java.io.Reader)
(Unknown Source)
   at FibonacciExample.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.util.regex.PatternSyntaxException: At position 2 in
regular expression pattern:
expected end of character class
(.*)\bmodify\s*\(([^)]+)\)(.*)
  ^
   at java.util.regex.Pattern.Pattern(java.lang.String, int)
(/usr/lib/libgcj.so.6.0.0)
   at java.util.regex.Pattern.compile(java.lang.String, int)
(/usr/lib/libgcj.so.6.0.0)
   at org.drools.semantics.java.KnowledgeHelperFixer.() (Unknown
Source)   at java.lang.Class.initializeClass()
(/usr/lib/libgcj.so.6.0.0)
   ...8 more

Is it require to place .drl file in the same directory as that of the
source code ?

Thanks,
Venkatesh




What JDK are you using? "/usr/lib/libgcj.so.6.0.0" and "gnu.java.lang" makes
me think that it's GNU Classpath or something like that. It is quite
possible that there are incompatibilities with that runtime.
Have you tried running it with Sun's JDK?

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


[rules-users] Using Enums in LHS

2007-02-18 Thread Marcus Ilgner

Hi list,

I'm having problems using Enums in the LHS of my rules.
Running this rule


rule "demo"
when
$t : Transition( from == PlayerCharacter.STATE_IDLE,
 to == PlayerCharacter.STATE_GENERATING,
 state != TransitionState.REQUESTED )
then
System.out.println("The state is: " + $t.getState());
end



actually results in the output

The state is: REQUESTED


Am I doing something wrong?
I'm currently using the experimental 3.1.0M1 release.


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


Re: [rules-users] Subclasses matche superclasses problem.

2007-02-16 Thread Marcus Ilgner

Hi Oana,

On 2/16/07, nicolae oana <[EMAIL PROTECTED]> wrote:

Hi everybody,

I have a class Car which is superclass for class ConvertibleCar, two rules
(described below) and a ConvertibleCar fact in working memory that causes
both rules to fire, resulting this way an unwanted change to the car`s
attribute and an infinite loop.

How do I evitate this problem: the specialization class fact to not match
its superclass column in a rule?

ConvertibleCar car =new ConvertibleCar(1);

rule "rule-1"
when
   $car:Convertible()
then
   $car.setPotentialTheftRating("high");
end

rule "rule-2"
when
$car:Car(price<2)
 then
$car.setPotentialTheftRating("low");
 end

Best regards, Oana



I'd say that this behaviour is correct in principle. If you want to
avoid this, you could add further constraints in the rules concerning
the superclass:

rule "rule-2"
   when
   $car:Car(price<2, class != Convertible.class)
then
   $car.setPotentialTheftRating("low");
end

I'm not sure if this works exactly like that (don't have a Drools
installation at hand), but  I guess you get the idea.

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


Re: [rules-users] java.lang.NoSuchMethodError:org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[

2007-02-15 Thread Marcus Ilgner

Hi,

On 2/15/07, Nagabhushanam B <[EMAIL PROTECTED]> wrote:


Hi ,

I have installed Eclipse 3.2 and tomcat 5.5, when I am trying to jboss rule
I am getting the following exception

Even though I added org.eclipse.jdt.core_3.2.0.v_671.jar in
to my class path

Guys help me out from this& urgent



java.lang.NoSuchMethodError:org.eclipse.jdt.internal.compiler.CompilationResult.getProblems
()[Lorg/eclipse/jdt/core/compiler/IProblem;

  at
org.apache.jasper.compiler.JDTCompiler$2.acceptResult(
JDTCompiler.java:341)

  at
org.eclipse.jdt.internal.compiler.Compiler.compile(
Compiler.java:417)

  at
org.apache.jasper.compiler.JDTCompiler.generateClass(
JDTCompiler.java:399)

  at org.apache.jasper.compiler.Compiler.compile(
Compiler.java:288)

  at org.apache.jasper.compiler.Compiler.compile(
Compiler.java:267)

  at org.apache.jasper.compiler.Compiler.compile(
Compiler.java:255)

  at org.apache.jasper.JspCompilationContext.compile(
JspCompilationContext.java:556 )

  at
org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:293 )

  at
org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)

  at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)

  at javax.servlet.http.HttpServlet.service(
HttpServlet.java:802)

  at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252 )

  at
org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173 )

  at
org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:213 )

  at
org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:178 )

  at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:126 )

  at
org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:105 )

  at
org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:107 )

  at
org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:148)

  at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:868 )

  at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection
(Http11Protocol.java:744 )

  at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:527 )

  at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:80 )

  at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:684 )

  at java.lang.Thread.run( Thread.java:534)


Looking at that stacktrace (which isn't much information), I'd guess
that this isn't a rules-related problem (there's no Drools-related
class mentioned) but rather a conflict between the Eclipse compiler
and some other library you're using.
This component probably sees that
org.eclipse.jdt.internal.compiler.Compiler exists, tries to use it and
coughs up because it expects another version.
Still guessing, since I'm not much versed with Tomcat, I'd say that
it's compiler component is trying the Eclipse compiler and needs to be
told to specifically use whatever compiler it was using before.

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


Re: [rules-users] Example of contains operator...

2007-02-13 Thread Marcus Ilgner

On 2/13/07, jdepaul <[EMAIL PROTECTED]> wrote:


Ok thanks - that worked when partnerList was an ArrayList, how would I code
my "contains" condition if the parternList was a HashMap!?


You could write an accessor in your model called getPartnerListKeys()
which returns getPartnerList().keySet() and then use (partnerListKeys
contains "2900") in your rule.
I'm not 100% sure (started with JBoss Rules only a couple of days
ago), but I'm pretty confident that this should work.

hth
Marcus


Michael Neale wrote:
>
> contains works on the Collection interface. So if parnerList is a
> ArrayList
> of String, then you could do:  parnerList contains "2900"
>


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