230fcb8466db28aee2274270421377a566dde564
[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.formatintentinputMgt.formatintentinputModule;
17
18 import lombok.extern.log4j.Log4j2;
19 import org.apache.commons.collections.CollectionUtils;
20 import org.checkerframework.checker.units.qual.A;
21 import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
22 import org.onap.usecaseui.intentanalysis.bean.models.Condition;
23 import org.onap.usecaseui.intentanalysis.bean.models.Context;
24 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
25 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
26 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
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.service.IntentService;
31 import org.onap.usecaseui.intentanalysis.util.CommonUtil;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Component;
34
35 import java.util.ArrayList;
36 import java.util.List;
37
38 @Log4j2
39 @Component
40 public class FormatIntentInputActuationModule extends ActuationModule {
41     @Autowired
42     IntentProcessService processService;
43     @Autowired
44     IntentService intentService;
45     @Override
46     public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) {
47         log.info("do nothing");
48     }
49
50     @Override
51     public void directOperation() {
52     }
53
54     @Override
55     public void interactWithIntentHandle() {
56     }
57
58     @Override
59     public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
60     }
61     @Override
62     public void saveIntentToDb(Intent intent){
63         List<Context> intentContexts = intent.getIntentContexts();
64         if (CollectionUtils.isEmpty(intentContexts)) {
65             intentContexts = new ArrayList<>();
66         }
67         Context ownerInfoCon = new Context();
68         ownerInfoCon.setContextId(CommonUtil.getUUid());
69         ownerInfoCon.setContextName("ownerInfo");
70         List<Condition> conditionList = new ArrayList<>();
71         Condition condition = new Condition();
72         condition.setConditionId(CommonUtil.getUUid());
73         condition.setConditionName("ownerName");
74         condition.setOperator(OperatorType.EQUALTO);
75         condition.setConditionValue(FormatIntentInputManagementFunction.class.getSimpleName());
76         conditionList.add(condition);
77         ownerInfoCon.setContextConditions(conditionList);
78         intentContexts.add(ownerInfoCon);
79         intent.setIntentContexts(intentContexts);
80         intentService.createIntent(intent);
81     }
82
83 }