Re: [rules-users] Knowledge Base and Guvnor

2011-01-04 Thread Michael Anstis
Hi,

You should be able to use the URL syntax with KnowledgeBuilder as follows:-

final String STANDARD_URL = "
http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/standard/LATEST.drl
";
final String CUSTOMER_URL="
http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/customer/LATEST.drl
";

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

UrlResource standardUrlResource =
(UrlResource)ResourceFactory.newUrlResource(STANDARD_URL);
standardUrlResource.setBasicAuthentication("enabled");
standardUrlResource.setUsername("xyz");
standardUrlResource.setPassword("abc");

UrlResource customerUrlResource =
(UrlResource)ResourceFactory.newUrlResource(CUSTOMER_URL);
customerUrlResource.setBasicAuthentication("enabled");
customerUrlResource.setUsername("xyz");
customerUrlResource.setPassword("abc");

kbuilder.add( standardUrlResource, ResourceType.DRL);
kbuilder.add( customerUrlResource, ResourceType.DRL);

assertFalse( kbuilder.hasErrors() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

I don't think you'd need to (or want to) create two KnowledgeBases: You
could ensure "standard" rules are applied first by any of Drools' agenda
controls; i.e. salience, agenda-group or ruleflow; plus sharing a single
KnowledgeBase ensures rules in both packages that share patterns are
optimissed in the RETE network.

Use of ChangeSet could make things a little simpler too (rather than the
individual UrlResources).

Cheers,

Mike

On 3 January 2011 20:03, Dean Whisnant  wrote:

> Hi all, thank you for all the help in the past.
>
> I'm to a point in my project of implementing Guvnor built packages into my
> java code that calls drools.
>
> In the past I used the simple solution of building the knowledge agent on a
> .drl file as follows:
>
>//Setup the knowledge session for drools
>private static KnowledgeBase readKnowledgeBase() throws Exception {
>KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
>.newKnowledgeBuilder();
>
>  kbuilder.add(ResourceFactory.newClassPathResource("Standard837P.drl"),
>ResourceType.DRL);
>KnowledgeBuilderErrors errors = kbuilder.getErrors();
>if (errors.size() > 0) {
>for (KnowledgeBuilderError error : errors) {
>System.err.println(error);
>}
>throw new IllegalArgumentException("Could not parse
> knowledge.");
>}
>KnowledgeBase kbase =
> KnowledgeBaseFactory.newKnowledgeBase();
>kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>return kbase;
>}
>
> A little background before the question.  My project includes one set of
> rules that are standard business logic, we'll call that STANDARD for now and
> one set of rules that any one of my 45 customers could have created, we'll
> call CUSTOMER, on our common guvnor server.  My java code knows which
> customer is running the app, so determining which two packages I want to
> fire is simple.  The part that is not as straight forward for me is how I
> then I migrate using the guvnor urls in my above code.
>
> I thought it would be as easy as to replace "Standard837P.drl" above with
> the STANDARD url and create a second add that would use the CUSTOMER url.
>
> I also want all of my STANDARD rules applied before my CUSTOMER rules are
> applied.  This got me thinking that I need to have two independent knowledge
> bases running so that I fire all in the first and then fire all in the
> second.
>
> Backing up a bit again, my application looks through an incoming file
> inserting facts into the knowledge base for one medical claim line item,
> fires rules, writes out results to a database, and then moves on to the next
> claim line item in the file.
>
> 1) What would the syntax need to be to implement the STANDARD and CUSTOMER
> urls?
> 2) Would I need to create two independent knowledge bases?
> 3) DO you see any performance issues in this arrangement?
>
> Thank you!
>
> Dean
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread maverik j
is there any restriction in terms of using custom function in condition
etc.
If I add function evaluation to conditions its messing up with dsl. For
pattern matching if I use custom function defined in drl then its not able
to parse that properly

[when][] {attr:\S+} follows pattern {pattern:\S+} =
funcToEvalPattern({attr},( {pattern} )
in this case it is getting translated to
exists(Person:Person(subordinate != null , funcToEvalPattern( *eval*( name,
"I" ) ) )
where as I was hoping this to be
exists(Person:Person(subordinate != null , *eval *(funcToEvalPattern( name,
"I" ) ) )

Regards,
-Maverik

On Tue, Jan 4, 2011 at 12:24 PM, maverik j  wrote:

> cool...this was of great help, I will try this out I think it shoudl solve
> the purpose.
>
> Thanks once again,
> Maverik
>
> 2011/1/3 Wolfgang Laun 
>
> Try using eval as a last resort. A better (smaller, more robust) DSL can be
>> designed around facts and their attributes.
>>
>> "||" (and "OR") can be used, but setting parentheses in order to get the
>> priority right is difficult. In constraints, you may have to resort to
>> "memberof" or "not memberof".
>>
>> Your sample isn't self-contained. But I think that the following DSL and
>> the DSLR might give you some ideas how to proceed.
>>
>> [keyword][]check that {conditions}= eval( {conditions} )
>> [keyword][]AND = &&
>> [keyword][]OR  = ||
>>
>> [when][][Tt]here is an? {entity}= {entity}: {entity}()
>> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>>
>> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>>
>> [when][]- with a valid {attr} = {attr}: {attr} != null
>> [when][]- with {attr} not equal to {value} = {attr} != {value}
>> [when][]- eval\( {whatever} \)=eval( {whatever} )
>>
>> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
>> {pattern} )
>> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value} )
>> [when][] {attr:\S+} is valid  =  {attr} != null
>>
>> rule "Rule 5"
>> when
>> There is a Department
>> There is at least one Person
>> - with name not equal to "xxx"
>> - with a valid subordinate
>> - check that the Person's Id is valid AND the Department's Id follows
>> pattern "I" AND the Department's HeadOfDpt not equal name
>> then
>> end
>>
>> Notice that "-check that..." must be written as a single line.
>>
>> -W
>>
>>
>>
>>
>> 2011/1/3 maverik j 
>>
>>>   Hi,
>>>
>>>  We are planning to use DSL/DSRL approach with generic DSL template like
>>> say
>>>
>>> [condition][]The {object} has valid {field}={object}({field} != null )
>>>
>>> [condition][]there is object {*obj*} that = {*obj*}()
>>>
>>> [condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}
>>>
>>> [condition][]- has valid {*attr*} = {*attr*} != null
>>>
>>> [condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}
>>>
>>> But there are quite few of requirements like to have DSL rules that can
>>> generate expression as follows:
>>> exists Employee(
>>>attribute name not equals "xxx"
>>>&& the attribute subOrdinate is not null
>>>&& eval(
>>>the attribute $dept.getId() is not null
>>>&& attribute $dept.getId() follows pattern "I"
>>>&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
>>>)
>>> )
>>>
>>> I am not sure if this is possible with DSL. Using '-' operator we cannot
>>> really add '&&', '||' conditions it by-default expands to ',' separated and
>>> conditions. And wirtting generic rules with and/or is not really dynamic to
>>> allow any number of expressions in evaluation.
>>>
>>> i am struggling to get this run since long time so any help/thoughts on
>>> this would be  highly appriciable !!!
>>>
>>> Thanks & Regards,
>>> -Maverik
>>>
>>> ___
>>> rules-users mailing list
>>> rules-users@lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread Wolfgang Laun
2011/1/4 maverik j 

