0
votes

I am trying to visualize some drl file not using drools workbench(or business central). I've found the function to create drl file by passing value. However, I can't find the way to do opposite thing.

I expect to parse the existed drl file into some value or other format that can be easily used in my Vue project. At the moment I am looking for it in Drools souce code but can't find it.

I don't want to use drools workbench because it's not convenient enough to use. But if there are some functions or libraries in its souce code, please let me know. It's also very helpful.

I am using drools 7.0.0.final now.

Thanks for reading my question, if you have any idea, please help me.

1
Please specify the version of Drools you are using. - Ioannis Barakos
Oh sorry, I forgot this. I am using drools 7.0.0.final. - Eyre Young
You want the text from DRL? or you want to get the Rules from Kie Server already loaded in a Drools package (e.g. org.kie.api.definition.rule.Rule)? To make it clear, you want to read / parse DRL file stored in your Kie Server from a java application running remotely? Also what information you want to read from DRL? Conditions and actions? Rule names only? - Ioannis Barakos

1 Answers

1
votes

I'm not sure about what you're trying to achieve, but let me give you some hints.

The org.drools.compiler.compiler.DrlParser in the drools-compiler module will parse the DRL and generate the PackageDescr, pretty much an AST of the rule file. Take a look at org.drools.compiler.compiler.DrlParserTest for an example.

The org.drools.compiler.builder.impl.KnowledgeBuilderImpl will create the *Impl* classes which are used by the runtime of Drools.

Alternatively you can take a look at the drools-model-compiler module, in which theres a compiler org.drools.modelcompiler.builder.ModelBuilderImpl that compiles *Descrs into a Java DSL we created recently, the executable model. see org.drools.modelcompiler.CompilerTest and org.drools.modelcompiler.PatternDSLTest

Let me know if it helps.

Good luck