Re: [rules-users] Call query from other query

2011-11-28 Thread Mark Proctor
The query is treated just like a pattern. ? indicates whether the query
should be materialised or not. In general if you aren't sure, then don't
include the ? and let it materialise.

The queries do not return any results, they are not functions. Like
patterns the resuls are returned from out variable bindings in the
parameters. The work in the same way that prolog predicates work, and you
can find tuns of literatore on that.

see  2.2.2.8 has a fair overview of this:
http://docs.jboss.org/drools/release/5.3.0.Final/droolsjbpm-introduction-docs/html/releaseNotes.html#d0e50

see 5.9 here:
http://docs.jboss.org/drools/release/5.3.0.Final/drools-expert-docs/html/ch05.html#d0e6233

This should work for your example:
query query1(List $facts)
   $facts := List() from collect( Fact( name == "name1" ) )
end

query query2
   query1($l;)
end

The above $l should join with the results of query1, as it's unbound and
thus an output variable.

Mark

On Mon, Nov 28, 2011 at 12:41 PM, Syargey  wrote:

> I read in Drools guide, that queries can now call other queries.
>
> But the guide doesn't give much details, mostly paying attention to a
> rather
> specific case.
>
> I have two queries having common parts and try to figure out how to  get
> rid
> of duplicate code.
>
> Here is the simplified form of queries I'd like to have:
> -
>
> query query1
>$facts: List()
>from collect( Fact( name == "name1" ) )
> end
>
> query query2
>$l: List()
>from collect( Fact( value == "1" ) from ?query1() )
> end
>
> -
>
> query2 syntax is invalid and and it is not clear for me how $facts from
> query1 can be accessed in query2.
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Call-query-from-other-query-tp3542082p3542082.html
> Sent from the Drools: User forum 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] Spring, KnowledgeAgent, and Guvnor

2011-11-28 Thread Mark Proctor
We'll be working on deployment next year that is not tied to specific
versions of drools. The reason for this is that the Packge is really just a
cached form representing the DRL, to avoid compiling drls on the client. We
actually just serialise the resulting objects. But internally we do a lot
of changes as we add features, so binary compatability of these cached
objects is not easily and cheapily possible.

In the future we hope to produec a simpler intermediary format that will be
durable across different versions of drools. It will require the clients to
do a bit more work, as it won't be as cheap as serialisation. But we hope
that it'll be an acceptable trade off.

Mark

On Mon, Nov 28, 2011 at 5:23 PM, paulB  wrote:

> Seems that upgrading my Guvnor install to match the version Drools in my
> project has done the trick to some extent.  Still dealing with some errors,
> but the original error has not presented itself.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Spring-KnowledgeAgent-and-Guvnor-tp3500761p3542830.html
> Sent from the Drools: User forum 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] Retrieving rule name in "then" clause

2011-11-28 Thread Davide Sottara
Actually, you can do 

/then
...
 drools.getRule().getName()
...
end/

"drools" is a reference to an instance implementing the KnowledgeHelper
interface.

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Retrieving-rule-name-in-then-clause-tp3543557p3543606.html
Sent from the Drools: User forum 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] Retrieving rule name in "then" clause

2011-11-28 Thread GPatel
not from the rule, but you can use an agenda listener for the same



From:   Ronald Albury 
To: rules-users@lists.jboss.org
Date:   11/28/2011 02:58 PM
Subject:[rules-users] Retrieving rule name in "then" clause
Sent by:rules-users-boun...@lists.jboss.org



Is there a simple way for me to be able to access the rule name in the 
'then' clause?
When rules fail I want to pass the rule name into my internal error 
handler.

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



-
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you ___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Retrieving rule name in "then" clause

2011-11-28 Thread Ronald Albury
Let me clarify in advance ... my rules are detecting errors in input data
... so when a rule fires it accesses my internal error handler.  I realize
that rules fire when they succeed, not when they fail.

On Mon, Nov 28, 2011 at 4:56 PM, Ronald Albury  wrote:

> Is there a simple way for me to be able to access the rule name in the
> 'then' clause?
> When rules fail I want to pass the rule name into my internal error
> handler.
>
> Thanks in advance
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Retrieving rule name in "then" clause

2011-11-28 Thread Ronald Albury
Is there a simple way for me to be able to access the rule name in the
'then' clause?
When rules fail I want to pass the rule name into my internal error handler.

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


Re: [rules-users] facts custom sort

2011-11-28 Thread Wolfgang Laun
You can simplify the query:

query "sortedItems"
 TreeMap( $values: values() )
   from accumulate( $f: Fact(),
  init( TreeMap map = new TreeMap(); ),
  action( map.put(factKey($f), $f); ),
  reverse( map.remove(factKey($f)); ),
  result( map ) )
end

-W


On 28 November 2011 10:58, Syargey  wrote:

> I don't want to sort facts outside of drools rules. The sorting is part of
> business requirements. My opinion is that is not a good thing to keep parts
> of business logic in different places.
>
> I spent some time to figure out how it is possible to sort a collection of
> facts and here is my solution:
> ---
> function String factKey(Fact f)
> {
>return String.format( "%010d~~%s~~%s", f.getRank(), f.getName(),
> f.getValue() );
> }
>
> query sortFactsQuery
>$factsMap: HashMap()
>from accumulate( $f: Fact(),
> init( HashMap map = new HashMap(); ),
>   action( map.put(factKey($f), $f); ),
>   reverse( map.remove(factKey($f)); ),
>   result( map ) )
>$sortedKeyList: TreeSet()
>from collect( String() from $factsMap.keySet() )
>$sortedFacts: List()
>from accumulate( $key: String() from $sortedKeyList,
>collectList( $factsMap.get( $key )
> ) )
> end
> ---
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/facts-custom-sort-tp3538410p3541805.html
> Sent from the Drools: User forum 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] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-28 Thread Vincent LEGENDRE
Tried to load my fusion package before any others. Same problem

- Mail original -

De: "Vincent LEGENDRE" 
À: "Rules Users List" 
Envoyé: Lundi 28 Novembre 2011 19:48:03
Objet: Re: [rules-users] Fusion : must declare @role(event) for all class 
hierarchy ?


Hi Edson, and thanks for answering

? - are the fact types (classes) in the same package or different packages?
Different packages. But I tried this on my little sample (put the sub-class in 
another package than the mother class), and this works

? - Are the declaration(s)/rules in the same file or different files?
Same file (DRL)

? - Are you using a single kbuilder to build the whole thing on your 
application or using different kbuilders?
? - Is the order in which you are loading the files into the kbuilder and the 
order you add packages in your kbase the same on your application and your test?
My kbase has a unique package, got from a single DRL file, built by a single 
(new) kbuilder.

But I use one kbuilder per package, only for build time, and I have other 
packages / kbases, for other rule sessions ...
Here I create 3 packages (and 3 kbases), using one new kbuilder for each. These 
3 packages don't have any fusion construction in them.
Then I build the 4th package / kbase, using one new kbuilder, and this is this 
package which contains some fusion rules.
Does kbuilders can collide in some way ? May be that as the 3 first package 
don't use any fusion, all the classes are tagged as "not event", kept 
somewhere, and reused in the 4th kbuilder, that only update the explicitely 
"event" classes ? I will try to load the fusion kb first to see what happend 
... but I am sceptic, as the 3 first package don't use the ***Event objects ...

There is another difference on my package build process.
My little test is built over the Hello World sample. My app uses more 
sophisticated way of getting resources, but finally calls the same 
kbuilder.add... magic method ...
The only difference is that :
- HelloWorld sample, and my little test, uses kbuilder.add( 
newClassPathResource(...) , ResourceType.DRL) to get resources that are located 
in a eclipse source folder
- My application uses kbuilder.add( newFileResource(...) , ResourceType.DRL) to 
fetch resources in the file system


