RIF releases spec for production rules
by Michael Neale
For anyone interested in rules standards:
http://www.w3.org/2005/rules/wiki/PRD
Before your eyes glaze over, it has some interesting points,
particularly section 1.3 (Running example). - note the easier to read
presentation syntax (which I think it means to be totally compatible
with the XML at the AST level).
Anyone interested in implementing some support for PRD part of RIF,
either via XML or via a grammar for the presentation syntax (not sure
if converters already exist to go from presentation syntax to XML). We
could have a competition to see who does it ;)
Standards are interesting, although often impractical in practice.
However, they are often important for people as it increases the
comfort level with technology (even if they know that interchange or
migration may not be trivial or smooth, at least its not total lock in
from their point of view). For example, look at SQL. At a low level
its radically different between databases, yet people still feel
comfortable using it.
In terms of how we could implement it:
a) parse to our desc/AST
b) parse to X, dump to DRL
Obviously A is better, but its (probably) more work, and harder to
debug as you are building it.
Thoughts?
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
16 years, 5 months
XJC and JAXB DataLoader
by Mark Proctor
I got the Smooks Data Loader working last week, as mentioned in my blog,
and now trying to do something similar for JAXB. However for this to
work you need to generate the java source code at runtime and add it to
PackageBuilder for compilation. I'm told that XJC can indeed generate
source code, without needing to use the disk, but I'm having problems
getting it to work. Any one done this before, and have some feedback on
how to make this work?
-----------The test.xsd file-----------
schema xmlns = "http://www.w3.org/2001/XMLSchema"
xmlns:exp="http://www.oracle.com/sample3/"
targetNamespace="http://www.oracle.com/sample3/"
elementFormDefault="qualified">
<complexType name="Address">
<sequence>
<element name="name" type="string"/>
<element name="doorNumber" type="short"/>
<element name="street" type="string"/>
<element name="city" type="string"/>
</sequence>
</complexType>
<complexType name="USAddress">
<complexContent>
<extension base="exp:Address">
<sequence>
<element name="state" type="string"/>
<element name="zip" type="integer"/>
<element name="country" type="string"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element name="myAddress" type="exp:USAddress"/>
</schema>
--------The Test-------------
public void test1() throws Exception {
Options xjcOpts = new Options();
xjcOpts.setSchemaLanguage( Language.XMLSCHEMA );
InputStream stream = getClass().getResourceAsStream( "test.xsd"
);
assertNotNull( stream );
InputSource source = new InputSource( new InputStreamReader(
stream ) );
source.setSystemId( ".xsd" );
xjcOpts.addGrammar( source );
ErrorReceiver errorReceiver = new
DroolsJaxb.JaxbErrorReceiver4Mvn();
Model model = ModelLoader.load( xjcOpts, new JCodeModel(),
errorReceiver);
final Outline outline = model.generateCode(xjcOpts,
errorReceiver);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
model.codeModel.build( xjcOpts.createCodeWriter( new
SingleStreamCodeWriter( baos ) ) );
String str = new String( baos.toByteArray() );
System.out.println( str );
}
-------------The Error----------------
java.io.IOException: Stream closed
at
com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:305)
at
com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:88)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:147)
at
com.sun.tools.xjc.ModelLoader.createXSOMSpeculative(ModelLoader.java:496)
at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:366)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at
org.drools.dataloaders.jaxb.DroolsJaxbTest.test1(DroolsJaxbTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
16 years, 5 months
FW: Rule Parameters/Aliases
by Anstis, Michael (M.)
Just in case anybody else mistook Yoni's posting.
-----Original Message-----
From: y.mazar(a)gmail.com [mailto:y.mazar@gmail.com]
Sent: 09 July 2008 13:59
To: Anstis, Michael (M.)
Subject: RE: Rule Parameters/Aliases
Hi Mike,
Indeed I used some of the contents of the first post, but the intension
in this one is different than the first post.
The first post (which was posted at the users sections) was in purpose
to see if there is a simple workaround which will save the need in
development.
We are starting to realize that we will have to develop this
functionality ourselves and this post requests development advices,
leads or referals - and I believe that this should be pointed to
developers audience rather than the users.
Yoni
p.s. I am not completly aware who runs the forums but I believe that
some answers which cannot be answered by the users of a specific product
may be answerd by the developers who know the product better....
Anstis, Michael (M.) wrote:
>
> I am not sure re-posting the same questions a couple of weeks later
will
> give any better responses.
>
> I also know this would better be addressed to the users forum and not
> the developers'.
>
> With regards,
>
> Mike
>
> -----Original Message-----
> From: rules-dev-bounces(a)lists.jboss.org
> [mailto:rules-dev-bounces@lists.jboss.org] On Behalf Of Yoni Mazar
> Sent: 09 July 2008 12:51
> To: rules-dev(a)lists.jboss.org
> Subject: [rules-dev] Rule Parameters/Aliases
>
>
> Hi all,
>
> We are at the begining of a new clinical decision-support project.
> We plan using drools (using Eclipse) in order to manage and execute
our
> business logic.
> As part of our research, we also evaluated JRules which has a feature
> that
> is very important to us and we could not find in Drools.
> Unless we missed it out, we will probably try and add this
functionality
> ourselves.
>
> In JRules, one can define a ruleset (corresponds to a package) with
> parameters. Each parameter has a datatype (a class), a direction
> (in/out/inout), and an alias.
> Then, within the rules, the user can refer to the parameter alias. For
> example, a user can define a ruleset with the following parameters:
>
> *class=LabResult, direction=in, alias=hemoglobin
> *class=LabResult, direction=in, alias=creatinin
>
> Then, within a rule, one can write:
> when hemoglobin.value<10 and creatinin.value>34
> then...
>
> Now, the application retrieves the patient data accordingly
(hemoglobin
> and
> creatinine data separetly - even though they are of the same type) and
> sets
> the ruleset parameters:
> ruleset.parameters.add("hemoglobin",hemoglobinFact)
> ruleset.parameters.add("creatinin",creatininFact)
>
> It is important that the definition of the aliases will be done
outside
> of
> the rule (and not by defining in-rule variables)
>
> This approach simplifies the rules since some of the filtering is
being
> applied externally (not in the rule itself)
>
> Does someone has an idea how to bridge this gap using Drools?
> Are there any workarounds that can be used in order to avoid changes
in
> code?
>
> And here we can use your help:
> We are new to Drools (and still have to dive into the big ocean of
code
> that
> exists).
> The following features
>
> 1) defining parameters (in the package level...something like import)
> 2) adding in/out modifiers (can be used in LHS, RHS, or both)
> 3) allowing assignment of aliases to parameters
> 4) adding such functionality to the rule editor (auto-complete ,type
> safety)
>
> Where should we start?
> Do you have any ideas that can help start this process (e.g. relevant
> classes, modules)?
> We would appreciate any help regarding any of the items in the list
> above.
> Any hints, suggestions, directions, referals and so on.
>
> Thanks a lot.
>
> Yoni
>
> --
> View this message in context:
> http://www.nabble.com/Rule-Parameters-Aliases-tp18359434p18359434.html
> Sent from the drools - dev mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
Quoted from:
http://www.nabble.com/Rule-Parameters-Aliases-tp18359434p18360008.html
16 years, 5 months
array property evaluation
by Cosimo Birtolo
i all,
I'm using drools rule with axis2 and tomcat 6.0.13 and i get this error
org.drools.RuntimeDroolsException: Exception executing predicate eval( stereotypeID[1] == "D1" )
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:216)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at
org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at sapi.adapter.ws.AdapterManager.getAdaptedEntity(AdapterManager.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at
java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: org.mvel.PropertyAccessException: unable to resolve property: stereotypeID[1]
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:286)
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:186)
at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:21)
at
org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:235)
at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:45)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:209)
... 37 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:459)
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:264)
... 45 more
import sapi.adapter.ws.EntityAdapter;
import sapi.KnowledgeManager.bean.Entity;
import
sapi.KnowledgeManager.bean.UserContextStereotype;
rule "all_1.1"
salience 10
no-loop true
when
$ent : Entity();
$ucs : UserContextStereotype(
magnifier==true &&
stereotypeID[1]=="D1");
then
$ent = EntityAdapter.resize($ent,90);
end
I don't understand why when I start this rule under eclipse it work just fine.
If I use this application as webService I get this error.
Can anyone help me?
Thanks
Posta, news, sport, oroscopo: tutto in una sola pagina
Crea l'home page che piace a te!.
Posta, news, sport, oroscopo: tutto in una sola pagina.
Crea l'home page che piace a te!
www.yahoo.it/latuapagina
16 years, 5 months
array property evaluation
by Cosimo Birtolo
Hi all,
I'm using drools rule with axis2 and tomcat 6.0.13 and i get this error
org.drools.RuntimeDroolsException: Exception executing predicate eval( stereotypeID[1] == "D1" )
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:216)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at sapi.adapter.ws.AdapterManager.getAdaptedEntity(AdapterManager.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: org.mvel.PropertyAccessException: unable to resolve property: stereotypeID[1]
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:286)
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:186)
at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:21)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:235)
at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:45)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:209)
... 37 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:459)
at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:264)
... 45 more
import sapi.adapter.ws.EntityAdapter;
import sapi.KnowledgeManager.bean.Entity;
import sapi.KnowledgeManager.bean.UserContextStereotype;
rule "all_1.1"
salience 10
no-loop true
when
$ent : Entity();
$ucs : UserContextStereotype(
magnifier==true &&
stereotypeID[1]=="D1");
then
$ent = EntityAdapter.resize($ent,90);
end
I don't understand why when I start this rule under eclipse it work just fine.
If I use this application as webService I get this error.
Can anyone help me?
Thanks
Posta, news, sport, oroscopo: tutto in una sola pagina.
Crea l'home page che piace a te!
www.yahoo.it/latuapagina
16 years, 5 months