2 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule;
18 import org.apache.commons.lang.StringUtils;
19 import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService;
20 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
21 import org.onap.usecaseui.intentanalysis.bean.models.*;
22 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
23 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
24 import org.onap.usecaseui.intentanalysis.service.IntentService;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.stereotype.Component;
28 import java.util.List;
31 public class CLLAssuranceActuationModule extends ActuationModule {
33 private IntentService intentService;
36 private PolicyService policyService;
39 public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
44 public void directOperation(IntentGoalBean intentGoalBean) {
45 Intent intent = intentGoalBean.getIntent();
46 String cllId = getCLLId(intent);
47 String bandwidth = getBandwidth(cllId);
48 IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
49 if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) {
50 policyService.updateIntentConfigPolicy(cllId, bandwidth, "true");
51 } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) {
52 policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
53 } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) {
54 policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
59 public void interactWithIntentHandle() {
64 public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
65 directOperation(intentGoalBean);
69 public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){
73 private String getBandwidth(String cllId) {
74 List<Intent> deliveryIntentList = intentService.getIntentByName("CLL Delivery Intent");
75 for (Intent deliveryIntent : deliveryIntentList) {
76 List<Expectation> deliveryExpectationList = deliveryIntent.getIntentExpectations();
77 for (Expectation deliveryExpectation : deliveryExpectationList) {
78 if (StringUtils.equalsIgnoreCase(cllId, deliveryExpectation.getExpectationObject().getObjectInstance())) {
79 List<ExpectationTarget> deliveryTargetList = deliveryExpectation.getExpectationTargets();
80 for (ExpectationTarget deliveryTarget : deliveryTargetList) {
81 if (StringUtils.equalsIgnoreCase("bandwidth", deliveryTarget.getTargetName())) {
82 List<Condition> deliveryConditionList = deliveryTarget.getTargetConditions();
83 for (Condition deliveryCondition : deliveryConditionList) {
84 if (StringUtils.equalsIgnoreCase("condition of the cll service bandwidth", deliveryCondition.getConditionName())) {
85 return deliveryCondition.getConditionValue();
96 public String getCLLId(Intent intent) {
97 List<Expectation> expectationList = intent.getIntentExpectations();
98 for (Expectation expectation : expectationList) {
99 if (StringUtils.equalsIgnoreCase("assurance", expectation.getExpectationType().name())) {
100 return expectation.getExpectationObject().getObjectInstance();