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 lombok.extern.slf4j.Slf4j;
19 import org.apache.commons.lang.StringUtils;
20 import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService;
21 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
22 import org.onap.usecaseui.intentanalysis.bean.models.*;
23 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
24 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
25 import org.onap.usecaseui.intentanalysis.service.ContextService;
26 import org.onap.usecaseui.intentanalysis.service.IntentService;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Component;
30 import java.util.List;
33 public class CLLAssuranceActuationModule extends ActuationModule {
35 private IntentService intentService;
38 private PolicyService policyService;
40 private ContextService contextService;
43 public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
48 public void directOperation(IntentGoalBean intentGoalBean) {
49 Intent intent = intentGoalBean.getIntent();
50 String cllId = getCLLId(intent);
51 String bandwidth = getBandwidth(cllId);
52 IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
53 if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) {
54 policyService.updateIntentConfigPolicy(cllId, bandwidth, "true");
55 } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) {
56 policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
57 } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) {
58 policyService.updateIntentConfigPolicy(cllId, bandwidth, "false");
63 public void interactWithIntentHandle() {
68 public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
69 directOperation(intentGoalBean);
73 public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){
74 log.info("cllDeliveryActuationModule begin to update originIntent subIntentInfo");
75 contextService.updateContextList(originIntent.getIntentContexts(), originIntent.getIntentId());
78 private String getBandwidth(String cllId) {
79 List<Intent> deliveryIntentList = intentService.getIntentByName("CLL Delivery Intent");
80 for (Intent deliveryIntent : deliveryIntentList) {
81 List<Expectation> deliveryExpectationList = deliveryIntent.getIntentExpectations();
82 for (Expectation deliveryExpectation : deliveryExpectationList) {
83 if (StringUtils.equalsIgnoreCase(cllId, deliveryExpectation.getExpectationObject().getObjectInstance())) {
84 List<ExpectationTarget> deliveryTargetList = deliveryExpectation.getExpectationTargets();
85 for (ExpectationTarget deliveryTarget : deliveryTargetList) {
86 if (StringUtils.equalsIgnoreCase("bandwidth", deliveryTarget.getTargetName())) {
87 List<Condition> deliveryConditionList = deliveryTarget.getTargetConditions();
88 for (Condition deliveryCondition : deliveryConditionList) {
89 if (StringUtils.equalsIgnoreCase("condition of the cll service bandwidth", deliveryCondition.getConditionName())) {
90 return deliveryCondition.getConditionValue();
101 public String getCLLId(Intent intent) {
102 List<Expectation> expectationList = intent.getIntentExpectations();
103 for (Expectation expectation : expectationList) {
104 if (StringUtils.equalsIgnoreCase("assurance", expectation.getExpectationType().name())) {
105 return expectation.getExpectationObject().getObjectInstance();