jimmydot | 3982f4f | 2017-05-07 14:58:24 -0400 | [diff] [blame^] | 1 | package org.openecomp.portalsdk.core.drools;
|
| 2 | global String age
|
| 3 |
|
| 4 | rule "Default"
|
| 5 | when
|
| 6 | $droolsRuleService : DroolsRuleServiceImpl( state != null )
|
| 7 | then
|
| 8 | System.out.println($droolsRuleService.accessLabel() +" "+ $droolsRuleService.getState() +" state legal age is " + getDefaultIfNull(age));
|
| 9 | $droolsRuleService.setResultsString($droolsRuleService.getState()+" state legal age is " + getDefaultIfNull(age));
|
| 10 | end
|
| 11 |
|
| 12 | rule "Drools NJ"
|
| 13 | when
|
| 14 | $droolsRuleService : DroolsRuleServiceImpl( state == "NJ" )
|
| 15 | then
|
| 16 | System.out.println($droolsRuleService.accessLabel() +" "+ "NJ state legal age is " + getDefaultIfNull(age));
|
| 17 | $droolsRuleService.setResultsString("NJ state legal age is " + getDefaultIfNull(age));
|
| 18 | end
|
| 19 |
|
| 20 | rule "Drools KY"
|
| 21 | when
|
| 22 | $droolsRuleService : DroolsRuleServiceImpl( state == "KY" )
|
| 23 | then
|
| 24 | System.out.println($droolsRuleService.accessLabel() +" "+ "KY state legal age is " + getDefaultIfNull("20"));
|
| 25 | $droolsRuleService.setResultsString("KY state legal age is " + getDefaultIfNull("20"));
|
| 26 | end
|
| 27 |
|
| 28 | rule "Drools NY"
|
| 29 | when
|
| 30 | $droolsRuleService : DroolsRuleServiceImpl( state == "NY" )
|
| 31 | then
|
| 32 | System.out.println($droolsRuleService.accessLabel() +" "+ "NY state legal age is " + getDefaultIfNull("21"));
|
| 33 | $droolsRuleService.setResultsString("NY state legal age is " + getDefaultIfNull("21"));
|
| 34 | end
|
| 35 |
|
| 36 | function String getDefaultIfNull(String age) {
|
| 37 | return age == null ? "18" : age;
|
| 38 | }
|