Aturan. Kata ini sudah kita kenal sejak kecil. Pertama, orang tua mengajari kami cara melakukan hal yang benar, lalu kami datang ke sekolah, di mana guru mendikte aturan mereka sendiri. Di universitas, kita kembali dihadapkan pada peraturan yang ditetapkan oleh guru dan kantor dekan untuk kita. Seiring bertambahnya usia, kami mulai mengikuti hukum yang dikembangkan oleh negara. Apa kesamaan semua aturan ini? Fakta bahwa mereka telah diverifikasi selama bertahun-tahun, puluhan tahun, dan bahkan beberapa generasi. Bayangkan seperti apa hidup kita jika peraturannya sering diubah: setiap minggu atau setiap hari!
, Mediascope, : , . . -. , , .
?
, . ( ) - . BRMS Business Rule Management System. ,
- , -. , - , - .
, , «», . . : , , , , . , !
BRMS . : IBM, Red Hat, Agiloft, SAS Bosch. β , . JBoss Drools. , , , , - DRL, Excel-. UI- . , UI Excel-.
- ?
- , . , , , . .
, (gender). (SEX). , gender = male, «» 1. 2. DRL :
rule "Rule 1 Example 1"
when
$s: Respondent($s.gender == "male")
then
$s.addResult("SEX", "1");
end
rule "Rule 2 Example 2"
when
$s: Respondent($s.gender == "female")
then
$s.addResult("SEX", "2");
end
, , Gherkin. , ( when) , ( then). Drools Left Hand Side ( LHS), - Right Hand Side ( RHS). : Respondent. fact, Drools, . gender result. , , framework . $.
Excel-:
?
, , , , . , Drools , Miscrosoft Excel OpenOffice, CSV. DRL-.
: . RuleSet, β RuleTable. , .
DRL- . - . . :
RuleSet β DRL.
Import β , Java-, , , java.lang.Math
Functions β , RuleSetβ. DRL-.
, RuleTable, , , Drools DRL-. . nameforRuleTable.
:
NAME β . .
DESCRIPTION β . . , .
CONDITION β Left Hand Side , ACTION. .
ACTION β , . addResult, Map . . ACTION Java-, . .
, CONDITION ACTION .
, $s Respondent. , , , Import. CONDITION , . CONDITION-: , Import.
, , CONDITION ACTION, . , . . (Text-Parameter-Result ). . /, , Drools . .
?
, , . .
, Respondent. β , . (, , ). , , Drools, Respondent. , Map<String, String> result, . , Respondent :
public class Respondent {
public int id;
public String gender;
public Boolean isActive;
public Integer age;
public List<String> pets;
public String city;
public List<String> devices;
public Map<String, String> properties;
public Car car;
public MobileBrand mobileBrand;
public Household household;
public Map<String, String> result = new HashMap<>();
public void addResult(String key, String value) {
result.put(key, value);
}
// getters, setters, constructor
}
, , . , , ? isActive. true β , false β .
, : . , , , . Respondent. DRL:
rule "name_for_RuleTable_20"
when
$s: Respondent(isActive == true, gender == "male")
then
$s.addResult("SEX", "M");
end
rule "name_for_RuleTable_21"
when
$s: Respondent(isActive == true, gender == "female")
then
$s.addResult("SEX", "F");
end
$param - . isActive == $param isActive == true. . Drools , . , gender.
. :
, - 17 18 . , .
, β . , . , , PHONE_SALES_PER 2019 . , $param . , MobileBrand Import .
, . , ACTION $param, . . in:
: SAMSUNG APPLE, PREMIUM. , HUAWEI XIAOMI, NOT_PREMIUM. ( , :) ) , .
, ? contains. java.util.Collection. Respondent pets. , . , , . Β« Β» β , $param .
: forall(<>){<>}. . , . , , . . , , , param. , β ($s). , , Drools , - (city devices), CONDITION .
, β . size:
- , , . Β«-Β». Drools :
, . . , Car c : , , . , , . , -, . from:
, . , , Car, Respondent, Map<String, String> properties . POWER. Drools getValue. Functions :
:
, . : , PlayStation. , Household Respondent TVDevices PlayStation. :
?
. ACTION? , Java. . , , ACTION .
Drools, :
set β , Drools ;
update β , set;
modify β , , ;
insert β .
modify.
RuleTable , - 99 0. , $r, Respondentβa false. RuleTable isActive REJECTED TRUE.
CONDITION. , . , , . . Drools . , , , .
Drools (https://github.com/sxexesx/drools-decision-table).
Terima kasih atas perhatiannya! Saya harap artikel ini bermanfaat bagi mereka yang ingin terjun ke dunia BRMS yang menakjubkan!