Please don't keep telling me to do something that can't be done.
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.KnowledgeBase;
import org.drools.definition.KnowledgePackage;
public List<String> getRuleNamesFromPackage( String kPackageName ){
List<String> nameList = new ArrayList<String>();
for( KnowledgePackage knowledgePackage:
session.getKnowledgeBase().getKnowledgePackages() ){
if( kPackageName == null || kPackageName.equals(
knowledgePackage.getName() ) ){
for( org.drools.definition.rule.Rule rule: knowledgePackage.getRules() ){
org.drools.rule.Rule odrRule = (org.drools.rule.Rule)rule;
//<<<<< line 155: try a cast to get rule's agenda
nameList.add( rule.getName() );
}
}
}
return nameList;
}
Exception in thread "main" java.lang.ClassCastException:
org.drools.definitions.rule.impl.RuleImpl cannot be cast to
org.drools.rule.Rule
at rss.checker.engine.impl.DroolsEngine.getRuleNamesFromPackage(DroolsEngine.java:155)
at rss.checker.engine.impl.DroolsEngine.getRuleNames(DroolsEngine.java:165)
at rss.checker.init.Main.exec(Main.java:51)
at rss.checker.init.Main.main(Main.java:68)
There's lots of rules around that have agenda-group "whatever". ARE
YOU PLANNING TO ABOLISH THIS????
I ONLY WANT TO GET BACK WHAT I WROTE ACCORDING TO THE CURRENTLY VALID
DOCUMENTATION!!!
-W
On 20 August 2010 20:30, Mark Proctor <mproctor(a)codehaus.org> wrote:
On 20/08/2010 17:21, Wolfgang Laun wrote:
> Please note that I am and was well aware of org.drools.rule.Rule. But this isn't
> available from what you get via StatefulKnowledgeSession, KnowledgeBasae,
> KnowledgePackage. See below.
I want to compltely change agenda-groups, ruleflow-groups,
activation-groups etc.
In the same way you'll be reluctant to want to use internal methods as
they will change over time. I'm reluctant to expose internal things that
I know I want to change in the near term. We have to support those apis
for 5 years.
Can you caste for now to try and solve your problem? The information is
there if you caste to org.drools.rule.Rule. We are working on pushing
more things out of core and compiler over time as we feel confident in
exposing those things. But it takes time and we are conservative in
this, as we want to avoid doing anything that makes future changes hard.
Mark
> On 20 August 2010 17:46, Mark Proctor<mproctor(a)codehaus.org> wrote:
>> On 20/08/2010 11:13, Wolfgang Laun wrote:
>>> StatefulKnowledgeSession session = ...;
>>> for( KnowledgePackage knowledgePackage:
>>> session.getKnowledgeBase().getKnowledgePackages() ){
>>> for( Rule rule: knowledgePackage.getRules() ){
>>> ???
>>>
>>> but it turns out that this "rule" object is of the interface type
>>> org.drools.definition.rule.Rule
>>> implemented by
>>> org.drools.definitions.rule.impl.Rule
>>> which is just as meagre as the interface. Dead end, apparently.
>> You looked at the wrong implementation. Notice that Rule is also
>> implemented by org.drools.rule.Rule. That one has the meat you need.
>>
> This is what I wrote:
>
>>> Using other classes like Package or RuleBase from the "unstable"
part
>>> of the API to get at
>>> the "real meat" in org.drools.rule.Rule isn't really a way I
want to go.
>>>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev