Re: [rules-users] java.lang.NullPointerException in simple example

2014-04-25 Thread Leonard93
check your kmodule.xml and see if it has CashFlowKS as one of the kbases in
it, drools cannot find the rulebase with rules for the application
basically.




--
View this message in context: 
http://drools.46999.n3.nabble.com/java-lang-NullPointerException-in-simple-example-tp4028177p4029363.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Is there a better way to write this rule?

2014-04-23 Thread Leonard93
It only works if you do it like this:
rule "Discount Egypt"
salience 0
when
$T : TripRequest ( destination == "Egypt" )
$dest: DiscountResult()
then
$dest= (DiscountResult) $T.getResult();
   $dest.setDiscount(5);
end


Since getResult() returns an instance of the interface IResult, it needs to
be cast to the proper type first. But this approach does not feel better
than the previous notation.

But thanks for the replies.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327p4029333.html
Sent from the Drools: User forum 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] Is there a better way to write this rule?

2014-04-23 Thread Leonard93
When I have the following rule:

rule "Discount Egypt"
salience 0
when
$T : TripRequest ( destination == "Egypt" )
then
((DiscountResult) $T.getResult()).setDiscount(5);
end


Is there a better way to do the 'then' part of the rule (when it comes to
formatting, but still executes the same thing)? 
My request object has a result object that has a method called setDiscount
that needs to be called.

The setDiscount cannot be in the request object because there are multiple
kinds of Result Objects, thus the casting to its type.

This rule works fine, I was just wondering if there are any easier ways to
do it. I already found out you can do 'destination' instead of
'getDestination()' which helps make the rules more readable.





--
View this message in context: 
http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rule-tp4029327.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT

2014-04-18 Thread Leonard93
I have the same problem with almost identical code. The thing is that when I
run the code normally from a Java main class there are no problems with
finding the module. But if I run my web service that calls the same code it
breaks with the same exception.

Any idea's ?




--
View this message in context: 
http://drools.46999.n3.nabble.com/Cannot-find-KieModule-org-default-artifact-1-0-0-SNAPSHOT-tp4027760p4029290.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Loading rules from the filesystem?

2014-04-16 Thread Leonard93
Thank you, That did help together with reading the documentation again I
could piece together various parts better than before, I couldn't really
make the connections as well just from reading the docs ><.

It works now :). Although I understand why the things are designed as it is,
I am not fully convinced of the usage of the Drools Workbench and might want
to have my own graphical interface for making rules.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Loading-rules-from-the-filesystem-tp4029275p4029278.html
Sent from the Drools: User forum 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] Loading rules from the filesystem?

2014-04-16 Thread Leonard93
Can anyone here give me a good documentation place or thingy where I can read
about how to implement the drools 6 method of loading your rules from a
folder in the file system instead of inside the jar.

I have it working currently with the knowledgebase class, but since that is
deprecated I want to use the new classes. Although I read the drools
documentation about KieBase and such and programmatically defining your
kmodule. I did not really understand how that will help me load my rules
from a folder.

Basically what I want is that the rules located in C:\RulesFolder\rules.drl
will be loaded into my application and available within a stateless session.

Thanks.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Loading-rules-from-the-filesystem-tp4029275.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools causes switch(enum e) to break?

2014-04-14 Thread Leonard93
Well I don't know. It is just a guess that I made since it is the only lead I
have on it so far.

What I have tried so far:
-The error happens in Eclipse Kepler and Juno when opening the same project.
-A netbeans project with the drools binaries imported (opened the same
project still) works fine with no errors.

So maybe its something within eclipse? Since Netbeans works fine for me now
together with Drools.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233p4029237.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools causes switch(enum e) to break?

2014-04-14 Thread Leonard93
The enum is called RuleType, sorry. I am posting this here because this error
only happens within Drools projects, in normal java projects this error does
not happen.

The error is /"Cannot switch on a value of type RuleType. Only convertible
int values or enum variables are permitted"/ no more, no less. It happens on
the *switch(type)*. I don't really know how it can happen but maybe someone
here could give some pointers.

Once again, the same switch and enum in a bland java project gives no
problems.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233p4029235.html
Sent from the Drools: User forum 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] Drools causes switch(enum e) to break?

2014-04-14 Thread Leonard93
So I have a really weird problem and I think it could be relate-able to
Drools, or maybe not but maybe some people here have seen it before.

