Combine DSL and Java Code?
by Markus Helbig
Hi,
following example:
Item Class:
public class MyItem {
public MyItem() {}
public String getMessage()
{
return "Hello World!";
}
}
DSL:
[condition][]is of type MyItem=MyItem()
[consequence][]write "{value}" to stdout=System.out.println("{value}");
DSRL File:
rule
when
$item: is of type MyItem
then
write $item.getMessage() to stdout
end
Is this "write $item.getMessage() to stdout" possible in any way?
Currently i'm not able to get it to work ...
Cheers
Markus
18 years
Need guide how to deploy rules
by Rahul Upadhyay
Hi
How can I add(deploy) rules in a web application( struts ) without using
BRMS in JBOSS server.
need sample example..
thanks in advance
regards
Rahul Upadhyay
18 years
JBRMS persistence
by Mark Proctor
We use our own API which currently only has a jackrabbit impl - although
note that jackrabbit can have several backend types from disk, to memory
to database, where is even a hibernate persistence store. Creating a JCR
like implementation is a lot of work, we chose jackrabbit as it is
opensource and a standard and provides much of what we need out of the
box - why spend a month or three creating something that is like JCR but
is implemented with hibernate instead of just just using JCR? So in
reality our choice for JackRabbit is about time and leveraging what is
available, as there are no clear alternatives out there. That does not
mean we are against an alternative backend store, indeed Mic is mucking
around with a Scala implementation, we wrote against our own API exactly
so that we could replace JCR if we ever deemed it necessary. If someone
was to make a better backend for us, we would consider using it.
Mark
Michael Rhoden wrote:
> Couple questions about the JBRMS persistence layer. I have been trying to figure out how to upgrade and incorporate the new 4.03 code into my current app using 2.x and 3.x drools. After many months of off and on playing with 4.x I want to see if I have some things straight.
>
> 1) JBRMS is built atop Jackrabbit. It appears this is the only option for persistence. Is this correct?
> 2) It seems Jack Rabbit and the whole JCR standard, while nice I guess for coders, seems difficult to integrate with. All objects are stored as binaries, even in the db persistence manager and there is no way to access the rules except programmatically. Correct?
> 3) Assuming I'm on the right track with the above two items, and please don't take this the wrong way, I love you guys and what you are doing, why use Jackrabbit?
>
> It seems like a real bad idea to have an open system to store rules and then lock it away. I'm sure you guys have some good reasons but I'm having a real tough time and quite frankly am disappointed. From my perspective rules are one of the major assets of my company. I can't allow them to be locked up in a system. I must be able to access them from a jdbc source for backups, conversion, referencing, reporting, etc. The data however complex in structure must be transparent. Say I want to convert off Drools for another engine, or build around the JBRMS data structure to extend the app for proprietary purposes, or just want to access the rules in an indexed way to present them to power users to see the guts of a rule inside our application. Maybe you can do this now, I just haven't seen the light.
>
> Again I understand JBRMS is still quite new, and my hope Jackrabbit was just the quick and dirty way to get this deployed.
>
> 4) Are there any plans to have a straight jdbc persistence atop a hibernate (plug the ole JBoss way) backend?
>
> Not to leave you with just negative bits. Drools 4.x rocks and regardless of using the JBRMS we are looking at porting up to the latest version. The new frontend UI (coming soon) to the JBRMS looks nice too. Thanks for all the hard work.
>
> -Michael
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
18 years
Globals in LHS of a rule?
by Michael Zimmermann
Hi there,
according to the online documentation globals are supported in the LHS
of a rule, yet requires a bit of care to use there.
But how do I use globals in the LHS? Is there any option to access a
globals variable directly like:
globals List myList
rule "SomeRule"
when
myList.size() == 2
then
...
Or can I have to use globals only in eval() statements?
cu, Michael
18 years
inserting fact in subflow, availability to other flows?
by Eric Miles
I have a main flow that calls a subflow. In this subflow, I am
inserting a fact. In a rule in the main flow, it can not find this fact
in working memory. Is it possible to insert a fact in a subflow and
have it available to a parent flow?
Thanks!
18 years
Rule firing problem - must be missing something obvious
by J Michael Dean
I am passing a glucose decision object with a value of 12, and have a
state object that starts out with its flag set false. The desired
behavior is that the value will be recognized as "extremeHypoglycemia"
by the first rule, and then the second rule will recommend giving a
glucose bolus.
When I pass both objects in without "true" to cause automatic
updating, then the first rule fires, the output is
false
Fired detect extreme hypoglycemia
true
and then the program stops. It does not fire the second rule.
When I add true to the insertion of these objects, then the program
recurses, and still never hits the second rule. Interestingly, the
output is
true
Fired detect extreme hypoglycemia
true
true
Fired detect extreme hypoglycemia
true
...
ETC.
rule "First rule: Detect extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision( serumGlucoseConcentration < 40 )
decisionState : GlucoseDecisionState(extremeHypoglycemia == false)
then
System.out.println("Fired detect extreme hypoglycemia");
System.out.println(decisionState.isExtremeHypoglycemia());
decisionState.setExtremeHypoglycemia(true);
decision.setRationaleText(decision.getRationaleText() +
"Extreme hypoglycemia (Current glucose is " +
decision.getSerumGlucoseConcentration() +" mg/dL).\n");
System.out.println(decisionState.isExtremeHypoglycemia());
update(decision);
end
rule "Second rule: Give glucose bolus for extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision()
decisionState : GlucoseDecisionState(extremeHypoglycemia == true )
then
System.out.println("Fired glucose bolus rule");
decisionState.setRecommendedGlucoseBolus(true);
decision.setRationaleText(decision.getRationaleText() +
"Glucose bolus recommended because of extreme hypoglycemia.\n");
end
18 years
Best way to detect duplicate rule names?
by Jared Davis
Hi,
What is the best way to detect duplicate rule names in drl files? In my
application a duplicate rule name is an error.
There are multiple drl files loaded into one package. If the rule name is
duplicated across the files only the last rule is used. This behavior is clearly
documented.
The code below silently eats duplicated rules.
Reader sourceDrl = new InputStreamReader( new FileInputStream("r1.drl"));
Reader sourceDsl = new InputStreamReader( new FileInputStream("r.dsl"));
Reader sourceDrlTwo = new InputStreamReader( new FileInputStream("r2.drl"));
Reader sourceDslTwo = new InputStreamReader( new FileInputStream("r.dsl"));
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( sourceDrl, sourceDsl );
builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
System.out.println(builder.hasErrors()); // returns false
// A duplicate rule is not an error
Package pkg = builder.getPackage();
Is there a better alternative than loading each drl into a separate
PackageBuilder to track the individual rule counts in each drl file?
eg
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( sourceDrl, sourceDsl );
int ruleCountOne = builder.getPackage().getRules().length;
PackageBuilder builderTwo = new PackageBuilder();
builderTwo.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
int ruleCountTwo = builderTwo.getPackage().getRules().length;
// now re-compile file (reset readers as well...)
builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
if (builder.getPackage().getRules().length != (ruleCountOne + ruleCountTwo)) {
System.out.println("A duplicate exists - No clue what the name is");
// grep -i rule *.drl | sort | uniq -c
}
This does not detect a duplicate rule name in the same file - that would be even
better.
Regards,
Jared Davis
18 years
RE:Problem Using Update
by Sikkandar Nawabjan
Hi,
I have rule like this
rule "Update Id"
dialect "mvel"
salience 100000
no-loop true
when
$add:Address(name=="india")
then
$add.setId("100");
update($add)
end
am getting the error org.drools.FactException: Update error: handle not found for object
and Address <mailto:Address@4b25933f> @4b25933f. Is it in the working memory?
what could be the problem? can't i use update??????
Thanks and Regs,
basha
18 years
RE:update is not working properly
by Sikkandar Nawabjan
Hi,
This exception is not throwing very often. Occasionally i got this FactException . Is it because of another rule/Fact? i have the following rule also
rule "check created error"
dialect "mvel"
salience 100000
no-loop true
when
$add:Address(continent=="asia")
then
retract( $add)
can't a drl file contain both update and retract together? if both rules satisfy the facts what will happen for the handle?
Thanks and Regs,
Basha
Sikkandar Nawabjan wrote:
>
>
> Hi,
>
> I have rule like this
>
> rule "Update Id"
>
> dialect "mvel"
>
> salience 100000
>
> no-loop true
>
> when
>
> $add:Address(name=="india")
>
> then
>
> $add.setId("100");
>
> update($add)
>
> end
>
That should work, its a fairly trivial use case, so I'm very surprised
it doesn't.... If you are suare this isn't working for you, can you open
a jira with a minimal self contained test project showing the error.
> am getting the error org.drools.FactException: Update error: handle not found for object
>
18 years
drools-ant task and decision tables
by Matija
Hi, does the drools-ant task know how to compile (.xls) decision
tables, or does it only compile .drl (and .brl, .xml etc.) files? I'm
having a bit of trouble getting it working, it keeps giving me the
"Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel'"
exception (anyone know what's up with that, as far as I know that
class is there along with all the required jars)?
I'm trying to determine if it's worth my time trying to resolve the
error (I can't use the ant task if it doesn't support decision
tables).
Regards,
M.
18 years