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;
18 import org.apache.commons.collections.CollectionUtils;
19 import org.onap.usecaseui.intentanalysis.bean.enums.DetectionGoalType;
20 import org.onap.usecaseui.intentanalysis.bean.models.DetectionGoalBean;
21 import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
22 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
23 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
24 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
25 import org.onap.usecaseui.intentanalysis.service.IntentService;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.stream.Collectors;
36 public class CLLBusinessKnowledgeModule implements KnowledgeModule {
37 private static Logger LOGGER = LoggerFactory.getLogger(CLLBusinessKnowledgeModule.class);
40 IntentService intentService;
43 public Intent intentCognition(Intent intent) {
44 List<String> intendIdList = intentResolution(intent);
46 determineDetectionGoal(intent, intendIdList);
51 * find similar intents in DB
56 public List<String> intentResolution(Intent intent) {
57 //dc contain original intent
58 String intentName = intent.getIntentName();
59 List<Intent> intentList = intentService.getIntentList();
60 List<Intent> sameNameIntentList = intentList.stream().filter(x -> x.getIntentName()
61 .contains(intentName)).collect(Collectors.toList());
62 List<String> intentIdList = new ArrayList<>();
63 if (CollectionUtils.isNotEmpty(sameNameIntentList)) {
64 List<Expectation> expectationList = intent.getIntentExpectations();
65 for (Intent dbIntent : sameNameIntentList) {
66 String intentId = dbIntent.getIntentId();
68 for (Expectation expectation : expectationList) {//original expectations
69 //Determine if there is the same ObjectType
70 List<Expectation> sameObjTypeList = dbIntent.getIntentExpectations().stream()
71 .filter(x -> x.getExpectationObject().getObjectType().equals(expectation.getExpectationObject().getObjectType()))
72 .collect(Collectors.toList());
73 if (CollectionUtils.isNotEmpty(sameObjTypeList)) {
74 //Determine the targetName of the Expectation which hava same ObjectType
75 List<String> targetNameList = expectation.getExpectationTargets()
76 .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList());
77 for (Expectation dbExpectation : sameObjTypeList) {
78 List<String> dbTargetNameList = dbExpectation.getExpectationTargets()
79 .stream().map(ExpectationTarget::getTargetName).collect(Collectors.toList());
80 //todo name compare need ai
81 if (dbTargetNameList.containsAll(targetNameList)) {
87 if (count == expectationList.size()) {
88 intentIdList.add(intentId);
97 void intentReportResolution() {
101 * query the implementation of intent requirements in the system
103 void getSystemStatus() {
107 void interactWithIntentOwner() {
111 * Determine add, delete, modify according to theobject,target and context of the expectation
113 DetectionGoalBean determineDetectionGoal(Intent intent, List<String> intentIdList) {
114 int size = intentIdList.size();
116 return new DetectionGoalBean(intent, DetectionGoalType.ADD);
118 return new DetectionGoalBean(intent, DetectionGoalType.UPDATE);