I am quite sure that the difference cannot be here for real ... I guess that 
all of these methods finally result in opening a InputStream that contains DRL 
raw text to feed a parser, which don't care about how the inputStream was 
created ...

? - Also, which version of Drools are you using? Did you tried with latest 
snapshot from the 5.3.x branch or with master branch (5.4.x)?
5.3.Final official stable version. and before that the 5.2.Final version 
(problem is there too).
Did not tried with any "not official" version (I already experienced problem 
when migrating guvnor repos from candidates releases ...).




? - Any additional information you can give us might help us figure out the 
problem.
Ok. The problem here is that I can't provide you the full code, and anyway you 
won't go into this code for some mysterious bug ...
The two sub classes (InitEvent, and DisposeEvent) are very basic derivated 
classes. They only use "extends ChantierEvent" and nothing more (no interfaces).
They have a different constructor signature than their parent, but I also test 
that with my little sample and this is not the problem ...
These classes have attributes that links to other classes in the project. By 
transitivity, all business objects are loaded (by the class loader). These BO 
contains annotations for DB persistance (but they are attributes, the ***Event 
classes does not have any annotations).


I don't know what to add ...
I will go on testing a bit, and report back here.
Thanks !


___
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] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-28 Thread Vincent LEGENDRE
Hi Edson, and thanks for answering 

? - are the fact types (classes) in the same package or different packages? 
Different packages. But I tried this on my little sample (put the sub-class in 
another package than the mother class), and this works 

? - Are the declaration(s)/rules in the same file or different files? 
Same file (DRL) 

? - Are you using a single kbuilder to build the whole thing on your 
application or using different kbuilders? 
? - Is the order in which you are loading the files into the kbuilder and the 
order you add packages in your kbase the same on your application and your 
test? 
My kbase has a unique package, got from a single DRL file, built by a single 
(new) kbuilder. 

But I use one kbuilder per package, only for build time, and I have other 
packages / kbases, for other rule sessions ... 
Here I create 3 packages (and 3 kbases), using one new kbuilder for each. These 
3 packages don't have any fusion construction in them. 
Then I build the 4th package / kbase, using one new kbuilder, and this is this 
package which contains some fusion rules. 
Does kbuilders can collide in some way ? May be that as the 3 first package 
don't use any fusion, all the classes are tagged as "not event", kept 
somewhere, and reused in the 4th kbuilder, that only update the explicitely 
"event" classes ? I will try to load the fusion kb first to see what happend 
... but I am sceptic, as the 3 first package don't use the ***Event objects ... 

There is another difference on my package build process. 
My little test is built over the Hello World sample. My app uses more 
sophisticated way of getting resources, but finally calls the same kbuilder.add 
... magic method ... 
The only difference is that : 
- HelloWorld sample, and my little test, uses kbuilder.add( 
newClassPathResource(...) , ResourceType.DRL) to get resources that are located 
in a eclipse source folder 
- My application uses kbuilder.add( newFileResource(...) , ResourceType.DRL) to 
fetch resources in the file system 


I am quite sure that the difference cannot be here for real ... I guess that 
all of these methods finally result in opening a InputStream that contains DRL 
raw text to feed a parser, which don't care about how the inputStream was 
created ... 

? - Also, which version of Drools are you using? Did you tried with latest 
snapshot from the 5.3.x branch or with master branch (5.4.x)? 
5.3.Final official stable version. and before that the 5.2.Final version 
(problem is there too). 
Did not tried with any "not official" version (I already experienced problem 
when migrating guvnor repos from candidates releases ...). 




? - Any additional information you can give us might help us figure out the 
problem. 
Ok. The problem here is that I can't provide you the full code, and anyway you 
won't go into this code for some mysterious bug ... 
The two sub classes (InitEvent, and DisposeEvent) are very basic derivated 
classes. They only use "extends ChantierEvent" and nothing more (no 
interfaces). 
They have a different constructor signature than their parent, but I also test 
that with my little sample and this is not the problem .. . 
These classes have attributes that links to other classes in the project. By 
transitivity, all business objects are loaded (by the class loader). These BO 
contains annotations for DB persistance (but they are attributes, the ***Event 
classes does not have any annotations). 


I don't know what to add ... 
I will go on testing a bit, and report back here. 
Thanks ! 

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


Re: [rules-users] Unclear error when rule name missing

2011-11-28 Thread Wolfgang Laun
2011/11/28 Ronald Albury 

> I guess I need to learn how to submit bugs.  Any help is appreciated.
>

For starters, you can look at
http://www.atlassian.com/software/jira/overview and study some examples at
https://jira.jboss.org/browse/JBRULES.



> If you forget the name of the rule, instead of a clear error (like "Rule
> name missing") you get a NullPointerException with no indication why.
>

A lot is lacking for this to be a usable bug report: no version; no stack
dump; no complete (minimal) example to reproduce the bug.

-W


>
> Thanks
>
> ___
> 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] duration attribute & other rule language features issue

2011-11-28 Thread Wolfgang Laun
It seems that a full definition of the semantics of @expires is still
missing from the Fusion manual.

"After that time, assuming no rule *still needs the event*, the engine will
expire and remove the event from the session automatically." (Emphasis by
me.)

So, when does a rule "need an event"? This is a very iffy definition.

Consider:
   when
  Event()
   then
This rule certainly "needs" an Event fact, but does it still need it after
the first firing? Not unless Event() is modified, which might happen
elsewhere.

In the case of a timer() being added to a rule, there is a similar dilemma.
A rule like
  rule
timer(int: 5s)
  when
Event()
  then
does and, simultaneously does not, "need" an Event() fact. If Event() is
retracted after less than 5s, the rule should not fire - so the rule does
not "need" the fact. OTOH, its timed firing depends on the presence of an
Event() - so the rule "needs" the fact.

You can easily thwart the algorithm that determines "is needed":

rule "check timer attribute"
timer (int: 5s 1s)
when
$alert : Object( eval($alert instanceof Alert) ) from entry-point
"EventStream"
then
 System.out.println( ((Alert)$alert).getId() +
" time: " +
(Calendar.getInstance().getTimeInMillis()));
end

-W



On 28 November 2011 07:32, prashant.badhe  wrote:

> Here is the complete rule that we trying out with 'timer' & '@expires' :
>
> ~
> package xyz;
>
> import abc.Alert;
> import abc.CResult;
>
> import java.util.regex.Matcher;
> import java.util.regex.Pattern;
> import java.util.ArrayList;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.Date;
> import java.util.Calendar;
> import java.util.Timer;
>
> declare Alert
>@role( event )
>@expires( 30s )
> end
>
> declare CResult
>@role( event )
>@expires( 30s )
> end
>
> rule "check timer attribute"
>agenda-group "xyz"
>auto-focus true
>no-loop
>salience 140
>   timer (int: 5s)
>//duration ( 5s )
>
>when
>$alert : Alert( $alertId:id ) from entry-point "EventStream"
>then
>System.out.println("Inside RHS...[alert=" + $alert.getId()
> + "]
> [Time: " + (Calendar.getInstance().getTimeInMillis()));
>
> end
> ~
>
> We are trying this out on Drools 5.3.0 stateful knowledge session operating
> in stream mode.
>
> The above rule is not firing on inserting Alert fact. If I comment line
> 'timer (int: 5s 5s)' then it starts firing.
>
> About the @expires, our assumption is Alert fact inserted is not expiring,
> as the count returned by getFactCount() on WM entrypoint object is returned
> as 1 even after a thread sleep of more than 60 seconds post the rule
> firing.
>
> Please correct us if this assumption is wrong or something more is required
> for @expires to work. Similarly for timer(int: 5s) let us know what is
> wrong.
>
> Does the facts that are expired remains in WM but are not evaluated for any
> new facts/rules inserted in WM OR they are removed from WM?
>
> -Prashant
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.html
> Sent from the Drools: User forum 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] Spring, KnowledgeAgent, and Guvnor

2011-11-28 Thread paulB
Seems that upgrading my Guvnor install to match the version Drools in my
project has done the trick to some extent.  Still dealing with some errors,
but the original error has not presented itself.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Spring-KnowledgeAgent-and-Guvnor-tp3500761p3542830.html
Sent from the Drools: User forum 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] Unclear error when rule name missing

2011-11-28 Thread Ronald Albury
I guess I need to learn how to submit bugs.  Any help is appreciated.

If you forget the name of the rule, instead of a clear error (like "Rule
name missing") you get a NullPointerException with no indication why.

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


Re: [rules-users] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-28 Thread Edson Tirelli
   Vincent,

   It seems it is a merging problem on declarations, but unfortunately, the
exceptions you are seeing are the symptoms, not the cause, so I can't infer
much from them.

   Some suggestions to try to isolate the problem: are the fact types
(classes) in the same package or different packages? Are the
declaration(s)/rules in the same file or different files? Are you using a
single kbuilder to build the whole thing on your application or using
different kbuilders? Is the order in which you are loading the files into
the kbuilder and the order you add packages in your kbase the same on your
application and your test?

   These are some of the conditions that trigger declaration merges. I know
it is not much, but try checking these things... maybe you get lucky and
manage to reproduce the problem so that we can debug it and fix it.

   Also, which version of Drools are you using? Did you tried with latest
snapshot from the 5.3.x branch or with master branch (5.4.x)?

   Any additional information you can give us might help us figure out the
problem.

   Thanks,
 Edson

On Mon, Nov 28, 2011 at 11:01 AM, Vincent LEGENDRE <
vincent.legen...@eurodecision.com> wrote:

> Well, after trying and trying to reproduce with a simpler case, @role is
> always correctly inherited.
> But in my application, it seems not, or may be it is another problem.
>
> I have 3 classes : ChantierEvent (the main mother class) and its 2
> subClasses : InitEvent and DisposeEvent
> When I declare @role(event) for all 3 classes, everything works wells
> When I only declare for the motherclass, this exception is raised (at
> insertion of a InitEvent) :
> java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot
> be cast to org.drools.common.EventFactHandle
>at
> org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:316)
>at
> org.drools.rule.VariableRestriction.isAllowedCachedRight(VariableRestriction.java:122)
>at
> org.drools.rule.VariableConstraint.isAllowedCachedRight(VariableConstraint.java:121)
>at
> org.drools.common.TripleBetaConstraints.isAllowedCachedRight(TripleBetaConstraints.java:208)
>at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:158)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
>at
> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
>at
> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
>at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
>at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
>at
> org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
> --> call of insert(new InitEvent(...));
>at
> com.sncf.morse.server.MVFusionThreadSession.addEvent(MVFusionThreadSession.java:158)
>
>
> I first think about a problem on "after" operator, so I commented out the
> rule that uses it, and this error is raised then (I also use sliding
> windows) :
> java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot
> be cast to org.drools.common.EventFactHandle
>at
> org.drools.rule.SlidingTimeWindow.updateNextExpiration(SlidingTimeWindow.java:211)
>at
> org.drools.rule.SlidingTimeWindow.assertRightTuple(SlidingTimeWindow.java:128)
>at
> org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:84)
>at org.drools.reteoo.NotNode.assertObject(NotNode.java:114)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
>at
> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
>at
> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
>at
> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
>at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
>at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
>at
> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
>at
> org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
> --> call of insert(new InitEvent(...));
>at
> com.sncf.morse.server.MVFusionThreadSession.addEvent(MVFusionThreadSession.java:158)
>
>
> Do you have any ideas on why this could

