Enhancements to Rule XML (BRL)
by Amit Kumar
Hello folks,
Sorry for barging in by subscribing to this developers alias
We are a Intellectual capital Management team in Cisco Systems. We have been
using our own engines to do specific jobs for past 10 years, as part of
future growth we have decided to do away with our own custom engines and use
the drools engine to do Inference & event management rules. Good choice ..
:)
We have evaluated the capabilities of rule authoring UIs in drools and have
faced some resistance from our Subject Matter Experts to build our own UIs
.. basically some templates which they can fill out instead of understanding
the complexities of Guvnor. Also we felt that some layer of abstraction
could be provided above guvnor UI since it does not yet provide support for
IC (Fusion based)
Approach:
We are trying to put in some extensions to BRL to support the fusion
usecases and any other which we need. The reason we are doing it to BRL is
the same as yours .. that UI editors work with XML kind of structure instead
of a DRL file.
So eventually we would also enhance the BRL->DRL converters and provide
support in BRL to ObjectContainment (Facts containing collection of facts)
and provide testing capabilities for inference and event IC.
Concern:
If we make any enhancements to BRL then we would want to integrate back to
community code so we can utilize any extensions to the BRL, DRL and
converters which are done by community and do not paint ourselves in a
corner.
We can share our work to provide ideas back to community and may be we can
provide some other enhancements for the community.
Can you kindly guide us on how to make these enhancements and how do we
contribute to the code. and any standards and guidelines pages.
Regards,
Amit
14 years, 5 months
Drools.Frustration
by Alex Besogonov
Good $time_of_day!
I'm a Drools newbie trying to use it in production. So I want to share
some of my frustration and some of my solutions to this frustration :)
First, let's start with insertLogical - it's useless. It can easily
mislead user into thinking that changed objects are retracted. Of
course, other users bumped into it before me:
http://drools-java-rules-engine.46999.n3.nabble.com/insertLogical-and-mod...
, but the proposed resolution is ugly.
So I wrote a wrapper around the 'insertLogical' function which
introduces the notion of 'fact key', so only one fact with the given
key can exist in the working memory at a time. To borrow the example
in the referenced mail thread:
============
rule "fact = 1"
when
$f : UserFact(fact1 == 1);
then
insertLogical(new CreatedFact($f.getFact2()));
end
============
Becomes:
============
global ConsequenceHelper ch; # Code of the ConsequenceHelper is attached
rule "fact = 1" language "mvel"
when
$f : UserFact(fact1 == 1);
then
ch.insertGuarded(drools, new CreatedFact($f.getFact2()),
{$f.getFact2()}); # Here {$f.getFact2()} is the CreatedFact's key.
end
============
So if this rule fires again, the stale object will be retracted and
the newly created object will be asserted. It would be nice to see
something like this integrated into the Drools core...
Next, I'd like to say something about Drools LHS language. Well, it's
VERY confusing. I spent two hours debugging internals of MVEL to
understand why this doesn't work:
============
rule "Double Shift OT"
dialect "mvel" agenda-group "OT Calculation"
when
$at : AcctTransaction()
exists(AcctTransaction(this!=$at, acct.plannedEndTimestamp
coincides[2h] $at.plannedStartTimestamp))
then
...
end
============
Turns out, I can't use these nice Drools Fusion predicates to for deep
properties. It would be nice, if it was at least mentioned somewhere
in the documentation. No workaround for this one, I had to write
global helper functions.
And the final problem (so far). Drools has this nice 'from' feature
which allows to use objects not in the working memory. However, it's
not possible to do this:
============
rule "Blah"
when
$l : Long() from new Long(42L)
then
...
end
============
I had to write a helper function which just returns its parameter to
work around this one.
And the final note - DRL is too cut&pasty. There's no _good_ way to
reuse predicates used in the LHS (there's rule inheritance, but it's
not always applicable) and actions in the RHS.
14 years, 5 months
Package based import/export in Guvnor
by Jervis Liu
Hi,
I am currently evaluating a Guvnor feature request which is to implement
package based import/export. The idea is to use this feature to move a
rule package from the DEV repo to QA to Stage to the Prod repo. For
details please check https://jira.jboss.org/browse/GUVNOR-311. My
initial investigation shows that it is not possible to do a single
package import/export technically. A single package in Guvnor repository
is never a self-contained unit. For example, every asset under the
package has a mandatory attribute which is a reference link to category
information. In short, package can not be exported/imported as long as
it contains references to entities outside package.
There are two things I would like to ask for your opinions. Firstly, can
you think of any way to implement this import/export feature? Personally
I dont see how this can be done. This is similar to relational database,
generally it is impossible to export and import data from/to a single
non-isolated table in database. Or sometimes it is possible but with
extensive care normally involved in manual work to deal with dirty data.
In our case, one example of dirty data is category, but what can we do
with category information, we discard package information when we do
package export?
Secondly, if such feature can not be implemented, can we figure out a
different way to help users to better manage the life cycle in Guvnor?
The current version of Guvnor is not very strong on this part yet. If
you are a Guvnor user or you have experience of using similar products,
how did you manage and how do you want to manage the lifecycle of assets
in your repository?
Thanks,
Jervis
14 years, 5 months
IRC: interesting topic: use of lists using "from" in LHS and iterated over in RHS
by Anstis, Michael (M.)
HI,
There was an interesting discussion today on IRC; a user "jochen"
reported NPEs when trying to iterate lists in the RHS constructed in the
LHS using "from collect".
I was wondering how Drools handles lists constructed in the LHS; if the
list contained 5 elements but another rule retracted one of those
elements would the list available in the RHS contain 4 or 5 elements?
Here's a simplification of what was posted at
http://pastebin.com/yKGSxFkA
Rule 1
when
$cheese : ArrayList() from collect(CheeseFact());
then
for(int i=0; i<$cheese.size(); i++) {
//Something useful...
}
end
What if there was another rule that did something like this:-
Rule 2
When
$cf : CheeseFact(type == "chedder")
Then
retract($cf);
end
What would be the list Rule 1 iterates?
I'd assume since I believe activation execution to be serial it would
depend on the agenda's conflict resolution strategy or rule salience?
What would be the learned opinion?
With kind regards,
Mike
14 years, 5 months
NPE due to activation.getDeclarationValue( declId );
by Wolfgang Laun
Assuming that this part of the API is meant to be used like this:
List<String> declIds = );
for( String declId: activation.getDeclarationIDs( ){
Object declVal = activation.getDeclarationValue( declId );
// ...
}
I'm using this during ActivationEvent logging. If, however, a
fact is retracted, this code, when executed for an
AfterActivationFiredEvent, throws a NPE when declId is a
binding for a component of the retracted fact.
The optimum solution would be to not get such useless bindings
in the List<String> returned by getDeclarationIDs() which
is in AgendaItem.java. I have added the if-statement:
public List<String> getDeclarationIDs() {
Declaration[] declArray = this.getRule().getDeclarations();
List<String> declarations = new ArrayList<String>();
for( Declaration decl : declArray ) {
// return only "sound" declaration IDs
if( this.tuple.get( decl ).getObject() != null ){
declarations.add( decl.getIdentifier() );
}
}
return Collections.unmodifiableList( declarations );
}
This is untested!
-W
14 years, 5 months