"Rule-Id" for a Drools Rule

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

"Rule-Id" for a Drools Rule

harishtejwani
All:

We are using Drools to detect specific events/conditions in our system.

In the 'then' condition of Drools rule, we would like to persist the "Rule Id" of the rule that created the specific event/condition

This is because all our reporting is based on "rules" as filters, where users can look at exceptions by specific rules.

Is there a suggestion or sample as how can the "Rule Id" be persisted or indicated in the then condition that is immutable or can be long-lived. The current approach of using Rule Name itself as the ID is brittle as this can be changed and suddenly all reports would break.

If we assign ID's to rules, where do we keep the mapping of RULE ID to Rules. If we store rules in GUVRNOR is there a way we can get Rule Id's for Rules?

Best regards

Harish Tejwani  
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

laune
It seems to me that rule metadata would be the answer to your problem.
This keeps the ID right in the rule.

Alternatively, you could make the ID an immutable part of the rule name,
e.g. "change me here but [don't change me here]".

-W


On 8 May 2011 06:17, harishtejwani <[hidden email]> wrote:
All:

We are using Drools to detect specific events/conditions in our system.

In the 'then' condition of Drools rule, we would like to persist the "Rule
Id" of the rule that created the specific event/condition

This is because all our reporting is based on "rules" as filters, where
users can look at exceptions by specific rules.

Is there a suggestion or sample as how can the "Rule Id" be persisted or
indicated in the then condition that is immutable or can be long-lived. The
current approach of using Rule Name itself as the ID is brittle as this can
be changed and suddenly all reports would break.

If we assign ID's to rules, where do we keep the mapping of RULE ID to
Rules. If we store rules in GUVRNOR is there a way we can get Rule Id's for
Rules?

Best regards

Harish Tejwani

--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Id-for-a-Drools-Rule-tp2914385p2914385.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: "Rule-Id" for a Drools Rule

drdaveg
In reply to this post by harishtejwani
Is the reply correct?  There are obvious mechanisms to create metadata on the object model in Drools and while there are data structures in the rules to store metadata setting user-defined metadata on rules does not seem to have supporting predicates.   I would be interested in seeing a rule metadata example.

Incidentally, I build AgendaFilter's on all sorts of criteria, including rule numbers that I have embedded in the rule name.  Note the issue I posted on ruleflow-groups and agenda filters.  I got around the issue with agenda groups.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

laune


On 8 May 2011 16:48, drdaveg <[hidden email]> wrote:
Is the reply correct?

Yes.
 
 There are obvious mechanisms to create metadata on the
object model in Drools and while there are data structures in the rules to
store metadata setting user-defined metadata on rules does not seem to have
supporting predicates.

I beg your pardon?
 
  I would be interested in seeing a rule metadata
example.

rule "some rule"
    @ID( theid )
when
   ...
then
   System.out.println( "@ID: " + drools.getRule().getMetaData().get( "ID" ) );
end

Running in 5.2.x, but should also work with 5.1.1.

-W



_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

harishtejwani
Thanks everyone for the replies.

Wolfgang, as a note - in JavaDocs the method getMetaData("attribute") is deprecated
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/apidocs/index.html

Does anyone-know why?

Hopefully - getMetaData() would be here to stay!

I think the suggestion to use ID meta-data attribute on rule is the best and most stable!!

Thanks again

Harish
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

laune
On 8 May 2011 19:05, harishtejwani <[hidden email]> wrote:
Thanks everyone for the replies.

Wolfgang, as a note - in JavaDocs the method getMetaData("attribute") is
deprecated
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/apidocs/index.html

Does anyone-know why?

The return type String is too narrow. The intent is to make this work like Java annotations.
 
Hopefully - getMetaData() would be here to stay!

Looks like it. Depending on usage, it might not only return a String but also a Map, but that's not your concern.

-W
 

I think the suggestion to use ID meta-data attribute on rule is the best and
most stable!!

Thanks again

Harish

--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Id-for-a-Drools-Rule-tp2914385p2915766.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

harishtejwani
Hello Wolfgang / Team:

The concept of meta-data works very nicely in DRL

rule "Our Rule A"
    @ID( "11003589" )
when
….
then