Re: [rules-users] Guvnor hates me

2011-11-28 Thread Ronald Albury
Thanks Michael ... you've been very helpful.

Yes, I am considering helping out on the documentation (my undergrad is in
Instructional Technology) ... if I can ever figure out how all of this
works.  I have also read thru some of the 3rd party books on the subject,
and I find them quite lacking also.  I am not a dumb person, and I am not
inexperienced (been programming since 1980) ... so either I am just having
issues with the writing style of the manuals/books, or other people are
having trouble with them as well.


While we're waiting for an eclipse person to speak up, I have another
eclipse question.  If I do a Project->Build All, I can see the errors in my
rule files.  How can I configure eclipse to see the drl errors when I save
the files (as happens with my Java files).

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


Re: [rules-users] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-28 Thread Vincent LEGENDRE
Well, after trying and trying to reproduce with a simpler case, @role is always 
correctly inherited.
But in my application, it seems not, or may be it is another problem.

I have 3 classes : ChantierEvent (the main mother class) and its 2 subClasses : 
InitEvent and DisposeEvent
When I declare @role(event) for all 3 classes, everything works wells
When I only declare for the motherclass, this exception is raised (at insertion 
of a InitEvent) :
java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be 
cast to org.drools.common.EventFactHandle
at 
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:316)
at 
org.drools.rule.VariableRestriction.isAllowedCachedRight(VariableRestriction.java:122)
at 
org.drools.rule.VariableConstraint.isAllowedCachedRight(VariableConstraint.java:121)
at 
org.drools.common.TripleBetaConstraints.isAllowedCachedRight(TripleBetaConstraints.java:208)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:158)
at 
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
at 
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at 
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at 
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
 --> call of insert(new InitEvent(...));
at 
com.sncf.morse.server.MVFusionThreadSession.addEvent(MVFusionThreadSession.java:158)


I first think about a problem on "after" operator, so I commented out the rule 
that uses it, and this error is raised then (I also use sliding windows) :
java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be 
cast to org.drools.common.EventFactHandle
at 
org.drools.rule.SlidingTimeWindow.updateNextExpiration(SlidingTimeWindow.java:211)
at 
org.drools.rule.SlidingTimeWindow.assertRightTuple(SlidingTimeWindow.java:128)
at 
org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:84)
at org.drools.reteoo.NotNode.assertObject(NotNode.java:114)
at 
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
at 
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at 
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at 
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
 --> call of insert(new InitEvent(...));
at 
com.sncf.morse.server.MVFusionThreadSession.addEvent(MVFusionThreadSession.java:158)


Do you have any ideas on why this could happend ?
In what case the role could not be inherited (I tried to make my minimal sample 
class look like the real one, but I can't reproduce ..).

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


Re: [rules-users] RuleFlow WorkItem check for abort

2011-11-28 Thread Quevedo
Hi Cherokee,

To answer your first question you can check the state of a workitem in its
onExit action by:

import org.jbpm.workflow.instance.node.WorkItemNodeInstance
import org.drools.runtime.process.WorkItem


WorkItem workItem =
((WorkItemNodeInstance)kcontext.getNodeInstance()).getWorkItem();
System.out.println("State of the workitem " + workItem.getName() + " on exit
is " + workItem.getState());

I hope it could be useful.

Quevedo

--
View this message in context: 
http://drools.46999.n3.nabble.com/RuleFlow-WorkItem-check-for-abort-tp2778938p3542291.html
Sent from the Drools: User forum 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] drools-spring dependency on drools-grid-impl

2011-11-28 Thread kennywest
Done:
https://issues.jboss.org/browse/JBRULES-3299

The dummy classes and interfaces I'm using are also included.

--
View this message in context: 
http://drools.46999.n3.nabble.com/drools-spring-dependency-on-drools-grid-impl-tp3541271p3542201.html
Sent from the Drools: User forum 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] drools-spring dependency on drools-grid-impl

