Re: [rules-users] Problem with logging using Drools 5.3.0

2012-04-25 Thread FlyingEagle
Thx, Mark for your advice.
I use my own implementation of SystemEventListener now, which uses the log4j
Logger for logging.
This works fine.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Problem-with-logging-using-Drools-5-3-0-tp3934918p3937481.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] Need Help: Error creating bean with name 'kbase'

2012-04-25 Thread singkamas
Hi everyone.

I am new to Drools and Spring MVC. I tried out the example from 
http://blog.athico.com/2011/01/rules-based-validation-using-drools.html
http://blog.athico.com/2011/01/rules-based-validation-using-drools.html  but
still I am getting an error. I have beeng looking over the net for hours
now. and have tried everything i can/know to make it work. I also have tried
multiple tutorials, blogs etc. But i still cant seem to get away from that
error.

I would greatly appreciate any help. Thanks in advance.

*Servlet Context*
===
?xml version=1.0 encoding=UTF-8?
beans:beans xmlns=http://www.springframework.org/schema/mvc;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xmlns:beans=http://www.springframework.org/schema/beans;
xmlns:context=http://www.springframework.org/schema/context;
xmlns:drools=http://drools.org/schema/drools-spring;
xsi:schemaLocation=http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd;




annotation-driven /
 

