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.formatintentinputMgt.formatintentinputModule;
18 import lombok.extern.log4j.Log4j2;
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.Intent;
24 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
25 import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
27 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
28 import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
29 import org.onap.usecaseui.intentanalysis.service.IntentService;
30 import org.onap.usecaseui.intentanalysis.util.CommonUtil;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Component;
34 import java.util.ArrayList;
35 import java.util.List;
39 public class FormatIntentInputActuationModule extends ActuationModule {
41 IntentProcessService processService;
43 IntentService intentService;
46 public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) {
47 log.info("do nothing");
51 public void directOperation(IntentGoalBean intentGoalBean) {
55 public void interactWithIntentHandle() {
59 public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
64 public void saveIntentToDb(Intent intent){
65 List<Context> intentContexts = intent.getIntentContexts();
66 if (CollectionUtils.isEmpty(intentContexts)) {
67 intentContexts = new ArrayList<>();
69 Context ownerInfoCon = new Context();
70 ownerInfoCon.setContextId(CommonUtil.getUUid());
71 ownerInfoCon.setContextName("ownerInfo");
72 List<Condition> conditionList = new ArrayList<>();
73 Condition condition = new Condition();
74 condition.setConditionId(CommonUtil.getUUid());
75 condition.setConditionName("ownerName");
76 condition.setOperator(OperatorType.EQUALTO);
77 condition.setConditionValue(FormatIntentInputManagementFunction.class.getSimpleName());
78 conditionList.add(condition);
79 ownerInfoCon.setContextConditions(conditionList);
80 intentContexts.add(ownerInfoCon);
81 //ownerId intentId=parent intent id
82 Context ownerIdContext = new Context();
83 ownerIdContext.setContextId(CommonUtil.getUUid());
84 ownerIdContext.setContextName("ownerId");
85 List<Condition> idConditionList = new ArrayList<>();
86 Condition idCondition = new Condition();
87 idCondition.setConditionId(CommonUtil.getUUid());
88 idCondition.setConditionName("intentId");
89 idCondition.setOperator(OperatorType.EQUALTO);
90 idCondition.setConditionValue(intent.getIntentId());
91 idConditionList.add(idCondition);
92 ownerIdContext.setContextConditions(idConditionList);
93 intentContexts.add(ownerIdContext);
95 intent.setIntentContexts(intentContexts);
96 intentService.createIntent(intent);
99 public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){