Flow variables not getting updated when fact changes in rule node
by Todd Pagni
I am seeing a problem in the latest stable build 12/27 andn 1/26 where a
flow variable does not get updates from a facts updated in a rule node
in the flow. Both the flow variable and the fact are initially the same
object instance, but It looks like the flow variable gets a cloned
instance after the rule node.
I am inserting 1 fact and running a flow with a debug node, a rule node,
a debug node, and a human task. As you can see below the hashcode
changes for the flow variable after the rule node, but retains the user
value set earlier in the flow. After the rule node the user should be
myuser which is set in the rule, but instead has the value bogus, which
is set in the first debug node.
Is anyone else seeing similar issues in drools flow? This is happening
when we run in JBoss 5.1. This is a blocking issue that makes drools
flow unusable for us, so any help you can provide is appreciated.
Debug:
15:00:31,985 INFO [STDOUT] ******** flowApproval hashcode at fact
insert:18886777
15:00:31,985 INFO [STDOUT] Hibernate: insert into ProcessInstanceInfo
(externalVariables, lastModificationDate, lastReadDate, processId,
processInstanceByteArray, startDate, state, OPTLOCK) values (?, ?, ?, ?,
?, ?, ?, ?)
15:00:31,985 INFO [STDOUT] ******** first flow node, hashcode: 18886777
user: null
15:00:31,985 INFO [STDOUT] ******** first flow node after approver set
to bogus, hashcode: 18886777 user: bogus
15:00:32,000 INFO [STDOUT] Hibernate: update ProcessInstanceInfo set
externalVariables=?, lastModificationDate=?, lastReadDate=?,
processId=?, processInstanceByteArray=?, startDate=?, state=?, OPTLOCK=?
where processInstanceId=? and OPTLOCK=?
15:00:32,000 INFO [STDOUT] Hibernate: insert into
ProcessInstanceInfo_eventTypes (ProcessInstanceInfo_processInstanceId,
element) values (?, ?)
15:00:32,000 INFO [STDOUT] Hibernate: update SessionInfo set dirty=?,
lastModificationDate=?, rulesByteArray=?, startDate=? where id=?
15:00:32,000 INFO [STDOUT] ******** in rule node setting approver to
enduser, hashcode: 18886777 user: myuser
15:00:32,000 INFO [STDOUT] Hibernate: select
processins0_.processInstanceId as col_0_0_ from ProcessInstanceInfo
processins0_ where ? in (select eventtypes1_.element from
ProcessInstanceInfo_eventTypes eventtypes1_ where
processins0_.processInstanceId=eventtypes1_.ProcessInstanceInfo_processI
nstanceId)
15:00:32,000 INFO [STDOUT] Hibernate: select
processins0_.processInstanceId as processI1_149_0_,
processins0_.externalVariables as external2_149_0_,
processins0_.lastModificationDate as lastModi3_149_0_,
processins0_.lastReadDate as lastRead4_149_0_, processins0_.processId as
processId149_0_, processins0_.processInstanceByteArray as
processI6_149_0_, processins0_.startDate as startDate149_0_,
processins0_.state as state149_0_, processins0_.OPTLOCK as OPTLOCK149_0_
from ProcessInstanceInfo processins0_ where
processins0_.processInstanceId=?
15:00:32,016 INFO [STDOUT] ******** after rule node, hashcode:15392910
user: bogus
Rule:
dialect "mvel"
rule "Assign Initial Approver"
ruleflow-group "approver"
no-loop
when
$flow : com.datacert.FlowApproval()
then
modify( $flow ) { setLastapprover( 'myuser' ) };
System.out.println("******** in rule node setting approver
to enduser, hashcode: " + $flow.hashCode() + " user: " +
$flow.getLastapprover());
end
Flow:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://schema.omg.org/spec/BPMN/2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://schema.omg.org/spec/BPMN/2.0
BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
xmlns:tns="http://www.jboss.org/drools">
<itemDefinition id="entityIdItem" structureRef="java.lang.Object" />
<itemDefinition id="entityItem" structureRef="java.lang.Object" />
<itemDefinition id="flowApprovalItem" structureRef="java.lang.Object"
/>
<resource id="Actor" name="Human Actor" />
<process id="com.datacert.workflow.Base" name="approval" >
<!-- process variables -->
<property id="entityId" itemSubjectRef="tns:entityIdItem"/>
<property id="entity" itemSubjectRef="tns:entityItem"/>
<property id="flowApproval" itemSubjectRef="tns:flowApprovalItem"/>
<!-- nodes -->
<endEvent id="_2" name="End" g:x="564" g:y="16" g:width="48"
g:height="48" />
<userTask id="_4" name="Human Task" g:x="432" g:y="16" g:width="100"
g:height="48" >
<ioSpecification>
<dataInput id="_4_CommentInput" name="Comment" />
<dataInput id="_4_TaskNameInput" name="TaskName" />
<dataInput id="_4_ContentInput" name="Content" />
<inputSet>
<dataInputRefs>_4_CommentInput</dataInputRefs>
<dataInputRefs>_4_TaskNameInput</dataInputRefs>
<dataInputRefs>_4_ContentInput</dataInputRefs>
</inputSet>
<outputSet>
</outputSet>
</ioSpecification>
<property id="_4_Comment" />
<property id="_4_TaskName" />
<property id="_4_Content" />
<dataInputAssociation>
<assignment>
<from xs:type="tFormalExpression">workitem</from>
<to xs:type="tFormalExpression">_4_CommentInput</to>
</assignment>
<sourceRef>_4_Comment</sourceRef>
<targetRef>_4_CommentInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<assignment>
<from xs:type="tFormalExpression">Human Task</from>
<to xs:type="tFormalExpression">_4_TaskNameInput</to>
</assignment>
<sourceRef>_4_TaskName</sourceRef>
<targetRef>_4_TaskNameInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<assignment>
<from xs:type="tFormalExpression">#{entityId}</from>
<to xs:type="tFormalExpression">_4_ContentInput</to>
</assignment>
<sourceRef>_4_Content</sourceRef>
<targetRef>_4_ContentInput</targetRef>
</dataInputAssociation>
<potentialOwner resourceRef="tns:Actor" >
<resourceAssignmentExpression>
<formalExpression>#{flowApproval.getLastapprover()}</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>
<scriptTask id="_6" name="After Rule" g:x="320" g:y="16"
g:width="80" g:height="48" >
<script>System.out.println("******** after rule node, hashcode:" +
flowApproval.hashCode() + " user: " +
flowApproval.getLastapprover());</script>
</scriptTask>
<startEvent id="_1" name="StartProcess" g:x="16" g:y="16"
g:width="48" g:height="48" />
<businessRuleTask id="_3" name="Rule" g:x="208" g:y="16"
g:width="80" g:height="48" g:ruleFlowGroup="approver" />
<scriptTask id="_7" name="Before Rule" g:x="96" g:y="16"
g:width="80" g:height="48" >
<script>System.out.println("******** first flow node, hashcode: "
+ flowApproval.hashCode() + " user: " + flowApproval.getLastapprover());
flowApproval.setLastapprover("bogus");
System.out.println("******** first flow node after approver set to
bogus, hashcode: " + flowApproval.hashCode() + " user: " +
flowApproval.getLastapprover());</script>
</scriptTask>
<!-- connections -->
<sequenceFlow sourceRef="_4" targetRef="_2" />
<sequenceFlow sourceRef="_6" targetRef="_4" />
<sequenceFlow sourceRef="_3" targetRef="_6" />
<sequenceFlow sourceRef="_7" targetRef="_3" />
<sequenceFlow sourceRef="_1" targetRef="_7" />
</process>
</definitions>
Most Code:
package com.datacert;
import groovy.lang.GroovyClassLoader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.log4j.Level;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.SessionConfiguration;
import org.drools.SystemEventListenerFactory;
import org.drools.base.MapGlobalResolver;
import org.drools.bpmn2.xml.BPMNSemanticModule;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.persistence.jpa.JPAKnowledgeService;
import org.drools.process.workitem.wsht.CommandBasedWSHumanTaskHandler;
import org.drools.runtime.Environment;
import org.drools.runtime.EnvironmentName;
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessInstance;
import org.drools.runtime.process.WorkItemManager;
import org.drools.task.service.MinaTaskServer;
import org.drools.task.service.TaskService;
import com.arjuna.ats.jta.TransactionManager;
public class FlowService {
private static final String FLOW_SERVICE_URL =
"flow.service.url";
private static final String FLOW_SERVICE_LOCATION =
"flow.service.location";
private TaskService taskService;
private MinaTaskServer server;
private EntityManagerFactory taskServerEntityManagerFactory;
public void startWorkflow() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("entityId", 22);
parameters.put("flowApproval", new FlowApproval());
KnowledgeBase kbase = getKnowledgeBase("approval.bpmn",
"approval.drl");
StatefulKnowledgeSession ksession = getSession(kbase);
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
registerHumanTaskHandler(ksession);
ksession.insert(parameters.get("flowApproval"));
System.out.println("******** flowApproval hashcode at fact
insert:" + parameters.get("flowApproval").hashCode());
ProcessInstance pi =
ksession.startProcess("com.datacert.workflow.Base", parameters);
ksession.fireAllRules();
}
private ClassLoader getClassLoader() {
GroovyClassLoader gcl = new GroovyClassLoader();
gcl.addClasspath("c:\\temp\\");
return gcl;
}
private Environment getEnvironment() {
Environment env = KnowledgeBaseFactory.newEnvironment();
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
InitialContext ctx = null;
try {
ctx = new InitialContext();
} catch (NamingException e) {
System.err.println(e);
}
env.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManager.transactionManager(ctx));
return env;
}
private KnowledgeBase getKnowledgeBase(String xmlFileName, String
ruleFileName) {
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null,
getClassLoader());
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(getKnowledgeBuilder(xmlFileName,
ruleFileName).getKnowledgePackages());
return kbase;
}
private KnowledgeBuilder getKnowledgeBuilder(String xmlFileName,
String ruleFileName) {
Thread.currentThread().setContextClassLoader(getClassLoader());
System.setProperty("drools.dialect.mvel.strict", "false");
KnowledgeBuilderConfiguration conf =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
getClassLoader());
((PackageBuilderConfiguration) conf).initSemanticModules();
((PackageBuilderConfiguration) conf).addSemanticModule(new
BPMNSemanticModule());
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(conf);
kbuilder.add(ResourceFactory.newClassPathResource("approval.bpmn"),
ResourceType.DRF);
kbuilder.add(ResourceFactory.newClassPathResource("approval.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.");
}
return kbuilder;
}
private StatefulKnowledgeSession getSession(int sessionId,
KnowledgeBase kbase) {
return
JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase,
getSessionConfig(), getEnvironment());
}
private StatefulKnowledgeSession getSession(KnowledgeBase kbase) {
return JPAKnowledgeService.newStatefulKnowledgeSession(kbase,
getSessionConfig(), getEnvironment());
}
private KnowledgeSessionConfiguration getSessionConfig() {
SessionConfiguration c = new SessionConfiguration();
c.setClassLoader(getClassLoader());
return c;
}
private void registerHumanTaskHandler(StatefulKnowledgeSession
ksession) {
CommandBasedWSHumanTaskHandler approveTask = new
CommandBasedWSHumanTaskHandler(ksession);
WorkItemManager wm = ksession.getWorkItemManager();
wm.registerWorkItemHandler("Human Task", approveTask);
}
}
Thanks,
Todd
15 years, 11 months
incompatible error
by Sikkandar Nawabjan
Hi,
Am using drools 5 and am getting following error when I do packaging the
drl and dsls
org.drools.base.SalienceInteger incompatible with org.drools.rule.Rule
what could be the reason?
Thanks
sikkandar
15 years, 11 months
Does rule execution block when the Knowlege Agent is rebuild KnowlegeBase???
by Wing
Hello Drools User,
I am using Knowlege Agent to monitor changes in the repository. I have
started the following services:
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
I was able to change the rules in the repository and the changes did get
pick up in my application and everything is working fine as expected.
However, I have a question regarding rule execution when the Knowlege Base
is in the middle of being build by the Knowlege Agent. What happen when I
execute the rules using:
ksessionStateless = knowledgeAgent.newStatelessKnowledgeSession();
ksessionStateless.execute(ObjList);
Will the method ksessionStateless.execute(ObjList) block and wait until the
Knowlege Base is finish being build by the knowledge agent or the method
won't block and just pick up the old Knowlege Base and then switch to the
new knowlege base when the knowlege agent is finish building it? Will the
method ksessionStateless.execute(ObjList) block or not block?
thanks very much in advace for any help on this!
Wing Tang
--
View this message in context: http://n3.nabble.com/Does-rule-execution-block-when-the-Knowlege-Agent-is...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
ConsequenceException when retract from entry point
by jschmied
Hi!
I have
rule "test 3"
when
$t : My_Type() from entry-point "NM"
then
entryPoints["NM"].retract($t)
end
I get a:
org.drools.runtime.rule.ConsequenceException: rule: test 3
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:981)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:918)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1130)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:739)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:705)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:200)
at com.sample.ProcessTest.main(ProcessTest.java:97)
Caused by: [Error: unable to resolve method:
org.drools.common.NamedEntryPoint.retract(my.package.My_Type) [arglength=1]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:905)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:315)
at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:138)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:133)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
at org.mvel2.MVEL.executeExpression(MVEL.java:995)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:87)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:972)
... 6 more
what can I do?
Thanks
Juergen
--
View this message in context: http://n3.nabble.com/ConsequenceException-when-retract-from-entry-point-t...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
infinite loop in decision table
by djb
Hi,
I have successfully used UNLOOP to stop repitition of rules in my decision
table when one rule fires when all rules are mutually exclusive...
but I've got two rows/rules matching a condition for a given input, and it
is back to an infinite loop.
Is there something like lock-on-active for a decision table?
My table is basically something like the following, with an update in the
action:
Tariff X Minimum age Maximum Age
1234 5 <blank>
2345 <blank> 30
It checks whether a claim has a tariff, so so if a claim has both tariffs
and is between those two ages, it gets into an infinite update loop.
Thanks,
Daniel
--
View this message in context: http://n3.nabble.com/infinite-loop-in-decision-table-tp129933p129933.html
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Is it possible to restore StatefulKnowledgeSession?
by Grigoriev, Grigoriy
Hi everyone,
I have a ruleflow that calls a ruleflow group.
In rhs of one of the rules in the ruleflow group an Exception is thrown. After that, when I insert a new fact into the working memory, the activations for the new fact are not created. To make the session work again, I call .getAgenda().clear(). However, session works incorrectly after that.
Is there any other way to 'restore' the StatefulKnowledgeSession, after it has thrown an Exception or should I always create a new session in this case?
With best regards,
Grigoriy.
15 years, 11 months
KnowledgeAgent and Guvnor restart
by Gerret Hansper
Hello,
I have got an issue with the KnowledgeAgent that seems not to survive a Guvnor
restart. The scenario is as follows:
* We use Drools 5.0
* On our application server we create a KnowledgeAgent
applying a ChangeSet that points to a package binary on a separate Guvnor server
like so:
SystemEventListenerFactory.setSystemEventListener(new
SystemEventLogger());
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent(workflowName);
agent.applyChangeSet(changeSet);
* Creating the kbase, registering globals and running sessions works fine.
* We shut down Guvnor (or the connection goes down, this was how we spotted the
problem) and restart it after a minute
* We then try to run sessions from the
same agent as above via
kagent.getKnowledgeBase().newStatefulKnowledgeSession();
which returns a ksession, but then setting a global we get
java.lang.RuntimeException: Unexpected global [log]
at
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:5
50)
at
org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessio
nImpl.java:284)
>From the debugger I can see that indeed the ruleBase's globals map is empty. The
SystemEventLogger indicates that the KnowledgeAgent unsubscribes from its
resource when Guvnor is down and rebuilds its kbase. Also, it stops scanning the
resource and does not find it once Guvnor is up again. (See log snippet below).
Wouldn't it be better in these cases to keep the resource as is in memory and
try to rescan? I figure that as long as the resource is specified in the
changeSet it should be considered part of the kbase and not be removed if it
cannot be found.
For the time being, does anyone have a suggestion how to avoid these problems?
We could catch the RuntimeException and recreate the KnowledgeAgent, but perhaps
there is a better way?
Thanks, Gerret
-- SystemEventLog --
# Guvnor is up here
07:58:01,881 ResourceChangeScanner attempt to scan 1 resources
07:58:02,209 ResourceChangeScanner thread is waiting for 60
07:58:15,067 ResourceChangeScanner attempt to scan 1 resources
# Guvnor goes down here
07:58:16,738 ResourceChangeScanner removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification received ChangeSet notification
07:58:16,738 ResourceChangeScanner thread is waiting for 60
07:58:16,738 ResourceChangeNotification processing ChangeSet
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 ResourceChangeNotification thread is waiting for queue update
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17 to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738
KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:59:02,202 ResourceChangeScanner attempt to scan 0 resources
07:59:02,202 ResourceChangeScanner thread is waiting for 60
# Guvnor back up here
07:59:16,731 ResourceChangeScanner attempt to scan 0 resources
07:59:16,731 ResourceChangeScanner thread is waiting for 60
15 years, 11 months
Rule Templates with empty cells
by jschmied
Hi!
If I write rules in a decision table I can leave cells empty if I don't need
to use all of the conditions in a row.
How can I do this with the ExternalSpreadsheetCompiler?
I would need something like:
rule "rule_(a){row.rowNumber}"
when
$s : MyType1()
@ifDefined{field1} $e : MyType2(val1 == "@{field1}") from $s.SUB;
@ifDefined{field2} $e : MyType2(val2 == "@{field2}") from $s.SUB;
then
retract($s);
end
Thanks
Juergen
--
View this message in context: http://n3.nabble.com/Rule-Templates-with-empty-cells-tp138571p138571.html
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
"collection contains" problem
by Mike Dougherty
Hello all,
I've been getting more and more into using Drools Expert, but I certainly still have a lot to learn. I have almost a complete rules file ready to go. But I am having an issue with the LHS checking that a collection contains a certain object value. The rule currently looks like this:
rule "Rule Name"
no-loop true
when
property : StatusProperty( name == "propertyName", value == "valueA" )
t : TrainingStatus( currentSection == "section_a", properties contains property )
then
t.setNextSection( "section_b" );
t.setPreviousSection( "section_overview" );
update( t );
end
The TrainingStatus object has the following fields:
public class TrainingStatus implements Serializable {
private String currentSection;
private String nextSection;
private String previousSection;
private Set<StatusProperty> properties = new TreeSet<StatusProperty>();
}
And the StatusProperty object has the following:
public class StatusProperty implements Serializable {
private String name;
private String value;
}
I'm inserting a TrainingStatus object that should match this rule. But the resulting object does not have the nextSection and previousSection fields set to the values they should.
Can anyone advise on how to get this rule working as expected?
Thanks for your help!
Mike
15 years, 11 months