I have a simple enum called 'RuleTypes' which is defined in its own file.
I have somewhere in my class a switch statement where I use the enum like
this:

(The method is not finished, but its enough to show the problem)

public IResult EvaluateRule(Object obj, RuleType type)
{
//TODO
switch(type)
{
case Discount :
TripRequest lr = (TripRequest) obj;
_Session.execute(lr);
return lr.getResult();
case Content:
break;
case None:
break;
default:
break;
}

return null;
}

But I get an error saying 'Cannot switch on a value of type RuleType. Only
convertible int values or enum variables are permitted'. While RuleType an
enum is 100% sure.

Yet if I make a new project (with no drools libraries), make the same
RuleType enum in its own file and have an empty class doing:

public Test(RuleType type)
{
switch(type)
{
case Discount :
break;
case Content:
break;
case None:
break;
default:
break;
}
}

There are no compiler errors. Anyone know here what could possibly happen?
The only thing I could find was a possible Eclipse bug but that one had a
fix that does not work for me (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413368 ).





--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
Ah thank you, I will look into that and try :) It seems like that would be
indeed the problem.




--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190p4029194.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
I did not realize you could import them in the config and then reference them
right away in the rule without doing the data modelling step. Although I did
that and it still has the same problems.

GenericDataObject.jar
  

is the jar I am using, The rule I am using for it now is:
 

I added the two classes in the config imports aswell as the enum that is
used for the country value.




--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190p4029192.html
Sent from the Drools: User forum 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] External Jar/Pojo in Drools Workbench.

2014-04-10 Thread Leonard93
Hello everyone, I have a small question/problem.

I have created a class (POJO) in Eclipse and I want to be able to write
rules over this class in the Drools Workbench, thus I exported the class and
the classes it depends on (1 other class) to a Jar and imported it in the
Drools workbench.

Now what I did next is I added the jar dependency to my workbench project,
created a new datamodel and set its super class to the external class from
the jar and left the rest empty.

When I then try to use this datamodel in a guided rule or anything I can
access the variables defined in the external class fine when using the rule
editor. But when I save I get various compiler errors.

Currently I tried to make a rule template and I got these errors (I am using
the standard example project to test it out):

Unable to create Field Extractor for *'Destination'Field/method
'destination'* not found for class '*org.mortgages.Test' *

Unable to Analyse Expression *Destination ==
GenericDataObject$Country.Germany*: [Error: unable to resolve method using
strict-mode: *org.mortgages.Test.GenericDataObject$Country()]* [Near : {...*
Destination == GenericDataObject$Country.Germ }]* ^ [Line: 9, Column: 2]


The class from the jar looks like this:
public class GenericDataObject {

public enum Country
{
Egypt,
Germany,
Turkey,
France,
Unknown
}

public GenericDataObject()
{
result = new Result();
}

public Result result;
public Country Destination;

public void setDiscount(int amount)
{
result.discount = amount;
}
}

public class Result
{
public int discount;

public Result()
{
discount = 0;
}
}



--
View this message in context: 
http://drools.46999.n3.nabble.com/External-Jar-Pojo-in-Drools-Workbench-tp4029190.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Identical Facts over rules, results being cached?

2014-04-09 Thread Leonard93
Okay, Thanks for the insights on this point :).
I was considering something with caching but if its not worth the hassle
then I'd rather spend my time working on other parts of the application.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Identical-Facts-over-rules-results-being-cached-tp4029169p4029177.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Identical Facts over rules, results being cached?

2014-04-09 Thread Leonard93
Wouldn't that depend on how long the data is being kept and how often
identical rules are being fired?

Or would you say the rule engine is faster than all the actions in between
that it wouldnt matter?



--
View this message in context: 
http://drools.46999.n3.nabble.com/Identical-Facts-over-rules-results-being-cached-tp4029169p4029172.html
Sent from the Drools: User forum 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] Identical Facts over rules, results being cached?

2014-04-09 Thread Leonard93
Let's say I have 10 rules and I fire the same object over it multiple times.

This means the result that I would get back is the same every time, since it
is the same object over the same rules (In a stateless environment).
Does Drools cache the result internally for such cases? Knowing that when
the same object comes over the same rules it can give the result back right
away instead of going over the rules first.

Just something I want to know and couldn't really find in the documentation
easily.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Identical-Facts-over-rules-results-being-cached-tp4029169.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users