> is there any restriction in terms of using custom function in condition
> etc.
> If I add function evaluation to conditions its messing up with dsl. For
> pattern matching if I use custom function defined in drl then its not able
> to parse that properly
>
> [when][] {attr:\S+} follows pattern {pattern:\S+} =
> funcToEvalPattern({attr},( {pattern} )
>

Is this exactly what you have in the DSL definition? It's syntactically
incorrect.


> in this case it is getting translated to
> exists(Person:Person(subordinate != null , funcToEvalPattern( *eval*(
> name, "I" ) ) )
> where as I was hoping this to be
> exists(Person:Person(subordinate != null , *eval *(funcToEvalPattern(
> name, "I" ) ) )
>
>

I cannot reproduce this. But it may depend on the order of your entries in
you DSL file.

-W



> Regards,
> -Maverik
>
> On Tue, Jan 4, 2011 at 12:24 PM, maverik j  wrote:
>
>> cool...this was of great help, I will try this out I think it shoudl solve
>> the purpose.
>>
>> Thanks once again,
>> Maverik
>>
>> 2011/1/3 Wolfgang Laun 
>>
>> Try using eval as a last resort. A better (smaller, more robust) DSL can
>>> be designed around facts and their attributes.
>>>
>>> "||" (and "OR") can be used, but setting parentheses in order to get the
>>> priority right is difficult. In constraints, you may have to resort to
>>> "memberof" or "not memberof".
>>>
>>> Your sample isn't self-contained. But I think that the following DSL and
>>> the DSLR might give you some ideas how to proceed.
>>>
>>> [keyword][]check that {conditions}= eval( {conditions} )
>>> [keyword][]AND = &&
>>> [keyword][]OR  = ||
>>>
>>> [when][][Tt]here is an? {entity}= {entity}: {entity}()
>>> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>>>
>>> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>>>
>>> [when][]- with a valid {attr} = {attr}: {attr} != null
>>> [when][]- with {attr} not equal to {value} = {attr} != {value}
>>> [when][]- eval\( {whatever} \)=eval( {whatever} )
>>>
>>> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
>>> {pattern} )
>>> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value} )
>>> [when][] {attr:\S+} is valid  =  {attr} != null
>>>
>>> rule "Rule 5"
>>> when
>>> There is a Department
>>> There is at least one Person
>>> - with name not equal to "xxx"
>>> - with a valid subordinate
>>> - check that the Person's Id is valid AND the Department's Id follows
>>> pattern "I" AND the Department's HeadOfDpt not equal name
>>> then
>>> end
>>>
>>> Notice that "-check that..." must be written as a single line.
>>>
>>> -W
>>>
>>>
>>>
>>>
>>> 2011/1/3 maverik j 
>>>
   Hi,

  We are planning to use DSL/DSRL approach with generic DSL template like
 say

 [condition][]The {object} has valid {field}={object}({field} != null )

 [condition][]there is object {*obj*} that = {*obj*}()

 [condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}

 [condition][]- has valid {*attr*} = {*attr*} != null

 [condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}

 But there are quite few of requirements like to have DSL rules that can
 generate expression as follows:
 exists Employee(
attribute name not equals "xxx"
&& the attribute subOrdinate is not null
&& eval(
the attribute $dept.getId() is not null
&& attribute $dept.getId() follows pattern "I"
&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
)
 )

 I am not sure if this is possible with DSL. Using '-' operator we cannot
 really add '&&', '||' conditions it by-default expands to ',' separated and
 conditions. And wirtting generic rules with and/or is not really dynamic to
 allow any number of expressions in evaluation.

 i am struggling to get this run since long time so any help/thoughts on
 this would be  highly appriciable !!!

 Thanks & Regards,
 -Maverik

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


>>>
>>> ___
>>> rules-users mailing list
>>> rules-users@lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread maverik j
2011/1/4 Wolfgang Laun 

>
>
> 2011/1/4 maverik j 
>
>  is there any restriction in terms of using custom function in condition
>> etc.
>> If I add function evaluation to conditions its messing up with dsl. For
>> pattern matching if I use custom function defined in drl then its not able
>> to parse that properly
>>
>> [when][] {attr:\S+} follows pattern {pattern:\S+} =
>> funcToEvalPattern({attr},( {pattern} )
>>
>
> Is this exactly what you have in the DSL definition? It's syntactically
> incorrect.
>


>   Sorry for that, it is actually
>


>  [when][] {*attr*} follows pattern {pattern} = startsWithFunction( {*attr*},
> {pattern} )
>>
>>  and is being added as last statement in DSL (for testing purpose I am
>> using same dsl as you have shown)
>>
>

>   in this case it is getting translated to
>> exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
>> name, "I" ) ) )
>> where as I was hoping this to be
>> exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
>> name, "I" ) ) )
>>
>>
>
> I cannot reproduce this. But it may depend on the order of your entries in
> you DSL file.
>
> Actually I tried changing order as well but didnt worked. I have actually
defined these common functions in drl and added that to knowledgebase along
with these DSL and DSLR.



