From 9643136574c0c06909ebe9af120c022fbb951b6d Mon Sep 17 00:00:00 2001 From: hekeguang Date: Thu, 25 Aug 2022 11:13:58 +0800 Subject: Add intent investigation process code . Issue-ID: USECASEUI-696 Change-Id: I4da04a605207212fb8359c47959392138c0b4696 Signed-off-by: hekeguang --- .../bean/enums/DetectionGoalType.java | 36 ------ .../intentanalysis/bean/enums/ExpectationType.java | 5 +- .../intentanalysis/bean/enums/IntentGoalType.java | 36 ++++++ .../intentanalysis/bean/enums/SupportArea.java | 5 +- .../bean/models/DetectionGoalBean.java | 30 ----- .../intentanalysis/bean/models/IntentGoalBean.java | 34 ++++++ .../models/IntentManagementFunctionRegInfo.java | 4 +- .../CLLBusinessDecisionModule.java | 134 ++++++++++++++++++--- .../CLLBusinessKnowledgeModule.java | 22 ++-- .../intentBaseService/IntentHandleService.java | 35 ++++-- .../intentModule/DecisionModule.java | 21 ++-- .../intentModule/KnowledgeModule.java | 3 +- .../IntentDetectionService.java | 3 +- .../IntentInvestigationService.java | 16 ++- .../intentProcessService/IntentProcessService.java | 11 +- .../intentanalysis/mapper/IMFRegInfoMapper.java | 7 +- .../intentanalysis/service/ImfRegInfoService.java | 26 ++++ .../service/impl/ImfRegInfoServiceImpl.java | 42 +++++++ .../service/impl/IntentServiceImpl.java | 2 + .../usecaseui/intentanalysis/util/CommonUtil.java | 24 ++++ .../intentanalysis/util/CustomTrustManager.java | 2 +- .../intentanalysis/util/RestfulServices.java | 2 +- .../main/resources/mybatis/sql/ConditionMapper.xml | 2 +- .../resources/mybatis/sql/IMFRegInfoMapper.xml | 4 + 24 files changed, 368 insertions(+), 138 deletions(-) delete mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java create mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGoalType.java delete mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java create mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBean.java create mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java create mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java create mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CommonUtil.java (limited to 'intentanalysis/src/main') diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java deleted file mode 100644 index abe3ef0..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/DetectionGoalType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.usecaseui.intentanalysis.bean.enums; - -import lombok.Getter; - -@Getter -public enum DetectionGoalType { - ADD(0, "add"), - UPDATE(1, "update"), - DELETE(2, "delete"); - - private int index; - - private String desc; - - DetectionGoalType(int index, String desc) { - this.index = index; - this.desc = desc; - } - -} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java index fbddde2..34b0b8b 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/ExpectationType.java @@ -17,12 +17,11 @@ package org.onap.usecaseui.intentanalysis.bean.enums; import lombok.Getter; -import lombok.Setter; @Getter public enum ExpectationType { - EXPECTATION1(0, "expectationType1"), - EXPECTATION2(1, "expectationType2"); + DELIVERY(0, "delivery"), + ASSURANCE(1, "assurance"); private int index; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGoalType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGoalType.java new file mode 100644 index 0000000..624f1e2 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGoalType.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.usecaseui.intentanalysis.bean.enums; + +import lombok.Getter; + +@Getter +public enum IntentGoalType { + CREATE(0, "create"), + UPDATE(1, "update"), + DELETE(2, "delete"); + + private int index; + + private String desc; + + IntentGoalType(int index, String desc) { + this.index = index; + this.desc = desc; + } + +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/SupportArea.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/SupportArea.java index 3cf08f7..6543580 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/SupportArea.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/SupportArea.java @@ -22,8 +22,9 @@ import lombok.Getter; @Getter public enum SupportArea { SLICING(0, "slicing"), - FEMALE(1, "5g"), - MALE(2, "4g"); + CLLBUSINESS(1, "cllbusiness"), + DELIVERY(2, "delivery"), + ASSURANCE(3, "assurance"); private int type; private String desc; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java deleted file mode 100644 index 6ea045b..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/DetectionGoalBean.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.usecaseui.intentanalysis.bean.models; - -import lombok.Data; -import org.onap.usecaseui.intentanalysis.bean.enums.DetectionGoalType; - -@Data -public class DetectionGoalBean { - private Intent intent; - private DetectionGoalType detectionGoalType; - - public DetectionGoalBean(Intent intent, DetectionGoalType detectionGoalType) { - this.intent = intent; - this.detectionGoalType = detectionGoalType; - } -} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBean.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBean.java new file mode 100644 index 0000000..b4ae516 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentGoalBean.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.usecaseui.intentanalysis.bean.models; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; + +@Data +public class IntentGoalBean { + private Intent intent; + private IntentGoalType intentGoalType; + + public IntentGoalBean(Intent intent, IntentGoalType intentGoalType) { + this.intent = intent; + this.intentGoalType = intentGoalType; + } + + public IntentGoalBean() { + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java index b137942..7b3ff5a 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/IntentManagementFunctionRegInfo.java @@ -30,5 +30,7 @@ public class IntentManagementFunctionRegInfo { private String supportModel; private List supportInterfaces; private String handleName; - private IntentFunctionType intentFunctionType;//out or in + //distinguish internal or external function + private IntentFunctionType intentFunctionType; + } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java index 8214b46..bcda367 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java @@ -16,39 +16,145 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; -import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import lombok.extern.log4j.Log4j2; +import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType; +import org.onap.usecaseui.intentanalysis.bean.models.Expectation; +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; +import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; +import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; +import org.onap.usecaseui.intentanalysis.util.CommonUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.stream.Collectors; + +@Log4j2 @Service public class CLLBusinessDecisionModule implements DecisionModule { - @Override - public void determineUltimateGoal() {} + @Autowired + private ImfRegInfoService imfRegInfoService; + @Autowired + private ApplicationContext applicationContext; @Override - public IntentManagementFunction exploreIntentHandlers() { - - return null; - + public void determineUltimateGoal() { } @Override - public void intentDefinition() {} + public IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean) { + // db filter imf supportArea; + //SupportInterface> supportInterfaces; + IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); + String intentName = intentGoalBean.getIntent().getIntentName(); + List imfRegInfoList = imfRegInfoService.getImfRegInfoList(); + //todo + List imfList = imfRegInfoList.stream(). + filter(x -> x.getSupportArea().contains(intentName) + && x.getSupportInterfaces().contains(intentGoalType)).collect(Collectors.toList()); + if (!Optional.ofNullable(imfList).isPresent()) { + log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName); + } + return (IntentManagementFunction) applicationContext.getBean(imfList.get(0).getHandleName()); + } @Override - public void decideSuitableAction() {} + public void intentDefinition() { + } @Override - public boolean needDecompostion() { + public void decideSuitableAction() { + } + + + public boolean needDecompostion(IntentGoalBean intentGoalBean) { + //different expectationType need decompostion ExpectationType>1 or objtype>1 + if (intentGoalBean.getIntentGoalType().equals(IntentGoalType.CREATE)) { + List intentExpectations = intentGoalBean.getIntent().getIntentExpectations(); + List expectationTypeList = intentExpectations.stream() + .map(Expectation::getExpectationType).distinct().collect(Collectors.toList()); + if (expectationTypeList.size() > 1) { + return true; + } else { + List objectTypeList = intentExpectations.stream().map(x -> + x.getExpectationObject().getObjectType()).collect(Collectors.toList()); + if (objectTypeList.size() > 1) { + return true; + } + } + } return false; } - @Override - public void intentDecomposition() {} + public List intentDecomposition(IntentGoalBean intentGoalBean) { + //ExpectationType expectation.ExpectationObject.objtype + Map> expectationTypeListMap = intentGoalBean.getIntent().getIntentExpectations() + .stream().collect(Collectors.groupingBy(x -> x.getExpectationType())); + List subIntentGoalList = new ArrayList<>(); + IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); + for (Map.Entry> entry : expectationTypeListMap.entrySet()) { + + Map> objTypeMap = entry.getValue().stream() + .collect(Collectors.groupingBy(x -> x.getExpectationObject().getObjectType())); + for (Map.Entry> objEntry : objTypeMap.entrySet()) { + IntentGoalBean subIntentGoalBean = new IntentGoalBean(); + Intent subIntent = new Intent(); + subIntent.setIntentId(CommonUtil.getUUid()); + subIntent.setIntentName(objEntry.getValue().get(0).getExpectationName().replace("Expectation", "Intent")); + subIntent.setIntentExpectations(objEntry.getValue()); + //TODO intentFulfilmentInfo intentContexts + subIntentGoalBean.setIntentGoalType(intentGoalType); + subIntentGoalBean.setIntent(subIntent); + subIntentGoalList.add(subIntentGoalBean); + } + } + return subIntentGoalList; + } + + public List intentOrchestration(List subIntentGoalList) { + List sortList = new ArrayList<>(); + List deliveryGoalList = subIntentGoalList.stream().filter(x -> x.getIntent().getIntentName() + .equalsIgnoreCase("delivery")).collect(Collectors.toList()); + List assuranceGoalList = subIntentGoalList.stream().filter(x -> x.getIntent().getIntentName() + .equalsIgnoreCase("assurance")).collect(Collectors.toList()); + List otherGoalList = subIntentGoalList.stream().filter(x -> !x.getIntent().getIntentName() + .equalsIgnoreCase("assurance") && !x.getIntent().getIntentName() + .equalsIgnoreCase("delivery")).collect(Collectors.toList()); + sortList.addAll(deliveryGoalList); + sortList.addAll(assuranceGoalList); + sortList.addAll(otherGoalList); + return sortList; + } @Override - public void intentOrchestration() {} + public void interactWithTemplateDb() { + } @Override - public void interactWithTemplateDb() {} + public List> findHandler(IntentGoalBean intentGoalBean) { + boolean needDecompostion = needDecompostion(intentGoalBean); + List> intentMapList = new ArrayList<>(); + if (needDecompostion) { + List subIntentGoalList = intentDecomposition(intentGoalBean); + List sortList = intentOrchestration(subIntentGoalList); + for (IntentGoalBean subIntentGoal : sortList) { + Map map = new HashMap<>(); + IntentManagementFunction imf = exploreIntentHandlers(subIntentGoal); + //TODO call probe interface if fail intentFulfilmentInfo throw exception + map.put(subIntentGoal, imf); + intentMapList.add(map); + } + } else { + Map map = new HashMap<>(); + map.put(intentGoalBean, exploreIntentHandlers(intentGoalBean)); + intentMapList.add(map); + } + return intentMapList; + } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java index 43a6247..372b0d5 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessKnowledgeModule.java @@ -16,8 +16,8 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule; import org.apache.commons.collections.CollectionUtils; -import org.onap.usecaseui.intentanalysis.bean.enums.DetectionGoalType; -import org.onap.usecaseui.intentanalysis.bean.models.DetectionGoalBean; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.bean.models.Expectation; import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget; import org.onap.usecaseui.intentanalysis.bean.models.Intent; @@ -40,11 +40,10 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { IntentService intentService; @Override - public Intent intentCognition(Intent intent) { + public IntentGoalBean intentCognition(Intent intent) { List intendIdList = intentResolution(intent); getSystemStatus(); - determineDetectionGoal(intent, intendIdList); - return null; + return determineDetectionGoal(intent, intendIdList); } /** @@ -54,11 +53,8 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { */ public List intentResolution(Intent intent) { - //dc contain original intent - String intentName = intent.getIntentName(); - List intentList = intentService.getIntentList(); - List sameNameIntentList = intentList.stream().filter(x -> x.getIntentName() - .contains(intentName)).collect(Collectors.toList()); + //db contain original intent + List sameNameIntentList = intentService.getIntentByName(intent.getIntentName()); List intentIdList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(sameNameIntentList)) { List expectationList = intent.getIntentExpectations(); @@ -110,12 +106,12 @@ public class CLLBusinessKnowledgeModule implements KnowledgeModule { /** * Determine add, delete, modify according to theobject,target and context of the expectation */ - DetectionGoalBean determineDetectionGoal(Intent intent, List intentIdList) { + public IntentGoalBean determineDetectionGoal(Intent intent, List intentIdList) { int size = intentIdList.size(); if (size == 0) { - return new DetectionGoalBean(intent, DetectionGoalType.ADD); + return new IntentGoalBean(intent, IntentGoalType.CREATE); } else { - return new DetectionGoalBean(intent, DetectionGoalType.UPDATE); + return new IntentGoalBean(intent, IntentGoalType.UPDATE); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java index ab2419f..2d420d7 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentHandleService.java @@ -15,25 +15,38 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService; +import lombok.extern.slf4j.Slf4j; import org.onap.usecaseui.intentanalysis.bean.models.Intent; import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; +import org.onap.usecaseui.intentanalysis.common.ResponseConsts; +import org.onap.usecaseui.intentanalysis.exception.DataBaseException; import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService; +import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; - +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +@Slf4j @Service public class IntentHandleService { @Autowired private IntentProcessService processService; + @Autowired + private ImfRegInfoService imfRegInfoService; + @Autowired + private ApplicationContext applicationContext; /** * Process the original intent and find the corresponding IntentManagementFunction + * * @param intent */ - public void handleOriginalIntent(Intent intent){ - IntentManagementFunction intentOwner = getOtigalIMF(intent); - handleIntent(intent,intentOwner); + public void handleOriginalIntent(Intent intent) { + IntentManagementFunction intentOwner = getOriginalIMF(intent); + handleIntent(intent, intentOwner); } public void handleIntent(Intent intent, IntentManagementFunction intentOwner) { @@ -55,9 +68,17 @@ public class IntentHandleService { //This is used to get he IntentManagementFunction for a subIntent decomposition. return null; } - - public IntentManagementFunction getOtigalIMF(Intent intent){ + + public IntentManagementFunction getOriginalIMF(Intent intent) { //select IntentManagementFunction based on intent name - return null; + String intentName = intent.getIntentName(); + List imfRegInfoList = imfRegInfoService.getImfRegInfoList(); + List list = imfRegInfoList.stream().filter(x -> x.getSupportArea().contains(intentName)).collect(Collectors.toList()); + if (!Optional.ofNullable(list).isPresent()) { + String msg = String.format("Intent name %s doesn't exist IntentManagementFunction in database.", intent.getIntentName()); + log.error(msg); + throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY); + } + return (IntentManagementFunction) applicationContext.getBean(list.get(0).getHandleName()); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java index 1762e63..76601a8 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java @@ -16,23 +16,22 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; -public interface DecisionModule { - void determineUltimateGoal();// - IntentManagementFunction exploreIntentHandlers(); - void intentDefinition(); - void decideSuitableAction(); +import java.util.List; +import java.util.Map; - //confirm whether the intent needs to be decomposed and orchestrated - public boolean needDecompostion(); +public interface DecisionModule { + void determineUltimateGoal(); - //call decomposition module - public void intentDecomposition(); + IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean); - //call orchestration module - public void intentOrchestration(); + void intentDefinition(); + void decideSuitableAction(); public void interactWithTemplateDb(); + + public List> findHandler(IntentGoalBean intentGoalBean); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java index 4bb803b..d5caf1f 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/KnowledgeModule.java @@ -16,8 +16,9 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule; import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; public interface KnowledgeModule { //Parse, decompose, orchestrate the original intent - Intent intentCognition(Intent intent); + IntentGoalBean intentCognition(Intent intent); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java index 13ed2fd..699c1b1 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDetectionService.java @@ -16,6 +16,7 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule; import org.springframework.stereotype.Service; @@ -35,7 +36,7 @@ public class IntentDetectionService { } } - public Intent detectionProcess(Intent intent) { + public IntentGoalBean detectionProcess(Intent intent) { KnowledgeModule ownerKnowledgeModule = intentOwner.getKnowledgeModule(); return ownerKnowledgeModule.intentCognition(intent); diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java index 8c39066..36476b1 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentInvestigationService.java @@ -15,11 +15,16 @@ */ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; +import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class IntentInvestigationService { @@ -35,15 +40,8 @@ public class IntentInvestigationService { } } - public List investigationProcess() { + public List> investigationProcess(IntentGoalBean intentGoalBean) { DecisionModule intentDecisionModule = intentOwner.getDecisionModule(); - intentDecisionModule.needDecompostion(); - intentDecisionModule.intentDecomposition(); - intentDecisionModule.intentOrchestration(); - intentDecisionModule.decideSuitableAction(); - intentDecisionModule.exploreIntentHandlers();//返回handler - return null; + return intentDecisionModule.findHandler(intentGoalBean); } - - } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java index 5fa4b98..6bff142 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java @@ -16,11 +16,13 @@ package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService; import org.onap.usecaseui.intentanalysis.bean.models.Intent; +import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; @Service public class IntentProcessService { @@ -49,14 +51,15 @@ public class IntentProcessService { } public void intentProcess(Intent intent) { intentDetectionService.setIntentRole(intentOwner,intentHandler); - Intent detectIntent = intentDetectionService.detectionProcess(intent); + IntentGoalBean intentGoalBean = intentDetectionService.detectionProcess(intent); //investigation process intentInvestigationService.setIntentRole(intentOwner,intentHandler); - List intentManagementFunctions = - intentInvestigationService.investigationProcess();//List? + List> intentListMap = + intentInvestigationService.investigationProcess(intentGoalBean); - for (IntentManagementFunction intentHandler : intentManagementFunctions) { + + for (Map map : intentListMap) { //definition process intentDefinitionService.setIntentRole(intentOwner,intentHandler); intentDefinitionService.definitionPorcess(); diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java index ca4318d..0e76679 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.onap.usecaseui.intentanalysis.mapper; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; +import java.util.List; @Mapper public interface IMFRegInfoMapper { - void insertIMFRegInfoRegInfo(@Param(value = "fulfilmentInfo") IntentManagementFunctionRegInfo imfregInfo); + int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo info); + + List getImfRegInfoList(); } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java new file mode 100644 index 0000000..0d7a6b1 --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ImfRegInfoService.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.usecaseui.intentanalysis.service; + +import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; + +import java.util.List; + +public interface ImfRegInfoService { + + int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo regInfo); + List getImfRegInfoList(); +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java new file mode 100644 index 0000000..85ae90e --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.usecaseui.intentanalysis.service.impl; + +import lombok.extern.slf4j.Slf4j; +import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo; +import org.onap.usecaseui.intentanalysis.mapper.IMFRegInfoMapper; +import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +public class ImfRegInfoServiceImpl implements ImfRegInfoService { + @Autowired + private IMFRegInfoMapper imfRegInfoMapper; + + @Override + public int insertIMFRegInfoRegInfo(org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo regInfo) { + return imfRegInfoMapper.insertIMFRegInfoRegInfo(regInfo); + } + + @Override + public List getImfRegInfoList() { + return imfRegInfoMapper.getImfRegInfoList(); + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java index 7f491c9..dd3b9fe 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java @@ -133,6 +133,8 @@ public class IntentServiceImpl implements IntentService { if (CollectionUtils.isNotEmpty(intentList)) { for (Intent intent:intentList) { intent.setIntentExpectations(expectationService.getIntentExpectationsByIntentId(intent.getIntentId())); + // intent.setIntentContexts(); + // } return intentList; } else { diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CommonUtil.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CommonUtil.java new file mode 100644 index 0000000..260115a --- /dev/null +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CommonUtil.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.usecaseui.intentanalysis.util; + +import java.util.UUID; + +public class CommonUtil { + public static String getUUid() { + return UUID.randomUUID().toString().trim().replaceAll("-", ""); + } +} diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CustomTrustManager.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CustomTrustManager.java index daed733..46d9abf 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CustomTrustManager.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/CustomTrustManager.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onap.usecaseui.intentanalysis.utils; +package org.onap.usecaseui.intentanalysis.util; import javax.net.ssl.X509TrustManager; import java.security.cert.CertificateException; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/RestfulServices.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/RestfulServices.java index f37021f..7e7e6c2 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/RestfulServices.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/util/RestfulServices.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onap.usecaseui.intentanalysis.utils; +package org.onap.usecaseui.intentanalysis.util; import okhttp3.MediaType; import okhttp3.OkHttpClient; diff --git a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml index d77c06a..8a39762 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml @@ -21,7 +21,7 @@ - select condition_id conditionId, condition_name conditiontName, operator_type operatorType from condition where condition_id = #{parentId} diff --git a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml index 8f6cd3c..7b8a115 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml @@ -10,4 +10,8 @@ (#{imfregInfo.id}, #{imfregInfo.description}, #{imfregInfo.supportArea},#{imfregInfo.handleName},#{imfregInfo.intentFunctionType}) + + -- cgit 1.2.3-korg