resources mapping=/resources/** location=/resources/ /


beans:bean

class=org.springframework.web.servlet.view.InternalResourceViewResolver
beans:property name=prefix value=/WEB-INF/views/ /
beans:property name=suffix value=.jsp /
/beans:bean

context:component-scan base-package=com.spring.mvc /


drools:kbase id=kbase
drools:resources
drools:resource type=DRL
source=classpath:validation.drl/drools:resource
/drools:resources
/drools:kbase


drools:ksession id=ksession type=stateless name=ksession
kbase=kbase /

beans:bean id=validator

class=org.springframework.validation.beanvalidation.LocalValidatorFactoryBean/beans:bean

beans:bean id=collaborators
class=com.spring.mvc.validation.Collaborators
beans:constructor-arg
beans:map
beans:entry key=applicantDao 
value-ref=applicantDao/beans:entry

/beans:map
/beans:constructor-arg
/beans:bean

beans:bean id=applicantDao
class=com.spring.mvc.service.ApplicantDaoImpl/beans:bean

/beans:beans

===

*Here's the exception*
===
INFO: ERROR: org.springframework.web.servlet.DispatcherServlet - Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'kbase': Cannot create inner bean '(inner bean)' of type
[org.drools.container.spring.beans.DroolsResourceAdapter] while setting bean
property 'resources' with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name '(inner bean)#16': Error setting property values; nested exception
is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'resource'
threw exception; nested exception is java.lang.NoSuchMethodError:
org.drools.util.ClassLoaderUtil.getClassLoader([Ljava/lang/ClassLoader;Ljava/lang/Class;Z)Lorg/drools/util/CompositeClassLoader;
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at

Re: [rules-users] How to query rules to create reports to analyze usage

2012-04-25 Thread thomashatz
Thanks Wolfgang,

But don't the rules tables have basic info like 'last run date and time and 
user' type info...

Also how to setup an AgendaEventListener

Really appreciate your knowledge sharing

--- On Tue, 4/24/12, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 From: Wolfgang Laun wolfgang.l...@gmail.com
 Subject: Re: [rules-users] How to query rules to create reports to analyze 
 usage
 To: Rules Users List rules-users@lists.jboss.org
 Date: Tuesday, April 24, 2012, 4:30 AM
 For analyzing rules usage an
 AgendaEventListener should be used to
 register the information you are interested in. (You
 wouldn't need to
 query the rules DB for this anyway.)
 
 -W
 
 On 24/04/2012, thatz thomash...@yahoo.com
 wrote:
  Am new user to Drools, have 300+ rules, but need to
 query them using SQL
  syntax to create reports and analyze rules usage (if
 rules are being called,
  etc.).  App developer said cannot query the rules
 db directly because it is
  proprietary.  Is there anyway to query rules or
 what is best way to analyze
  rules usage.  Thanks
 
  --
  View this message in context:
  http://drools.46999.n3.nabble.com/How-to-query-rules-to-create-reports-to-analyze-usage-tp3934833p3934833.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
 

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


[rules-users] Redundancy check option not working in Drools Verifier 5.4

2012-04-25 Thread worldofprasanna
Hi All,

I tried to use Drools Verifier to validate the available rules. I got all
the warning types like MISSING_EQUALITY, ALWAYS_FALSE. But I couldn t get
the redundancy warning, eventhough i have given the duplicate rules
explicitly. 

I am using Drools Verifier 5.4.0.Final.

Herewith given the following details,

1. Sample rule file


rule rule 1
when
$server : Server(processors==2, memory==1024)
then
System.out.println(rule 1)
end
rule rule 2
when
$server : Server(processors==2, processors!=2)
then
System.out.println(rule)
end
rule rule 3
when
$server : Server(processors==2, memory==1024)
then
System.out.println(rule 3)
end

2. Code which verifies the validity of the rule.


VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder(); 
 
Verifier verifier = vBuilder.newVerifier();

verifier.addResourcesToVerify(new
ClassPathResource(sample.drl,
DroolsVerifierCheck.class),
ResourceType.DRL);
  
verifier.fireAnalysis();
VerifierReport result = verifier.getResult();

// To display the warnings in verifier.
CollectionVerifierMessageBase warningMessages =
  result.getBySeverity(Severity.WARNING);
  for (VerifierMessageBase msg : warningMessages) {
  System.out.println(Note:  + msg.getMessage() +
   type:  + msg.getMessageType() +
   on:  + msg.getFaulty());
  }

Problem


In the sample rule, you can find rule 1 and rule 3 are same. But I didn t
get the warning for redundancy.

Research done


When i debug the code, i found like the rule Find redundant pattern
possibilities from rule possibilities and Find redundant restrictions from
pattern possibilities are loaded into the Knowledge base created and tagged
with Agenda group as Main, but those are not present in the Knowledge
session created (I mean after inserting the objects into the Knowledge
session in the code : VerifierImpl.java). 

Also can anybody explain when a rule will be present in the knowledge base
but not selected by the agenda. I haven t modified anything in the
AgendaFilter and its given the default value ScopeAgendaFilter. 

Kindly let me know why the redundancy warning is not given in my case ?

P.S : I have gone through the post below,

http://http://drools.46999.n3.nabble.com/Drools-verifier-td2681002.html
http://drools.46999.n3.nabble.com/Drools-verifier-td2681002.html 

and at the bottom they have asked the same question, but there is no answer
available for it.

Thanks,
Prasanna.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Redundancy-check-option-not-working-in-Drools-Verifier-5-4-tp3938055p3938055.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] Drools Guvnor - validate a rule results in Unable to Analyse Expression

2012-04-25 Thread FlyingEagle
Hi folks,

I have defined some rules in Eclipse and tested with JUnit tests and
everything was fine.
Now I defined the rules in Guvnor and while validating I get the following
error:

[CardTrapping] Unable to Analyse Expression Fraud fraud = new
Fraud(Fraud.CARD_TRAPPING, new SSTEvent[] { $event1, $event2, $event3,
$event4 }); fraudControl.handleFraud(fraud);: [Error: expected type:
com.wn.fraud.droolstest.model.SSTEvent; but found:
com.wn.fraud.droolstest.model.SSTEvent] [Near : {... SSTEvent[] { $event1,
$event2, $event3, $event4 }) }] ^ [Line: 1, Column: 70]

I have imported my data model, before creating the rules, therefor for the
type SSTEvent an import is defined. But it seems, that the type SSTEvent
exists with different versions?

I have this problem for each rule, when I'm using the SSTEvent type in the
then case.

Here the complete rule defintion:

package com.wn.fraud.droolstest

import com.wn.fraud.droolstest.model.Fraud;
import com.wn.fraud.droolstest.model.FraudControl;
import com.wn.fraud.droolstest.model.SSTEvent;

global FraudControl fraudControl;

rule CardTrapping
when
$event1 : SSTEvent ( eventNumber == SSTEvent.CARD_JAMMED ) from
entry-point device-event-stream
$event2 : SSTEvent ( this after [ 0s, 30s ] $event1, 
 eventNumber == SSTEvent.IN_SERVICE,
 deviceId == $event1.deviceId,
 branchName == $event1.branchName ) from entry-point
device-event-stream
$event3 : SSTEvent ( this after [ 0s, 30s ] $event2, 
 eventNumber == SSTEvent.CARD_JAMMED,
 deviceId == $event1.deviceId,
 branchName == $event1.branchName ) from entry-point
device-event-stream
$event4 : SSTEvent ( this after [ 0s, 30s ] $event3, 
 eventNumber == SSTEvent.IN_SERVICE,
 deviceId == $event1.deviceId,
 branchName == $event1.branchName ) from entry-point
device-event-stream
then
// inform fraud control
Fraud fraud = new Fraud(Fraud.CARD_TRAPPING, new SSTEvent[] {
$event1, $event2, $event3, $event4 });
fraudControl.handleFraud(fraud);
end 


Thx a lot for help!

--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-Guvnor-validate-a-rule-results-in-Unable-to-Analyse-Expression-tp3938096p3938096.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] How to query rules to create reports to analyze usage

2012-04-25 Thread Wolfgang Laun
On 25/04/2012, thomash...@yahoo.com thomash...@yahoo.com wrote:
 Thanks Wolfgang,

 But don't the rules tables have basic info like 'last run date and time and
 user' type info...

I'm not aware of any such information being collected and stored
automatically. But if this is a Guvnor function, I may have a very
blind spot there.


 Also how to setup an AgendaEventListener

It's done as with any other listener in JDK etc. Here are some code
snippets to get you started. This code is not necessarily best
practice or anything; it's meant to illustrate the essentials. The
constructor installs the listener.

public class AgendaWatcher implements AgendaEventListener {

// useful aux. method
private String ruleNameOfEvent( ActivationEvent actEvent ){
Activation activation = actEvent.getActivation();
Rule rule = activation.getRule();
return rule.getPackageName() + '.' + rule.getName();
}

public AgendaWatcher( KnowledgeRuntime knowledgeRuntime ){
knowledgeRuntime.addEventListener( (AgendaEventListener)this );
}

@Override
public void activationCancelled(ActivationCancelledEvent actEvent) {
 // happens frequently, for various reasons. may not be of interest.
}

@Override
public void activationCreated(ActivationCreatedEvent actEvent) {
// same thing.
}

@Override
public void beforeActivationFired(BeforeActivationFiredEvent arg0) {
}

@Override
public void afterActivationFired(AfterActivationFiredEvent actEvent) {
// count firings
Counts counts = getCountsForName( ruleNameOfEvent( actEvent ) );
counts.firings++;
}

@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent arg0) {
}
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent arg0) {
}
}





 Really appreciate your knowledge sharing

 --- On Tue, 4/24/12, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 From: Wolfgang Laun wolfgang.l...@gmail.com
 Subject: Re: [rules-users] How to query rules to create reports to analyze
 usage
 To: Rules Users List rules-users@lists.jboss.org
 Date: Tuesday, April 24, 2012, 4:30 AM
 For analyzing rules usage an
 AgendaEventListener should be used to
 register the information you are interested in. (You
 wouldn't need to
 query the rules DB for this anyway.)

 -W

 On 24/04/2012, thatz thomash...@yahoo.com
 wrote:
  Am new user to Drools, have 300+ rules, but need to
 query them using SQL
  syntax to create reports and analyze rules usage (if
 rules are being called,
  etc.).  App developer said cannot query the rules
 db directly because it is
  proprietary.  Is there anyway to query rules or
 what is best way to analyze
  rules usage.  Thanks
 
  --
  View this message in context:
  http://drools.46999.n3.nabble.com/How-to-query-rules-to-create-reports-to-analyze-usage-tp3934833p3934833.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


 ___
 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] How to query rules to create reports to analyze usage

2012-04-25 Thread Michael Anstis
The OP has not said if he uses Guvnor or not. We can only guess.

Last run date is a run-time metric. Guvnor only contains design-time
metrics. Therefore you'll have to devise your own mechanism using
AgendaListener as Wolfgang proposes.

Author (and other such metadata) is stored in Guvnor and is (probably)
available using the REST API - but it'll be on a per-asset basis and
definitely not lend itself to batch querying (e.g. as with a RDBMS) as you
imply.

Rule validity is another analysis you do not mention. drools-verifier may
be able to help there.

On 25 April 2012 17:43, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 On 25/04/2012, thomash...@yahoo.com thomash...@yahoo.com wrote:
  Thanks Wolfgang,
 
  But don't the rules tables have basic info like 'last run date and time
 and
  user' type info...

 I'm not aware of any such information being collected and stored
 automatically. But if this is a Guvnor function, I may have a very
 blind spot there.

 
  Also how to setup an AgendaEventListener

 It's done as with any other listener in JDK etc. Here are some code
 snippets to get you started. This code is not necessarily best
 practice or anything; it's meant to illustrate the essentials. The
 constructor installs the listener.

 public class AgendaWatcher implements AgendaEventListener {

// useful aux. method
private String ruleNameOfEvent( ActivationEvent actEvent ){
Activation activation = actEvent.getActivation();
Rule rule = activation.getRule();
return rule.getPackageName() + '.' + rule.getName();
}

public AgendaWatcher( KnowledgeRuntime knowledgeRuntime ){
knowledgeRuntime.addEventListener( (AgendaEventListener)this );
}

@Override
public void activationCancelled(ActivationCancelledEvent actEvent) {
 // happens frequently, for various reasons. may not be of interest.
}

@Override
public void activationCreated(ActivationCreatedEvent actEvent) {
// same thing.
}

@Override
public void beforeActivationFired(BeforeActivationFiredEvent arg0) {
}

@Override
public void afterActivationFired(AfterActivationFiredEvent actEvent) {
// count firings
Counts counts = getCountsForName( ruleNameOfEvent( actEvent ) );
counts.firings++;
}

@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent arg0) {
}
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent arg0) {
 }
 }




 
  Really appreciate your knowledge sharing
 
  --- On Tue, 4/24/12, Wolfgang Laun wolfgang.l...@gmail.com wrote:
 
  From: Wolfgang Laun wolfgang.l...@gmail.com
  Subject: Re: [rules-users] How to query rules to create reports to
 analyze
  usage
  To: Rules Users List rules-users@lists.jboss.org
  Date: Tuesday, April 24, 2012, 4:30 AM
  For analyzing rules usage an
  AgendaEventListener should be used to
  register the information you are interested in. (You
  wouldn't need to
  query the rules DB for this anyway.)
 
  -W
 
  On 24/04/2012, thatz thomash...@yahoo.com
  wrote:
   Am new user to Drools, have 300+ rules, but need to
  query them using SQL
   syntax to create reports and analyze rules usage (if
  rules are being called,
   etc.).  App developer said cannot query the rules
  db directly because it is
   proprietary.  Is there anyway to query rules or
  what is best way to analyze
   rules usage.  Thanks
  
   --
   View this message in context:
  
 http://drools.46999.n3.nabble.com/How-to-query-rules-to-create-reports-to-analyze-usage-tp3934833p3934833.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
 
 
  ___
  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

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


[rules-users] Guvnor and Joda time

2012-04-25 Thread Sean Su
Do we support Joda time objects in Guvnor (5.3)? I did add joda time jar on
the classpath (Guvnor's lib folder) and there is no class not found
exception. However I get following exception when trying to access the
deployment snapshot.

The snapshot worked fine when I was using Date. After switching to Joda
time, I did reload the POJO model and regenerated the deployment snapshot.

I am using 5.3.final.

java.lang.NullPointerException
at java.io.OutputStream.write(OutputStream.java:58)
at
org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage(FileManagerUtils.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at
org.drools.guvnor.server.files.FileManagerUtils_$$_javassist_seam_10.loadBinaryPackage(FileManagerUtils_$$_javassist_seam_10.java)
at
org.drools.guvnor.server.files.PackageDeploymentServlet$1.execute(PackageDeploymentServlet.java:252)
at
org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:75)
at
org.drools.guvnor.server.files.PackageDeploymentServlet.doGet(PackageDeploymentServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:625)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)

-- 
But beware of the Dark Side. Anger, fear, aggression - the Dark Side of
the Force are they. -Yoda
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Error while using Drools 5.3.0

2012-04-25 Thread mkhan_rt54fde
Hi,

Thanks for the reply.

In my application,one of the input parameters is Year.In my java class,I am
getting the modelyear from year and converting it an integer.But even then,
I am getting the error posted earlier.Here is my rule file:

rule Set Time To Live
when
there is a restoration request
then 
set quote process time to live to: 15
add additional action check state regulation for vintage car 
restoration
end


#validation
rule Year is required 
no-loop true
when
request does not contain model year
then 
set reason of rejection to year is required
reject request
end


#additional action
rule VIN required for newer vehicles 
no-loop true
when
request contains no VIN and the car was built after year 1982
then 
ask the customer to provide VIN
end

and here is my java class:

public class QuoteRequest {

private Contact contact;
private Address address;

private String make;
private String model;
private String style;
private String year;

private String VIN;
private String condition;
private String description;
private String zip;

private ListLink links = new ArrayListLink();

public static void printForMe() {
System.out.println(printing for you);
}

public Contact getContact() {
return contact;
}

public void setContact(Contact contact) {
this.contact = contact;
}

public Address getAddress() {
return address;
}

public void setAddress(Address address) {
this.address = address;
}

public String getMake() {
return make;
}

public void setMake(String make) {
this.make = make;
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public String getStyle() {
return style;
}

public void setStyle(String style) {
this.style = style;
}

public String getYear() {
return returnString(year);
}

public Integer getModelYear() {
Integer modelYear = (getYear() == null) ? null : 
Integer.parseInt(year);
return modelYear;
}

public void setYear(String year) {
this.year = year;
}

public String getVIN() {
return returnString(VIN);
}

public void setVIN(String vin) {
VIN = vin;
}

public String getCondition() {
return condition;
}

public void setCondition(String condition) {
this.condition = condition;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getZip() {
return zip;
}

public void setZip(String zip) {
this.zip = zip;
}

public ListLink getLinks() {
return links;
}

public void setLinks(ListLink links) {
this.links = links;
}

private String returnString(String s) {
 return (s == null || s.isEmpty()) ? null : s;  
}
}

Are there any changes I need to make any changes to the java class to fix
the error I am seeing?

Thanks.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Getting-Error-while-using-Drools-5-3-0-tp3936714p3939076.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] Best practice for 0..1 relations

2012-04-25 Thread Christopher Dolan
Aha, that makes sense! I didn't realize you could bind a variable from two 
different branches of an or. Following that pattern, my strawman rule becomes 
this:

rule household income
when
$p1 : Person()
((not Relation(person1 == $p1, type == spouse) and $p2income : 
int from 0) or
 Relation(person1 == $p1, type == spouse, $p2income: 
person2.getIncome()))
then
insertLogical(new Income($p1.getIncome() + $p2income));
end

Thanks! That's a good compromise of readability and maintainability.
Chris

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor
Sent: Tuesday, April 24, 2012 9:12 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Best practice for 0..1 relations

On 23/04/2012 21:31, Christopher Dolan wrote:
 Sorry, I wasn't clear... In the example, it's the spouse that's the optional 
 fact. I want the rule to fire whether or not a spouse exists, but the RHS 
 computes the income differently if a spouse exists or not. If a spouse is 
 added/removed, I want the rule to re-fire and the income should be changed.
Take a look at my Pong game and the Create Ball rule
https://github.com/droolsjbpm/drools/blob/master/drools-examples/src/main/resources/org/drools/games/pong/init.drl

I create a ball with different dx directions depend on different states, 
all from within one rule:

rule Create Ball when
  not Ball()
  ( PointWin(player.id == PlayerId.PlayerOne ) and dx : Number() from 2 ) or
  ( PointWin(player.id == PlayerId.PlayerTwo ) and dx : Number() from -2 ) 
or
  ( not PointWin( ) and dx : Number() from -2 )
then
 ball = new Ball( (pconf.tableWidth/2)-(pconf.ballWidth/2),
  (pconf.tableHeight/2)-(pconf.ballWidth/2),
   pconf.ballWidth);
 ball.speed = pconf.ballStartingSpeed;
 ball.dx = dx;
 insert( ball );
end



 Chris

 -Original Message-
 From: rules-users-boun...@lists.jboss.org 
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand
 Sent: Monday, April 23, 2012 3:22 PM
 To: rules-users@lists.jboss.org
 Subject: Re: [rules-users] Best practice for 0..1 relations

 So, I assume the fact that is not needed in the LHS is Income.

 By inserting Income into Working Memory, you are subjecting it to rete 
 evaluation against the current knowledge tree.  I consider the cost of each 
 operation.  Insert is very costly, and insertLogical even more costly.

 I don't know anything about how your data model is built, but based on this 
 very simple example, I would think you would be better off with a Global like 
 this:

 Global Income income

 Style 1: one rule for each scenario
  rule household income, single
  when
  $p1 : Person()
  not Relation(person1 == $p1, type == spouse)
  then
  income = new Income($p1.getIncome());
  end
  rule household income, married
  when
  $p1 : Person()
  Relation(person1 == $p1, type == spouse, $p2: person2)
  then
  income = new Income($p1.getIncome() + $p2.getIncome());
  end

 Style 2: a single rule with a collection
  rule household income 
  when
  $p1 : Person()
  $rels : List() from collect(Relation($p1 == person1, type == 
 spouse))
  then
  income = new Income($p1.getIncome() + ($rels.size() == 0 ? 0 : 
 $rels.get(0).getPerson2().getIncome());
  end

 Then in code, you can get the Global value to determine what it got set to, 
 if you need outside of the Drools processing.  All thread safety factors must 
 be considered in a multi-threaded environment.  Global are not objects know 
 to rete, and therefore, use of them is very fast in the LHS.  And the RHS is 
 never aware of changes to Globals (drools assumes them to be static values, 
 that do not change) so care must be taken if using them in the RHS of rules, 
 which I would advise against doing except for special cases where you know a 
 change in the global variable won't be a problem (such as this simple 
 scenario where the global is not used in the RHS at all).

 -Original Message-
 From: rules-users-boun...@lists.jboss.org 
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Christopher Dolan
 Sent: Monday, April 23, 2012 1:01 PM
 To: rules-users@lists.jboss.org
 Subject: [rules-users] Best practice for 0..1 relations

 What's the best way to encode a fact that's needed in the RHS but is not 
 important in the LHS?

 Consider a contrived example of computing total household income for single 
 or married persons. I can think of two ways to encode this rule, but I don't 
 like either of them:

 Style 1: one rule for each scenario
  rule household income, single
  when
  $p1 : Person()
  not Relation(person1 == $p1, 

Re: [rules-users] Best practice for 0..1 relations

2012-04-25 Thread Vincent LEGENDRE
The fact that you can bind from a constant is good to know.

But if I can give my feeling, I don't think that this more readable nor more 
maintainable.
To me, if you really want to factorize, using accumulate is better ...
Mark's rule has a relatively big an complex 'then' part that justify an extreme 
conditions factorization, which is not really your case.
But this is just a matter of taste ...

Here is my ideal rule for this problem, using accumulate :
rule household income
   when
  $p1 : Person()
  $additionnalIncome : Number() from accumulate ( 
Relation(person1 == $p1, type == spouse, $p2income: 
person2.getIncome()) ,
sum( $p2income )
  )
   then
  insertLogical(new Income($p1.getIncome() + $additionnalIncome));
end

Note that this is working for multiple spouses too ...


But I have one question : will this work properly with insertLogical ?


- Mail original -
De: Christopher Dolan christopher.do...@avid.com
À: Rules Users List rules-users@lists.jboss.org
Envoyé: Mercredi 25 Avril 2012 20:39:14
Objet: Re: [rules-users] Best practice for 0..1 relations

Aha, that makes sense! I didn't realize you could bind a variable from two 
different branches of an or. Following that pattern, my strawman rule becomes 
this:

rule household income
when
$p1 : Person()
((not Relation(person1 == $p1, type == spouse) and $p2income : 
int from 0) or
 Relation(person1 == $p1, type == spouse, $p2income: 
person2.getIncome()))
then
insertLogical(new Income($p1.getIncome() + $p2income));
end

Thanks! That's a good compromise of readability and maintainability.
Chris

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor
Sent: Tuesday, April 24, 2012 9:12 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Best practice for 0..1 relations

On 23/04/2012 21:31, Christopher Dolan wrote:
 Sorry, I wasn't clear... In the example, it's the spouse that's the optional 
 fact. I want the rule to fire whether or not a spouse exists, but the RHS 
 computes the income differently if a spouse exists or not. If a spouse is 
 added/removed, I want the rule to re-fire and the income should be changed.
Take a look at my Pong game and the Create Ball rule
https://github.com/droolsjbpm/drools/blob/master/drools-examples/src/main/resources/org/drools/games/pong/init.drl

I create a ball with different dx directions depend on different states, 
all from within one rule:

rule Create Ball when
  not Ball()
  ( PointWin(player.id == PlayerId.PlayerOne ) and dx : Number() from 2 ) or
  ( PointWin(player.id == PlayerId.PlayerTwo ) and dx : Number() from -2 ) 
or
  ( not PointWin( ) and dx : Number() from -2 )
then
 ball = new Ball( (pconf.tableWidth/2)-(pconf.ballWidth/2),
  (pconf.tableHeight/2)-(pconf.ballWidth/2),
   pconf.ballWidth);
 ball.speed = pconf.ballStartingSpeed;
 ball.dx = dx;
 insert( ball );
end



 Chris

 -Original Message-
 From: rules-users-boun...@lists.jboss.org 
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand
 Sent: Monday, April 23, 2012 3:22 PM
 To: rules-users@lists.jboss.org
 Subject: Re: [rules-users] Best practice for 0..1 relations

 So, I assume the fact that is not needed in the LHS is Income.

 By inserting Income into Working Memory, you are subjecting it to rete 
 evaluation against the current knowledge tree.  I consider the cost of each 
 operation.  Insert is very costly, and insertLogical even more costly.

 I don't know anything about how your data model is built, but based on this 
 very simple example, I would think you would be better off with a Global like 
 this:

 Global Income income

 Style 1: one rule for each scenario
  rule household income, single
  when
  $p1 : Person()
  not Relation(person1 == $p1, type == spouse)
  then
  income = new Income($p1.getIncome());
  end
  rule household income, married
  when
  $p1 : Person()
  Relation(person1 == $p1, type == spouse, $p2: person2)
  then
  income = new Income($p1.getIncome() + $p2.getIncome());
  end

 Style 2: a single rule with a collection
  rule household income 
  when
  $p1 : Person()
  $rels : List() from collect(Relation($p1 == person1, type == 
 spouse))
  then
  income = new Income($p1.getIncome() + ($rels.size() == 0 ? 0 : 
 $rels.get(0).getPerson2().getIncome());
  end

 Then in code, you can get the Global value to determine what it got set to, 
 if you need outside of the Drools processing.  All thread safety factors must 
 be considered in a multi-threaded environment.  Global are not objects know 
 to rete, and therefore, use of them 

Re: [rules-users] Need Help: Error creating bean with name 'kbase'

2012-04-25 Thread singkamas
I am still working on this item today I would greatly appreciate any help.
Thanks.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Need-Help-Error-creating-bean-with-name-kbase-tp3937782p3940150.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