>  -W
>
>
>
>> Regards,
>> -Maverik
>>
>> On Tue, Jan 4, 2011 at 12:24 PM, maverik j  wrote:
>>
>>> cool...this was of great help, I will try this out I think it shoudl
>>> solve the purpose.
>>>
>>> Thanks once again,
>>> Maverik
>>>
>>> 2011/1/3 Wolfgang Laun 
>>>
>>> Try using eval as a last resort. A better (smaller, more robust) DSL can
 be designed around facts and their attributes.

 "||" (and "OR") can be used, but setting parentheses in order to get the
 priority right is difficult. In constraints, you may have to resort to
 "memberof" or "not memberof".

 Your sample isn't self-contained. But I think that the following DSL and
 the DSLR might give you some ideas how to proceed.

 [keyword][]check that {conditions}= eval( {conditions} )
 [keyword][]AND = &&
 [keyword][]OR  = ||

 [when][][Tt]here is an? {entity}= {entity}: {entity}()
 [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()

 [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()

 [when][]- with a valid {attr} = {attr}: {attr} != null
 [when][]- with {attr} not equal to {value} = {attr} != {value}
 [when][]- eval\( {whatever} \)=eval( {whatever} )

 [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
 {pattern} )
 [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value} )
 [when][] {attr:\S+} is valid  =  {attr} != null

 rule "Rule 5"
 when
 There is a Department
 There is at least one Person
 - with name not equal to "xxx"
 - with a valid subordinate
 - check that the Person's Id is valid AND the Department's Id
 follows pattern "I" AND the Department's HeadOfDpt not equal name
 then
 end

 Notice that "-check that..." must be written as a single line.

 -W




 2011/1/3 maverik j 

>   Hi,
>
>  We are planning to use DSL/DSRL approach with generic DSL template
> like say
>
> [condition][]The {object} has valid {field}={object}({field} != null )
>
> [condition][]there is object {*obj*} that = {*obj*}()
>
> [condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}
>
> [condition][]- has valid {*attr*} = {*attr*} != null
>
> [condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}
>
> But there are quite few of requirements like to have DSL rules that can
> generate expression as follows:
> exists Employee(
>attribute name not equals "xxx"
>&& the attribute subOrdinate is not null
>&& eval(
>the attribute $dept.getId() is not null
>&& attribute $dept.getId() follows pattern "I"
>&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
>)
> )
>
> I am not sure if this is possible with DSL. Using '-' operator we
> cannot really add '&&', '||' conditions it by-default expands to ','
> separated and conditions. And wirtting generic rules with and/or is not
> really dynamic to allow any number of expressions in evaluation.
>
> i am struggling to get this run since long time so any help/thoughts on
> this would be  highly appriciable !!!
>
> Thanks & Regards,
> -Maverik
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jbos

Re: [rules-users] Does Drools Fusion support "Group By" clause ?

2011-01-04 Thread Gabor Szokoli
Hi,

Purely for educational purposes I am trying to figure out how this
will work when multiple Sale instances share the same "type" string.

It seems to me that under the default "identity" assertion mode of the
Working Memory, as many SaleType instances would be maintained as
there are unexpired Sale events. In the degenerate case of all n Sale
instances sharing the same type string, rules that bind a SaleType
variable on their LHS should fire n times more than expected.

Am I missing something?

On the other hand "declare" creates a constructor with parameters? Neat!

On Mon, Jan 3, 2011 at 4:28 PM, Edson Tirelli  wrote:
>
> declare SaleType
>    type : String
> end
>
> rule "register types"
> when
>     Sale( $type : type )
> then
>     insertLogical( new SaleType( $type ) );
> end
>

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread Wolfgang Laun
Do you have any comments ("#..." or "//...") between when and then? If so,
please remove and try again.

If this doesn't fix it, please post completely and exactly
- the rule from the DSLR
- the full DSL
- Drools version.

Thanks
-W



2011/1/4 maverik j 

>
>
> 2011/1/4 Wolfgang Laun 
>
>
>>
>> 2011/1/4 maverik j 
>>
>>  is there any restriction in terms of using custom function in condition
>>> etc.
>>> If I add function evaluation to conditions its messing up with dsl. For
>>> pattern matching if I use custom function defined in drl then its not able
>>> to parse that properly
>>>
>>> [when][] {attr:\S+} follows pattern {pattern:\S+} =
>>> funcToEvalPattern({attr},( {pattern} )
>>>
>>
>> Is this exactly what you have in the DSL definition? It's syntactically
>> incorrect.
>>
>
>
>>   Sorry for that, it is actually
>>
>
>
>>  [when][] {*attr*} follows pattern {pattern} = startsWithFunction( {*attr
>> *}, {pattern} )
>>>
>>>  and is being added as last statement in DSL (for testing purpose I am
>>> using same dsl as you have shown)
>>>
>>
>
>>   in this case it is getting translated to
>>> exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
>>> name, "I" ) ) )
>>> where as I was hoping this to be
>>> exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
>>> name, "I" ) ) )
>>>
>>>
>>
>> I cannot reproduce this. But it may depend on the order of your entries in
>> you DSL file.
>>
>> Actually I tried changing order as well but didnt worked. I have actually
> defined these common functions in drl and added that to knowledgebase along
> with these DSL and DSLR.
>
>
>
>>  -W
>>
>>
>>
>>> Regards,
>>> -Maverik
>>>
>>> On Tue, Jan 4, 2011 at 12:24 PM, maverik j wrote:
>>>
 cool...this was of great help, I will try this out I think it shoudl
 solve the purpose.

 Thanks once again,
 Maverik

 2011/1/3 Wolfgang Laun 

 Try using eval as a last resort. A better (smaller, more robust) DSL can
> be designed around facts and their attributes.
>
> "||" (and "OR") can be used, but setting parentheses in order to get
> the priority right is difficult. In constraints, you may have to resort to
> "memberof" or "not memberof".
>
> Your sample isn't self-contained. But I think that the following DSL
> and the DSLR might give you some ideas how to proceed.
>
> [keyword][]check that {conditions}= eval( {conditions} )
> [keyword][]AND = &&
> [keyword][]OR  = ||
>
> [when][][Tt]here is an? {entity}= {entity}: {entity}()
> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>
> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>
> [when][]- with a valid {attr} = {attr}: {attr} != null
> [when][]- with {attr} not equal to {value} = {attr} != {value}
> [when][]- eval\( {whatever} \)=eval( {whatever} )
>
> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
> {pattern} )
> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value}
> )
> [when][] {attr:\S+} is valid  =  {attr} != null
>
> rule "Rule 5"
> when
> There is a Department
> There is at least one Person
> - with name not equal to "xxx"
> - with a valid subordinate
> - check that the Person's Id is valid AND the Department's Id
> follows pattern "I" AND the Department's HeadOfDpt not equal name
> then
> end
>
> Notice that "-check that..." must be written as a single line.
>
> -W
>
>
>
>
> 2011/1/3 maverik j 
>
>>   Hi,
>>
>>  We are planning to use DSL/DSRL approach with generic DSL template
>> like say
>>
>> [condition][]The {object} has valid {field}={object}({field} != null )
>>
>> [condition][]there is object {*obj*} that = {*obj*}()
>>
>> [condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}
>>
>> [condition][]- has valid {*attr*} = {*attr*} != null
>>
>> [condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}
>>
>> But there are quite few of requirements like to have DSL rules that
>> can generate expression as follows:
>> exists Employee(
>>attribute name not equals "xxx"
>>&& the attribute subOrdinate is not null
>>&& eval(
>>the attribute $dept.getId() is not null
>>&& attribute $dept.getId() follows pattern "I"
>>&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
>>)
>> )
>>
>> I am not sure if this is possible with DSL. Using '-' operator we
>> cannot really add '&&', '||' conditions it by-default expands to ','
>> separated and conditions. And wirtting generic rules with and/or is not
>> really dynamic to allow any number of expressions in evaluation.
>>
>> i am struggling to get this run since long time so any help/thoughts
>> on this

Re: [rules-users] Does Drools Fusion support "Group By" clause ?

2011-01-04 Thread Wolfgang Laun
On 4 January 2011 11:15, Gabor Szokoli  wrote:

> Hi,
>
> Purely for educational purposes I am trying to figure out how this
> will work when multiple Sale instances share the same "type" string.
>
> It seems to me that under the default "identity" assertion mode of the
> Working Memory, as many SaleType instances would be maintained as
> there are unexpired Sale events. In the degenerate case of all n Sale
> instances sharing the same type string, rules that bind a SaleType
> variable on their LHS should fire n times more than expected.
>

This is n - 1 times :-)

The fix is simple:

when
 Sale( $type : type )
 not SaleType( type == $type )
then
 insertLogical( new SaleType( $type ) );

-W


> Am I missing something?
>
> On the other hand "declare" creates a constructor with parameters? Neat!
>
> On Mon, Jan 3, 2011 at 4:28 PM, Edson Tirelli 
> wrote:
> >
> > declare SaleType
> >type : String
> > end
> >
> > rule "register types"
> > when
> > Sale( $type : type )
> > then
> > insertLogical( new SaleType( $type ) );
> > end
> >
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread maverik j
Here is the complete DSL/DSLR

