Guvnor (5.3.0 Final)- Rule using accumulate with windows:length delivers an unexpected result
by axel
Hello All,
I'm using Guvnor 5.3.0-Final with Tomcat 6.0 testing the following simple
rule getting unexpected results. Maybe someone can give me a hint whats
wrong in my rule.
Thanks in advance!
Axel
Short Rule description:
A list is built from selected event-facts evalEvent(@role (event), Double f,
String wam) over a certain window in a first line (because I found the hint
to do it seperately in another thread). Next, I want to caclculate the
avarage, but only from the selected events in the list. Finally, I check a
certain limit with the average and the RHS is just inserting a fact to
generate some output in the test case.
rule "Event Processing Evaluation"
dialect "mvel"
when
$list:java.util.List() from collect( evalEvent(wam == 'D1', f != null)
over window:length( 1 ))
$average:Double() from accumulate( evalEvent($vf:f) from
$list,average($vf) )
eval($average > 5)
then
internalEvent fact0 = new internalEvent();
fact0.setDesrc( "Internal Event: "+ $average );
insert(fact0 );
end
Test details from Guvnor Test that delivers an (for me) unexpected result:
I'm inserting three events, where the avarage of all three events is over
the limit, but taken only the last or last two (same result) as I want to do
with the window:length is not and shoud therefore not fire the rule. I added
below output details from the Guvnor Test that shows the following: The list
seams to be right (only the last event in $list), the avarage seams to be
right ($average = 5.0) - but the rule still fires.
It seams for me that the average of all three evnts is internally used for
eval($average > 5). I tried a lot of variants, but nothing works well. I'd
like to check to use an entry-point if that changes the result, but I found
no way within the Guvnor Test Case Editor putting enty points in for events.
OBJECT ASSERTED value:evalEvent( wam=D1, f=6.0 ) factId: 1
OBJECT ASSERTED value:evalEvent( wam=D1, f=5.0 ) factId: 6
OBJECT ASSERTED value:evalEvent( wam=D1, f=5.0 ) factId: 9
FIRING rule: [Event Processing Evaluation] activationId:Event Processing
Evaluation [3, 2, 0] declarations: $list=[evalEvent( wam=D1, f=5.0 )](2);
$average=5.0(3)
OBJECT ASSERTED value:internalEvent( desrc=Internal Event: 5.0 ) factId:
12
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-5-3-0-Final-Rule-using-accumulat...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
String length check
by lansyj
Hi folks,
I'm trying to create a guided rule which treats customers differently based
on the length of their customer ID. The generated rule source is as follows:
rule "OP Customer"
dialect "mvel"
when
$bean : ProgramMemberBean( profileVO.memberID.size() == "8" )
then
$bean.setSegmentCode( "OP_CUSTOMER" );
update( $bean );
end
Everything seems good to me, but I get the following error upon validation:
[OP Customer] [ERR 101] Line 4:53 no viable alternative at input ')' in rule
"OP Customer" in pattern ProgramMemberBean
[OP Customer] [ERR 102] Line 4:55 mismatched input '==' expecting ')' in
rule "OP Customer" in pattern ProgramMemberBean
Any help is very much appreciated.
Best Regards
-lj
--
View this message in context: http://drools.46999.n3.nabble.com/String-length-check-tp3502269p3502269.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Email Service
by ANJALI
Hi guys,
Iam trying to send email through drools by using bpmn.xml...in
order to do so i need to register a work item handler into my session.
I have done in this way
ksession.getWorkItemManager().registerWorkItemHandler("Email",
emailWorkItemHandler);
And this is my class for that handler
public class NotificationWorkItemHandler implements
WorkItemHandler {
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
// extract parameters
String from = (String) workItem.getParameter("From");
String to = (String) workItem.getParameter("To");
String message = (String) workItem.getParameter("Message");
String priority = (String) workItem.getParameter("Priority");
// send email
*EmailService service =
ServiceRegistry.getInstance().getEmailService();*
service.sendEmail(from, to, "Notification", message);
// notify manager that work item has been completed
manager.completeWorkItem(workItem.getId(), null);
}
My issue is Email service need some import but I cant see what needs to be
included....
Could any one help me out in this issue?
Thanks in advance
Anjali
--
View this message in context: http://drools.46999.n3.nabble.com/Email-Service-tp3506142p3506142.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
[rule engine advantage?]Logic and Data Separation - how to archieve the transparent domain/fact object insertion?
by kapokfly
Logic and Data Separation
Your data is in your domain objects, the logic is in the rules. This is
fundamentally breaking the
OO coupling of data and logic, which can be an advantage or a disadvantage
depending on
your point of view. The upshot is that the logic can be much easier to
maintain as there are
changes in the future, as the logic is all laid out in rules. This can be
especially true if the logic
is cross-domain or multi-domain logic. Instead of the logic being spread
across many domain
objects or controllers, it can all be organized in one or more very distinct
rules files.
------------------------
The current practice we are following demonstrate a strong relationship
between fact objects and the rule files itself, the rule needs to understand
what fact object available in the working memory and the working memory may
also consider what kind of rules can be written against objects in memory
thus the application developers need insert/write rules carefully and better
to be done by 1 developer (or we can say, depends on how the rule is
written, it will impact what objects/how objects are being inserted into the
working memory).
Can someone share their experiences how to make the knowledge session/fact
object maintenance work as transparent as possible? how to decouple the fact
object maintenance work from the rules? At which layer you usually insert
fact object to the work memory?
Ivan
-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/rule-engine-advantage-Logic-and-Data-Se...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Help needed - Repository not getting initialised?
by Praveen
Hi,
Repository is not getting initialised, throws NPE.
Please advise.
TIA.
public static Repository repository;
public static Session getSession() throws Exception {
return getSession(true);
}
public static synchronized Session getSession(boolean erase) {
try {
if (repository == null) {
if (erase) {
File repoDir = new File("repository");
System.out.println("DELETE test repo dir: "
+ repoDir.getAbsolutePath());
RepositorySessionUtil.deleteDir(repoDir);
System.out.println("TEST repo dir deleted.");
}
JCRRepositoryConfigurator config = new
JackrabbitRepositoryConfigurator();
String home = System
.getProperty("guvnor.repository.dir");
repository = config.getJCRRepository(home);
Session testSession = repository
.login(new SimpleCredentials("alan_parsons",
"password".toCharArray()));
RulesRepositoryAdministrator admin = new
RulesRepositoryAdministrator(
testSession);
if (erase && admin.isRepositoryInitialized()) {
admin.clearRulesRepository();
}
config.setupRulesRepository(testSession);
return testSession;
} else {
return repository.login(new SimpleCredentials(
"alan_parsons", "password".toCharArray()));
}
} catch (RepositoryException e) {
throw new IllegalStateException(e);
}
}
public static void main(String [] args) throws Exception{
getSession();
}
Below is the exception..
DELETE test repo dir: D:\drools\TestRepository\repository
TEST repo dir deleted.
Exception in thread "main" java.lang.NullPointerException: dispatcher
at
org.apache.jackrabbit.core.observation.ObservationManagerImpl.<init>(ObservationManagerImpl.java:97)
at
org.apache.jackrabbit.core.WorkspaceImpl.getObservationManager(WorkspaceImpl.java:748)
at
org.apache.jackrabbit.core.SessionImpl.removeRegisteredEventListeners(SessionImpl.java:1193)
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:1222)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.doDispose(RepositoryImpl.java:2194)
at
org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.dispose(RepositoryImpl.java:2149)
at
org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1175)
at
org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1127)
at
org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:544)
at
org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:366)
at
org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:673)
at
org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
at
org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
at
org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
at
org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
at Hello.getSession(Hello.java:50)
at Hello.getSession(Hello.java:27)
at Hello.main(Hello.java:72)
Regards,
Praveen.
--
View this message in context: http://drools.46999.n3.nabble.com/Help-needed-Repository-not-getting-init...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
discrepency between drools eclipse editor and runtime
by sam prar
Hi,
I have a simple drl written using the eclipse drools editor.
-----------
package com.x.workflow
import com.x.api.dto.User;
rule "validate_user"
when
userX : User(getName().equals("test123"))
then
userX.setDescription("changed in workflow)";
System.out.println("user is test123");
end
--------
The editor does not flag any errors, but, when I run the workflow through
my webapp, I see the following error :
Rule Compilation error : [Rule name='validate_user']
com/x/workflow/Rule_validate_user.java (7:439) : Syntax error, insert
")" to complete Expression
904224 [tomcat-http--51] ERROR
org.activiti.engine.impl.interceptor.CommandContext - Error while closing
command context
java.lang.IllegalArgumentException: Could not parse knowledge.
at
org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67)
at
org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:61)
the java file Rule_validate_user.java is not written by me, in fact I
cannot locate it in my source.
It appears it is generated by drools engine.
And, I cannot find what is wrong with my drl file from the error printed.
Appreciate any pointers.
thanks
sapra
14 years, 5 months
discrepency between drools eclipse editor and runtime
by saprar
Hi,
I am trying to work with Activiti and drools. I am new to both.
I have a simple drl written using the eclipse drools editor.
-----------
package com.x.workflow
import com.x.api.dto.User;
rule "validate_user"
when
userX : User(getName().equals("test123"))
then
userX.setDescription("changed in workflow)";
System.out.println("user is test123");
end
--------
The editor does not flag any errors, but, when I run the workflow through my
webapp, I see the following error :
Rule Compilation error : [Rule name='validate_user']
com/x/workflow/Rule_validate_user.java (7:439) : Syntax error, insert ")"
to complete Expression
904224 [tomcat-http--51] ERROR
org.activiti.engine.impl.interceptor.CommandContext - Error while closing
command context
java.lang.IllegalArgumentException: Could not parse knowledge.
at
org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:67)
at
org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:61)
the java file Rule_validate_user.java is not written by me, in fact I cannot
locate it in my source.
It appears it is generated by drools engine.
And, I cannot find what is wrong with my drl file from the error printed.
Appreciate any pointers.
thanks
sapra
--
View this message in context: http://drools.46999.n3.nabble.com/discrepency-between-drools-eclipse-edit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months