Problems with result mapping for custom workitems
by PAYET, Manuel
Hello everyone, I have a problem using result mapping in custom workitems when I try to set an attribute of an object as one of the result:
I make the following mapping in Result Mapping of my workitem:
Parameter Variable
message workmodel.message
and all I have is
Could not find variable scope for variable workmodel.message
when trying to complete Work Item workitem_test
Continuing without setting variable.
I hope, someone can help me, I tried all that I could think about...
you will find below all my project, sorry for the long post...:
/forum/src/main/java/mpayet/test/forum/App.java
=======================================================================
package mpayet.test.forum;
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import workDefinitions.WorkitemTest;
import workDefinitions.Workmodel;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello World!");
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
final Map<String, Object> map = new HashMap<String, Object>();
map.put("workmodel", new Workmodel());
session.getWorkItemManager().registerWorkItemHandler("workitem_test", new WorkitemTest(session));
session.startProcess("flow", map);
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("flow.rf"),
ResourceType.DRF);
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;
}
}
=======================================================================
/forum/src/main/java/workDefinitions/WorkitemTest.java
=======================================================================
package workDefinitions;
import java.util.HashMap;
import java.util.Map;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
public class WorkitemTest implements WorkItemHandler {
final StatefulKnowledgeSession session;
public WorkitemTest(final StatefulKnowledgeSession session) {
this.session = session;
}
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
final Map<String, Object> mapResult = new HashMap<String, Object>();
mapResult.put("message", "message");
mapResult.put("nombre", 1);
manager.completeWorkItem(workItem.getId(), mapResult);
}
}
=======================================================================
/forum/src/main/java/workDefinitions/Workmodel.java
=======================================================================
package workDefinitions;
public class Workmodel {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
=======================================================================
/forum/src/main/java/META-INF/DefinitionsWorkitem.conf
=======================================================================
import org.drools.process.core.datatype.impl.type.StringDataType;
import org.drools.process.core.datatype.impl.type.IntegerDataType;
[
// exemple de workitem
[
"name" : "workitem_test",
"parameters" : [
"typeObjet" : new StringDataType(),
"nombre" : new IntegerDataType()
],
"displayName" : "workitem test",
"icon" : "icons/icone_service.gif"
]
]
=======================================================================
/forum/src/main/java/flow.rf
=======================================================================
<?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="flow" id="flow" package-name="com.mpayet.test" routerLayout="1" >
<header>
<imports>
<import name="workDefinitions.Workmodel" />
</imports>
<variables>
<variable name="workmodel" >
<type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="workDefinitions.Workmodel" />
</variable>
</variables>
</header>
<nodes>
<actionNode id="13" name="affichage variable" x="16" y="176" width="161" height="48" >
<action type="expression" dialect="mvel" >var model =(Workmodel)context.getVariable("workmodel")
System.out.println(model.message)</action>
</actionNode>
<end id="8" name="End" x="72" y="256" width="48" height="48" />
<start id="1" name="Start" x="72" y="16" width="48" height="48" />
<workItem id="20" name="workitem test" x="46" y="97" width="100" height="48" >
<work name="workitem_test" >
<parameter name="nombre" >
<type name="org.drools.process.core.datatype.impl.type.IntegerDataType" />
</parameter>
<parameter name="typeObjet" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
</work>
<mapping type="out" from="message" to="workmodel.message" />
</workItem>
</nodes>
<connections>
<connection from="20" to="13" />
<connection from="13" to="8" />
<connection from="1" to="20" />
</connections>
</process>
=====================================================================
Thank you very much if you took the time to think about my problem,
Manuel PAYET
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is
intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to
read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message
in error, please notify the sender immediately and delete all copies of this message.
15 years, 11 months
Using Drools for Batch Data Validation
by Richard, Rene
Hello,
I am new to Drools (1 day of reading and watching video podcasts etc...). We have a requirement for our project where we'll have an input table HSQLDB table and some validation rules we need to apply on the data in the table. Some tables will have > 45 000 records or more. Would this kind of Batch validation be something Drools is good at? Rules can change over time and the table definition can also.
It seems like Drools would be a good tool for doing the validation. I'm imagining an input table and an output table. The input table is the table we want to run validation for. The output table is a table that has had validation run against it an an extra column with a validation pass/fail status for reporting purposes...
Thanks in advance
Rene
15 years, 11 months
split constraint same as LHS of rule
by Kathy Sward
We have recently started using flow along with rules. We noticed that for our split constraints, those constraints often matched the LHS of our rules. We took the approach of removing the constraint from the rule, under the premise that we would only need to have the constraint one place, and not duplicating the constraint would be helpful if we ever needed to change the constraint. We are using POJO for data, with a "decision" object holding the input data. The LHS of the rule now just looks to see that there is a decision object. This works just fine. My question is whether there is some reason why we ought to keep the constraint in both places--is there any known down side to having the constraint be just within flow?
-- Kathy
15 years, 11 months
ListDataType in Ruleflow file?
by David Cracauer
Greetings,
Is there anyway to define the value of a variable defined as a ListDataType
in a ruleflow file? I have a custom WorkItem that can be configured with a
list of possible values that will complete it, and I'd like to define it in
the ruleflow file. However, any time I define it with anything in the
<value></value> section, I get this error:
An error has occurred. See error log for more details.
: only whitespace content allowed before start tag and not a (position:
START_DOCUMENT seen a... @1:1)
Is it possible to define a list directly in the ruleflow file?
Thanks,
Dave
--
View this message in context: http://n3.nabble.com/ListDataType-in-Ruleflow-file-tp741319p741319.html
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Parameterize temporary restrictions in Drools Fussion
by Ana Villa
Mostrar forma romanizada
It is possible to parameterize the temporary restrictions fussion drools? For
example use expressions like "this after [*, $object.getTimer ()] $event"
In my sample project does not work ...
Thanks
15 years, 11 months
Drools Planner - Constraint Occurrences in working memory
by awuttke
Hello,
let's assume I have a planning problem and the planner cannot find an
optimal solution. The best score was found some iterations back and the
planner stops due to it's configuration (e.g.
<maximumUnimprovedStepCount>50</maximumUnimprovedStepCount>).
When calling getBestScore() I get the best score of all iterations. But how
can I retrieve the corresponding constraint occurrences that explain how
this score was calculated?
When retrieving the ConstraintOccurrence from the working memory using
localSearchSolverScope.getWorkingMemory() I can only find
ConstraintOccurrence objects that probably match to the last iteration
executed but not the ConstraintOccuerence objects matching the best score.
Does the planner keep these best score ConstraintOccurrence objects in a
different place? If yes, how can they be retrieved?
Thank you,
Andreas
--
View this message in context: http://n3.nabble.com/Drools-Planner-Constraint-Occurrences-in-working-mem...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Add some default status
by fmetral
Hi all,
I'd like to package a drools-guvnor war that contains some default status.
What I want is to create two status:
- draft which is already available in Guvnor by default
- Validated for rules that have been tested
But I don't want to create this status by hand with UI. I'd like to have it
by default in the war package so that when I copy my war on an other server,
I have this status (Validated).
Is it possible to do this?
How can I proceed?
Thanks in Advance
Florent
--
View this message in context: http://n3.nabble.com/Add-some-default-status-tp732084p732084.html
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Problem in giving comments in Drools 5.0 Rule Template File
by Nikhil S. Kulkarni
Hi ,
I am facing a problem in giving comments in drools 5.0 Rules Template file. I have tried using regular java
Comments like // (Single line comments), /***/(Multiline comments),# .But it is giving exception.
So what format we can use for giving comments in .drt template file?
Please inform if you have any idea about this.
Thanks & Regards,
Nikhil S. Kulkarni
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 years, 11 months
rules on web application
by joseramon diaz
Hi all,
I *think* we should use a rules engine on our web application, as some
bussiness rules should be changed by user, and their context can be quite
reduced.
We have a web application, and rules would apply to some bussiness objects,
but my question is about hot to integrate the rules editor in our web
application.
One option I can imagine is to let him modify XML inside a textarea, but
it seems quite hard for him. Is there any web editor for rules that we can
integrate in our web application, as in eclipse?
Thanks
Jose Ramón
15 years, 11 months