Retriving Rule Id in Rule Template
by srinivasasanda
Hi All,
How to retrieve the cell number(rule id) when i click the load template
data.
My actual requirement is,I created a rule template where i defined some
conditions and actions.Now,when i clicked the load template data,i filled
condition columns and action columns.
I added 4 rows in template data.Now there are 4 rules available which are
postfixed with ids(cell numbers).
Now,how can i get that cellnumbers(1,2,3,4) in then part of rule condition.
Please suggest me
--
View this message in context: http://drools.46999.n3.nabble.com/Retriving-Rule-Id-in-Rule-Template-tp36...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Inserting rules from guvnor into database
by srinivasasanda
Hi All,
Greetings,
I would like to know how to insert the rules from guvnor into
database.Ofcourse,I retrieved the rules from guvnor through KnowledgePackage
classes and API and inserted manually through java code.
But,I should not need that.My requirement is whenever i created rule in the
guvnor and click save changes,my repository of rules must be inserted into
database(mysql or postgres).How can i achieve that.Please suggest me.How can
i achieve that.
Thanks in Advance
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-rules-from-guvnor-into-databa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Uable to reolve type
by gg
This is my rules file and its throwing this error:
[ isContained : unable to resolve type while building function
]
--------------------------------------------------------------------------------
package com.sample
import com.sample.DroolsTest.Message;
import com.sample.DroolsTest.Result;
import com.sample.DroolsTest.Discount;
import java.util.Arrays;
import java.util.List;
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
Thanks,
--GG
--
View this message in context: http://drools.46999.n3.nabble.com/Uable-to-reolve-type-tp3634048p3634048....
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Function Mismatch <eof>
by gg
I have written this in my rules file: But I getting this error :
[29,0]: [ERR 102] Line 29:0 mismatched input '<eof>' in function
"isContained"
[0,0]: Parser returned a null Package
-----------------------------------------------------------------------------
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
--
View this message in context: http://drools.46999.n3.nabble.com/Function-Mismatch-eof-tp3634033p3634033...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Lists of Lists membership
by gg
I have a List of List of String : List<List<String>> and an array of
strings: String [].
I want to fire a rule each time the inside "List of String" is contained in
the array of String [].
for example
List<List<String>> :
(1,2,3)
(2,3)
(4,5,6)
and String []:
(2,3,4)
so this should fire 1 rule corresponding to (2,3) contained in (2,3,4)
Thanks,
--GG
--
View this message in context: http://drools.46999.n3.nabble.com/Lists-of-Lists-membership-tp3633943p363...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Removing Special Characters
by Lalitha
Hi all,
I am working on drools. I would like to remove Special characters which
are existed in the data i.e. replacing special characters with null.
Following is the code:
rule "Wild Character validation"
when
c : CustomerInfo(customerName != "");
then
int l = c.length();
int ch = 0;
int i = 0;
for (i = 0; i < l; i++) {
if (data.charAt(i) != "*"|| data.charAt(i) != "#"){
continue;
}
ch++;
data.setCharAt(i, "");
}
c.setCustomerName(data);
end
Is there any wrong in this code? If so please help me out. Waiting for your
suggestion .
Thanks and Regards,
Lalitha.
--
View this message in context: http://drools.46999.n3.nabble.com/Removing-Special-Characters-tp3628821p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Could not parse knowledge when using 'not contains' in a quote leading a '!'
by Miles Wen
hi all,
This code could not be parsed correctly:
rule "out"
when
Msg(!(set not contains "test"))
then
end
I tried a few simple situations and found that when using 'not contains'
operator in a '!' leading quote triggers this problem. If no '!' prefixing
the quote,the program works like a charm...
Is this a bug? I wish that I posted in the right forum(or I would go to
submit an issue?)..
The example above seemed so stupid(you can use a 'contains' operator
instead), but this is the simplest toy example.And this problem would be
looked more important if you want to write some logic like this:
Msg(!(set not contains "test" || !bool && string == "hello"))
So...
Is there anyone who also encountered this problem? I'm using drools 5.3.0
final.
Any help would appreciated.
Thanks!
--
Regards.
Miles. Wen
12 years, 10 months
Extracting management information from the content of the rules
by Henrique Lira
Hi,
I'm doing an evaluation of Guvnor tool, and one of the requirements that we
wish to be met is the ability to extract management reports from the content
of the rules. Let me explain better: assuming I have several rules that
define discounts for products depending on their characteristics, how can I
get, for example, which products have a discount of X%? I tried using the
search function of the Guvnor, but I found it very simple to more managerial
information like this? Is there any other functionality to generate more
complex queries?
Thanks in advance,
Henrique
--
View this message in context: http://drools.46999.n3.nabble.com/Extracting-management-information-from-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
MVEL optimization?!?
by ronalbury
I'm not sure how to explain this, other than it appears that MVEL is trying
to optimize the When conditions in my rules.
I have a utility class, Test, with a number of methods on it (including null
protected versions of Drools "in" and "matches"). Note that the valueInList
method can return null (e.g. if the product code is null), and the
getAgeAsInt method can also return null (if the age is null). I don't like
having to test if the result of the method is true, but I kept running into
null pointer errors in the Drools expression evaluation code and had to
adopt this convention.
Here are two example rules (one in Java dialect and one in MVEL dialect). I
realize that a list of one is a degenerate case for using 'inList', but it
should still work.
rule "Term 15Plus Max Age - Washington"
dialect "java"
when
$ea : EasyApp(
Test.valueInList($ea.getEaProductCode(), "L15P")==true
&& Test.valueInList($ea.getEaIssueState(), "WA")==true
&& $ea.getPriIns_xmPerson().getAgeAsInt() > 65
)
then
$ea.addError(drools.getRule().getName());
end
rule "Term 20 Max Age - New Jersey"
when
$ea : EasyApp(
Test.valueInList(eaProductCode, "L20")==true
&& Test.valueInList(eaIssueState, "NJ")==true
&& priIns_xmPerson.ageAsInt > 64
)
then
$ea.addError(drools.getRule().getName());
end
I have approximately 30 different rules similar to those above. When I have
the rules written in MVEL, it appears to be only be evaluating one rule per
EasyApp injection (I have a log message when ever valueInList is called),
and I get bogus results. However, when I shift to java dialect then it
appears that the methods are called for each rule I have defined (as I would
have expected).
Can anyone tell me if I am doing something wrong, and explain why Drools is
behaving as it is?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-optimization-tp3632072p3632072.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
urlResource, applyChangeset and authentication error
by kachaps4u
/Hello there, I was trying to do write a simple rule inside BRMS: When a car
model year is older than 1989, then destroy the car. Package was validated
and created the snapshot and copied the uri. Then I created a Drools Project
and was trying to access those resources through uri but I am not able to go
forward. Its showing 401 exception at the line I specified the uri in the
code, see below:/
package pop.blah.test;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.definition.type.FactType;
public class CarApp {
public static void main(String[] args) {
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
"myAgent1" );
kagent.applyChangeSet(
ResourceFactory.newUrlResource("http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.bla..."));
KnowledgeBase kbase = kagent.getKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ResourceFactory.getResourceChangeScannerService().start();
try {
FactType carType = kbase.getFactType( "pop.blah.test", "Car" );
Object bmw = carType.newInstance();
carType.set( bmw,"name","My Car" );
carType.set( bmw,"make","BMW-x5" );
carType.set( bmw,"year", 1977);
ksession.insert( bmw );
ksession.fireAllRules();
boolean dest = (Boolean) carType.get( bmw, "destroy" );
if (dest==true) {
System.out.println("I am gona destroy that car!");
}
else {
System.out.println("I am happy with my car!");
}
}
catch (Exception E) {
E.printStackTrace();
}
finally {
ksession.dispose();
}
}
}
/and here is my Error:/
[2012:01:03 08:01:578:info] ResourceChangeNotification created
[2012:01:03 08:01:578:info] ResourceChangeScanner reconfigured with
interval=60
[2012:01:03 08:01:578:info] ResourceChangeScanner created with default
interval=60
[2012:01:03 08:01:578:debug] ResourceChangeNotification monitor added
monitor=org.drools.io.impl.ResourceChangeScannerImpl@1bd7848
[2012:01:03 08:01:593:debug] KnowledgeAgent building resource map
[2012:01:03 08:01:593:info] KnowledegAgent has started listening for
ChangeSet notifications
[2012:01:03 08:01:593:info] KnowledgeAgent created, with configuration:
monitorChangeSetEvents=true scanResources=true scanDirectories=true
newInstance=true
[2012:01:03 08:01:859:exception]
java.lang.RuntimeException: Unable to parse ChangeSet
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:393)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for
URL:
http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/package/pop.bla...
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210)
at org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146)
at org.drools.io.impl.UrlResource.getReader(UrlResource.java:214)
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:391)
... 2 more
[2012:01:03 08:01:859:exception]
java.lang.RuntimeException: Unable to parse ChangeSet
at
org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:397)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
[2012:01:03 08:01:859:info] KnowledgeAgent applying ChangeSet
Exception in thread "main" java.lang.NullPointerException
at
org.drools.agent.impl.KnowledgeAgentImpl.processChangeSet(KnowledgeAgentImpl.java:215)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:183)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:168)
at pop.blah.test.CarApp.main(CarApp.java:16)
Please help me.
--
View this message in context: http://drools.46999.n3.nabble.com/urlResource-applyChangeset-and-authenti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months