forall is satisfied when there is nothing?
by Sonata
Hi, I am using the "forall" keyword on the LHS and it seems the condition is
satisfied when there is nothing to match. e.g. "forall (MyClass(value ==
"test"))" fires the rule when there is no MyClass() object in the working
memory. My workaround is add "exists (MyClass())".
Also, same for "not (exists (MyClass(value != "test")))", but I can
understand this, as there is no MyClass() object, it doesn't exists and
hence "not" gives true.
But for "forall", it doesnt sound right to me. I wonder if "forall" is
actually implemented as "not exists" in the engine.
Please clarify if this is by design or a bug. Build is 5.5.0.Final
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/forall-is-satisfied-when-there-is-nothi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools conddition fails if I use HashMap to check objects
by Avin
Hi,
I have a rule written which compare objects with objects present in HashMap
and if object is found then clause gets executed.
I am able to wite the conditions for comparing with HashMap but if I add any
assign any value from the fact object before comparison then my conditions
fail to evaluate and my then clause runs for all the objects
Below is the code
rule "rule 1"
when
//$factData: ConcentrationDataTable() this line makes rule fail
TempStorage($mapObject : concPercentRefObjects)
ConcentrationDataTable($concPercentage : concPercentage)
$referenceData : ConcentrationDataTable($keyObject : concPercentRefkey)
eval( $mapObject.get($keyObject) != null )
and
eval($concPercentage >
(((ConcPercentRef)$mapObject.get($keyObject)).getPercent()))
then
System.out.println("Rule 222 executed "+ " condition "+$factData + "
reference value "+$mapObject.get($keyObject) );
//filteredDataList.add($factData); I require this object(fact object) to
be stored in list for further process
end
*Results *
Rule 222 executed condition 1424975 1424975 key value value 1424975
Rule 222 executed condition 14249751 14249751 key value 1424975 --
failed result should not have got printed
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-conddition-fails-if-I-use-HashMa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Drools KB Object hierarchy Serilisation and Deserialisation thread safety issue
by adarsh.chaini@hsbcib.com
Hi,
We have found that some of the drools classes are not thread safe and
hence causing the whole KB serialisation and deserialisation issues in
a highly concurrent distributed cluster.
The below is an example of one of the instances we have come across where
the usage of a non thread safe collection as instance variables has
caused the issue.
Could someone look into this and advise:
1) If this has been reported /identified and logged somewhere as an issue
already
2)If there has been any fix to problems like this in later versions of
5.3.0.Final ?.
3)If not fixed already what is the process to initiate a fix.
Caused by: java.io.InvalidObjectException: Illegal mappings count: -1
at java.util.HashMap.readObject(HashMap.java:1130)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeReadObject(
ObjectStreamClass.java:1004)
at java.io.ObjectInputStream.readSerialData(
ObjectInputStream.java:1891)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at org.jbpm.workflow.core.DroolsAction.readExternal(
DroolsAction.java:61)
at
org.jbpm.workflow.core.impl.DroolsConsequenceAction.readExternal(
DroolsConsequenceAction.java:49)
at java.io.ObjectInputStream.readExternalData(
ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1794)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at org.drools.rule.JavaDialectRuntimeData.readExternal(
JavaDialectRuntimeData.java:182)
at java.io.ObjectInputStream.readExternalData(
ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1794)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at java.util.HashMap.readObject(HashMap.java:1155)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeReadObject(
ObjectStreamClass.java:1004)
at java.io.ObjectInputStream.readSerialData(
ObjectInputStream.java:1891)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at org.drools.rule.DialectRuntimeRegistry.readExternal(
DialectRuntimeRegistry.java:59)
at java.io.ObjectInputStream.readExternalData(
ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1794)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at org.drools.rule.Package.readExternal(Package.java:197)
at java.io.ObjectInputStream.readExternalData(
ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1794)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at java.util.HashMap.readObject(HashMap.java:1155)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeReadObject(
ObjectStreamClass.java:1004)
at java.io.ObjectInputStream.readSerialData(
ObjectInputStream.java:1891)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at org.drools.common.AbstractRuleBase.readExternal(
AbstractRuleBase.java:270)
at org.drools.reteoo.ReteooRuleBase.readExternal(
ReteooRuleBase.java:223)
at org.drools.impl.KnowledgeBaseImpl.readExternal(
KnowledgeBaseImpl.java:116)
at java.io.ObjectInputStream.readExternalData(
ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readOrdinaryObject(
ObjectInputStream.java:1794)
at java.io.ObjectInputStream.readObject0(
ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370
)
at com.hsbc.gbm.dsl.domain.DSLRuleSet$Serializer.createInstance(
DSLRuleSet.java:328)
at com.hsbc.gbm.dsl.domain.DSLRuleSet$Serializer.createInstance(
DSLRuleSet.java:1)
at com.hsbc.gbm.dsl.domain.AbstractSerializer.deserialize(
AbstractSerializer.java:144)
Thanks and regards,
Adarsh CHAINI
SENIOR LEAD DEVELOPMENT SPECIALIST | HSBC Bank Plc
8 Canada Square, London E14 5HQ, UK
_______________________________________________
Phone
Int: (0)79914720 Ext: +44 (0)20 79914720
Mobile
+44(0)7595530105
Email
adarsh.chaini(a)hsbcib.com
_______________________________________________
Protect our environment - please only print this if you have to!
************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for
a new issue, by investment clients of the firm for whom the Bank as a firm
already provides other services. It may equally decide to allocate to its
own proprietary book or with an associate of HSBC Group. This represents a
potential conflict of interest. HSBC Bank plc has internal arrangements
designed to ensure that the firm would give unbiased and full advice to
the corporate finance client about the valuation and pricing of the
offering as well as internal systems, controls and procedures to identify
and manage conflicts of interest.
HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the
Financial Conduct Authority and the Prudential Regulation Authority
************************************************************
-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!
This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.
10 years, 11 months
is the When part java?
by wtang
the dialect I have set to "java".
Now, I know this make the Then part java. How about the When part? Is the
When part ever java when I set the dialect to "java". My understanding is
that When part is never Java.
I have a map of string and need to support the following operators:
equal
does not equal
contains
does not contain
starts with
end with
matches Reg Ex
I know for equal and does not equal I can do
$map: Map(
this["Message.label"] == "iPhone" || this["Message.label"] == "iPhone"
)
how about other?
thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/is-the-When-part-java-tp4027582.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Duplicate Facts with overriden equals/hashcode
by glambert27
Hi,I have an issue I'm trying to track down and won't to rule out the data
being an issue. Running 5.5 ExpertI have a Fact; let's say "Person"Class
Person {private String fName;private String lName;private String
ssn;getters/setters@Overridepublic boolean equals(final Object obj) {
if ( obj == null ) return false; if(obj instanceof Person){
final Person other = (Person) obj; return Objects.equal(ssn,
other.ssn); } else{ return false; }}
@Override public int hashCode(){ return Objects.hashCode(ssn);
}}Now if I insert 2 person objects with the same ssn. Actually if my LHS is
$list : ArrayList() collect( Person() ), do I expect 2, 1, or 0 for my
arraylist. What is seeing is that the arraylist is 0 but that doesn't make
sense to me and I think there is another underline issue.
--
View this message in context: http://drools.46999.n3.nabble.com/Duplicate-Facts-with-overriden-equals-h...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months
Re: [rules-users] Is rule introspection available from the Drools API?
by milen igrachev
Hello, initially i didn't give more details to keep my question short and save time to the ppl that read it. I actually believed that such functionality might be covered and available and details would have just prolong my question.
Here is some additional information on why I am looking for such functionality. In my project I want to use Drools as external rule engine. My project is not written in Java and the effort to transfer it is inconsiderable. What I want to start using Drools for is a simple blackbox of getting answers from a Stateless Drools Session, most likely without any need of reinference. Simply ask and get answered. During the runtime of my project there is a vast amount of information that can be considered as a fact . However in most of the cases what I need is to invoke a simple ruleset that actually need like 1% of the facts that I currently know at any particular moment. So what I want to do is ask Drools "Hey I want to invoke ruleset, can you please tell me what are the facts that it is using so I can pass all of them, that I currently have?". Then after receiving the answer I will filter the 1% from the big picture and will finally ask Drools to answer my question.
What I want to avoid is passing hundreds of instance/facts with hundreds of fields that are actually never user. Of course I realise that the rule introspection that I am asking for is not my only option, I can create the .drl metadata during the ruleset definition. Some more ideas poped into my head, so far, but the best solution for me seems to be if we can just call Drools about that information and it return it as a straight answer.
That is why I am trying to identify if it is possible to recive the rule metadata from Drools. At first I thought it could be available in a snap of a finger with some method calls, however now I am interested to see what is the effort to make it happen.
Hope it helps. Thanks for the support.
Best Regards, Milen
-------- Original Letter --------
From: Stephen Masters stephen.masters(a)me.com
About: Re: [rules-users] Is rule introspection available from the
Drools API?
To: Drools List
Sent at: Tuesday, 2014, January 7 12:08:39 EET
It may also be worth explaining exactly what you aim to achieve through this and why. From what I have seen, most people who ask about introspecting the LHS of rules via the API, don’t actually need to do that.
Steve
On 7 Jan 2014, at 08:56, Wolfgang Laun <
wolfgang.laun(a)gmail.com > wrote:
Hi,
while you continue this line of research you might consider possible
ramifications and snags, and be prepared for them.
The syntax for writing LHS conditions is quite complex - it's more
complex than Java expressions, because the CE eval() alone will give
you (almost) all of that. Rule authors may also use DRL functions,
which could hide field access.
If *you* author the rules, you may be able to avoid the worst, but it
won't be a piece of cake.
Cheers
-W
On 07/01/2014, milen igrachev <
igrachev(a)abv.bg > wrote:
Hello thanks for the quick and precise answer!
I believe that the time difference will be a bit of a problem for the IRC
chat , but i will be online (channel: #drools user: igrachev) today and will
try to check it often.
However big thanks for the support and the
willingness to help!
You are saying that the code is there, but is not public and documented.
Well being not public seems to be a problem, but do you
think it is
possible to give me an example with the official Drools "first rule" -
Sample.drl. The one that comes with the first Drools project.
So do you
believe it will be possible to paste me some code on how to retrieve the
information that this ruleset is using one fact of type Message
and two of
it's attributes -
status
and
message.
So just some code in a public
static void main (String [] args) will be great :), or any kind of
explanation :).
Once again thank you.
Have a nice day,
Milen
----Original Letter----
From: Mark Proctor
mproctor(a)codehaus.org
About: Re: [rules-users] Is rule introspection available from the Drools
API?
To: Rules Users List
Sent at: Monday, 2014, January 6 16:05:33 EET
The code is there, but it’s not public and not documented, and the code can
be a little hard to understand - as it’s grown organically over the years.
You’ll need to cast and unwrap and look at member vars. Start on the Rule
and the lhs variable. You can always pop onto irc, with live questions,and
we’ll try and respond quickly.
http://www.jboss.org/drools/irc
Mark
On 6 Jan 2014, at 09:51, milen igrachev
igrachev(a)abv.bg
> wrote:
Hello,
is there a way to introspect a Drools file from within java code?
What I need is to be able to identify the facts and the fact attributes
that are used in a given DRL file.
For example if I have a rule stored in a customer.drl DRL file within my
project, containing the following definition:
package myRulePackage
import org.rules.model.Customer
import org.rules.model.Mambership
rule "is eligible customer"
when
$c:Customer(status == "active")
Membership(customer == $c, type == "premium")
then
$c.setEligibilityStatus(true);
end
What i need is a way to understand that this ruleset customer.drl is using
two fact types - Customer and Membership and three of their attributes -
Customer.status, Membership.customer and Membership.type.
I found some information on the internet that such functionality is not
supported, however the information was a bit too old, so I decided to ask
again.
Big thanks for the support!
Milen
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
10 years, 11 months
Re: [rules-users] Is rule introspection available from the Drools API?
by milen igrachev
Well the problem with the fields of the fact objects is just the same as the one with the fact types.
Let me try to explain.
The business objects representing the business abstractions in my project are overlaping with the Fact model.
I believe that this is the standard case :). Actually we can ignore the technical particularity that we have a Java fact model and another business application model, because the two model will be mirrored. We can think that for each business class there is a fact class for Drools to use :). The business classes are complex and consist of many fields. For example the biggest contains ovet 450 fields. The most common ones to be used as facts consists of 373 and 314 fields. If I identify just the Fact Types then I will need to extract all the information that is available for that fact before pass it to Drools, then Instantiate a Java instance to represent the Fact and initialize the instance with the information. What I am trying to avoid here is the transfer of that many useless information once again. In the most common case I will need 1 to 10 fields per Fact Type. So passing the 300 seems redundant.
Best Regards, Milen
-------- Original Letter --------
From: Wolfgang Laun wolfgang.laun(a)gmail.com
About: Re: [rules-users] Is rule introspection available from the Drools
API?
To: Rules Users List
Sent at: Tuesday, 2014, January7 15:04:21 EET
As you describe it, the fields of the fact objects shouldn't matter.
On 07/01/2014, milen igrachev igrachev(a)abv.bg > wrote:
> Hello, initially i didn't give more details to keep my question short and
> save time to the ppl that read it. I actually believed that such
> functionality might be covered and available and details would have just
> prolong my question.
> Here is some additional information on why I am looking for such
> functionality. In my project I want to use Drools as external rule engine.
> My project is not written in Java and the effort to transfer it is
> inconsiderable.
I guess you mean "considerable".
> What I want to start using Drools for is a simple blackbox
> of getting answers from a Stateless Drools Session, most likely without any
> need of reinference. Simply ask and get answered. During the runtime of my
> project there is a vast amount of information that can be considered as a
> fact . However in most of the cases what I need is to invoke a simple
> ruleset that actually need like 1% of the facts that I currently know at
> any particular moment. So what I want to do is ask Drools "Hey I want to
> invoke ruleset, can you please tell me what are the facts that it is
> using so I can pass all of them, that I currently have?". Then after
> receiving the answer I will filter the 1% from the big picture and will
> finally ask Drools to answer my question.
If these "rule sets" are unrelated with each other, you might put them into
separater DRL files. Then the import list will tell you which facts this
rule set needs, and so all you need is simple text processing...
-W
> What I want to avoid is passing hundreds of instance/facts with hundreds
> of fields that are actually never user. Of course I realise that the rule
> introspection that I am asking for is not my only option, I can create the
> .drl metadata during the ruleset definition. Some more ideas poped into my
> head, so far, but the best solution for me seems to be if we can just call
> Drools about that information and it return it as a straight answer.
>
> That is why I am trying to identify if it is possible to recive the rule
> metadata from Drools. At first I thought it could be available in a snap of
> a finger with some method calls, however now I am interested to see what is
> the effort to make it happen.
> Hope it helps. Thanks for the support.
> Best Regards, Milen
>
>
>
>
>
>
> -------- Original Letter --------
>
> From: Stephen Masters stephen.masters(a)me.com
>
> About: Re: [rules-users] Is rule introspection available from the
> Drools API?
>
> To: Drools List
>
> Sent at: Tuesday, 2014, January 7 12:08:39 EET
>
>
>
>
>
>
> It may also be worth explaining exactly what you aim to achieve through
> this and why. From what I have seen, most people who ask about introspecting
> the LHS of rules via the API, don’t actually need to do that.
>
>
>
>
>
>
> Steve
>
>
>
>
>
>
>
>
>
> On 7 Jan 2014, at 08:56, Wolfgang Laun <
> wolfgang.laun(a)gmail.com > wrote:
>
>
>
>
> Hi,
>
>
>
> while you continue this line of research you might consider possible
>
> ramifications and snags, and be prepared for them.
>
>
>
> The syntax for writing LHS conditions is quite complex - it's more
>
> complex than Java expressions, because the CE eval() alone will give
>
> you (almost) all of that. Rule authors may also use DRL functions,
>
> which could hide field access.
>
>
>
> If *you* author the rules, you may be able to avoid the worst, but it
>
> won't be a piece of cake.
>
>
>
> Cheers
>
> -W
>
>
>
>
>
>
>
> On 07/01/2014, milen igrachev <
> igrachev(a)abv.bg > wrote:
>
>
>
> Hello thanks for the quick and precise answer!
>
>
> I believe that the time difference will be a bit of a problem for the IRC
>
> chat , but i will be online (channel: #drools user: igrachev) today and
> will
>
> try to check it often.
> However big thanks for the support and the
>
> willingness to help!
>
>
> You are saying that the code is there, but is not public and documented.
>
> Well being not public seems to be a problem, but do you
> think it is
>
> possible to give me an example with the official Drools "first rule" -
>
> Sample.drl. The one that comes with the first Drools project.
> So do you
>
> believe it will be possible to paste me some code on how to retrieve the
>
> information that this ruleset is using one fact of type Message
> and two of
>
> it's attributes -
> status
> and
> message.
> So just some code in a public
>
> static void main (String [] args) will be great :), or any kind of
>
> explanation :).
>
>
> Once again thank you.
>
>
> Have a nice day,
>
> Milen
>
>
>
>
>
>
>
> ----Original Letter----
>
> From: Mark Proctor
> mproctor(a)codehaus.org
>
>
>
> About: Re: [rules-users] Is rule introspection available from the Drools
>
>
> API?
>
>
>
> To: Rules Users List
>
>
>
> Sent at: Monday, 2014, January 6 16:05:33 EET
>
>
>
>
>
> The code is there, but it’s not public and not documented, and the code can
>
> be a little hard to understand - as it’s grown organically over the years.
>
>
>
>
>
>
>
> You’ll need to cast and unwrap and look at member vars. Start on the Rule
>
> and the lhs variable. You can always pop onto irc, with live questions,and
>
> we’ll try and respond quickly.
>
>
>
>
> http://www.jboss.org/drools/irc
>
>
>
>
>
>
>
> Mark
>
>
>
>
>
>
>
> On 6 Jan 2014, at 09:51, milen igrachev
>
> igrachev(a)abv.bg
>
> > wrote:
>
>
>
>
>
>
>
>
>
> Hello,
>
>
>
>
>
>
> is there a way to introspect a Drools file from within java code?
>
>
>
>
>
>
> What I need is to be able to identify the facts and the fact
> attributes
>
> that are used in a given DRL file.
>
>
>
>
>
>
>
>
>
>
>
>
> For example if I have a rule stored in a customer.drl DRL file within
> my
>
> project, containing the following definition:
>
>
>
>
>
>
> package myRulePackage
>
>
>
>
>
>
>
>
>
>
>
>
> import org.rules.model.Customer
>
>
>
>
>
>
> import org.rules.model.Mambership
>
>
>
>
>
>
>
>
>
>
>
>
> rule "is eligible customer"
>
>
>
>
>
>
> when
>
>
>
>
>
>
>
> $c:Customer(status == "active")
>
>
>
>
>
>
>
> Membership(customer == $c, type == "premium")
>
>
>
>
>
>
> then
>
>
>
>
>
>
>
> $c.setEligibilityStatus(true);
>
>
>
>
>
>
> end
>
>
>
>
>
>
>
>
>
>
>
>
> What i need is a way to understand that this ruleset customer.drl is
> using
>
> two fact types - Customer and Membership and three of their attributes -
>
> Customer.status, Membership.customer and Membership.type.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> I found some information on the internet that such functionality is
> not
>
> supported, however the information was a bit too old, so I decided to ask
>
> again.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Big thanks for the support!
>
>
>
>
>
>
> Milen
>
>
>
>
>
>
> _______________________________________________
>
>
>
>
>
>
> rules-users mailing list
>
>
>
>
>
>
> rules-users(a)lists.jboss.org
>
>
>
>
>
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
>
>
> rules-users mailing list
>
>
>
>
> rules-users(a)lists.jboss.org
>
>
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
>
>
>
> _______________________________________________
>
> rules-users mailing list
>
>
> rules-users(a)lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
>
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
10 years, 11 months
Re: [rules-users] Is rule introspection available from the Drools API?
by milen igrachev
Hello thanks for the quick and precise answer!
I believe that the time difference will be a bit of a problem for the IRC chat , but i will be online (channel: #drools user: igrachev) today and will try to check it often. However big thanks for the support and the willingness to help!
You are saying that the code is there, but is not public and documented. Well being not public seems to be a problem, but do you think it is possible to give me an example with the official Drools "first rule" - Sample.drl. The one that comes with the first Drools project. So do you believe it will be possible to paste me some code on how to retrieve the information that this ruleset is using one fact of type Message and two of it's attributes - status and message. So just some code in a public static void main (String [] args) will be great :), or any kind of explanation :).
Once again thank you.
Have a nice day,
Milen
----Original Letter----
From: Mark Proctor mproctor(a)codehaus.org
About: Re: [rules-users] Is rule introspection available from the Drools
API?
To: Rules Users List
Sent at: Monday, 2014, January 6 16:05:33 EET
The code is there, but it’s not public and not documented, and the code can be a little hard to understand - as it’s grown organically over the years.
You’ll need to cast and unwrap and look at member vars. Start on the Rule and the lhs variable. You can always pop onto irc, with live questions,and we’ll try and respond quickly.
http://www.jboss.org/drools/irc
Mark
On 6 Jan 2014, at 09:51, milen igrachev igrachev(a)abv.bg > wrote:
> Hello,
> is there a way to introspect a Drools file from within java code?
> What I need is to be able to identify the facts and the fact attributes that are used in a given DRL file.
>
> For example if I have a rule stored in a customer.drl DRL file within my project, containing the following definition:
> package myRulePackage
>
> import org.rules.model.Customer
> import org.rules.model.Mambership
>
> rule "is eligible customer"
> when
> $c:Customer(status == "active")
> Membership(customer == $c, type == "premium")
> then
> $c.setEligibilityStatus(true);
> end
>
> What i need is a way to understand that this ruleset customer.drl is using two fact types - Customer and Membership and three of their attributes - Customer.status, Membership.customer and Membership.type.
>
>
> I found some information on the internet that such functionality is not supported, however the information was a bit too old, so I decided to ask again.
>
>
> Big thanks for the support!
> Milen
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
10 years, 11 months
Best pattern for getting results OUT of Integration server?
by dunnlow
I have some confusion about running rules in the Integration Server (v5.5).
I am sending POJOs to the server from a camel (v2.10) Spring client app.
The client inserts a POJO (via batchexecutioncommand) and the rules change
an attribute on the POJO to return the value to the client.
I know, I know, changing attributes of facts is frowned upon (but when I
started I didn't know any better... I swear).
The problem I'm having (surprise) is that updating the fact (to return to
the client app) is causing unwanted activations, no-loops, lock-on-actives
etc etc. So, I'm looking into changing this and inserting two string
objects into my command so that the rules only modify those string objects.
My questions:
1) Is that the best (/a good) way to implement this?
2) My big question/misunderstanding: Does the integration server handle the
batchexecutioncommands in series or is it inserting into the working memory
in parallel (ie. are all executions from the first insert completed before
the next batchexecutioninsert command is evaluated)?
For example,
If I have a loop that inserts one POJO (Fact.class) and two POJOs (S.class,
a simple class with one string class variable) can I safely do something
like below (is the engine able to keep Fact1 with its inserted S1 and S2
objects separate from the next S objects that might be inserted immediately
after OR might all Facts and S objects get confused (due to multi-threading,
parallel operation, etc):
rule "evaluate a Fact POJO"
when
$fact1 : Fact (value > 100, card=="NONE")
$s1 : S ()
$s2 : S (this != $s1)
then
$s1 = "OK"
$s2 = "BLUECARD"
end
rule "remove inserted objects so memory doesn't fill up"
salience -1000
when
$completedFact : Fact ()
then
retract ($completedFact)
end
rule "remove inserted objects so memory doesn't fill up"
salience -1000
when
$completedS : S ()
then
retract($completedS)
end
My client will use the resulting s1 and s2 values so I obviously don't want
the returned s1 and s2 values for fact1 to be confused with the s1 and s2
values for fact2.
3) Currently, I need to retract the pojos I insert once the processing is
done(like above) -- kinda ugly. Is there a way to implement a "logical"
insert for the integration server or a better way to handle this?
Thanks for any thoughts!
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Best-pattern-for-getting-results-OUT-of...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 11 months