But how do we manage this in Guvnor? Guvnor's Technical editor does like if I add @ before 'when'.

=>

How can we create/manage rule-metadata attributes in Guvnor (for rules) and even for facts if they are declared?

e.g. In Technical or Guided Editors? i.e. How can we create such Meta-data when defining a new rule.

Is there anyway-way to Auto-generate these or Auto Assign these e.g. I can Auto Generate the RULE-ID or set-it to a known value?

Thanks in advance for your reply ;)

Best

Harish
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

abhinay_agarwal
is there a way to maintain an ID ?

Thanks,
Abhinay
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

Stephen Masters
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

laune
In reply to this post by abhinay_agarwal
You have taken up an old thread (May 2011, yes, 2011) out of the blue.
No wonder people on the list don't know what you're talking about.
Don't assume everybody is doing things via Nabble.

-W

On 09/04/2013, abhinay_agarwal <[hidden email]> wrote:

> is there a way to maintain an ID ?
>
> Thanks,
> Abhinay
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Rule-Id-for-a-Drools-Rule-tp2914385p4023259.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

abhinay_agarwal
I wasn't aware of the fact that people use something else other than nabble. Will keep in mind from next time and put my question more clearly.

My question is, I know there is a UUID for everything that is created in guvnor. But, is the UUID, created duration an asset creation, unique, and does the value of UUID change when any change is brought to the package or asset (i have checked with renaming a rule and the value doesnt change).

Does the UUID depend on asset name and package ? i.e. if i have two rule in two different packages with same name, then is there any change that their UUID may match ?

Will the UUID remain same if i export the package and import it somewhere else ?

Basically, i need a Unique Identifier for all my assets in Guvnor and i guess UUID can help me out.

Regards,
Abhinay
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

manstis
UUID used by Guvnor is static. It does not change.

UUID is not available at the Drools runtime (i.e. when you have created a KnowledgeBase).

UUID will not exist in 6.0.


On 10 April 2013 03:36, abhinay_agarwal <[hidden email]> wrote:
I wasn't aware of the fact that people use something else other than nabble.
Will keep in mind from next time and put my question more clearly.

My question is, I know there is a UUID for everything that is created in
guvnor. But, is the UUID, created duration an asset creation, unique, and
does the value of UUID change when any change is brought to the package or
asset (i have checked with renaming a rule and the value doesnt change).

Does the UUID depend on asset name and package ? i.e. if i have two rule in
two different packages with same name, then is there any change that their
UUID may match ?

Will the UUID remain same if i export the package and import it somewhere
else ?

Basically, i need a Unique Identifier for all my assets in Guvnor and i
guess UUID can help me out.

Regards,
Abhinay



--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Id-for-a-Drools-Rule-tp2914385p4023283.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

abhinay_agarwal
hi mike,

Here is a scenario,

Lets say I have rules named "rule1", "rule2" inside guvnor. I am extracting the rule names using REST api, pointing to some url http://../package/packageName/assets. I need the rule names in my application, so I have kept the rule names in my DB.

If tomorrow I need to change the rule name of "rule1" to "xyz", how does my application keep a track of which rule name has been changed out of the two and update the same in my DB.

For the time being, I am using the UUID, and its doing the job very well. But, if it becomes obsolete in the future, is there a replacement to it ?

Abhinay
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] "Rule-Id" for a Drools Rule

manstis
There is no replacement.

In 6.0 your best approach would be to write a class that @Observes ResourceRenamedEvent and bundle it into the WAR.

The event contains "old path" and "new path".





On 10 April 2013 16:04, abhinay_agarwal <[hidden email]> wrote:
hi mike,

Here is a scenario,

Lets say I have rules named "rule1", "rule2" inside guvnor. I am extracting
the rule names using REST api, pointing to some url
http://../package/packageName/assets. I need the rule names in my
application, so I have kept the rule names in my DB.

If tomorrow I need to change the rule name of "rule1" to "xyz", how does my
application keep a track of which rule name has been changed out of the two
and update the same in my DB.

For the time being, I am using the UUID, and its doing the job very well.
But, if it becomes obsolete in the future, is there a replacement to it ?

Abhinay



--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Id-for-a-Drools-Rule-tp2914385p4023306.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users