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;
19 import lombok.extern.slf4j.Slf4j;
20 import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
21 import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
22 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
23 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
24 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
25 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
27 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
28 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
29 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
30 import org.onap.usecaseui.intentanalysis.service.IntentService;
31 import org.springframework.beans.BeanUtils;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.context.ApplicationContext;
34 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
35 import org.springframework.stereotype.Component;
37 import javax.annotation.Resource;
38 import java.time.LocalDateTime;
39 import java.util.concurrent.FutureTask;
43 @Component("CLLAssuranceIntentManagementFunction")
44 public class CLLAssuranceIntentManagementFunction extends IntentManagementFunction {
45 @Resource(name = "CLLAssuranceActuationModule")
46 public void setActuationModule(ActuationModule actuationModule) {
47 this.actuationModule = actuationModule;
50 @Resource(name = "CLLAssuranceKnowledgeModule")
51 public void setKnowledgeModule(KnowledgeModule knowledgeModule) {
52 this.knowledgeModule = knowledgeModule;
55 @Resource(name = "CLLAssuranceDecisionModule")
56 public void setDecisionModule(DecisionModule decisionModule) {
57 this.decisionModule = decisionModule;
61 ApplicationContext applicationContext;
62 @Resource(name = "intentTaskExecutor")
63 ThreadPoolTaskExecutor executor;
66 private CLLBusinessIntentManagementFunction cllBusinessIntentManagementFunction;
69 private IntentInterfaceService intentInterfaceService;
72 private IntentService intentService;
75 public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
79 public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
80 //ask knowledgeModole of handler imf for permision and operate
82 log.debug("cllAssurance Intent {} begin time:{}", intentGoalBean.getIntentGoalType(), LocalDateTime.now());
83 log.debug(Thread.currentThread().getName());
84 CreateCallable assuranceCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext);
85 FutureTask<String> futureTask = new FutureTask<>(assuranceCallable);
86 executor.submit(futureTask);
87 log.info(futureTask.get());
88 } catch (Exception ex) {
89 log.error("exception is {}", ex.getMessage());
95 public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
97 String parentIntentId = intentService.findParentByIntentId(intentId);
99 FulfillmentInfo newInfo = new FulfillmentInfo();
100 BeanUtils.copyProperties(fulfillmentInfo, newInfo);
102 intentInterfaceService.reportInterface(cllBusinessIntentManagementFunction, parentIntentId, newInfo);
104 saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);