Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions Simplifying the Development of Rules Using Domain Specific Languages in DROOLS Ludwig Ostermayer, Geng Sun, Dietmar Seipel University of W¨ urzburg, Dept. of Computer Science INAP 2013 – Kiel, 12.09.2013
32
Embed
Simplifying the Development of Rules Using Domain · PDF fileIntroduction DROOLS DSL Design The Tool PROLOG–Based AnalysisConclusions Simplifying the Development of Rules Using Domain
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Simplifying the Development of RulesUsing Domain Specific Languages in DROOLS
Ludwig Ostermayer, Geng Sun, Dietmar Seipel
University of Wurzburg, Dept. of Computer Science
INAP 2013 – Kiel, 12.09.2013
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
1 Introduction
2 DROOLS
DROOLS Rule LanguageDSLs in DROOLS
3 DSL DesignDSL TemplatesAnnotations
4 The ToolDSL EditorDSL Rule EditorAttribute Editor
5 PROLOG–Based AnalysisTemplatesRules
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Introduction
the business rules approach provides a methodology forsystem development creating applications as white boxesbusiness logic is visible, because it is separated intobusiness rulesBusiness Rule Management Systems (BRMS) have beendevelopedin BRMS you can define, deploy, execute, monitor, andmaintain decision logicDROOLS is a BRMS
a Domain Specific Language (DSL) is a programminglanguage of limited expressiveness for a particular problemdomainthe DSL Rule Generator (DSLR) is a tool improving thedevelopment process in DROOLS
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
BRMS Project
Project with Trinodis GmbH:
development of business rules applicationsusage of PROLOG technology and related technologyseveral case studies in real business scenariosanalysis of business rulesbusiness analyst–friendly annotation of business rules
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Introducing DROOLS
DROOLS – the Business Logic Integration PlatformJAVA–baseddeveloped by the JBOSS community
DROOLS consists of several modules:Expert (Inference Engine)Guvnor (Business Rules Manager)Fusion (Event Processing/Temporal Reasoning)Planner (Automated Planning)
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Production Rule System DROOLS EXPERT
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
DROOLS Rule Language
formerly: rules were written in XML
XML format is not supported any morenow: rules are written basically in the DROOLS RuleLanguangesimple text files with the extension .drlrules are packed by namespaces – referred to as packageglobal variables can be defined and used within rules viathe globals statementcomplex logic can be outsourced and used within rules viathe functions statement
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
[when] indicates the expression as condition[then] is used for an action blockthe single equality sign ”=” separates the expressions inDSL format from the corresponding DRL format
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
A Rule written in the DSL
rule "microfinance"when
The loan withloan_amount is smaller than 5000
and duration_year is no more than 3The customer with
monthly_income is greater than 2000and credit_report is "good"
thenThe loan will be approvedSet the interest_rate of the loan to 0.025
end
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
DROOLS DSL Editor
a very ”basic” DSL editorlacks user friendliness and functionalityno content assistno package explorer for JAVA classes, attributes ormethodsno component to simply create rules in a DSL
lacks reusability
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
DSLR Generator
a few guided steps to create rules in a readable format andwith correct syntaxdevelopment a DSL with the aid of generic templatesgraphical editors help during the construction of syntacticalcorrect rulesa brief example illustrating the usage
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
A Template for a DSL Expression
The #instance with#field is smaller than {value} =
#instance: #class(#field < {value})
generic templates for expressions containing the mappinginformation between DSL and DRL
keywords and parameters in a template can be replacedtemplates are designed in JAVA
but transformed to XML to improve readability
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
<expression>The #instance with #field is smallerthan {value}
</expression><code>
#instance:#class(#field < {value})</code>
</dsl></condition>
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Annotations
form of syntactic meta-data added to JAVA source codeused to accomplish multilingual DSLsclasses, attributes and methods can be annotatedkeywords are replaced by annotation values
@EnExpression(value = "amount of loan")@GerExpression(value = "Kredithoehe")private double loan_amount;
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Components
5 components for the creation of rules, each has a graphicaluser interface
Transformed rules are analyzed, but usually cannot beexecuted.
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Rule Anomalies
If there isa condition referencing a fact with identifier Id, e.g.,application, andan instruction modifyObject(Id) in the action block,
then DROOLS fires all appropriate rules again, which results ina loop. This can be avoided by the no-loop attribute.
drools anomaly(+Prolog, -Anomaly)
reports the anomalies on backtracking.
Further anomalies:duplicates,contradictions,in connection with prioritization.
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Visualization: Proof Trees
red circles: derived atomsblue boxes: rule nodes are labeled by numbersorange circles: basic predicates from the configuration
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions
Conclusions
What we have presented:a tool, DSLR Generator, for handling DSLsgraphical user interfaces supporting the rule developmentreusable and generic DSL templatesmaintenance of the meta–data for the rulesanalysis of templates
Future work:extension of the PROLOG–based anomaly analysis,especially for rulesa library of DSL templates for various problem domains
Introduction DROOLS DSL Design The Tool PROLOG–Based Analysis Conclusions