[rules-users] Events facts in process constraints

paulB paul.borlin at sironahealth.com
Thu Feb 4 16:12:34 EST 2010


Hi,

I am starting out with RuleFlow this week.  I have created a flow that uses
rules I had created in the past.  The issue began when I tried to define a
Rule Constraint for a Split.  The Fact I am referencing in that Rule
Constraint is defined as an Event fact in my rules file.   When I attempt to
insert the fact into WorkingMemory (using ksession.insert(object);), I get
the error below.   It appears to me that the fact is being inserted as
"default" fact, but somewhere along the chain it's interpreted as an Event
fact? Is this conflicts in the process' definition of the fact to the rule's
definition?  Did I miss some tie-up between the rules and process? Is there
a way in the process to declare a fact as an event? Thanks!


Using Drools 5.0


RULE FILE SNIPPET:
package PostEventProcessor
...
import com.company.TrxQueueIn
...
declare TrxQueueIn
   @role( event )
   @timestamp( releaseTime )
end
...



RULE FLOW SNIPPET:

<?xml version="1.0" encoding="UTF-8"?> 
<process xmlns="http://drools.org/drools-5.0/process"
         xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
         xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
         type="RuleFlow" name="Post Event Processor post event"
id="PEPpostEvent" package-name="PostEventProcessor" >

  <header>
    <imports>
      <import name="org.drools.runtime.process.WorkflowProcessInstance" />
      <import name="com.company.TrxSurvey" />
      <import name="com.company.TrxQueueIn" />
    </imports>
    <variables>
      <variable name="SurveyComplete" >
        <type
name="org.drools.process.core.datatype.impl.type.BooleanDataType" />
        <value>false</value>
      </variable>
      <variable name="MaxAttempts" >
        <type
name="org.drools.process.core.datatype.impl.type.BooleanDataType" />
        <value>false</value>
      </variable>
      <variable name="trxDetail" >
        <type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="com.sironahealth.database.intelliview.domain.TrxDetail" />
      </variable>
      <variable name="SurveyFlow" >
        <type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
      </variable>
    </variables>
  </header>

  <nodes>
    <start id="1" name="Start" x="137" y="16" width="80" height="40" />
    <ruleSet id="2" name="Max Attempts" x="137" y="88" width="80"
height="40" ruleFlowGroup="MaxAttempts" />
    <ruleSet id="3" name="Reason Actions" x="54" y="232" width="117"
height="40" ruleFlowGroup="ReasonActions" />
    <subProcess id="4" name="Next Survey" x="406" y="585" width="129"
height="40" processId="PEPSurevysBIO" >
      <mapping type="in" from="trxDetail" to="trxDetail" />
    </subProcess>
    <split id="5" name="Survey Completed?" x="211" y="392" width="141"
height="40" type="2" >
      <constraints>
        <!-- THIS IS THE CONSTRAINT THAT GIVES ME PROBLEMS - SECOND LINE OF
RULE -->
        <constraint toNodeId="10" toType="DROOLS_DEFAULT" name="Survey
Completed" priority="1" type="rule" dialect="mvel" >processInstance :
WorkflowProcessInstance()
TrxQueueIn(queueStatus == "CLO", trxDetail ==
(processInstance.getVariable("trxDetail"))) </constraint>
        <constraint toNodeId="6" toType="DROOLS_DEFAULT" name="Survey Not
Complete" priority="2" type="rule" dialect="mvel" >eval(true)</constraint>
      </constraints>
    </split>
    <end id="6" name="End" x="182" y="503" width="80" height="40" />
    <end id="7" name="End" x="430" y="657" width="80" height="40" />
    <end id="8" name="End" x="279" y="238" width="80" height="40" />
    <split id="9" name="Max Attempts?" x="124" y="160" width="106"
height="40" type="2" >
      <constraints>
        <constraint toNodeId="8" toType="DROOLS_DEFAULT" name="Maxed"
priority="1" type="code" dialect="java" >return MaxAttempts;</constraint>
        <constraint toNodeId="3" toType="DROOLS_DEFAULT" name="Not Maxed"
priority="1" type="code" dialect="java" >return !MaxAttempts;</constraint>
      </constraints>
    </split>
    <actionNode id="10" name="Action" x="430" y="513" width="80" height="40"
>
        <action type="expression" dialect="java" >SurveyFlow =
"PEPSurevysBIO";</action>
    </actionNode>
    <split id="11" name="Is Survey?" x="73" y="315" width="80" height="40"
type="2" >
      <constraints>
        <constraint toNodeId="12" toType="DROOLS_DEFAULT" name="Not a
survey" priority="2" type="rule" dialect="mvel" >eval(true)</constraint>
        <constraint toNodeId="5" toType="DROOLS_DEFAULT" name="Surveyed"
priority="1" type="rule" dialect="mvel" >processInstance :
WorkflowProcessInstance()
TrxSurvey(trxDetail == (processInstance.getVariable("trxDetail"))
)</constraint>
      </constraints>
    </split>
    <end id="12" name="End" x="18" y="396" width="80" height="40" />
  </nodes>

  <connections>
    <connection from="1" to="2" />
    <connection from="9" to="3" bendpoints="[113,179]" />
    <connection from="10" to="4" />
    <connection from="11" to="5" bendpoints="[280,335]" />
    <connection from="5" to="6" bendpoints="[]" />
    <connection from="4" to="7" />
    <connection from="9" to="8" bendpoints="[317,181]" />
    <connection from="2" to="9" />
    <connection from="5" to="10" bendpoints="[467,412]" />
    <connection from="3" to="11" />
    <connection from="11" to="12" bendpoints="[59,335]" />
  </connections>

</process>






STACK TRACE:

java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be
cast to org.drools.common.EventFactHandle
	at
org.drools.rule.SlidingTimeWindow.updateNextExpiration(SlidingTimeWindow.java:192)
	at
org.drools.rule.SlidingTimeWindow.assertRightTuple(SlidingTimeWindow.java:119)
	at
org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:87)
	at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:153)
	at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
	at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:344)
	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
	at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:360)
	at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:337)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
	at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
	at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
	at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
	at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
	at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:216)
-- 
View this message in context: http://n3.nabble.com/Events-facts-in-process-constraints-tp187826p187826.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list