DSLr:
rule "Your First Rule"
 when
There is a Department
There is at least one Person
- with a valid subOrdinate
- check that name follows pattern "M"
then
   >System.out.println("Test Generic Cosntranit done !!!");
end

DSL:
[keyword][]check that {conditions}= eval( {conditions} )
[keyword][]AND = &&
[keyword][]OR  = ||
[when][][Tt]here is an? {entity}= {entity}: {entity}()
[when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
[when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
[when][]- with {attr} equal to {value} = {attr} == {value}
[when][]- with a valid {attr} = {attr} != null
[when][]- with {attr} not equal to {value} = {attr} != {value}
[when][]- eval\( {whatever} \)= eval( {whatever} )
[when][] {attr} equals {value} = {attr}.equals({value})
[when][] {attr} is valid  =  {attr} != null
[when][] {attr} follows pattern {x} =  startsWithFunction({attr},{x})

Function used in drl is:
function boolean startsWithFunction(String value, String beginning) {
 if (value == null) return false;
 if (beginning == null) return false;
 return value.startsWith(beginning);
}
I am using drools version 5.1.1

Thanks & Regards,
-Maverik

2011/1/4 Wolfgang Laun 

> Do you have any comments ("#..." or "//...") between when and then? If so,
> please remove and try again.
>
> If this doesn't fix it, please post completely and exactly
> - the rule from the DSLR
> - the full DSL
> - Drools version.
>
> Thanks
> -W
>
>
>
>
> 2011/1/4 maverik j 
>
>>
>>
>> 2011/1/4 Wolfgang Laun 
>>
>>
>>>
>>> 2011/1/4 maverik j 
>>>
>>>  is there any restriction in terms of using custom function in condition
 etc.
 If I add function evaluation to conditions its messing up with dsl. For
 pattern matching if I use custom function defined in drl then its not able
 to parse that properly

 [when][] {attr:\S+} follows pattern {pattern:\S+} =
 funcToEvalPattern({attr},( {pattern} )

>>>
>>> Is this exactly what you have in the DSL definition? It's syntactically
>>> incorrect.
>>>
>>
>>
>>>   Sorry for that, it is actually
>>>
>>
>>
>>>  [when][] {*attr*} follows pattern {pattern} = startsWithFunction( {*
>>> attr*}, {pattern} )

  and is being added as last statement in DSL (for testing purpose I am
 using same dsl as you have shown)

>>>
>>
>>>in this case it is getting translated to
 exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
 name, "I" ) ) )
  where as I was hoping this to be
 exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
 name, "I" ) ) )


>>>
>>> I cannot reproduce this. But it may depend on the order of your entries
>>> in you DSL file.
>>>
>>> Actually I tried changing order as well but didnt worked. I have actually
>> defined these common functions in drl and added that to knowledgebase along
>> with these DSL and DSLR.
>>
>>
>>
>>>  -W
>>>
>>>
>>>
 Regards,
 -Maverik

 On Tue, Jan 4, 2011 at 12:24 PM, maverik j wrote:

> cool...this was of great help, I will try this out I think it shoudl
> solve the purpose.
>
> Thanks once again,
> Maverik
>
> 2011/1/3 Wolfgang Laun 
>
> Try using eval as a last resort. A better (smaller, more robust) DSL
>> can be designed around facts and their attributes.
>>
>> "||" (and "OR") can be used, but setting parentheses in order to get
>> the priority right is difficult. In constraints, you may have to resort 
>> to
>> "memberof" or "not memberof".
>>
>> Your sample isn't self-contained. But I think that the following DSL
>> and the DSLR might give you some ideas how to proceed.
>>
>> [keyword][]check that {conditions}= eval( {conditions} )
>> [keyword][]AND = &&
>> [keyword][]OR  = ||
>>
>> [when][][Tt]here is an? {entity}= {entity}: {entity}()
>> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>>
>> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>>
>> [when][]- with a valid {attr} = {attr}: {attr} != null
>> [when][]- with {attr} not equal to {value} = {attr} != {value}
>> [when][]- eval\( {whatever} \)=eval( {whatever} )
>>
>> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
>> {pattern} )
>> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value}
>> )
>> [when][] {attr:\S+} is valid  =  {attr} != null
>>
>> rule "Rule 5"
>> when
>> There is a Department
>> There is at least one Person
>> - with name not equal to "xxx"
>> - with a valid subordinate
>> - check that the Person's Id is valid AND the Department's Id
>> follows pattern "I" AND the Department's HeadOfDpt not equal name
>> then
>> end
>>
>> Notice that "-check that..." must be written as a single line.
>>
>> -W
>>
>>
>

Re: [rules-users] Drools in production use vs. JBoss BRMS commercially supported version?

2011-01-04 Thread Mauricio Salatino
The drools platform has an incredible amount of features, the core is stable
but as mark said new features and new bug fixes can only be found in the
community release. I also think that the community answers pretty fast to
critical bug fixes. So basically depends on your use case and in the amount
of new features that you want to use.
My two cents..

2011/1/4 dc tech 

> Thanks Mark.
> Agreeing with you that the Enterprise release is clearly more stable, the
> question really is how stable is the community release? For instance,
> Tomcat's 'community' release i.e. the version downloaded from Apache
> directly is very, very mature and stable. We've run that for many years with
> hardly any problems. Is the Drools community release close to that? Would we
> face big risks going with it in a production environment? I should add that
> the environment is not a financial type of system and we can probably live
> with a little bit of risk.
>
> Thanks again.
>
>
> On Mon, Jan 3, 2011 at 10:01 PM, Mark Proctor wrote:
>
>> On 04/01/2011 01:41, dc tech wrote:
>> > I wonder if any, or perhaps many,  of you are using Drools community
>> > version in production systems? Or are you using the jBoss BRMS - the
>> > commercially supported version?
>> >
>> > If you are using the community version, what is your sense of
>> > stability of the releases?
>> The commercial project code base is supported for 5 years and bugs are
>> patched without forcing you to include new features or apis. It's tested
>> against a wider range of projects and application servers and releases
>> are generally based on a given corporate schedule.
>>
>> The project is released when it's ready and bug fixes are not
>> backported, so you always need to be running bleeding edge to get latest
>> bug fixes. So while you get the bug fixes, you also get all the new
>> features which haven't had much testing yet and can introduce some level
>> of instability. This puts a lot more onus, and thus cost, onto the end
>> user to test more thoroughly in their environments.
>>
>> Mark
>> > On 1/3/11, smogstate  wrote:
>> >> I have same issue. Can anyone help?
>> >> --
>> >> View this message in context:
>> >>
>> http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-within-Stateless-Session-in-Drools-5-1-tp2094451p2187624.html
>> >> Sent from the Drools - User mailing list archive at Nabble.com.
>> >> ___
>> >> rules-users mailing list
>> >> rules-users@lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>>
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 - CTO @ http://www.plugtree.com
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino "Salaboy" Mauricio -
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Does Drools Fusion support "Group By" clause ?

