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.models.Intent;
19 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
20 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
21 import org.onap.usecaseui.intentanalysis.service.IntentService;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Service;
25 import java.util.Iterator;
26 import java.util.LinkedHashMap;
30 public class IntentProcessService {
32 IntentDetectionService intentDetectionService;
34 IntentInvestigationService intentInvestigationService;
36 IntentDefinitionService intentDefinitionService;
38 IntentDistributionService intentDistributionService;
40 IntentOperationService intentOperationService;
42 IntentService intentService;
43 private IntentManagementFunction intentOwner;
44 private IntentManagementFunction intentHandler;
47 public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) {
48 if (intentOwner != null) {
49 this.intentOwner = intentOwner;
51 if (intentHandler != null) {
52 this.intentHandler = intentHandler;
56 public void intentProcess(Intent intent) {
57 intentDetectionService.setIntentRole(intentOwner, intentHandler);
58 IntentGoalBean intentGoalBean = intentDetectionService.detectionProcess(intent);
60 //investigation process
61 intentInvestigationService.setIntentRole(intentOwner, intentHandler);
62 LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap =
63 intentInvestigationService.investigationProcess(intentGoalBean);
65 Iterator<Map.Entry<IntentGoalBean, IntentManagementFunction>> iterator = intentMap.entrySet().iterator();
66 while (iterator.hasNext()) {
67 Map.Entry<IntentGoalBean, IntentManagementFunction> next = iterator.next();
68 //definition process save subintent
69 intentDefinitionService.setIntentRole(intentOwner, intentHandler);
70 intentDefinitionService.definitionPorcess(next);
72 //distribution process
73 intentDistributionService.setIntentRole(intentOwner, intentHandler);
74 intentDistributionService.distributionProcess(next);
76 intentOperationService.setIntentRole(intentOwner, next.getValue());
77 intentOperationService.operationProcess(next.getKey().getIntent());