Executing on a arbitrarily complex object
by gazzaaa87
Hi all,
I am using a StatelessKnowledgeSession and therefore call the execute method
to invoke the rules engine. Having carried out a basic test, it would appear
that calling execute on an arbitrarily complex object does not insert child
objects, rather rules will only fire if they are based on the parent.
e.g. let's say you have a class called 'Father', which holds a collection of
'Child' objects. By calling session.execute(fatherObject) I need rules to
fire that use the Child pattern without having to loop through 'insert'ing
all the child elements manually.
Has anyone come across a way around this? Having originally posted on the
dev forum there were a few suggestions:
- You could use the "from" keyword but your rules wouldn't work on *any*
arbitrary object - but this could be overcome if you could identify a
suitable super-class to extend for your arbitrary objects.
- Have you considered using the "from" Conditional Element, which lets
you reason over components of a fact's collection-type element, without them
being inserted as facts. See the Drools Expert manual for details.
- One way it has been done in the past is to have some rule with a
higher salience take that "root" object and "explode" it into the children
objects (as deep as needed).
The only thing I managed to find was the use of a Batch Executor but you
have to set that up before calling execute and therefore it's still
effectively a manual process.
If only Drools used java annotations, it would be ideal to specify behaviour
similar to cascade with JPA.
Any help or pointers much appreciated!
Dan
--
View this message in context: http://n3.nabble.com/Executing-on-a-arbitrarily-complex-object-tp192130p1...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
Executing runExamples.sh on OSX
by NickD
Hello all,
Newbie question here, but I wasn't sure from the manual if the issue was
mine or related to OS X.
I am trying to run the drools-planner examples in
src/main/assembly/scripts/runExamples.sh, but continue to get this error
nomatter what example I try. Am I missing something simple?
% ./runExamples.sh
./runExamples.sh: line 3:
lib/drools-planner-examples-${project.version}.jar: bad substitution
The environment is OSX Snow Leopard with Drools compiled from latest source
(5.1) in the last week as per the Planner manual. JAVA_HOME, etc is defined.
Any suggestions are very welcome.
Cheers, Nick
--
View this message in context: http://n3.nabble.com/Executing-runExamples-sh-on-OSX-tp188577p188577.html
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 11 months
String as an argument
by Khalil Hafsi
Hi Guys,
I am using Drools fusion 5, My "Event" class // @role (event) // has a
string parameter "id" , however if I try to do :
//
Rule ..
..
$a : Event(id == "a")
then
//do something
end
It complains about "Conversion from double is not supported in
java.lang.String" , is there any way to make it accept String arguments ?
Thanks,
K.H-
15 years, 11 months
Re: [rules-users] RES: Problem with proxy objects
by Edson Tirelli
Rogerio,
I don't know what javassist does with your class... if it preserves the
object hierarchy (what I think it probably does), then it must work. The
only way to find out the reason is with an isolated test case and do some
debugging to understand why it is not failing the isAssignableFrom() tests.
[]s
Edson
2010/2/5 Rogerio Baldini <rogerio.baldini(a)powerlogic.com.br>
> I think you didn't understand my problem.
> I don't have any problem related to Java arrays.
> My problem is drools is not working with proxy objects.
>
> I am executing drools rules with one javassist object
> (package.MyClass_$$_javassist_2) and drools is not recognizing this object
> as package.MyClass and is not executing my rule.
>
> Thanks,
>
> Rogério
>
>
>
>
> -----Mensagem original-----
> De: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org] Em nome de Wolfgang Laun
> Enviada em: sexta-feira, 5 de fevereiro de 2010 14:13
> Para: Rules Users List
> Assunto: Re: [rules-users] Problem with proxy objects
>
> <quote from="Drools Expert Manual">
> Unfortunately a Java array does not implement the Iterable interface, so
> we
> have to use the JDK converter method Arrays.asList(...).
> </quote>
>
> Try
> ksession.execute( Arrays.asList( new Object[] { myObject} ) );
>
> -W
>
> 2010/2/5 Rogerio Baldini <rogerio.baldini(a)powerlogic.com.br>:
> > Hi guys,
> >
> >
> >
> > I am trying to execute rules passing a proxy object to it.
> >
> > The object myObject is a javassist proxy object:
> > package.MyClass_$$_javassist_2
> >
> >
> >
> > Properties p = new Properties();
> >
> > p.put("url",
> > "http://localhost:8090/drools-guvnor/org.drools.guvnor.Guvnor/package/
> > pacote/LATEST");
> >
> >
> >
> > RuleAgent agent = RuleAgent.newRuleAgent(p);
> >
> > RuleBase ruleBase = agent.getRuleBase();
> >
> >
> >
> > StatelessSession ksession = ruleBase.newStatelessSession();
> >
> >
> >
> > ksession.execute(new Object[] {myObject});
> >
> >
> >
> >
> >
> > So, with this proxy object, my rule is not executed. If I pass a real
> > instance, the rule works fine.
> >
> >
> >
> > package mypackage;
> >
> > import package.MyClass;
> >
> >
> >
> > global java.util.List list
> >
> >
> >
> > rule "Testing"
> >
> > dialect "java"
> >
> > when
> >
> > f: MyClass()
> >
> > then
> >
> > System.out.println("Exist "+f.getDay());
> >
> > f.setDay("15");
> >
> > end
> >
> >
> >
> >
> >
> > Can anybody help me ?
> >
> > Thanks,
> >
> > Rogerio
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
15 years, 11 months
Re: [rules-users] RES: Problem with proxy objects
by Wolfgang Laun
On Fri, Feb 5, 2010 at 5:46 PM, Rogerio Baldini
<rogerio.baldini(a)powerlogic.com.br> wrote:
> I think you didn't understand my problem.
Perhaps. But the code you posted doesn't seem right.
> I don't have any problem related to Java arrays.
> My problem is drools is not working with proxy objects.
>
> I am executing drools rules with one javassist object
> (package.MyClass_$$_javassist_2) and drools is not recognizing this object
> as package.MyClass and is not executing my rule.
>
In any case, your rules must reference the classes of the objects you
insert, or a superclasse, or an implemented interface. Otherwise, no
rule will fire.
-W
> Thanks,
>
> Rogério
>
>
>
>
> -----Mensagem original-----
> De: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org] Em nome de Wolfgang Laun
> Enviada em: sexta-feira, 5 de fevereiro de 2010 14:13
> Para: Rules Users List
> Assunto: Re: [rules-users] Problem with proxy objects
>
> <quote from="Drools Expert Manual">
> Unfortunately a Java array does not implement the Iterable interface, so we
> have to use the JDK converter method Arrays.asList(...).
> </quote>
>
> Try
> ksession.execute( Arrays.asList( new Object[] { myObject} ) );
>
> -W
>
> 2010/2/5 Rogerio Baldini <rogerio.baldini(a)powerlogic.com.br>:
>> Hi guys,
>>
>>
>>
>> I am trying to execute rules passing a proxy object to it.
>>
>> The object myObject is a javassist proxy object:
>> package.MyClass_$$_javassist_2
>>
>>
>>
>> Properties p = new Properties();
>>
>> p.put("url",
>> "http://localhost:8090/drools-guvnor/org.drools.guvnor.Guvnor/package/
>> pacote/LATEST");
>>
>>
>>
>> RuleAgent agent = RuleAgent.newRuleAgent(p);
>>
>> RuleBase ruleBase = agent.getRuleBase();
>>
>>
>>
>> StatelessSession ksession = ruleBase.newStatelessSession();
>>
>>
>>
>> ksession.execute(new Object[] {myObject});
>>
>>
>>
>>
>>
>> So, with this proxy object, my rule is not executed. If I pass a real
>> instance, the rule works fine.
>>
>>
>>
>> package mypackage;
>>
>> import package.MyClass;
>>
>>
>>
>> global java.util.List list
>>
>>
>>
>> rule "Testing"
>>
>> dialect "java"
>>
>> when
>>
>> f: MyClass()
>>
>> then
>>
>> System.out.println("Exist "+f.getDay());
>>
>> f.setDay("15");
>>
>> end
>>
>>
>>
>>
>>
>> Can anybody help me ?
>>
>> Thanks,
>>
>> Rogerio
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years, 11 months
Re: [rules-users] Problem with proxy objects
by Wolfgang Laun
<quote from="Drools Expert Manual">
Unfortunately a Java array does not implement the Iterable interface,
so we have to use the JDK converter method Arrays.asList(...).
</quote>
Try
ksession.execute( Arrays.asList( new Object[] { myObject} ) );
-W
2010/2/5 Rogerio Baldini <rogerio.baldini(a)powerlogic.com.br>:
> Hi guys,
>
>
>
> I am trying to execute rules passing a proxy object to it.
>
> The object myObject is a javassist proxy object:
> package.MyClass_$$_javassist_2
>
>
>
> Properties p = new Properties();
>
> p.put("url",
> "http://localhost:8090/drools-guvnor/org.drools.guvnor.Guvnor/package/paco...");
>
>
>
> RuleAgent agent = RuleAgent.newRuleAgent(p);
>
> RuleBase ruleBase = agent.getRuleBase();
>
>
>
> StatelessSession ksession = ruleBase.newStatelessSession();
>
>
>
> ksession.execute(new Object[] {myObject});
>
>
>
>
>
> So, with this proxy object, my rule is not executed. If I pass a real
> instance, the rule works fine.
>
>
>
> package mypackage;
>
> import package.MyClass;
>
>
>
> global java.util.List list
>
>
>
> rule "Testing"
>
> dialect "java"
>
> when
>
> f: MyClass()
>
> then
>
> System.out.println("Exist "+f.getDay());
>
> f.setDay("15");
>
> end
>
>
>
>
>
> Can anybody help me ?
>
> Thanks,
>
> Rogerio
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
15 years, 11 months
How to Use BigDecimal in Drools 5.0
by Nikhil S. Kulkarni
Hi,
I have a doubt that how to use java.math.BigDecimal within facts of Drools.
Waiting for reply.
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