df1c43786f753a7f061fca77b7a29c8b22368d61
[usecase-ui/intent-analysis.git] /
1 /*
2  * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
17
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;
24
25 import java.util.List;
26 import java.util.Map;
27
28 @Service
29 public class IntentProcessService {
30     @Autowired
31     IntentDetectionService intentDetectionService;
32     @Autowired
33     IntentInvestigationService intentInvestigationService;
34     @Autowired
35     IntentDefinitionService intentDefinitionService;
36     @Autowired
37     IntentDistributionService intentDistributionService;
38     @Autowired
39     IntentOperationService intentOperationService;
40 @Autowired
41     IntentService intentService;
42     private IntentManagementFunction intentOwner;
43     private IntentManagementFunction intentHandler;
44
45
46     public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler){
47         if (intentOwner!= null){
48             this.intentOwner = intentOwner;
49         }
50         if (intentHandler!= null){
51             this.intentHandler= intentHandler;
52         }
53     }
54     public void intentProcess(Intent intent) {
55         intentDetectionService.setIntentRole(intentOwner,intentHandler);
56         IntentGoalBean intentGoalBean = intentDetectionService.detectionProcess(intent);
57
58         //investigation process
59         intentInvestigationService.setIntentRole(intentOwner,intentHandler);
60         List<Map<IntentGoalBean,IntentManagementFunction>> intentListMap =
61                 intentInvestigationService.investigationProcess(intentGoalBean);
62
63
64         for (Map<IntentGoalBean,IntentManagementFunction> map : intentListMap) {
65             //definition process  save subintent
66             intentDefinitionService.setIntentRole(intentOwner,intentHandler);
67             intentDefinitionService.definitionPorcess(map);
68
69             //distribution process
70             intentDistributionService.setIntentRole(intentOwner,intentHandler);
71             intentDistributionService.distributionProcess(map);
72
73             //operation process     enery entry only have one key-value
74             for (Map.Entry<IntentGoalBean, IntentManagementFunction> entry : map.entrySet()) {
75                 intentOperationService.setIntentRole(intentOwner,entry.getValue());
76                 intentOperationService.operationProcess(entry.getKey().getIntent());
77             }
78
79         }
80     }
81
82
83 }