2011-11-28 Thread Mauricio Salatino
Yes we can do that pretty quickly. It was in that way in the past but
now with the new refactorings it becomes a single module again.


On Mon, Nov 28, 2011 at 6:23 AM, Geoffrey De Smet
 wrote:
> Hi Kenny,
>
>> extract the grid classes that drools-spring is dependent on out into a 
>> drools-grid artifact that instead of depending on the full impl
> Can you file a JIRA for this issue?
> http://issues.jboss.org -> JBRULES
>
> Op 28-11-11 10:11, kennywest schreef:
>> I resolved this by simply removing the jar and add dummy implementations in
>> my own project for the required classes that are in drools-grid-impl. This
>> is not pretty, but it works :)
>>
>> --
>> View this message in context: 
>> http://drools.46999.n3.nabble.com/drools-spring-dependency-on-drools-grid-impl-tp3541271p3541726.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> --
> With kind regards,
> Geoffrey De Smet
>
>
> ___
> 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.jugargentina.org
 - 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


[rules-users] Call query from other query

2011-11-28 Thread Syargey
I read in Drools guide, that queries can now call other queries.

But the guide doesn't give much details, mostly paying attention to a rather
specific case.

I have two queries having common parts and try to figure out how to  get rid
of duplicate code.

Here is the simplified form of queries I'd like to have:
-

query query1
$facts: List()
from collect( Fact( name == "name1" ) )
end

query query2
$l: List()
from collect( Fact( value == "1" ) from ?query1() )
end

-

query2 syntax is invalid and and it is not clear for me how $facts from
query1 can be accessed in query2.


--
View this message in context: 
http://drools.46999.n3.nabble.com/Call-query-from-other-query-tp3542082p3542082.html
Sent from the Drools: User forum 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] facts custom sort

2011-11-28 Thread Syargey
I don't want to sort facts outside of drools rules. The sorting is part of
business requirements. My opinion is that is not a good thing to keep parts
of business logic in different places.

I spent some time to figure out how it is possible to sort a collection of
facts and here is my solution:
---
function String factKey(Fact f) 
{
return String.format( "%010d~~%s~~%s", f.getRank(), f.getName(),
f.getValue() );
}

query sortFactsQuery
$factsMap: HashMap()
from accumulate( $f: Fact(),
 init( HashMap map = new HashMap(); ),
   action( map.put(factKey($f), $f); ),
   reverse( map.remove(factKey($f)); ),
   result( map ) )
$sortedKeyList: TreeSet() 
from collect( String() from $factsMap.keySet() )
$sortedFacts: List()
from accumulate( $key: String() from $sortedKeyList,
collectList( $factsMap.get( $key ) ) )
end
---

--
View this message in context: 
http://drools.46999.n3.nabble.com/facts-custom-sort-tp3538410p3541805.html
Sent from the Drools: User forum 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] drools-spring dependency on drools-grid-impl

2011-11-28 Thread Geoffrey De Smet
Hi Kenny,

> extract the grid classes that drools-spring is dependent on out into a 
> drools-grid artifact that instead of depending on the full impl
Can you file a JIRA for this issue?
http://issues.jboss.org -> JBRULES

Op 28-11-11 10:11, kennywest schreef:
> I resolved this by simply removing the jar and add dummy implementations in
> my own project for the required classes that are in drools-grid-impl. This
> is not pretty, but it works :)
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/drools-spring-dependency-on-drools-grid-impl-tp3541271p3541726.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

-- 
With kind regards,
Geoffrey De Smet


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


Re: [rules-users] drools-spring dependency on drools-grid-impl

2011-11-28 Thread kennywest
I resolved this by simply removing the jar and add dummy implementations in
my own project for the required classes that are in drools-grid-impl. This
is not pretty, but it works :)

--
View this message in context: 
http://drools.46999.n3.nabble.com/drools-spring-dependency-on-drools-grid-impl-tp3541271p3541726.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users