2011-01-04 Thread Edson Tirelli
   Sorry, my mistake. Wolfgang's suggestion works, but you can also
simply define type as the key on sales type:

declare SalesType
type : String @key
end

   Logical insertions always use equality method, even if regular
insertions use identity.

   Edson


2011/1/4 Wolfgang Laun :
>
>
> On 4 January 2011 11:15, Gabor Szokoli  wrote:
>>
>> Hi,
>>
>> Purely for educational purposes I am trying to figure out how this
>> will work when multiple Sale instances share the same "type" string.
>>
>> It seems to me that under the default "identity" assertion mode of the
>> Working Memory, as many SaleType instances would be maintained as
>> there are unexpired Sale events. In the degenerate case of all n Sale
>> instances sharing the same type string, rules that bind a SaleType
>> variable on their LHS should fire n times more than expected.
>
> This is n - 1 times :-)
>
> The fix is simple:
>
> when
>      Sale( $type : type )
>  not SaleType( type == $type )
> then
>      insertLogical( new SaleType( $type ) );
>
> -W
>
>>
>> Am I missing something?
>>
>> On the other hand "declare" creates a constructor with parameters? Neat!
>>
>> On Mon, Jan 3, 2011 at 4:28 PM, Edson Tirelli 
>> wrote:
>> >
>> > declare SaleType
>> >    type : String
>> > end
>> >
>> > rule "register types"
>> > when
>> >     Sale( $type : type )
>> > then
>> >     insertLogical( new SaleType( $type ) );
>> > end
>> >
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Human Task Service Persistence

2011-01-04 Thread tangrui...@gmail.com
Sorry for the delayed reply, I almost missed this email.

In the file ProcessInstanceInfo.orm.xml, there's a statement like

  






I think you should notice this, but this really does not work, I don't know
why this happens, maybe some bugs of Hibernate.


On Wed, Dec 22, 2010 at 8:35 PM, ramram  wrote:

>
> Hi tangrui,
>
>   i have applied the mapping provided by you and the process as well as the
> task functioned well. I tried to change the name of the table provided and
> everything worked fine except for the EVENTTYPES table which is still being
> created under name of eventTypes what may be cause the problem of this and
> how can we add a mapping to it to solve the issue.
>
>
> Regards,
> Ram
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Human-Task-Service-Persistence-tp1868778p2131089.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
唐睿
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread Wolfgang Laun
You have omitted the regular expressions from some of the variable
definitions
in DSL entries:

[when][] {attr:\S+} follows pattern {x:\S+} =
startsWithFunction({attr},{x})

Restore them all, and it's OK.

-W



2011/1/4 maverik j 

> Here is the complete DSL/DSLR
>
> DSLr:
> rule "Your First Rule"
>
>  when
> There is a Department
> There is at least one Person
> - with a valid subOrdinate
> - check that name follows pattern "M"
> then
>>System.out.println("Test Generic Cosntranit done !!!");
> end
>
> DSL:
> [keyword][]check that {conditions}= eval( {conditions} )
> [keyword][]AND = &&
> [keyword][]OR  = ||
> [when][][Tt]here is an? {entity}= {entity}: {entity}()
> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
> [when][]- with {attr} equal to {value} = {attr} == {value}
> [when][]- with a valid {attr} = {attr} != null
>
> [when][]- with {attr} not equal to {value} = {attr} != {value}
> [when][]- eval\( {whatever} \)= eval( {whatever} )
> [when][] {attr} equals {value} = {attr}.equals({value})
> [when][] {attr} is valid  =  {attr} != null
> [when][] {attr} follows pattern {x} =  startsWithFunction({attr},{x})
>
> Function used in drl is:
> function boolean startsWithFunction(String value, String beginning) {
>  if (value == null) return false;
>  if (beginning == null) return false;
>  return value.startsWith(beginning);
> }
> I am using drools version 5.1.1
>
> Thanks & Regards,
> -Maverik
>
> 2011/1/4 Wolfgang Laun 
>
>> Do you have any comments ("#..." or "//...") between when and then? If so,
>> please remove and try again.
>>
>> If this doesn't fix it, please post completely and exactly
>> - the rule from the DSLR
>> - the full DSL
>> - Drools version.
>>
>> Thanks
>> -W
>>
>>
>>
>>
>> 2011/1/4 maverik j 
>>
>>>
>>>
>>> 2011/1/4 Wolfgang Laun 
>>>
>>>

 2011/1/4 maverik j 

  is there any restriction in terms of using custom function in
> condition etc.
> If I add function evaluation to conditions its messing up with dsl. For
> pattern matching if I use custom function defined in drl then its not able
> to parse that properly
>
> [when][] {attr:\S+} follows pattern {pattern:\S+} =
> funcToEvalPattern({attr},( {pattern} )
>

 Is this exactly what you have in the DSL definition? It's syntactically
 incorrect.

>>>
>>>
   Sorry for that, it is actually

>>>
>>>
  [when][] {*attr*} follows pattern {pattern} = startsWithFunction( {*
 attr*}, {pattern} )
>
>  and is being added as last statement in DSL (for testing purpose I am
> using same dsl as you have shown)
>

>>>
in this case it is getting translated to
> exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
> name, "I" ) ) )
>  where as I was hoping this to be
> exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
> name, "I" ) ) )
>
>

 I cannot reproduce this. But it may depend on the order of your entries
 in you DSL file.

 Actually I tried changing order as well but didnt worked. I have
>>> actually defined these common functions in drl and added that to
>>> knowledgebase along with these DSL and DSLR.
>>>
>>>
>>>
  -W



> Regards,
> -Maverik
>
> On Tue, Jan 4, 2011 at 12:24 PM, maverik j wrote:
>
>> cool...this was of great help, I will try this out I think it shoudl
>> solve the purpose.
>>
>> Thanks once again,
>> Maverik
>>
>> 2011/1/3 Wolfgang Laun 
>>
>> Try using eval as a last resort. A better (smaller, more robust) DSL
>>> can be designed around facts and their attributes.
>>>
>>> "||" (and "OR") can be used, but setting parentheses in order to get
>>> the priority right is difficult. In constraints, you may have to resort 
>>> to
>>> "memberof" or "not memberof".
>>>
>>> Your sample isn't self-contained. But I think that the following DSL
>>> and the DSLR might give you some ideas how to proceed.
>>>
>>> [keyword][]check that {conditions}= eval( {conditions} )
>>> [keyword][]AND = &&
>>> [keyword][]OR  = ||
>>>
>>> [when][][Tt]here is an? {entity}= {entity}: {entity}()
>>> [when][][Tt]here is at least one {entity}= exists {entity}:
>>> {entity}()
>>>
>>> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>>>
>>> [when][]- with a valid {attr} = {attr}: {attr} != null
>>> [when][]- with {attr} not equal to {value} = {attr} != {value}
>>> [when][]- eval\( {whatever} \)=eval( {whatever} )
>>>
>>> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
>>> {pattern} )
>>> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals(
>>> {value} )
>>> [when][] {attr:\S+} is valid  =  {attr} != null
>>>
>>> rule "Rule 5"
>>> w

[rules-users] KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage

2011-01-04 Thread John Peterson
This is sort of a repost of an error I've been getting, but I thought
with the new year, I'd give it another shot.

