One Star

Regarding implementation of bussiness Rule in Talend

Hi All,

I am new user of Drools tool. I have done a sample business Rule in Drools and tested. It is working fine in Drools. So I validated the package and imported .drl file into talend studio under Meta data (Embedded Rules).
The code generated for the business rule is as follows:
package modelonsales
import salesmodel.Sales

import java.util.ArrayList
import java.util.HashMap
import java.lang.Integer
global ArrayList list
global HashMap globalMap

rule "SalesBR"
dialect "mvel"
when
exists Sales( sales >= "100" )
then
Sales fact0 = new Sales();
fact0.setName( "Discount" );
fact0.setSales( -10 );
insert(fact0 );
end

When I executing the job it is giving errors as follows:

Starting job DroolsJob at 14:14 21/11/2011.
connecting to socket on port 3678
connected


^

at org.mvel2.compiler.AbstractParser.procTypedNode(AbstractParser.java:1278)
at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:712)
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:106)
at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:55)
at org.drools.rule.builder.dialect.mvel.MVELExprAnalyzer.analyzeExpression(MVELExprAnalyzer.java:86)
at org.drools.rule.builder.dialect.mvel.MVELDialect.analyzeBlock(MVELDialect.java:492)
at org.drools.rule.builder.dialect.mvel.MVELConsequenceBuilder.build(MVELConsequenceBuilder.java:84)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:649)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at project1.droolsjob_0_1.DroolsJob$1KnowledgeBase_tRules_2.readKnowledgeBaseDRL(DroolsJob.java:595)
at project1.droolsjob_0_1.DroolsJob$1KnowledgeBase_tRules_2.readKnowledgeBase(DroolsJob.java:584)
at project1.droolsjob_0_1.DroolsJob.tFileInputExcel_2Process(DroolsJob.java:648)
at project1.droolsjob_0_1.DroolsJob.runJobInTOS(DroolsJob.java:1247)
at project1.droolsjob_0_1.DroolsJob.main(DroolsJob.java:1121)
Unable to resolve ObjectType 'Sales' :
Unable to build expression for 'consequence': unknown class or illegal statement: Sales 'Sales fact0 = new Sales();
fact0.setName( "Discount" );
fact0.setSales( -10 );
insert(fact0 );
' :
Error importing : 'salesmodel.Sales'
Exception in component tRules_2
java.lang.IllegalArgumentException: Could not parse knowledge.
at project1.droolsjob_0_1.DroolsJob$1KnowledgeBase_tRules_2.readKnowledgeBaseDRL(DroolsJob.java:604)
at project1.droolsjob_0_1.DroolsJob$1KnowledgeBase_tRules_2.readKnowledgeBase(DroolsJob.java:584)
at project1.droolsjob_0_1.DroolsJob.tFileInputExcel_2Process(DroolsJob.java:648)
at project1.droolsjob_0_1.DroolsJob.runJobInTOS(DroolsJob.java:1247)
at project1.droolsjob_0_1.DroolsJob.main(DroolsJob.java:1121)
disconnected
Job DroolsJob ended at 14:14 21/11/2011.


I have attached the screen shots along with this topic. Please find the attachments.
Please help me out on this issue.
Thanks and Regards,
Lalitha.
3 REPLIES
Four Stars

Re: Regarding implementation of bussiness Rule in Talend

Hi Lalitha
Some Business Rule implemented in Drools engine varies in syntax which talend recognize's. I think there is some syntax error in your imported Business Rule.
And for best Business Rule implementation refer: http://www.ibm.com/developerworks/java/library/j-drools/ and http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/ch05.html#d0e2785

tHANKS
ANIL KUMAR
anilmca4u@gmail.com
__________________________________________
Greeting on the eve of New Year..Have a wonderful new year u and to your team.
Happy 2012
One Star

Re: Regarding implementation of bussiness Rule in Talend

Hi Anil,

Thank you for your reply. I took the component from palette. Those configurations are different from it. At last we got the output.
Regards,
Lalitha.
Four Stars

Re: Regarding implementation of bussiness Rule in Talend

Hey Lalitha
Good to here you that you got it...Congratulation


tHANKS
ANIL KUMAR
anilmca4u@gmail.com
__________________________________________
Greeting on the eve of New Year..Have a wonderful new year u and to your team.
Happy 2012