Pattern matching rules
by rganesh84
I was just wondering if there is a pattern matcher available in drools.
Below is a sample
rule "Action Movies"
dialect "java"
when
ui : UserInfo(likes contains "Action")
then
List sw = new ArrayList();
sw.add("Die Hard");
sw.add("The Avengers");
ui.setRecs(sw);
end
the rule strictly checks for word "Action" but if the likes list contains
"Action Movies" the rule won't get processed. Is there a pattern matching
ability or a like search for a String/list containing strings?
--
View this message in context: http://drools.46999.n3.nabble.com/Pattern-matching-rules-tp4025112.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
'last modified' and 'created by' attributes for a asset showing wrong userid in Guvnor 5.4.0.final
by vadlam
Has anyone come across this scenario ?
In Guvnor 5.4.0.final, when user1 initially logs in and updates a asset(
saves and closes it, logs out ) , subsequent asset updates for same asset or
different asset by user2 still show as done by user1 which is incorrect.
updates done by user2 need to be shown as Last modified by user2 and not
user1 .
In the log file extract shown below, though the changes were done by user2 ,
it shows in the logs as well as Guvnor asset attributes screen as done by
user1 which is incorrect.
This is even though user1 and user2 logged out and logged in a couple of
times to see if Guvnor was holding on to an asset .
8443-exec-1} (SecurityServiceImpl) - Logging in user [user1]
[2013-07-19 13:22:22,311 INFO] {http-bio-8443-exec-15}
(SecurityServiceImpl) - Logging in user [user2]
[2013-07-19 13:29:54,501 INFO] {http-bio-8443-exec-20}
(RepositoryAssetService) - USER:user1
CHECKING IN asset: [EducationRules] UUID:
[35c6a33b-5e09-4bef-a850-fd72aee7d909]
[2013-07-19 13:33:36,930 INFO] {http-bio-8443-exec-26}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [EducationRules]
UUID: [35c6a33b-5e09-4bef-a850-fd72aee7d909]
[2013-07-19 13:39:14,178 INFO] {http-bio-8443-exec-26}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [EducationRules]
UUID: [35c6a33b-5e09-4bef-a850-fd72aee7d909]
[2013-07-19 13:43:20,491 INFO] {http-bio-8443-exec-37}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [EducationRules]
UUID: [35c6a33b-5e09-4bef-a850-fd72aee7d909]
[2013-07-19 13:44:35,731 INFO] {http-bio-8443-exec-36}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [NeedProducts]
UUID: [dbed4045-52f3-4cfe-9d7e-a9506ab65c7b]
[2013-07-19 13:45:19,537 INFO] {http-bio-8443-exec-36}
(SecurityServiceImpl) - Logging in user [user2]
[2013-07-19 13:45:40,223 INFO] {http-bio-8443-exec-33}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [NeedProducts]
UUID: [dbed4045-52f3-4cfe-9d7e-a9506ab65c7b]
[2013-07-19 13:47:15,307 INFO] {http-bio-8443-exec-38}
(SecurityServiceImpl) - Logging in user [user2]
[2013-07-19 13:47:41,765 INFO] {http-bio-8443-exec-37}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [VisaOptions] UUID:
[ab453826-b0e2-4966-b25c-f2ca4ad59df7]
[2013-07-19 13:49:16,209 INFO] {http-bio-8443-exec-39}
(ServiceImplementation) - USER:user1 CREATING new asset name [Option] in
package [SreeramCreditOptions_R113]
[2013-07-19 13:49:16,911 INFO] {http-bio-8443-exec-39}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [Option] UUID:
[2d9ac9df-5cf9-4656-9e75-76f4bac64580]
[2013-07-19 13:49:54,430 INFO] {http-bio-8443-exec-39}
(RepositoryAssetService) - USER:user1 CHECKING IN asset: [Option] UUID:
[2d9ac9df-5cf9-4656-9e75-76f4bac64580]
-----
Ram
--
View this message in context: http://drools.46999.n3.nabble.com/last-modified-and-created-by-attributes...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
Getting deadlock-like thread state
by Bojan Janisch
Hey drools users,
I'm running drools multiple times in parallel with ECJ (genetic algorithm framework). Also I'm running ECJ multiple times in parallel (evaluation purpose).
But each time I want to run ECJ, after an unspecific time, one thread is running infinite long while ECJ waits for it to finish. Additionally to this my
working memory is steadily growing while hanging in this deadlock-like state, though this might not be due to drools. This goes on until I get an gc out of
memory exception.
I've created a threaddump which always looks so:
java.lang.Thread.State: RUNNABLE
at java.lang.Object.notifyAll(Native Method)
at org.drools.common.DefaultAgenda.notifyHalt(DefaultAgenda.java:1478)
- locked <0x00002af5f3b0fe88> (a java.util.concurrent.atomic.AtomicBoolean)
at org.drools.common.DefaultAgenda.addActivation(DefaultAgenda.java:466)
at org.drools.common.DefaultAgenda.addActivation(DefaultAgenda.java:326)
at org.drools.reteoo.RuleTerminalNode.assertLeftTuple(RuleTerminalNode.java:259)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
at org.drools.reteoo.JoinNode.propagateFromLeft(JoinNode.java:107)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:95)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
at org.drools.reteoo.JoinNode.propagateFromLeft(JoinNode.java:107)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:95)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:196)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:71)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:159)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at rulevolution.RulEvolution.runDrools(RulEvolution.java:343)
at rulevolution.RulEvolution.evaluate(RulEvolution.java:185)
at ec.simple.SimpleEvaluator.evalPopChunk(SimpleEvaluator.java:259)
at ec.simple.SimpleEvaluator$SimpleEvaluatorThreadCG.run(SimpleEvaluator.java:341)
at ec.util.ThreadPool$PoolThread.run(ThreadPool.java:57)
Locked ownable synchronizers:
- <0x00002af5f3ae95d0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
To my Programm:
Rules are generated in parallel and for each rule, a new KnowledgeBase, KnowledgeBuilder and StatefulKnowledgeSession is created.
Objects are inserted into the session and the rule is fired. The session will be disposed after no facts matches my rule or 1000
conclusions are fired.
I've searched the net for a similar problem, but with no success. Does someone know why Drools get into such a thread state and
how to get out of it?
I appreciate any help.
Bojan
11 years, 4 months
Change Notification doesn't work with eval(true) in one of the rules
by Sammi
All the rules defined in a single DRL were running fine until one day we
added eval(manager.isEnabledSomeSettings()) into one of the rule in drl,
which causing an issue for change update on the fly (see below error
stacks). When we changed that eval to Boolean(this == Boolean.TRUE) from
manager.isEnabledSomeSettings() then the change notification getting back to
work properly. Any ideas?
KnowledgeAgent adding KnowledgeDefinitionsPackage
com.baml.investxa.rule.order
Exception in thread "Thread-15" java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
at java.util.HashMap$EntryIterator.next(HashMap.java:834)
at java.util.HashMap$EntryIterator.next(HashMap.java:832)
at org.drools.reteoo.EvalConditionNode.doRemove(EvalConditionNode.java:311)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:372)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at
org.drools.reteoo.RightInputAdapterNode.doRemove(RightInputAdapterNode.java:254)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:368)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:429)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:232)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:414)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:836)
at
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:628)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:541)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:427)
at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:434)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1031)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:909)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:648)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:192)
at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1202)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "Thread-22" java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
at java.util.HashMap$EntryIterator.next(HashMap.java:834)
at java.util.HashMap$EntryIterator.next(HashMap.java:832)
at org.drools.reteoo.EvalConditionNode.doRemove(EvalConditionNode.java:311)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:372)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at
org.drools.reteoo.RightInputAdapterNode.doRemove(RightInputAdapterNode.java:254)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:368)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:429)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:232)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:414)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:836)
at
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:628)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:541)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:427)
at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:434)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1031)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:909)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:648)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:192)
at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1202)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "Thread-21" java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
at java.util.HashMap$EntryIterator.next(HashMap.java:834)
at java.util.HashMap$EntryIterator.next(HashMap.java:832)
at org.drools.reteoo.EvalConditionNode.doRemove(EvalConditionNode.java:311)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:372)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at
org.drools.reteoo.RightInputAdapterNode.doRemove(RightInputAdapterNode.java:254)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.BetaNode.doRemove(BetaNode.java:368)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.FromNode.doRemove(FromNode.java:390)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:429)
at org.drools.common.BaseNode.remove(BaseNode.java:105)
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:232)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:414)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:836)
at
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:628)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:541)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:427)
at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:434)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1031)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:909)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:648)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:192)
at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1202)
at java.lang.Thread.run(Thread.java:662)
--
View this message in context: http://drools.46999.n3.nabble.com/Change-Notification-doesn-t-work-with-e...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
by Manasi
Hi,
I am also getting same error when trying to a call rule stored in guvnor.
Following error I am getting:
Exception in thread "main" java.lang.ClassCastException:
[Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:82)
at org.drools.agent.URLScanner.readPackage(URLScanner.java:171)
at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:143)
at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:119)
at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:427)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:379)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:364)
at org.drools.agent.RuleAgent.init(RuleAgent.java:264)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:204)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:164)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:273)
I am using Drools 5.4 version.
The error is coming when trying to get the RuleAgent:
RuleAgent agent = RuleAgent.newRuleAgent("/com/model/drools.properties");
drools.properties contains:
url =
http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/FeltKnapRes...
name=guvnorAgent
enableBasicAuthentication=True
username=admin
password=admin
FeltKnapRestriktionerKundeMedAnl is the package name I have created in
guvnor ,and I want to call one of the rule in this package.
Thanks,
Manasi
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
Importing functionS from another drl in 5.5.0
by Sonata
If you have defined functions in a drl, in order to use those functions in
another drl of a different package, you will have to import each individual
function, like
package A;
function void func1 () {
System.out.println("Hello");
}
function void func2 () {
System.out.println("There");
}
pacakge B;
import function A.func1.func1;
import function A.func2.func2;
rule Test
when
then func1(); func2(); end
Is there any way to do something like import function A.*; in Drools 5.5.0
to use all the functions defined in another drl?
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/Importing-functionS-from-another-drl-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months
DRL always posting the format as txt instead of model.drl
by learnbrms
Hi,
I am using the following code to post or update the DRL using ATOM. But I am
seeing that DRL is always posted and displayed in Guvnor as .txt
(Format:txt) instead of Format:model.drl.
public int createUpdateTextAsset(String assetLoc, String ruleName, String
ruleDescription, String fileToUpload, String requestMethod)
{
System.out.println("--------Begin createUpdateTextAsset ----------");
System.out.println("assetLoc "+assetLoc+"\nruleName
"+ruleName+"\nruleDescription "+ruleDescription+"\nfileToUpload
"+fileToUpload+"\nrequestMethod "+requestMethod);
String authCode = user+":"+password;
StringBuilder content = null;
Scanner scanner = null;
client = WebClient.create(baseURL);
try
{ File f = new File(fileToUpload);
content = new StringBuilder();
String NL = System.getProperty("line.separator");
scanner = new Scanner(new FileInputStream(f));
while (scanner.hasNextLine()) {
content.append(scanner.nextLine() + NL);
}
String ruleContent=content.toString();
String atom = "";
Response response = null;
String authString = "";
authString = "Basic " + org.apache.cxf.common.util.Base64Utility
.encode(authCode.getBytes());
client.header("Authorization", authString);
atom = "<entry xmlns=\"http://www.w3.org/2005/Atom\"
xml:base=\"";
atom += assetLoc;
atom += "\"><title type=\"text\">";
atom += ruleName;
atom += "</title><summary type=\"text\">";
atom += ruleDescription;
atom += "</summary>";
atom +="<metadata>";
atom +="<property name=\"archived\" value=\"false\" />";
atom +="<property name=\"rule-format\" value=\"model.drl\"/>";
atom +="</metadata>";
atom += "<content type=\"application/xml\">";
atom += ruleContent;
atom += "</content></entry>";
System.out.println("Atom :"+atom);
if(requestMethod=="POST"){
response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
.header("slug", ruleName+".drl")
.post(atom);
}else{
response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
.put(atom);
}
System.out.println("--------End createUpdateTextAsset ----------status
"+response.getStatus());
return response.getStatus();
}
*Output:*
Title: bre-validation-service-processing-model
Categories:
Last modified : 2013-07-17 00:07
by:
Note:
Initial:
Created on:2013-07-17 00:07
Created by:admin
Package:TestPackage6
Edit
Is Disabled:
*Format:txt*
UUID:c8247b22-1a14-4258-9cdf-5033518adf6b
--
View this message in context: http://drools.46999.n3.nabble.com/DRL-always-posting-the-format-as-txt-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 4 months