I've been getting the following exception in my code:

[2010:12:361 09:12:910:debug] KnowledgeAgent rebuilding KnowledgeBase
using ChangeSet
[2010:12:361 09:12:972:exception]
***java.lang.RuntimeException*: KnowledgeAgent exception while trying to
deserialize KnowledgeDefinitionsPackage
  at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***Kn
owledgeAgentImpl.java:664*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(***
KnowledgeAgentImpl.java:889*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(***KnowledgeAg
entImpl.java:704*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(***Knowledge
AgentImpl.java:584*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***KnowledgeAgen
tImpl.java:185*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***KnowledgeAgen
tImpl.java:168*)
  at
com.agencyawards2.RuleSessionProviderFactory.getSessionFactory(***RuleSe
ssionProviderFactory.java:95*)
  at
com.agencyawards2.RuleSessionProviderFactory.getProvider(***RuleSessionP
roviderFactory.java:35*)
  at com.agencyawards2.RunRules.runRules(***RunRules.java:27*)
  at com.agencyawards2.DroolsTest.main(***DroolsTest.java:40*)
Caused by:*** java.io.StreamCorruptedException*: invalid stream header:
7061636B
  at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
  at java.io.ObjectInputStream.(Unknown Source)
  at
org.drools.common.DroolsObjectInputStream.(***DroolsObjectInputStr
eam.java:71*)
  at
org.drools.core.util.DroolsStreamUtils.streamIn(***DroolsStreamUtils.jav
a:205*)
  at
org.drools.core.util.DroolsStreamUtils.streamIn(***DroolsStreamUtils.jav
a:174*)
  at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***Kn
owledgeAgentImpl.java:653*)
  ... 9 more

I'm running Drools 5.1.1 on my workstation in Eclipse.  When I run it
against Guvnor locally using version 5.1.1 installed as the "Guvnor
Standalone" downloaded at the same time as Drools 5.1.1 was downloaded
from the JBoss.org site, it works fine.

When I run it against the server, which was from the 5.0.1 "Guvnor
Standalone" installation, but I updated the drools-guvnor.war file to
use the new 5.1.1 version, I get the error listed above.  Based on my
research into the "KnowledgeAgent exception while trying to deserialize
KnowledgeDefinitionsPackage" error, it seems to stem from an
incompatibility between versions of Drools.

Do I need to install the 5.1.1 Guvnor Standalone to my server to bring
the versions into synch, or am I experiencing some other sort of
problem?

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage

2011-01-04 Thread Michael Anstis
Hi John,

AFAIK you need both client (i.e. your IDE) and server versions of Guvnor to
be the same.

If you are trying to load a package from an existing (5.0.1) Guvnor
repositoty I believe you will need to re-compile\re-package the binaries as
a number of SerialVersionIds changed.

It wasn't clear from your email whether this is what you have set-up.

Happy New Year!

Mike

2011/1/4 John Peterson 

>  This is sort of a repost of an error I’ve been getting, but I thought
> with the new year, I’d give it another shot.
>
> I’ve been getting the following exception in my code:
>
> [2010:12:361 09:12:910:debug] KnowledgeAgent rebuilding KnowledgeBase using
> ChangeSet
>
> [2010:12:361 09:12:972:exception]
>
> ***java.lang.RuntimeException*: KnowledgeAgent exception while trying to
> deserialize KnowledgeDefinitionsPackage
>
>   atorg.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***
> KnowledgeAgentImpl.java:664*)
>
>   atorg.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(*
> **KnowledgeAgentImpl.java:889*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(***
> KnowledgeAgentImpl.java:704*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(***
> KnowledgeAgentImpl.java:584*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***
> KnowledgeAgentImpl.java:185*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***
> KnowledgeAgentImpl.java:168*)
>
>   at com.agencyawards2.RuleSessionProviderFactory.getSessionFactory(
> ***RuleSessionProviderFactory.java:95*)
>
>   at com.agencyawards2.RuleSessionProviderFactory.getProvider(***
> RuleSessionProviderFactory.java:35*)
>
>   at com.agencyawards2.RunRules.runRules(***RunRules.java:27*)
>
>   at com.agencyawards2.DroolsTest.main(***DroolsTest.java:40*)
>
> Caused by:*** java.io.StreamCorruptedException*: invalid stream 
> header:7061636B
>
>   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
>
>   at java.io.ObjectInputStream.(Unknown Source)
>
>   at org.drools.common.DroolsObjectInputStream.(***
> DroolsObjectInputStream.java:71*)
>
>   at org.drools.core.util.DroolsStreamUtils.streamIn(***
> DroolsStreamUtils.java:205*)
>
>   at org.drools.core.util.DroolsStreamUtils.streamIn(***
> DroolsStreamUtils.java:174*)
>
>   atorg.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***
> KnowledgeAgentImpl.java:653*)
>
>   ... 9 more
>
> I’m running Drools 5.1.1 on my workstation in Eclipse.  When I run it
> against Guvnor locally using version 5.1.1 installed as the “Guvnor
> Standalone” downloaded at the same time as Drools 5.1.1 was downloadedfrom 
> the JBoss.org site, it works fine.
>
> When I run it against the server, which was from the 5.0.1 “Guvnor
> Standalone” installation, but I updated the drools-guvnor.war file to use
> the new 5.1.1 version, I get the error listed above.  Based on my research
> into the “KnowledgeAgent exception while trying to deserialize
> KnowledgeDefinitionsPackage” error, it seems to stem from an
> incompatibility between versions of Drools.
>
> Do I need to install the 5.1.1 Guvnor Standalone to my server to bring the
> versions into synch, or am I experiencing some other sort of problem?
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage

2011-01-04 Thread John Peterson
I upgraded Guvnor on the JBoss server by replacing the 5.0.1
drools-guvnor.war in /server/default/deploy with the drools-guvnor.war
for 5.1.1.  Once we restarted the server, everything seemed to be
working fine with the 5.1.1 features.  It wasn't until a couple weeks
later when we tried to connect that we started getting the failure
messages.  The package in question is new since the upgrade.

How do I re-compile/re-package the binaries?  I'm assuming this is
different from doing a "Save and validate configuration" or "Build
package" on the package screen.

Thanks and a Happy New Year to you as well!

John

Message: 2
Date: Tue, 4 Jan 2011 16:56:52 +
From: Michael Anstis 
Subject: Re: [rules-users] KnowledgeAgent exception while trying to
deserialize KnowledgeDefinitionsPackage
To: Rules Users List 
Message-ID:

Content-Type: text/plain; charset="windows-1252"

Hi John,

AFAIK you need both client (i.e. your IDE) and server versions of Guvnor
to be the same.

If you are trying to load a package from an existing (5.0.1) Guvnor
repositoty I believe you will need to re-compile\re-package the binaries
as a number of SerialVersionIds changed.

It wasn't clear from your email whether this is what you have set-up.

Happy New Year!

Mike

2011/1/4 John Peterson 

>  This is sort of a repost of an error I?ve been getting, but I thought

> with the new year, I?d give it another shot.
>
> I?ve been getting the following exception in my code:
>
> [2010:12:361 09:12:910:debug] KnowledgeAgent rebuilding KnowledgeBase 
> using ChangeSet
>
> [2010:12:361 09:12:972:exception]
>
> ***java.lang.RuntimeException*: KnowledgeAgent exception while trying 
> to deserialize KnowledgeDefinitionsPackage
>
>   
> atorg.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(*
> **
> KnowledgeAgentImpl.java:664*)
>
>   
> atorg.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase
> (*
> **KnowledgeAgentImpl.java:889*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(***
> KnowledgeAgentImpl.java:704*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(***
> KnowledgeAgentImpl.java:584*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***
> KnowledgeAgentImpl.java:185*)
>
>   at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***
> KnowledgeAgentImpl.java:168*)
>
>   at com.agencyawards2.RuleSessionProviderFactory.getSessionFactory(
> ***RuleSessionProviderFactory.java:95*)
>
>   at com.agencyawards2.RuleSessionProviderFactory.getProvider(***
> RuleSessionProviderFactory.java:35*)
>
>   at com.agencyawards2.RunRules.runRules(***RunRules.java:27*)
>
>   at com.agencyawards2.DroolsTest.main(***DroolsTest.java:40*)
>
> Caused by:*** java.io.StreamCorruptedException*: invalid stream 
> header:7061636B
>
>   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
>
>   at java.io.ObjectInputStream.(Unknown Source)
>
>   at org.drools.common.DroolsObjectInputStream.(***
> DroolsObjectInputStream.java:71*)
>
>   at org.drools.core.util.DroolsStreamUtils.streamIn(***
> DroolsStreamUtils.java:205*)
>
>   at org.drools.core.util.DroolsStreamUtils.streamIn(***
> DroolsStreamUtils.java:174*)
>
>   
> atorg.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(*
> **
> KnowledgeAgentImpl.java:653*)
>
>   ... 9 more
>
> I?m running Drools 5.1.1 on my workstation in Eclipse.  When I run it 
> against Guvnor locally using version 5.1.1 installed as the ?Guvnor 
> Standalone? downloaded at the same time as Drools 5.1.1 was
downloadedfrom the JBoss.org site, it works fine.
>
> When I run it against the server, which was from the 5.0.1 ?Guvnor 
> Standalone? installation, but I updated the drools-guvnor.war file to 
> use the new 5.1.1 version, I get the error listed above.  Based on my 
> research into the ?KnowledgeAgent exception while trying to 
> deserialize KnowledgeDefinitionsPackage? error, it seems to stem from 
> an incompatibility between versions of Drools.
>
> Do I need to install the 5.1.1 Guvnor Standalone to my server to bring

> the versions into synch, or am I experiencing some other sort of
problem?
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-- next part --
An HTML attachment was scrubbed...
URL:
http://lists.jboss.org/pipermail/rules-users/attachments/20110104/9374b2
49/attachment-0001.html 

--

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 50, Issue 11
***

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Guvnor - No function but rule containing it still validates

2011-01-04 Thread Rob Fisher
Using Guvnor 5.1.1

I've written a rule utilizing a function that does not exist within the
same package.  However, the rule still validates ok.  How is this
possible?  

Rob Fisher
Systems Analyst, Agency Awards
Desk 309-735-4136
Cell  309-660-4957


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Need help with Decision Table Conditions

2011-01-04 Thread Jason Mihalick

I have a decision table with the conditions shown in the graphic below.  When
Drools attempts to compile the spreadsheet I get the following errors:

nested exception is java.lang.RuntimeException: Unable to return Declaration
for identifier '$pgMeta' : [Rule name='Section Head Spacing_18']
Unable to create restriction '[VariableRestriction: == $pgMeta ]' for field
'pageMeta' in the rule 'Section Head Spacing_18' : [Rule name='Section Head
Spacing_18']
Unable to build expression for 'from' : [Error: Failed to compile: 2
compilation error(s):
 - (1,7) unqualified type in strict mode for: $pgMeta
 - (1,22) unable to resolve method using strict-mode:
java.lang.Object.getLineMetas()]
[Near : {... Unknown }]
 ^
[Line: 1, Column: 0] '$pgMeta.getLineMetas()' : [Rule name='Section Head
Spacing_18']

 
http://drools-java-rules-engine.46999.n3.nabble.com/file/n2195003/Picture_2.png 

The LHS of a hand-coded rule for this, is as follows:

when
$pageMeta :  PageMeta()
$bodyLines : LineMeta( pageMeta == $pageMeta, lineType == LineType.BODY
)
 from $pageMeta.getLineMetas()
$bodyLine :  LineMeta( previousPageMetaComponent != null,
   previousPageMetaComponent == previousLineMeta,
   previousLineMeta.lineType ==
LineType.SECTION_HEAD,
   verticalSpacingToPreviousPageMetaComponent <
5.9525 ) from $bodyLines
 
Can this rule be created in a Decision table or not?  Your help is most
appreciated!

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Need-help-with-Decision-Table-Conditions-tp2195003p2195003.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Knowledge Base and Guvnor

2011-01-04 Thread Dean Whisnant
Awesome, I was hoping there was a simple solution, but I just didn't see it in 
all the documents I've been through.  I'm starting out with my proof of concept 
by just coding like this and then will look more into ChangeSets as that sounds 
to be more in tuned to our application.

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Michael Anstis
Sent: Tuesday, January 04, 2011 3:31 AM
To: Rules Users List
Subject: Re: [rules-users] Knowledge Base and Guvnor

Hi,

You should be able to use the URL syntax with KnowledgeBuilder as follows:-

final String STANDARD_URL = 
"http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/standard/LATEST.drl";;
final String 
CUSTOMER_URL="http://your-guvnor-instance-host/org.drools.guvnor.Guvnor/package/customer/LATEST.drl";;

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

UrlResource standardUrlResource = 
(UrlResource)ResourceFactory.newUrlResource(STANDARD_URL);
standardUrlResource.setBasicAuthentication("enabled");
standardUrlResource.setUsername("xyz");
standardUrlResource.setPassword("abc");

UrlResource customerUrlResource = 
(UrlResource)ResourceFactory.newUrlResource(CUSTOMER_URL);
customerUrlResource.setBasicAuthentication("enabled");
customerUrlResource.setUsername("xyz");
customerUrlResource.setPassword("abc");

kbuilder.add( standardUrlResource, ResourceType.DRL);
kbuilder.add( customerUrlResource, ResourceType.DRL);

assertFalse( kbuilder.hasErrors() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

I don't think you'd need to (or want to) create two KnowledgeBases: You could 
ensure "standard" rules are applied first by any of Drools' agenda controls; 
i.e. salience, agenda-group or ruleflow; plus sharing a single KnowledgeBase 
ensures rules in both packages that share patterns are optimissed in the RETE 
network.

Use of ChangeSet could make things a little simpler too (rather than the 
individual UrlResources).

Cheers,

Mike
On 3 January 2011 20:03, Dean Whisnant mailto:d...@basys.com>> 
wrote:
Hi all, thank you for all the help in the past.

I'm to a point in my project of implementing Guvnor built packages into my java 
code that calls drools.

In the past I used the simple solution of building the knowledge agent on a 
.drl file as follows:

   //Setup the knowledge session for drools
   private static KnowledgeBase readKnowledgeBase() throws Exception {
   KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
   .newKnowledgeBuilder();
   
kbuilder.add(ResourceFactory.newClassPathResource("Standard837P.drl"),
   ResourceType.DRL);
   KnowledgeBuilderErrors errors = kbuilder.getErrors();
   if (errors.size() > 0) {
   for (KnowledgeBuilderError error : errors) {
   System.err.println(error);
   }
   throw new IllegalArgumentException("Could not parse 
knowledge.");
   }
   KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
   kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
   return kbase;
   }

A little background before the question.  My project includes one set of rules 
that are standard business logic, we'll call that STANDARD for now and one set 
of rules that any one of my 45 customers could have created, we'll call 
CUSTOMER, on our common guvnor server.  My java code knows which customer is 
running the app, so determining which two packages I want to fire is simple.  
The part that is not as straight forward for me is how I then I migrate using 
the guvnor urls in my above code.

I thought it would be as easy as to replace "Standard837P.drl" above with the 
STANDARD url and create a second add that would use the CUSTOMER url.

I also want all of my STANDARD rules applied before my CUSTOMER rules are 
applied.  This got me thinking that I need to have two independent knowledge 
bases running so that I fire all in the first and then fire all in the second.

Backing up a bit again, my application looks through an incoming file inserting 
facts into the knowledge base for one medical claim line item, fires rules, 
writes out results to a database, and then moves on to the next claim line item 
in the file.

1) What would the syntax need to be to implement the STANDARD and CUSTOMER urls?
2) Would I need to create two independent knowledge bases?
3) DO you see any performance issues in this arrangement?

Thank you!

Dean

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] using complex evaluate expressions with DSL

2011-01-04 Thread maverik j
Ohh ..that was tricky - I neeed to read this sincerely :)

thanks a ton for all your help and time 

Thanks & Regards,
Maverik

2011/1/4 Wolfgang Laun 

> You have omitted the regular expressions from some of the variable
> definitions
> in DSL entries:
>
> [when][] {attr:\S+} follows pattern {x:\S+} =
> startsWithFunction({attr},{x})
>
> Restore them all, and it's OK.
>
>
> -W
>
>
>
> 2011/1/4 maverik j 
>
>> Here is the complete DSL/DSLR
>>
>> DSLr:
>> rule "Your First Rule"
>>
>>  when
>> There is a Department
>> There is at least one Person
>> - with a valid subOrdinate
>> - check that name follows pattern "M"
>> then
>>>System.out.println("Test Generic Cosntranit done !!!");
>> end
>>
>> DSL:
>>  [keyword][]check that {conditions}= eval( {conditions} )
>> [keyword][]AND = &&
>> [keyword][]OR  = ||
>> [when][][Tt]here is an? {entity}= {entity}: {entity}()
>> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>> [when][]- with {attr} equal to {value} = {attr} == {value}
>> [when][]- with a valid {attr} = {attr} != null
>>
>> [when][]- with {attr} not equal to {value} = {attr} != {value}
>> [when][]- eval\( {whatever} \)= eval( {whatever} )
>> [when][] {attr} equals {value} = {attr}.equals({value})
>> [when][] {attr} is valid  =  {attr} != null
>> [when][] {attr} follows pattern {x} =  startsWithFunction({attr},{x})
>>
>> Function used in drl is:
>> function boolean startsWithFunction(String value, String beginning) {
>>  if (value == null) return false;
>>  if (beginning == null) return false;
>>  return value.startsWith(beginning);
>> }
>> I am using drools version 5.1.1
>>
>> Thanks & Regards,
>> -Maverik
>>
>> 2011/1/4 Wolfgang Laun 
>>
>>> Do you have any comments ("#..." or "//...") between when and then? If
>>> so, please remove and try again.
>>>
>>> If this doesn't fix it, please post completely and exactly
>>> - the rule from the DSLR
>>> - the full DSL
>>> - Drools version.
>>>
>>> Thanks
>>> -W
>>>
>>>
>>>
>>>
>>> 2011/1/4 maverik j 
>>>


 2011/1/4 Wolfgang Laun 


>
> 2011/1/4 maverik j 
>
>  is there any restriction in terms of using custom function in
>> condition etc.
>> If I add function evaluation to conditions its messing up with dsl.
>> For pattern matching if I use custom function defined in drl then its not
>> able to parse that properly
>>
>> [when][] {attr:\S+} follows pattern {pattern:\S+} =
>> funcToEvalPattern({attr},( {pattern} )
>>
>
> Is this exactly what you have in the DSL definition? It's syntactically
> incorrect.
>


>   Sorry for that, it is actually
>


>  [when][] {*attr*} follows pattern {pattern} = startsWithFunction( {*
> attr*}, {pattern} )
>>
>>  and is being added as last statement in DSL (for testing purpose I
>> am using same dsl as you have shown)
>>
>

>in this case it is getting translated to
>> exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
>> name, "I" ) ) )
>>  where as I was hoping this to be
>> exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
>> name, "I" ) ) )
>>
>>
>
> I cannot reproduce this. But it may depend on the order of your entries
> in you DSL file.
>
> Actually I tried changing order as well but didnt worked. I have
 actually defined these common functions in drl and added that to
 knowledgebase along with these DSL and DSLR.



