aa82ee9afcafe45d61c2429bef5ac3cfa6496963
[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.cllBusinessIntentMgt.cllBusinessModule;
17
18
19 import org.apache.commons.collections.CollectionUtils;
20 import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
21 import org.onap.usecaseui.intentanalysis.bean.models.Condition;
22 import org.onap.usecaseui.intentanalysis.bean.models.Context;
23 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
24 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
25 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
26 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
27 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
28 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
29 import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
30 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
31 import org.onap.usecaseui.intentanalysis.service.IntentService;
32 import org.onap.usecaseui.intentanalysis.util.CommonUtil;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 @Component
40 public class CLLBusinessActuationModule extends ActuationModule {
41     @Autowired
42     IntentProcessService processService;
43     @Autowired
44     IntentService intentService;
45     @Autowired
46     IntentInterfaceService intentInterfaceService;
47
48
49     @Override
50     public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
51         processService.setIntentRole(IntentHandler, null);
52         processService.intentProcess(intentGoalBean);
53     }
54
55     @Override
56     public void directOperation(IntentGoalBean intentGoalBean) {
57
58     }
59
60     @Override
61     public void interactWithIntentHandle() {
62
63     }
64
65     @Override
66     public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
67         //toNextIntentHandler(intentGoalBean, intentHandler);
68         intentHandler.receiveIntentAsOwner(intentGoalBean);
69     }
70         
71     @Override
72     public void saveIntentToDb(Intent intent){  //ownerid   parent intent id
73         List<Context> intentContexts = intent.getIntentContexts();
74         if (CollectionUtils.isEmpty(intentContexts)) {
75             intentContexts = new ArrayList<>();
76         }
77         //ownerId  intentId=""  show relatioship beteween  intent
78         Context ownerIdContext = new Context();
79         ownerIdContext.setContextId(CommonUtil.getUUid());
80         ownerIdContext.setContextName("ownerId");
81         List<Condition> idConditionList = new ArrayList<>();
82         Condition idCondition = new Condition();
83         idCondition.setConditionValue(intent.getIntentId());
84         idCondition.setOperator(OperatorType.EQUALTO);
85         idCondition.setConditionName("intentId");
86         idCondition.setConditionId(CommonUtil.getUUid());
87
88         idConditionList.add(idCondition);
89         ownerIdContext.setContextConditions(idConditionList);
90
91         intentContexts.add(ownerIdContext);
92         intent.setIntentContexts(intentContexts);
93         intentService.createIntent(intent);
94     }
95
96     @Override
97     public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){
98
99     }
100 }