drools programmatically generate a fact model

半腔热情 提交于 2019-12-22 12:38:10

问题


I need to generate an enormous fact model using an ontology external to drools. Now, I could certainly write a script/program to pull this off. My approach would be to generate a java bean for each ontology class which contains the appropriate fields, methods, and references to other java objects based on ontological relationships (probably in a map). My question is whether drools has a more elegant way to approach this problem. I figure it must be a common problem that the fact model is derivable from resource available outside of drools, so I'm wondering if maybe drools(or guvnor) has a built in method of generating a fact model given some structured input.

I did find some discussion in the following thread: http://drools.46999.n3.nabble.com/rules-users-Using-an-OWL-Ontology-in-drools-advice-td3724566.html

Unfortunately I wasn't able to get very far following this conversation.

Update:

The traits article linked by @alikok is very helpful. It at least provides a framework into which an ontology can fit. To summarize, one of the big problems with fitting an ontology into a java bean class model is that java doesn't do multiple inheritance. Almost any ontology will require this, and mine is no exception. Traits solve this with proxy classes, but they do it all in the background by allowing you to define new "traits" in the drl files.

I still have the problem of converting my ontology into a fact model. This is the main issue for this post (programmatically generating a fact model) so I don't want to check this as answered just yet. I could do it at compile time through a custom program like I describe above. I could also do it at runtime, though for my use case compile time would be much better. I'm hoping, however, that someone has already tackled this problem and can offer some insights into what approach they used.

来源:https://stackoverflow.com/questions/22292814/drools-programmatically-generate-a-fact-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!