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.
12 years, 8 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.
12 years, 8 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.
12 years, 8 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.
12 years, 8 months
Memory-Problemwith instance of "ReteooStatefulSession"
by anniejoseph
Hi,
I'm using jBoss Rules.But I run in to memory issues after using JBoss
rules. Using a profiling tool I collected heap dump
and I got the result as :
/One instance of "org.drools.reteoo.ReteooStatefulSession" loaded by
"sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88" occupies 657,328,888
(78.91%) bytes.
The memory is accumulated in one instance of
"*org.drools.reteoo.ReteooStatefulSession*"
loaded by "sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88".
Keywords
sun.misc.Launcher$AppClassLoader @ 0x7f899fdb6d88
org.drools.reteoo.ReteooStatefulSession/
The code I used for JBoss rules is given below.
kbase= KnowledgeBaseFactory.newKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
final String str =
CISMSRemotingUtils.getFullConfigFilePath("change-set.xml") ;
final String filePath = str.replaceAll(" ", "%20");
aconf = KnowledgeAgentFactory .newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent( "Agent", aconf);
kagent.applyChangeSet( ResourceFactory.newFileResource(filePath) );
kbase = kagent.getKnowledgeBase();
ksession= kbase.newStatefulKnowledgeSession();
sconf
=ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty( "drools.resource.scanner.interval", "3600");
ResourceFactory.getResourceChangeScannerService().configure( sconf );
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
This piece of code is given in the class constructor and rules are fired
inside this class
ksession.insert(data);
ksession.fireAllRules();
Can anyone help me to identify the problem?
--
View this message in context: http://drools.46999.n3.nabble.com/Memory-Problemwith-instance-of-ReteooSt...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Drools Planner/Optaplanner suitability
by droolster
Hello,
Please can the community tell me if Drools Planner/Optaplanner is the best
tool to use for the problem described below:
1. For a list of items, I assign a point depending on the value of each
item. For different values of an item, I will assign a different point (kind
of on a rule basis i.e. if value = A, then assign 3 points, if value = B,
then assign 9 points etc)
2. I multiply the points assigned to each item by a weight.
3. I sum the total number of weighted points and divide by the sum of the
weights (basically, I compute the weight average).
Is Drools Planner the right tool to use here or is it better to use Drools
Expert?
>From looking at the Drools Planner documentation, it looks like an
optimisation tool and I am not really doing any optimising here. I am just
calculating a value based on some rules.
Regards.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-Optaplanner-suitability-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months