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.intentBaseService.intentProcessService;
18 import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
19 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
20 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
21 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
22 import org.onap.usecaseui.intentanalysis.service.IntentService;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.stereotype.Service;
26 import java.util.Iterator;
27 import java.util.LinkedHashMap;
31 public class IntentProcessService {
33 IntentDetectionService intentDetectionService;
35 IntentInvestigationService intentInvestigationService;
37 IntentDefinitionService intentDefinitionService;
39 IntentDistributionService intentDistributionService;
41 IntentOperationService intentOperationService;
43 IntentService intentService;
44 private IntentManagementFunction intentOwner;
45 private IntentManagementFunction intentHandler;
48 public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) {
49 if (intentOwner != null) {
50 this.intentOwner = intentOwner;
52 if (intentHandler != null) {
53 this.intentHandler = intentHandler;
57 public IntentGoalBean intentProcess(IntentGoalBean originIntentGoalBean) {
59 intentDetectionService.setIntentRole(intentOwner, intentHandler);
60 IntentGoalBean newIntentGoalBean = intentDetectionService.detectionProcess(originIntentGoalBean);
62 //Èç¹ûÊÇupdate£¬Ö±½ÓÔÚinvestigationProcess»ñµÃintentÖж¨ÒåµÄhandlerµÄÐÅÏ¢£¬È»ºóÒ»¸öupdate »òÕßÁ½¸öupdate
63 //investigation process
64 intentInvestigationService.setIntentRole(intentOwner, intentHandler);
65 LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap =
66 intentInvestigationService.investigationProcess(newIntentGoalBean);
68 Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = intentMap.entrySet().iterator();
69 while (iterator.hasNext()) {
70 Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next();
71 //definition process save subintent
72 intentDefinitionService.setIntentRole(intentOwner, intentHandler);
73 intentDefinitionService.definitionPorcess(originIntentGoalBean.getIntent(), next);
75 //distribution process
76 intentDistributionService.setIntentRole(intentOwner, intentHandler);
77 intentDistributionService.distributionProcess(next);
79 intentOperationService.setIntentRole(intentOwner, next.getValue());
80 intentOperationService.operationProcess(originIntentGoalBean.getIntent(), next.getKey());
83 return newIntentGoalBean;