ClassCastException and other problems
by Sibylle Duerr
Hi there,
I have three issues, where I'm not sure if these are bugs in drools, or
if this is just the way it has to be.
the used classes in this case are:
Project
Model
ProcessModel extends Model
only the Project is in the working memory, because I didn't want to load
all elements due to performance issues (there can be thousends of
elements to load at startup).
if I have the following rule:
Project($models : models)
ProcessModel($activities : activities) from $models
there happen to be two problems. if the project does not only contain
ProcessModels but also TypeModels or others (all extend Model), this
leads to a ClassCastException.
I can solve this by writing the rule as follows:
Project($models : models)
$m : Model(eval($m instanceof ProcessModel)) from $models
ProcessModel($activities : activities) from $m
but this is not really nice and I hope there is a better solution for
this, is there?
the second problem this rule gives me, is when the set 'models' is
empty. that will also throw an exception. to solve this I write:
$p : Project(eval($p.hasModels()), $models : models)
$m : Model(eval($m instanceof ProcessModel)) from $models
ProcessModel($activities : activities) from $m
and I need to use this in each case where I have possible empty sets.
the last problem I encountered when I tried to load all elements to the
working memory and then redefine some rules. used classes:
Aggregation extends DomainElement
rule:
Aggregation(owner.owner != type.owner)
causes some exception. the root exception is a ClassCastException:
ProxyShadowProxy cannot be cast to Aggregation.
when I rewrite the rule as:
$element : DomainElement(eval($element instanceof Aggregation))
Aggregation(owner.owner != type.owner) from $element
everything works fine. but that again is not a nice solution.
any help?
best regards
sibylle
18 years
Constants initialize
by Thalupula Ravi
Hi,
Can some one suggest me how can i initialize a constant (String), which is
common to all rules and the value of constant can able to change by Business
users (BRMS).
I think we can use global variable or fact, but that need to be supplied by
client program and initialized at client side.
I'm expecting initialization at rules side, which can easily maintain by
business users.
Thanks in advance.
Regards,
Ravi Thalupula
--
View this message in context: http://www.nabble.com/Constants-initialize-tp17731133p17731133.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years
Question about timing rules
by Bagwell, Allen F
Another noob question:
Is there a generally understood way of implementing the concept of a time interval rule?
That is, lets say I have a Drools-enabled client which is constantly receiving information from outside resources. Most of this data (and the consequences of its changes) is time sensitive, so I'm calling the fireAllRules() method in a loop every minute.
And now, let's say I have a rule that in addition to being driven by incoming data changes has to be linked to a repeating clock interval or synched with wall time such that the rule only activates and fires if the data meets certain parameters AND it's been exactly 1 hour since the last check or that it will fire at the top of every wall time hour (1 PM, 2PM, 3 PM, etc.).
Furthermore, timing may change. A successful rule activation and firing might do something like "now change this timing so that for the next 24 hours, this rule must be examined every 30 minutes instead of every hour".
My initial reading of the Drools documetation I came across the Duration, and Date-* keywords. Their descriptions didn't seem to fit the bill.
I ask this because our old rules engine software that has been retired to obsolescence allowed this kind of thing to be easily set up. Coming at it in the Drools world seems a lot more challenging.
Thoughts? Examples?
-Allen
18 years
Converting to XML error, <from> tag not handled?
by PassiveReality
Hi
I'm currently trying to create a simple example in converting a DRL rule
into an XML rule and compiling that but it seems that the XML conversion is
not working correctly or have I done something wrong? Has anyone noticed
this problem too?
public static String convertDrlToXmlRule(String drlRule) throws
DroolsParserException
{
DrlParser parser = new DrlParser();
PackageDescr descr = parser.parse(drlRule);
// Dump to xml rule.
XmlDumper dumper = new XmlDumper();
return dumper.dump(descr);
}
the code above converts a drlRule and dumps out an XML format.
My example drl rule (this compiles fine):
public static String exampleRule = "package com.rules;" +
"import com.rules.my.test.Message;" +
"import com.rules.my.test.SubMessage;" +
"import com.rules.my.test.SubSubMessage;" +
"rule \"exampleRule\"" +
" dialect \"mvel\"" +
" when" +
" Message( $subMessage :
subMessage)\n" +
" SubMessage( $subSubMessage :
subSubMessage) from $subMessage\n" +
" SubSubMessage( message ==
\"SubSub\") from $subSubMessage\n" +
" \nthen\n" +
" System.out.println( $subMessage );"
+
" end";
What comes out:
<?xml version="1.0" encoding="UTF-8"?>
<package name="com.rules"
xmlns="http://drools.org/drools-4.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
<import name="com.rules.my.test.Message" />
<import name="com.rules.my.test.SubMessage" />
<import name="com.rules.my.test.SubSubMessage" />
<rule name="exampleRule ">
<rule-attribute name="dialect" value="mvel" />
<lhs>
<pattern object-type="Message" >
<field-binding field-name="subMessage" identifier="$subMessage" />
</pattern>
<pattern object-type="SubMessage" >
<field-binding field-name="subSubMessage"
identifier="$subSubMessage" />
<field-binding field-name="subSubMessage"
identifier="$subSubMessage" />
<from>
<expression> $subMessage </expression>
</from>
</pattern>
<pattern object-type="SubSubMessage" >
<field-constraint field-name="message">
<literal-restriction evaluator="==" value="SubSub" />
</field-constraint>
<field-constraint field-name="message">
<literal-restriction evaluator="==" value="SubSub" />
</field-constraint>
<from>
<expression> $subSubMessage </expression>
</from>
</pattern>
</lhs>
<rhs>
System.out.println( $subMessage );
</rhs>
</rule>
</package>
If you noticed above it comes out with duplicate field-constaints for
pattern SubSubMessage?? However, thats not a big problem, when I try to
compile the rule in XML format it throws:
org.xml.sax.SAXParseException: <from> is after an invalid element:
org.drools.xml.Handler
at org.drools.xml.XmlPackageReader.validate(XmlPackageReader.java:506)
at
org.drools.xml.XmlPackageReader.startElement(XmlPackageReader.java:394)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:321)
at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:247)
Any suggestions in what I am doing wrong?
Cheers,
Le.
18 years
How to Configure Hibernate and use in Drools
by RAJA SEKHAR REDDY MAYALURU
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
.
thanks for the help in advance
regards ,
Sekhar .
18 years
Rule Agent Performance : BRMS or pkg file ?
by Cabou, Carl
Hi all,
I'm using Drools 4.0.7.
I use the Drools api in my application with the rule Agent as describe
in the section 9.4.4.1 of the documentation and it works fine.
Since our application is running under weblogic 8.1, we must use JBoss
for BRMS because weblogic 8.1 is not java5 compliant, but I don't want
to use multiple app servers.
So the question is : what is best for performance ? use the BRMS at
runtime (< url > property) on JBoss or use only packages files on disk
(< file > property).
Anyway I will do perf benchmarks, I'm assuming it is better with package
files but I'd like to have some feedback before...
Regards,
Carl.
18 years
Possible OSWorkflow Merger
by Mark Proctor
I just wanted to give the Drools community a heads-up that the
OSWorkflow community might be merging with us - not confirmed yet, but
their project lead is keen. Our unified process work has matured and we
are now very close to having a migration path for OSWorkflow users, who
are keen to migrate to an actively maintained project. We've spoken to
Diego Naya Lazo, the project lead and author of the OSWorkflow Book
http://www.infoq.com/articles/naya-lazo-osworkflow, and he is liasing
with his community to see if they are happy to move forward with this.
The Drools process stuff also needs a name, as sub project - remember we
have total unification and integration between the rules and process
(see blog http://blog.athico.com/search/label/Rule%20Flow). So we can
either go down generic routes - Drools Flow, Drools Rules, Drools
Events. Or have something a bit more fun Drools Meastro, Drools X,
Drools Fusion - X is there sa I don't have a fun name for the rule part.
The idea is we will split the manual up into separate books that will
start from the understanding of a person from that discipline, before
jumping deep into how the techs are integrated.
This is huge news and puts us firmly onto the path of a unified
modelling environment, and hopefully an end to the days of having to
choose and purchase separate and poorly integrated products for rules,
processes and complex event processing.
Mark
18 years
Consequence Restriction
by Markus Helbig
Hi,
i have on DSL and several DSRL files. What i want to do is to restrict
the usage of consequence parts. Means
I have to possible kind of objects in my workingmemory, e.g. Item1 and Item2.
Item1 has a methode setValue1(), and Item2 setValue2()
my DSL has to possible consequence lines
[consequence][]set value1 {value} for {item}={item}.setValue1({value});
[consequence][]set value2 {value} for {item}={item}.setValue2({value});
so now you can use both consequences for the objects but you
shouldn't. currently at runtime an exception will occur. Is it
possible to check this fault at compile time?
Cheers
Markus
18 years
question on rule efficiency
by Barry Kaplan
When the value of a property is compared across two instances, is it better
to create variables for the properties, or is using the object.property for
the comparison equivalent?
Here's an example: I need to match based on the strikePrice property. Is
either version better than the other?
version 1)
putContract : OptionInstrument(
optionType == OptionType.PUT)
callContract : OptionInstrument(
optionType == OptionType.CALL,
strikePrice > putContract.strikePrice)
// compare using navigation
version 2)
putContract : OptionInstrument(
optionType == OptionType.PUT,
putStrikePrice : strikePrice)
// delcare the variable
callContract : OptionInstrument(
optionType == OptionType.CALL,
strikePrice > putStrikePrice)
// compare using variable
--
View this message in context: http://www.nabble.com/question-on-rule-efficiency-tp17672843p17672843.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years