2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.controlloop;
23 import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
24 import org.onap.policy.controlloop.CanonicalOnset;
25 import org.onap.policy.controlloop.VirtualControlLoopEvent;
26 import org.onap.policy.controlloop.VirtualControlLoopNotification;
27 import org.onap.policy.controlloop.ControlLoopNotificationType;
28 import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2;
29 import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2.NewEventStatus;
30 import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2;
31 import org.onap.policy.controlloop.utils.ControlLoopUtils;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
34 import org.slf4j.LoggerFactory;
35 import org.slf4j.Logger;
37 import org.onap.policy.drools.system.PolicyEngineConstants;
42 System.out.println(drools.getRule().getName());
47 * Called when the ControlLoopParams object has been inserted into working memory from the BRMSGW.
52 $params : ControlLoopParams()
55 Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
56 logger.info("{}: {} : TOSCA-POLICY=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "."
57 + drools.getRule().getName(), $params.getToscaPolicy());
62 * Called when a Tosca Policy is present.
65 rule "NEW.TOSCA.POLICY"
67 $policy : ToscaPolicy()
70 Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
71 logger.info("{}: [{}|{}|{}|{}]: CONTENT: {}", drools.getRule().getName(),
72 $policy.getType(), $policy.getTypeVersion(), $policy.getName(),
73 $policy.getVersion(), $policy);
75 ControlLoopParams params = ControlLoopUtils.toControlLoopParams($policy);
82 * Remove Control Loop Parameters.
86 $params : ControlLoopParams( $policyName : getPolicyName(), $policyVersion : getPolicyVersion() )
87 not ( ToscaPolicy( getName() == $policyName, getVersion() == $policyVersion ) )
90 Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
91 logger.info("{}: [{}|{}|{}]", drools.getRule().getName(),
92 $params.getPolicyScope(), $params.getPolicyName(), $params.getPolicyVersion());