I'm not entering the discussion on the use case, just making a couple of
technical points
1) The rule extension does not work because your rules are defined in
two different packages,
which is currently not supported. There was a similar thread not long ago.
I do agree that at least a warning - if not an error - should be raised
at compile time rather
than causing a late NPE execption. I'll see into that.
2) The "declare RuleConstant" below does not define global variables,
but a class for
which the default constructor would initialize the fields to default values.
You may want to declare an enum instead:
declare enum RuleConstant
COUPE( "C" ),
SEDAN( "S" );
code : String
end
you can then use it as an enum...
Vehicle( type == RuleConstant.COUPE )
or, more likely:
Vehicle( type == RuleConstant.COUPE.code )
assuming that the type field contains Strings such as "C" or "S"
Best
Davide
On 04/05/2013 11:17 AM, Arul Prashanth wrote:
Thanks Laune for your insight.
1. The idea of having RuleConstant in the workingMemory is that the
constants are defined in a drl and is being inserted into the working memory
by a high salience rule. This is to reduce the effort in actual application
build and deployment rather just package the rules and place the PKG file.
On a longer run the rules will be maintained by a different team who prefer
working only in DRL's and not in java files . I did considering them to be
access as Global variables but wheren't able to access in LHS. Hence
reverted back to adding them in working memory.
/declare RuleConstant
COUPE : String = "C";
SEDAN : String = "S";
end/
2. We did consider having the Vehicle object as fact but there were
requirements that required us to move back and forth a list of vehicles,
like if a vehicle is < 2011 and previous vehicle is > 1999 where vehicles
are ordered by purchase date compute X = Y. Though the below example doesn't
show case this scenario.
-----
- Prashanth
--
View this message in context:
http://drools.46999.n3.nabble.com/Abstracting-Rules-using-extends-tp40232...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users