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.clldeliveryIntentmgt;
19 import lombok.EqualsAndHashCode;
20 import lombok.extern.slf4j.Slf4j;
21 import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
22 import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentInfo;
23 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
24 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
25 import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
27 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
28 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
29 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
30 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
31 import org.onap.usecaseui.intentanalysis.service.IntentService;
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("CLLDeliveryIntentManagementFunction")
44 public class CLLDeliveryIntentManagementFunction extends IntentManagementFunction {
45 @Resource(name = "CLLDeliveryActuationModule")
46 public void setActuationModule(ActuationModule actuationModule) {
47 this.actuationModule = actuationModule;
50 @Resource(name = "CLLDeliveryKnowledgeModule")
51 public void setKnowledgeModule(KnowledgeModule knowledgeModule) {
52 this.knowledgeModule = knowledgeModule;
55 @Resource(name = "CLLDeliveryDecisionModule")
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("cllDelivery Intent create begin time:" + LocalDateTime.now());
83 CreateCallable deliveryCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext);
84 FutureTask<String> futureTask = new FutureTask<>(deliveryCallable);
85 executor.submit(futureTask);
86 log.info(futureTask.get());
87 } catch (Exception ex) {
88 log.error("exception is {}", ex.getMessage());
93 public void createReport(String intentId, FulfillmentInfo fulfillmentInfo) {
94 String parentIntentId = intentService.findParentByIntentId(intentId);
95 intentInterfaceService.reportInterface(cllBusinessIntentManagementFunction, parentIntentId, fulfillmentInfo);
97 saveFulfillmentAndObjectInstance(intentId, fulfillmentInfo);