blob: bf92f11e53729875aa4229277f3dee41ee8b1bba [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
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
21package org.onap.portalsdk.core.drools;
22global String age
23
24rule "Default"
25when
26$droolsRuleService : DroolsRuleServiceImpl( state != null )
27then
28System.out.println($droolsRuleService.accessLabel() +" "+ $droolsRuleService.getState() +" state legal age is " + getDefaultIfNull(age));
29$droolsRuleService.setResultsString($droolsRuleService.getState()+" state legal age is " + getDefaultIfNull(age));
30end
31
32rule "Drools NJ"
33when
34$droolsRuleService : DroolsRuleServiceImpl( state == "NJ" )
35then
36System.out.println($droolsRuleService.accessLabel() +" "+ "NJ state legal age is " + getDefaultIfNull(age));
37$droolsRuleService.setResultsString("NJ state legal age is " + getDefaultIfNull(age));
38end
39
40rule "Drools KY"
41when
42$droolsRuleService : DroolsRuleServiceImpl( state == "KY" )
43then
44System.out.println($droolsRuleService.accessLabel() +" "+ "KY state legal age is " + getDefaultIfNull("20"));
45$droolsRuleService.setResultsString("KY state legal age is " + getDefaultIfNull("20"));
46end
47
48rule "Drools NY"
49when
50$droolsRuleService : DroolsRuleServiceImpl( state == "NY" )
51then
52System.out.println($droolsRuleService.accessLabel() +" "+ "NY state legal age is " + getDefaultIfNull("21"));
53$droolsRuleService.setResultsString("NY state legal age is " + getDefaultIfNull("21"));
54end
55
56function String getDefaultIfNull(String age) {
57return age == null ? "18" : age;
58}