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.cllBusinessIntentMgt.cllBusinessModule;
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.intentBaseService.IntentManagementFunction;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
27 import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
28 import org.onap.usecaseui.intentanalysis.intentBaseService.intentinterfaceservice.IntentInterfaceService;
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;
38 public class CLLBusinessActuationModule extends ActuationModule {
40 IntentProcessService processService;
42 IntentService intentService;
44 IntentInterfaceService intentInterfaceService;
48 public void toNextIntentHandler(Intent intent, IntentManagementFunction IntentHandler) {
49 processService.setIntentRole(IntentHandler, null);
50 processService.intentProcess(intent);
54 public void directOperation() {
59 public void interactWithIntentHandle() {
64 public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) {
65 toNextIntentHandler(intentGoalBean.getIntent(),intentHandler);
69 public void saveIntentToDb(Intent intent){ //ownerid parent intent id
70 List<Context> intentContexts = intent.getIntentContexts();
71 if (CollectionUtils.isEmpty(intentContexts)) {
72 intentContexts = new ArrayList<>();
74 //ownerId intentId="" show relatioship beteween intent
75 Context ownerIdContext = new Context();
76 ownerIdContext.setContextId(CommonUtil.getUUid());
77 ownerIdContext.setContextName("ownerId");
78 List<Condition> idConditionList = new ArrayList<>();
79 Condition idCondition = new Condition();
80 idCondition.setConditionValue(intent.getIntentId());
81 idCondition.setOperator(OperatorType.EQUALTO);
82 idCondition.setConditionName("intentId");
83 idCondition.setConditionId(CommonUtil.getUUid());
85 idConditionList.add(idCondition);
86 ownerIdContext.setContextConditions(idConditionList);
88 intentContexts.add(ownerIdContext);
89 intent.setIntentContexts(intentContexts);
90 intentService.createIntent(intent);