3bc58e17d3e4d95a730e05a47d94e38b703b5358
[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.Iterator;
26 import java.util.LinkedHashMap;
27 import java.util.Map;
28
29 @Service
30 public class IntentProcessService {
31     @Autowired
32     IntentDetectionService intentDetectionService;
33     @Autowired
34     IntentInvestigationService intentInvestigationService;
35     @Autowired
36     IntentDefinitionService intentDefinitionService;
37     @Autowired
38     IntentDistributionService intentDistributionService;
39     @Autowired
40     IntentOperationService intentOperationService;
41     @Autowired
42     IntentService intentService;
43     private IntentManagementFunction intentOwner;
44     private IntentManagementFunction intentHandler;
45
46
47     public void setIntentRole(IntentManagementFunction intentOwner, IntentManagementFunction intentHandler) {
48         if (intentOwner != null) {
49             this.intentOwner = intentOwner;
50         }
51         if (intentHandler != null) {
52             this.intentHandler = intentHandler;
53         }
54     }
55
56     public void intentProcess(Intent intent) {
57         intentDetectionService.setIntentRole(intentOwner, intentHandler);
58         IntentGoalBean intentGoalBean = intentDetectionService.detectionProcess(intent);
59
60         //investigation process
61         intentInvestigationService.setIntentRole(intentOwner, intentHandler);
62         LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap =
63                 intentInvestigationService.investigationProcess(intentGoalBean);
64
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);
71
72             //distribution process
73             intentDistributionService.setIntentRole(intentOwner, intentHandler);
74             intentDistributionService.distributionProcess(next);
75
76             intentOperationService.setIntentRole(intentOwner, next.getValue());
77             intentOperationService.operationProcess(next.getKey());
78         }
79     }
80
81 }