Can we extend the Templates in Guvnor
by swaroop
Hi
Inside guvnor when we try to draft a rule we mostly use the default
templates for the LHS and RHS part . Is there any possibility to override
the generated/default templates to augment with some additional
functionality. Like for example for RHS part there would be *"Insert Fact
A"* in the guided editor and when i click that the drl generated in
background inserts Fact A ,i want to do some processing after inserting the
fact , like i want to add the fact to a list .
I evaluated DSL for the above usecase but with DSL i can explicity do some
processing in the background but i not be able to add the functionality of
setting/displaying/adding attributes of the particular fact
Do let me know if you have any suggestions
Regards
Swaroop
--
View this message in context: http://drools.46999.n3.nabble.com/Can-we-extend-the-Templates-in-Guvnor-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Specifying Infinite Limits
by droolster
Hello,
I have the following code to do some interval checking:
declare Classification
low : BigInteger
high : BigInteger
score : int
end
rule "classifications"
when
then
insert (new Classification(new BigInteger("-1000000000000"),
new BigInteger("1000000"), 1));
insert (new Classification(new BigInteger("1000000"), new
BigInteger("5000000"), 2));
insert (new Classification(new BigInteger("5000000"), new
BigInteger("25000000"), 3));
insert (new Classification(new BigInteger("25000000"), new
BigInteger("25000000000000"), 4));
end
rule "Foo"
when
$a: Classification( $low : getLow(), $high : getHigh() )
$b: Data( bar > $low && bar < $high )
then
System.out.println($a.getScore());
end
It works fine but I was wondering if there is a more elegant way to specify
the lowest and highest interval limits. At the moment, as you can see, I
have set it to a very low number and a very high number in the context of my
problem (-1000000000000 and 250000000000000 respectively) . For my problem
specification, these limits should rarely be reached. Can anyone tell me a
robust way of specifying these lowest and highest limits without putting
arbitarily low and high numbers.
Thanks in advance for your help.
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/Specifying-Infinite-Limits-tp4024627.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Specifying Infinite Limits
by droolster
Hello,
I have the following code to do some interval checking:
declare Classification
low : BigInteger
high : BigInteger
score : int
end
rule "classifications"
when
then
insert (new Classification(new BigInteger("-1000000000000"), new
BigInteger("1000000"), 1));
insert (new Classification(new BigInteger("1000000"), new
BigInteger("5000000"), 2));
insert (new Classification(new BigInteger("5000000"), new
BigInteger("25000000"), 3));
insert (new Classification(new BigInteger("25000000"), new
BigInteger("25000000000000"), 4));
end
rule "Foo"
when
$a: Classification( $low : getLow(), $high : getHigh() )
$b: Data( bar > $low && bar < $high )
then
System.out.println($a.getScore());
end
It works fine but I was wondering if there is a more elegant way to specify
the lowest and highest interval limits. At the moment, as you can see, I
have set it to a very low number and a very high number in the context of my
problem. For my problem specification, these limits should really be
reached. Can anyone tell me a robust way of specifying these lowest and
highest limits without putting arbitarily low and high numbers.
Thanks in advance for your help.
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/Specifying-Infinite-Limits-tp4024626.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Is it possible to update KnowledgeBase inside a rule?
by Sonata
Say I want to change the loaded packages dynamically base on some Business
logic,
is it possible to update the KnowledgeBase in rule files (not in Java) like
calling addKnowledgePackages() removeKnowledgePackage() etc.?
If it is possible, how do you make it so that the current session is updated
with the changes and re-fire for the new rules?
Or, how do you make it so that the current session is not affected but the
next session will be using the updated KnowledgeBase?
Thank you
P.S. I am using 5.5.0.Final
--
View this message in context: http://drools.46999.n3.nabble.com/Is-it-possible-to-update-KnowledgeBase-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Insert list of object to Guvnor in Decision table
by Raju Bandaru
Hi,
Am using Drools Guvnor 5.4 final version. I have created a package, decision
table in Guvnor and am invoking decision table from Spring application.
Please find attached snippet for your reference.
KnowledgeBase kbase = readKnowledgeBaseDefault();
StatefulKnowledgeSession ksession = null;
String message = null;
try {
ksession = kbase.newStatefulKnowledgeSession();
*ksession.insert(contactList);*
ksession.fireAllRules();
Requirement for me to send list of object(each objects is a rule :
contactList) to Guvnor and Guvnor should iterate the list of object and
invoke the rule.
Please help me on this requirement and how to achieve?
Regards,
Raju
--
View this message in context: http://drools.46999.n3.nabble.com/Insert-list-of-object-to-Guvnor-in-Deci...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Getter/Setter Methods for declared types
by droolster
Hello,
At compile time, are the getter and setter methods automatically created for
a declared type. In the Drools Expert PDF it gives the following example:
declare Person
name : String
dateOfBirth : java.util.Date
address : Address
end
and it states that the following class is generated:
public class Person implements Serializable {
private String name;
private java.util.Date dateOfBirth;
private Address address;
// empty constructor
public Person() {...}
// constructor with all fields
public Person( String name, Date dateOfBirth, Address address ) {...}
// if keys are defined, constructor with keys
public Person( ...keys... ) {...}
*// getters and setters*
// equals/hashCode
// toString
}
Then the setter is referenced as follows:
rule "Using a declared Type"
when
$p : Person( name == "Bob" )
then
// Insert Mark, who is Bob's mate.
Person mark = new Person();
*mark.setName("Mark");*
insert( mark );
end
----
I tried the same with this simple declared type:
declare Foo
bar : int
end
rule "abc"
when
some condition
then
Foo e = new Foo();
* e.setBar = 2;*
insert (e);
end
But the compiler complains indicating that it "cannot be resolved or is not
a field".
Do I need to specify the getter/setters in my DRL file explicitly?
Thank you for your help in advance.
Regards
--
View this message in context: http://drools.46999.n3.nabble.com/Getter-Setter-Methods-for-declared-type...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
accessing complex element while writing rules
by ashish6276
Hi
I am using xsd as my object model. using jaxb i am getting the jar and
using it. The xsd which i am using as complex architechture. where root
element is complex as well as element inside that are also complex..
<complexType name="AirRequest_V01">
<complexContent>
<extension base="tns:RulesRequest_V01">
<sequence>
<element name="customClientGroup"
type="clientgroup" minOccurs="0"></element>
<element name="directAccessRequested"
type="boolean"></element>
</sequence>
</extension>
</complexContent>
</complexType>
i just kept 1 element inside. type clientgroup is also complex type it has
clientname and client code inside it.
so now when i write rule i have rules where i need to have some condition
like
If client name of customClientGroup "XYZ" of AirRequest_V01 is "abc"
then
do this
i am not getting how can we access to this element client name
when AirRequest_V01 (customClientGroup )
after this its not giving me option to get clinet name.
if i start like
when customClientGroup (client name)
then how to map it to AirRequest_V01 with customclientgroup
please suggest some way as i am very new to drools.
--
View this message in context: http://drools.46999.n3.nabble.com/accessing-complex-element-while-writing...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months