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, 7 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, 7 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, 7 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, 7 months
OptaPlanner: unsolved score & constraint failure messages
by Sandeep Bandela
Hi,
I have some experience with drools 5 and now experimenting on planner &
drools 6.
I have 'unsolved' PlanningSolution that could be given to a solver and it
successfully solves it. (its just the curriculum example with few more
variables like teachingAssistant, equipment etc)
I need to know few things about this unsolved solution.
1) I want to know the score of this unsolved before starting to solve it.
can I do this without instantiating my own drools session with my score
holder and execute the rules for score? i.e only using optaplanner-api and
not depend on underlying rules engine used by planner.
2) I also want to have some information on what all rules got fired in
calculation of score (the negative ones). to print the conflicting planning
entities & their variables. I could put a message from each rule to some
object in workingMem. but how can I get those objects back after the solver
is done but didnt have a feasible solution/ or even for any given solution.
or is there any better way?
--
Regards,
Sandeep Bandela.
12 years, 7 months
Strange behaviour when adding rules during run-time
by IK81
Dear all,
I am encountering a strange issue that rules fire based on events, which I
already considered as expired. As far as I learned from the documentation
Drools automatically determines the expiration time of an event based on
analyzing the rules (e.g. if there's a temporal operator or aggregation
using the event). Ok, i do not use anything of that. My scenario is as
follows - for testing purposes I use a pseudo session clock and of course
the STREAM mode.
- At time 0 I insert an Event A and call fireAllRules
- Then I advance the time for 100 seconds
- Now I add a further rule by parsing a drl file and adding it to the
Knowledge base of my current session
- Then, still at time 100 I insert another Event B and call fireAllRules
again
The rule that I've inserted previously fires but unfortunately twice. Once
for event A (which I already considered as expired) and for event B (which
is that what I wanted).
Even if i use the @expires annotation in my drl this does not work
correctly. Do I have to call another method to trigger the expiration in the
session. Any suggestions?
Ingo
p.s. I am using Drools 5.5 final
--
View this message in context: http://drools.46999.n3.nabble.com/Strange-behaviour-when-adding-rules-dur...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months