Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM Core
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 | package org.onap.portalsdk.core.drools;
|
| 22 | global String age
|
| 23 |
|
| 24 | rule "Default"
|
| 25 | when
|
| 26 | $droolsRuleService : DroolsRuleServiceImpl( state != null )
|
| 27 | then
|
| 28 | System.out.println($droolsRuleService.accessLabel() +" "+ $droolsRuleService.getState() +" state legal age is " + getDefaultIfNull(age));
|
| 29 | $droolsRuleService.setResultsString($droolsRuleService.getState()+" state legal age is " + getDefaultIfNull(age));
|
| 30 | end
|
| 31 |
|
| 32 | rule "Drools NJ"
|
| 33 | when
|
| 34 | $droolsRuleService : DroolsRuleServiceImpl( state == "NJ" )
|
| 35 | then
|
| 36 | System.out.println($droolsRuleService.accessLabel() +" "+ "NJ state legal age is " + getDefaultIfNull(age));
|
| 37 | $droolsRuleService.setResultsString("NJ state legal age is " + getDefaultIfNull(age));
|
| 38 | end
|
| 39 |
|
| 40 | rule "Drools KY"
|
| 41 | when
|
| 42 | $droolsRuleService : DroolsRuleServiceImpl( state == "KY" )
|
| 43 | then
|
| 44 | System.out.println($droolsRuleService.accessLabel() +" "+ "KY state legal age is " + getDefaultIfNull("20"));
|
| 45 | $droolsRuleService.setResultsString("KY state legal age is " + getDefaultIfNull("20"));
|
| 46 | end
|
| 47 |
|
| 48 | rule "Drools NY"
|
| 49 | when
|
| 50 | $droolsRuleService : DroolsRuleServiceImpl( state == "NY" )
|
| 51 | then
|
| 52 | System.out.println($droolsRuleService.accessLabel() +" "+ "NY state legal age is " + getDefaultIfNull("21"));
|
| 53 | $droolsRuleService.setResultsString("NY state legal age is " + getDefaultIfNull("21"));
|
| 54 | end
|
| 55 |
|
| 56 | function String getDefaultIfNull(String age) {
|
| 57 | return age == null ? "18" : age;
|
| 58 | }
|