>  -W
>
>
>
>> Regards,
>> -Maverik
>>
>> On Tue, Jan 4, 2011 at 12:24 PM, maverik j wrote:
>>
>>> cool...this was of great help, I will try this out I think it shoudl
>>> solve the purpose.
>>>
>>> Thanks once again,
>>> Maverik
>>>
>>> 2011/1/3 Wolfgang Laun 
>>>
>>> Try using eval as a last resort. A better (smaller, more robust) DSL
 can be designed around facts and their attributes.

 "||" (and "OR") can be used, but setting parentheses in order to get
 the priority right is difficult. In constraints, you may have to 
 resort to
 "memberof" or "not memberof".

 Your sample isn't self-contained. But I think that the following DSL
 and the DSLR might give you some ideas how to proceed.

 [keyword][]check that {conditions}= eval( {conditions} )
 [keyword][]AND = &&
 [keyword][]OR  = ||

 [when][][Tt]here is an? {entity}= {entity}: {entity}()
 [when][][Tt]here is at least one {entity}= exists {entity}:
 {entity}()

 [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()

 [when][]- with a valid {attr} = {attr}: {attr} != null
 [when][]- with {attr} not equal to {value} = {attr} != {value}
 [wh

Re: [rules-users] Subject: Drools Planner - Design Suggestions

2011-01-04 Thread ge0ffrey

Dont just schedule adds: also schedule reserve adds in a queue.
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Subject-Drools-Planner-Design-Suggestions-tp2169722p2196930.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools 5.1 JMX Monitoring.

2011-01-04 Thread Benson Fung
Hi ,

As I understand, Drools 5.1 made API enhancement to support JMX standard and
enables knowledge base and knowledge session monitoring and inspection using
any JMX console.
It also can display the average firing time.  How to implement this?  Is
there any sample for this?  Please advise.


Thanks
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users