ontologies
by Olfa h
hello,
how I can create ontologies with Drools ?
thx
13 years, 11 months
Rule Compilation error when using custom classloader
by M. Kramer
Hello everybody,
I would appreciate some help with the compilation of a rule that involves
dynamically generated POJOs (minimal example at the end of the mail).
When I add the packages of the generated POJOs manually to the imported
packages of my Eclipse plug-in that executes the knowledge session
everything works fine.
When I use my custom classloader (that successfully loads all involved
classes, I checked this thoroughly) I get the following errors:
Unable to generate rule invoker. lts cannot be resolved to a type
Rule Compilation error lts cannot be resolved to a type
Do I need to change my rules just because the involved classes are now
loaded using my custom classloader?
Thanks for your help!
M. Kramer
This is the rule that only works if the package "lts" is listed under
"Import-Package" in the MANIFEST.MF:
import java.lang.String;
import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.emf.ecore.EObject;
global java.lang.String output;
global java.util.List list;
global java.util.List pclist;
rule "Aspect"
when
$s0Decl: lts.State(name == "a")
$s0: lts.State(this == $s0Decl)
then
java.util.List param = new ArrayList<HashMap<String,EObject>>();
java.util.List ids = new ArrayList<String>();
param.add($s0);
ids.add("0");
list.add(param);
pclist.add(ids);
end
This is the code that I am using to execute the rule:
void executeKnowledgeSession(String droolsRules, URLClassLoader
urlClassLoader, Iterable<EObject> iterable) {
KnowledgeBuilderConfiguration kBuilderConfiguration =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
urlClassLoader);
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(kBuilderConfiguration);
Resource droolsRulesResource =
ResourceFactory.newByteArrayResource(droolsRules.getBytes());
knowledgeBuilder.add(droolsRulesResource, ResourceType.DRL);
if (knowledgeBuilder.hasErrors()) {
...
}
KnowledgeBaseConfiguration kBaseConfiguration =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, urlClassLoader);
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(kBaseConfiguration);
knowledgeBase.getKnowledgePackages().clear();
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
StatelessKnowledgeSession knowledgeSession =
knowledgeBase.newStatelessKnowledgeSession();
knowledgeSession.setGlobal(...);
// execute the knowledge session
knowledgeSession.execute(iterable);
}
These are the exact errors that I get:
Unable to generate rule invoker. lts cannot be resolved to a type
lts cannot be resolved to a type
Rule Compilation error lts cannot be resolved to a type
Unable to generate rule invoker. : [Rule name='Aspect']
defaultpkg/Rule_Aspect_0DefaultConsequenceInvoker.java (22:883) : lts
cannot be resolved to a type
defaultpkg/Rule_Aspect_0DefaultConsequenceInvoker.java (22:901) : lts
cannot be resolved to a type
Rule Compilation error : [Rule name='Aspect']
defaultpkg/Rule_Aspect_0.java (6:322) : lts cannot be resolved to a type
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Compilation-error-when-using-custo...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
drl execution problem
by arup
i have one drl like below:
rule "FirstNameDifference"
no-loop true
lock-on-active true
when
person1: Person( $firstName1: firstName )
person2: Person( firstName != $firstName1 )
then
dataDifferenceVO.getDataDiffArray().add("Person/FirstName");
end
i'm passing a list of objects in which i have 2 person type objects. my aim
is to check if the firstnames are same or different. if its different i need
to add one String to the DataDiffArray that is declared inside
DataDifferenceVO class.
but as i pass 2 person objects in the WM the rule is getting executed twice.
i.e, the string "Person/FirstName" is getting added twice in the array list.
why is this happening?... the rule should compare 2 firstnames and return
one String...is not that?... what step should i take to achive what i
want....
Thanks a lot i advance... :) :) :)
--
View this message in context: http://drools.46999.n3.nabble.com/drl-execution-problem-tp3866929p3866929...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
Interface and @key in declare
by Findulas
Hello,
I want to declare a new fact base on an interface, f.e.: (i leave away all
those publics)
interface BoInterface {
int getId();
void setId(int id);
}
when i declare the fact
declare BoFact (
bo : BoInterface @key
)
the system throws an exception the a class is expected but an interface is
found, when trying to
perform the equals method.
Is there a restriction that @key cannot be used in a declare?
Greetings,
Bernd
--
View this message in context: http://drools.46999.n3.nabble.com/Interface-and-key-in-declare-tp3868085p...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
ClassCastException when comparing date type with literal
by Zeke
Hi, guys:
I meet a strange issue and need your help again... I am using Drools
4.0.7.
When my rule condition is as *Message( date > "Mar-01-2012" )*,
everything is OK. But if I change it to be as below:
*$msg : Message()
Order ( $msg.date > "Mar-01-2012" )*
I will meet "java.lang.String cannot be cast to java.util.Date"
ClassCastException. "Order" is another fact. I attach the exception call
stack. Please check it. It looks like a bug to me. Do we fix it in later
release? If so, can you tell me which release contains the fix? Thanks!
13 years, 11 months
Add to rules-users
by Matt Traynham
mtraynham(a)digitalsmiths.com
_______________________________________________________________________________
This e-mail message and its attachments are for the sole use of the designated
recipient(s). They may contain confidential information, legally privileged
information or other information subject to legal restrictions. If you are
not a designated recipient of this message, please do not read, copy, use or
disclose this message or its attachments, notify the sender by replying to
this message and delete or destroy all copies of this message and attachments
in all media.
13 years, 11 months
Timer (int & cron) ignore when statement
by kkelleyjr
I have a very simple case that does not seem to work. The timer works
correctly as an int or cron but it seems to ignore the when part. here is
the rule...
rule "Database Processing Cron"
timer ( cron: 0/15 * * ? * * * )
when $c : CronJennie()
eval( $c.hasInitialRunOccured() == false )
then
logger.info( "Database processing initial run..." +
$c.hasInitialRunOccured());
$c.setInitialRunOccured();
update($c)
end
-----------------------------------------------------------------------------------------------
i have also done the when as:
$c : CronJennie(hasInitialRunOccured() == false )
I am using the lates version 5.4.0 beta2, any ideas?
Thanks for any insight
--
View this message in context: http://drools.46999.n3.nabble.com/Timer-int-cron-ignore-when-statement-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months
Problem with passing a variable to a function
by Chambers Larry
Hi, one of our developers is having a problem with a specific rule. Within the condition he needs to call a function passing a value from a variable reference defined earlier in the condition. If he hard codes the value (for example passing a 1 instead of the variable) the rule works fine. If we use $driverSequence (which should be some integer) the rule will not fire.
This is the rule that is giving us problems. At the end of the "when" if we replace $driverSequence with a 1 then it works. Any ideas???
rule "DriverChangeAutoLoss"
dialect "mvel"
when
policy : Policy()
$Driver : Driver( $driverSequence : driverSequence, (eval(driverSequence == findPrimaryDriverSequence(policy))) )
(UWRDelta (driversAdded != null, driversAdded contains $driverSequence ) or UWRDelta(driverChanges != null, eval(isDriverChange(this, $driverSequence ))))
then
uwReportCriteria.addUWReport($Driver,"AutoLoss","CACHE_ONLY",null);
end
This e-mail is confidential. If you are not the intended recipient, you must not disclose or use the information contained in it. If you have received this e-mail in error, please tell us immediately by return e-mail to Email.Control(a)sentry.com and delete the document.
E-mails containing unprofessional, discourteous or offensive remarks violate Sentry policy. You may report employee violations by forwarding the message to Email.Control(a)sentry.com.
No recipient may use the information in this e-mail in violation of any civil or criminal statute. Sentry disclaims all liability for any unauthorized uses of this e-mail or its contents.
This e-mail constitutes neither an offer nor an acceptance of any offer. No contract may be entered into by a Sentry employee without express approval from an authorized Sentry manager.
Warning: Computer viruses can be transmitted via e-mail. Sentry accepts no liability or responsibility for any damage caused by any virus transmitted with this e-mail.
13 years, 11 months
Problem with passing a variable to a function
by larryc
Hi, one of our developers is having a problem with a specific rule. Within
the condition he needs to call a function passing a value from a variable
reference defined earlier in the condition. If he hard codes the value (for
example passing a 1 instead of the variable) the rule works fine. If we use
$driverSequence (which should be some integer) the rule will not fire.
This is the rule that is giving us problems. At the end of the "when" if we
replace $driverSequence with a 1 then it works. Any ideas???
rule "DriverChangeAutoLoss"
dialect "mvel"
when
policy : Policy()
$Driver : Driver( $driverSequence : driverSequence,
(eval(driverSequence == findPrimaryDriverSequence(policy))) )
(UWRDelta (driversAdded != null, driversAdded contains
$driverSequence ) or UWRDelta(driverChanges != null,
eval(isDriverChange(this, $driverSequence ))))
then
uwReportCriteria.addUWReport($Driver,"AutoLoss","CACHE_ONLY",null);
end
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-passing-a-variable-to-a-fu...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 11 months